mirror of
https://github.com/ONLYOFFICE/onlyoffice.github.io.git
synced 2026-02-10 18:05:06 +08:00
Merge remote-tracking branch 'ONLYOFFICE-PLUGINS/feature/AI'
This commit is contained in:
@ -58,13 +58,13 @@
|
||||
* Bug fix
|
||||
|
||||
## 2.1.5
|
||||
* Bug fix
|
||||
* Bug fix.
|
||||
|
||||
## 2.2.0
|
||||
* Refactoring
|
||||
|
||||
## 2.2.1
|
||||
* Bug fix
|
||||
* Bug fix.
|
||||
|
||||
## 2.2.2
|
||||
* Add xAI as internal provider.
|
||||
@ -76,7 +76,7 @@
|
||||
* Refactoring chat. Add docked mode for chat window.
|
||||
|
||||
## 2.2.5
|
||||
* Bug fix
|
||||
* Bug fix.
|
||||
|
||||
## 2.2.6
|
||||
* Add interface for system role detection.
|
||||
@ -89,3 +89,7 @@
|
||||
|
||||
## 2.2.8
|
||||
* Fix image actions. Add "OCR" and "Image to text" support.
|
||||
|
||||
## 2.2.9
|
||||
* Add support server settings.
|
||||
* Bug fix.
|
||||
|
||||
@ -108,6 +108,7 @@
|
||||
Custom providers
|
||||
</label>
|
||||
</div>
|
||||
<script type="text/javascript" src="scripts/utils/theme.js"></script>
|
||||
<script type="text/javascript" src="scripts/aiModelEdit.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
<img src="resources/icons/light/btn-remove.png" class="icon"/>
|
||||
</button>
|
||||
</div>
|
||||
<script type="text/javascript" src="scripts/utils/theme.js"></script>
|
||||
<script type="text/javascript" src="scripts/aiModelsList.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -27,6 +27,7 @@ limitations under the License.
|
||||
<script type="text/javascript" src="components/Tooltip/script.js"></script>
|
||||
<link rel="stylesheet" href="components/Tooltip/style.css">
|
||||
<link rel="stylesheet" href="./resources/styles/chat.css">
|
||||
<script type="text/javascript" src="scripts/utils/theme.js"></script>
|
||||
<script type="text/javascript" src="scripts/chat.js"></script>
|
||||
</head>
|
||||
<body style="display: flex;">
|
||||
|
||||
@ -17,69 +17,57 @@
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* Themes style for Models List */
|
||||
/* Themes style for List */
|
||||
body.theme-classic-light .list-view {
|
||||
border-color: #cfcfcf;
|
||||
--list-border: #cfcfcf;
|
||||
--item-hover-bg: #d8dadc;
|
||||
--item-hover-color: #444;
|
||||
--item-selected-bg: #7d858c;
|
||||
--item-selected-color: #fff;
|
||||
}
|
||||
body.theme-light .list-view,
|
||||
body.theme-gray .list-view {
|
||||
border-color: #c0c0c0;
|
||||
--list-border: #c0c0c0;
|
||||
--item-hover-bg: #e0e0e0;
|
||||
--item-hover-color: rgba(0, 0, 0, 0.8);
|
||||
--item-selected-bg: #cbcbcb;
|
||||
--item-selected-color: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
body.theme-dark .list-view {
|
||||
border-color: #666;
|
||||
--list-border: #666666;
|
||||
--item-hover-bg: #555;
|
||||
--item-hover-color: rgba(255, 255, 255, 0.8);
|
||||
--item-selected-bg: #707070;
|
||||
--item-selected-color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
body.theme-contrast-dark .list-view {
|
||||
border-color: #696969;
|
||||
--list-border: #696969;
|
||||
--item-hover-bg: #424242;
|
||||
--item-hover-color: #e8e8e8;
|
||||
--item-selected-bg: #666666;
|
||||
--item-selected-color: #e8e8e8;
|
||||
}
|
||||
|
||||
/* Themes style for Item Models List */
|
||||
body.theme-classic-light .list-view .item {
|
||||
border-color: #cfcfcf;
|
||||
}
|
||||
body.theme-classic-light .list-view .item:hover {
|
||||
background-color: #d8dadc;
|
||||
color: #444;
|
||||
}
|
||||
body.theme-classic-light .list-view .item.selected {
|
||||
background-color: #7d858c;
|
||||
color: #fff;
|
||||
.list-view {
|
||||
border-color: #e1e1e1;
|
||||
border-color: var(--list-border);
|
||||
border-color: var(--border-regular-control);
|
||||
}
|
||||
.list-view .item:hover {
|
||||
background-color: #eaeaea;
|
||||
background-color: var(--item-hover-bg);
|
||||
background-color: var(--highlight-button-hover);
|
||||
|
||||
body.theme-light .list-view .item,
|
||||
body.theme-gray .list-view .item {
|
||||
border-color: #c0c0c0;
|
||||
}
|
||||
body.theme-light .list-view .item:hover,
|
||||
body.theme-gray .list-view .item:hover {
|
||||
background-color: #e0e0e0;
|
||||
color: rgba(0, 0, 0, 0.8);
|
||||
color: var(--item-hover-color);
|
||||
color: var(--text-normal);
|
||||
}
|
||||
body.theme-light .list-view .item.selected,
|
||||
body.theme-gray .list-view .item.selected {
|
||||
background-color: #cbcbcb;
|
||||
.list-view .item.selected {
|
||||
background-color: #e1e1e1;
|
||||
background-color: var(--item-selected-bg);
|
||||
background-color: var(--highlight-button-pressed);
|
||||
|
||||
color: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
body.theme-dark .list-view .item {
|
||||
border-color: #666;
|
||||
}
|
||||
body.theme-dark .list-view .item:hover {
|
||||
background-color: #555;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
body.theme-dark .list-view .item.selected {
|
||||
background-color: #707070;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
body.theme-contrast-dark .list-view .item {
|
||||
border-color: #696969;
|
||||
}
|
||||
body.theme-contrast-dark .list-view .item:hover {
|
||||
background-color: #424242;
|
||||
color: #e8e8e8;
|
||||
}
|
||||
body.theme-contrast-dark .list-view .item.selected {
|
||||
background-color: #666666;
|
||||
color: #e8e8e8;
|
||||
color: var(--item-selected-color);
|
||||
color: var(--text-normal-pressed);
|
||||
}
|
||||
@ -10,20 +10,30 @@
|
||||
.tooltip.has-shadow {
|
||||
box-shadow: 0px 2px 5px #00000033;
|
||||
}
|
||||
|
||||
body.theme-classic-light .tooltip {
|
||||
--background-color: #fff;
|
||||
--border-color: #cfcfcf;
|
||||
}
|
||||
body.theme-light .tooltip,
|
||||
body.theme-gray .tooltip {
|
||||
background-color: #fff;
|
||||
border-color: #c0c0c0;
|
||||
}
|
||||
body.theme-classic-light .tooltip {
|
||||
background-color: #fff;
|
||||
border-color: #cfcfcf;
|
||||
--background-color: #fff;
|
||||
--border-color: #c0c0c0;
|
||||
}
|
||||
body.theme-dark .tooltip {
|
||||
background-color: #333;
|
||||
border-color: #666;
|
||||
--background-color: #333;
|
||||
--border-color: #666;
|
||||
}
|
||||
body.theme-contrast-dark .tooltip {
|
||||
background-color: #1e1e1e;
|
||||
border-color: #696969;
|
||||
--background-color: #1e1e1e;
|
||||
--border-color: #696969;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
background-color: #fff;
|
||||
background-color: var(--background-color);
|
||||
background-color: var(--background-normal);
|
||||
border-color: #e1e1e1;
|
||||
border-color: var(--border-color);
|
||||
border-color: var(--border-regular-control);
|
||||
}
|
||||
@ -12,11 +12,12 @@
|
||||
"sr-Latn-RS": "AI",
|
||||
"ja-JA": "AI",
|
||||
"sq-AL": "AI",
|
||||
"it": "IA"
|
||||
"it": "IA",
|
||||
"ar-SA": "AI"
|
||||
},
|
||||
|
||||
"guid" : "asc.{9DC93CDB-B576-4F0C-B55E-FCC9C48DD007}",
|
||||
"version": "2.2.8",
|
||||
"version": "2.2.9",
|
||||
"minVersion" : "8.2.0",
|
||||
|
||||
"variations" : [
|
||||
@ -34,7 +35,8 @@
|
||||
"sr-Latn-RS": "Koristite AI čet robota za obavljanje zadataka koji uključuju razumevanje ili generisanje prirodnog jezika ili koda.",
|
||||
"ja-JA": "自然言語やコードの理解または生成が必要なタスクを行うには、AIチャットボットを使用できます。",
|
||||
"sq-AL": "Shtoni dhe selektoni modele AI për detyra të ndryshme.",
|
||||
"it": "Utilizza il chatbot dell'IA per eseguire attività che implicano la comprensione o la generazione di codice o linguaggio naturale."
|
||||
"it": "Utilizza il chatbot dell'IA per eseguire attività che implicano la comprensione o la generazione di codice o linguaggio naturale.",
|
||||
"ar-SA": "استخدموا روبوت المحادثة الذكي لتنفيذ المهام التي تتطلب فهمًا أو إنتاجًا للغة الطبيعية أو البرمجة."
|
||||
},
|
||||
|
||||
"url" : "index.html",
|
||||
@ -46,7 +48,7 @@
|
||||
"type" : "background",
|
||||
"initDataType" : "none",
|
||||
"buttons" : [],
|
||||
"events" : ["onContextMenuShow", "onContextMenuClick", "onToolbarMenuClick"],
|
||||
"events" : ["onAIPluginSettings", "onContextMenuShow", "onContextMenuClick", "onToolbarMenuClick"],
|
||||
|
||||
"store": {
|
||||
"background": {
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
</div>
|
||||
<label id="error-label" class="hide"></label>
|
||||
<input id="file-input" type="file" multiple accept=".js"/>
|
||||
<script type="text/javascript" src="scripts/utils/theme.js"></script>
|
||||
<script type="text/javascript" src="scripts/customProviders.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -18,7 +18,8 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>AI Constructor</title>
|
||||
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.js"></script>
|
||||
<!--<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.js"></script>-->
|
||||
<script type="text/javascript" src="https://onlyoffice-plugins.github.io/onlyoffice.github.io/sdkjs-plugins/v1/plugins.js"></script>
|
||||
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins-ui.js"></script>
|
||||
<link rel="stylesheet" href="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.css">
|
||||
|
||||
@ -31,7 +32,6 @@
|
||||
<script type="text/javascript" src="scripts/engine/engine.js"></script>
|
||||
|
||||
<script type="text/javascript" src="scripts/engine/library.js"></script>
|
||||
<script type="text/javascript" src="scripts/engine/buttons.js"></script>
|
||||
<script type="text/javascript" src="scripts/engine/register.js"></script>
|
||||
|
||||
<script type="text/javascript" src="scripts/code.js"></script>
|
||||
|
||||
@ -144,50 +144,50 @@ body {
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
body.theme-light .toggle-button,
|
||||
body.theme-gray .toggle-button {
|
||||
border-color: #c0c0c0;
|
||||
}
|
||||
body.theme-light .toggle-button:hover:not([disabled]),
|
||||
body.theme-gray .toggle-button:hover:not([disabled]) {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
body.theme-light .toggle-button.active,
|
||||
body.theme-gray .toggle-button.active {
|
||||
background-color: #cbcbcb;
|
||||
}
|
||||
|
||||
/* Themes style for Toggle button */
|
||||
body.theme-classic-light .toggle-button {
|
||||
border-color: #cfcfcf;
|
||||
}
|
||||
body.theme-classic-light .toggle-button:hover:not([disabled]) {
|
||||
background-color: #d8dadc;
|
||||
}
|
||||
body.theme-classic-light .toggle-button.active {
|
||||
background-color: #7d858c !important;
|
||||
--border-color: #cfcfcf;
|
||||
--background-hover-color: #d8dadc;
|
||||
--background-active-color: #7d858c;
|
||||
}
|
||||
body.theme-classic-light .toggle-button.active img{
|
||||
filter: invert(1);
|
||||
}
|
||||
|
||||
body.theme-light .toggle-button,
|
||||
body.theme-gray .toggle-button {
|
||||
--border-color: #c0c0c0;
|
||||
--background-hover-color: #e0e0e0;
|
||||
--background-active-color: #cbcbcb;
|
||||
}
|
||||
|
||||
body.theme-dark .toggle-button {
|
||||
border-color: #666;
|
||||
}
|
||||
body.theme-dark .toggle-button:hover:not([disabled]) {
|
||||
background-color: #555;
|
||||
}
|
||||
body.theme-dark .toggle-button.active {
|
||||
background-color: #707070 !important;
|
||||
--border-color: #666;
|
||||
--background-hover-color: #555;
|
||||
--background-active-color: #707070;
|
||||
}
|
||||
|
||||
body.theme-contrast-dark .toggle-button {
|
||||
border-color: #696969;
|
||||
--border-color: #696969;
|
||||
--background-hover-color: #424242;
|
||||
--background-active-color: #666666;
|
||||
}
|
||||
body.theme-contrast-dark .toggle-button:hover:not([disabled]) {
|
||||
background-color: #424242;
|
||||
|
||||
.toggle-button {
|
||||
border-color: #e1e1e1;
|
||||
border-color: var(--border-color);
|
||||
border-color: var(--border-regular-control);
|
||||
}
|
||||
body.theme-contrast-dark .toggle-button.active {
|
||||
background-color: #666666 !important;
|
||||
.toggle-button:hover:not([disabled]) {
|
||||
background-color: #eaeaea;
|
||||
background-color: var(--background-hover-color);
|
||||
background-color: var(--highlight-button-hover);
|
||||
}
|
||||
.toggle-button.active {
|
||||
background-color: #e1e1e1 !important;
|
||||
background-color: var(--background-active-color) !important;
|
||||
background-color: var(--highlight-button-pressed) !important;
|
||||
}
|
||||
|
||||
.select2-container {
|
||||
|
||||
@ -38,21 +38,3 @@ body {
|
||||
#ai-models-list {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
/* Themes style for Item Models List */
|
||||
body.theme-classic-light #ai-models-list .item {
|
||||
border-color: #cfcfcf;
|
||||
}
|
||||
|
||||
body.theme-light #ai-models-list .item,
|
||||
body.theme-gray #ai-models-list .item {
|
||||
border-color: #c0c0c0;
|
||||
}
|
||||
|
||||
body.theme-dark #ai-models-list .item {
|
||||
border-color: #666;
|
||||
}
|
||||
|
||||
body.theme-contrast-dark #ai-models-list .item {
|
||||
border-color: #696969;
|
||||
}
|
||||
|
||||
@ -122,8 +122,10 @@ input {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
margin-bottom: 8px;
|
||||
background-color: #fff;
|
||||
background-color: var(--background-normal);
|
||||
padding: 6px 8px;
|
||||
border: 1px solid #e1e1e1;
|
||||
border: 1px solid var(--border-regular-control);
|
||||
border-radius: 2px;
|
||||
}
|
||||
@ -176,6 +178,7 @@ input {
|
||||
|
||||
.message_content_error_desc {
|
||||
margin-top: 4px;
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
color: var(--text-secondary);
|
||||
line-height: 14px;
|
||||
}
|
||||
@ -257,6 +260,7 @@ input {
|
||||
|
||||
#loading .span_message {
|
||||
padding: 0;
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
@ -305,6 +309,7 @@ input {
|
||||
}
|
||||
|
||||
.user_message .message_content {
|
||||
background-color: #fff;
|
||||
background-color: var(--background-toolbar);
|
||||
/* background-color: var(--highlight-button-hover); */
|
||||
}
|
||||
@ -357,9 +362,11 @@ input {
|
||||
|
||||
#attached_text_wrapper {
|
||||
padding: 6px 8px;
|
||||
background-color: #fff;
|
||||
background-color: var(--background-toolbar);
|
||||
border-top-left-radius: 2px;
|
||||
border-top-right-radius: 2px;
|
||||
border: 1px solid #e1e1e1;
|
||||
border: 1px solid var(--border-regular-control);
|
||||
margin-bottom: -1px;
|
||||
display: flex;
|
||||
@ -387,13 +394,16 @@ input {
|
||||
|
||||
#input_message_wrapper {
|
||||
display: flex;
|
||||
background-color: #fff;
|
||||
background-color: var(--background-normal);
|
||||
border-radius: 2px;
|
||||
border: 1px solid #e1e1e1;
|
||||
border: 1px solid var(--border-regular-control);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#input_message_wrapper.focused {
|
||||
border-color: #4A87E7;
|
||||
border-color: var(--border-control-focus);
|
||||
}
|
||||
|
||||
|
||||
@ -10,84 +10,22 @@ body {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
body.theme-light, body.theme-classic-light, body.theme-gray {
|
||||
background-color: #fff;
|
||||
body, body.theme-light, body.theme-classic-light, body.theme-gray {
|
||||
--body-background-color: #fff;
|
||||
}
|
||||
body.theme-dark {
|
||||
background-color: #333;
|
||||
--body-background-color: #333;
|
||||
}
|
||||
body.theme-contrast-dark {
|
||||
background-color: #212121;
|
||||
--body-background-color: #212121;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #fff !important;
|
||||
background-color: var(--body-background-color) !important;
|
||||
background-color: var(--background-normal) !important;
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: none;
|
||||
}
|
||||
|
||||
/* Stylesheet for list */
|
||||
.list {
|
||||
flex: 1;
|
||||
border: 1px solid;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.list .item {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Themes style for List */
|
||||
body .list {
|
||||
border-color: #cfcfcf;
|
||||
border-color: var(--border-list);
|
||||
}
|
||||
body.theme-classic-light .list {
|
||||
--border-list: #cfcfcf;
|
||||
}
|
||||
body.theme-light .list,
|
||||
body.theme-gray .list {
|
||||
--border-list: #c0c0c0;
|
||||
}
|
||||
body.theme-dark .list {
|
||||
--border-list: #666666;
|
||||
}
|
||||
body.theme-contrast-dark .list {
|
||||
--border-list: #696969;
|
||||
}
|
||||
|
||||
body.theme-classic-light .list .item:hover {
|
||||
background-color: #d8dadc;
|
||||
color: #444;
|
||||
}
|
||||
body.theme-classic-light .list .item.selected {
|
||||
background-color: #7d858c;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
body.theme-light .list .item:hover,
|
||||
body.theme-gray .list .item:hover {
|
||||
background-color: #e0e0e0;
|
||||
color: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
body.theme-light .list .item.selected,
|
||||
body.theme-gray .list .item.selected {
|
||||
background-color: #cbcbcb;
|
||||
color: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
body.theme-dark .list .item:hover {
|
||||
background-color: #555;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
body.theme-dark .list .item.selected {
|
||||
background-color: #707070;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
body.theme-contrast-dark .list .item:hover {
|
||||
background-color: #424242;
|
||||
color: #e8e8e8;
|
||||
}
|
||||
body.theme-contrast-dark .list .item.selected {
|
||||
background-color: #666666;
|
||||
color: #e8e8e8;
|
||||
}
|
||||
@ -13,6 +13,7 @@ body {
|
||||
#edit-ai-models {
|
||||
display: inline-flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 10px;
|
||||
}
|
||||
#edit-ai-models label {
|
||||
cursor: pointer;
|
||||
@ -22,7 +23,7 @@ body {
|
||||
|
||||
#actions-list {
|
||||
position: relative;
|
||||
height: 230px;
|
||||
height: 240px;
|
||||
margin-top: 32px;
|
||||
}
|
||||
|
||||
@ -48,6 +49,9 @@ body {
|
||||
#actions-list .item .label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
margin-right: 10px;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
#actions-list .item .label img{
|
||||
@ -56,6 +60,10 @@ body {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
#actions-list .item .label div{
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
#actions-list .ps__rail-y {
|
||||
margin: 0 !important;
|
||||
right: 0 !important;
|
||||
|
||||
@ -45,6 +45,14 @@ textarea {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
#summarize-btn {
|
||||
color: var(--text-inverse);
|
||||
background-color: var(--background-primary-dialog-button);
|
||||
}
|
||||
#summarize-btn:hover {
|
||||
background-color: var(--highlight-primary-dialog-button-hover) !important;
|
||||
}
|
||||
|
||||
#clear-btn {
|
||||
cursor: pointer;
|
||||
border-bottom: 1px dotted currentColor;
|
||||
@ -76,6 +84,7 @@ textarea {
|
||||
display: none;
|
||||
height: calc(100% - 7px);
|
||||
width: calc(100% - 4px);
|
||||
background: #fff;
|
||||
background: var(--background-normal);
|
||||
box-sizing: border-box;
|
||||
top: 2px;
|
||||
|
||||
@ -210,16 +210,11 @@ onResize();
|
||||
|
||||
function onThemeChanged(theme) {
|
||||
window.Asc.plugin.onThemeChangedBase(theme);
|
||||
themeType = theme.type || 'light';
|
||||
|
||||
var classes = document.body.className.split(' ');
|
||||
classes.forEach(function(className) {
|
||||
if (className.indexOf('theme-') != -1) {
|
||||
document.body.classList.remove(className);
|
||||
}
|
||||
});
|
||||
document.body.classList.add(theme.name);
|
||||
document.body.classList.add('theme-type-' + themeType);
|
||||
var themeType = theme.type || 'light';
|
||||
updateBodyThemeClasses(theme.type, theme.name);
|
||||
updateThemeVariables(theme);
|
||||
|
||||
$('img.icon').each(function() {
|
||||
var src = $(this).attr('src');
|
||||
var newSrc = src.replace(/(icons\/)([^\/]+)(\/)/, '$1' + themeType + '$3');
|
||||
|
||||
@ -67,17 +67,11 @@ onResize();
|
||||
|
||||
function onThemeChanged(theme) {
|
||||
window.Asc.plugin.onThemeChangedBase(theme);
|
||||
themeType = theme.type || 'light';
|
||||
|
||||
var classes = document.body.className.split(' ');
|
||||
classes.forEach(function(className) {
|
||||
if (className.indexOf('theme-') != -1) {
|
||||
document.body.classList.remove(className);
|
||||
}
|
||||
});
|
||||
document.body.classList.add(theme.name);
|
||||
document.body.classList.add('theme-type-' + themeType);
|
||||
|
||||
var themeType = theme.type || 'light';
|
||||
updateBodyThemeClasses(theme.type, theme.name);
|
||||
updateThemeVariables(theme);
|
||||
|
||||
let btnIcons = document.getElementsByClassName('icon');
|
||||
for (let i = 0; i < btnIcons.length; i++) {
|
||||
let icon = btnIcons[i];
|
||||
|
||||
@ -370,6 +370,13 @@
|
||||
document.getElementById('total_tokens').classList.remove('err-message');
|
||||
document.getElementById('total_tokens').innerText = 0;
|
||||
};
|
||||
|
||||
document.getElementById("chat_wrapper").addEventListener("click", function(e) {
|
||||
if (e.target.tagName === "A") {
|
||||
e.preventDefault();
|
||||
window.open(e.target.href, "_blank");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -577,17 +584,9 @@
|
||||
bCreateLoader = false;
|
||||
window.Asc.plugin.onThemeChangedBase(theme);
|
||||
|
||||
addCssVariables(theme);
|
||||
themeType = theme.type || 'light';
|
||||
|
||||
var classes = document.body.className.split(' ');
|
||||
classes.forEach(function(className) {
|
||||
if (className.indexOf('theme-') != -1) {
|
||||
document.body.classList.remove(className);
|
||||
}
|
||||
});
|
||||
document.body.classList.add(theme.name);
|
||||
document.body.classList.add('theme-type-' + themeType);
|
||||
var themeType = theme.type || 'light';
|
||||
updateBodyThemeClasses(theme.type, theme.name);
|
||||
updateThemeVariables(theme);
|
||||
|
||||
$('img.icon').each(function() {
|
||||
var src = $(this).attr('src');
|
||||
@ -596,33 +595,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
function addCssVariables(theme) {
|
||||
let colorRegex = /^(#([0-9a-f]{3}){1,2}|rgba?\([^\)]+\)|hsl\([^\)]+\))$/i;
|
||||
|
||||
let oldStyle = document.getElementById('theme-variables');
|
||||
if (oldStyle) {
|
||||
oldStyle.remove();
|
||||
}
|
||||
|
||||
let style = document.createElement('style');
|
||||
style.id = 'theme-variables';
|
||||
let cssVariables = ":root {\n";
|
||||
|
||||
for (let key in theme) {
|
||||
let value = theme[key];
|
||||
|
||||
if (colorRegex.test(value)) {
|
||||
let cssKey = '--' + key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
||||
cssVariables += ' ' + cssKey + ': ' + value + ';\n';
|
||||
}
|
||||
}
|
||||
|
||||
cssVariables += "}";
|
||||
|
||||
style.textContent = cssVariables;
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
|
||||
window.addEventListener("resize", onResize);
|
||||
onResize();
|
||||
|
||||
|
||||
@ -6,9 +6,9 @@ let summarizationWindow = null;
|
||||
let translateSettingsWindow = null;
|
||||
|
||||
let initCounter = 0;
|
||||
async function initWithTranslate() {
|
||||
initCounter++;
|
||||
if (2 === initCounter) {
|
||||
async function initWithTranslate(counter) {
|
||||
initCounter |= counter;
|
||||
if (3 === initCounter) {
|
||||
registerButtons(window);
|
||||
Asc.Buttons.registerContextMenu();
|
||||
Asc.Buttons.registerToolbarMenu();
|
||||
@ -91,7 +91,17 @@ async function GetOldCustomFunctions() {
|
||||
}
|
||||
|
||||
window.Asc.plugin.init = async function() {
|
||||
await initWithTranslate();
|
||||
// Check server settings
|
||||
if (window.Asc.plugin.info.aiPluginSettings) {
|
||||
try {
|
||||
AI.serverSettings = JSON.parse(window.Asc.plugin.info.aiPluginSettings);
|
||||
} catch (e) {
|
||||
AI.serverSettings = null;
|
||||
}
|
||||
delete window.Asc.plugin.info.aiPluginSettings;
|
||||
}
|
||||
|
||||
await initWithTranslate(1 << 1);
|
||||
clearChatState();
|
||||
|
||||
let editorVersion = await Asc.Library.GetEditorVersion();
|
||||
@ -195,7 +205,7 @@ window.Asc.plugin.init = async function() {
|
||||
};
|
||||
|
||||
window.Asc.plugin.onTranslate = async function() {
|
||||
await initWithTranslate();
|
||||
await initWithTranslate(1);
|
||||
};
|
||||
|
||||
window.Asc.plugin.button = function(id, windowId) {
|
||||
@ -290,6 +300,11 @@ function onOpenSettingsModal() {
|
||||
updateActions();
|
||||
updateModels();
|
||||
});
|
||||
settingsWindow.attachEvent("onUpdateHeight", function(height) {
|
||||
if(height > variation.size[1]) {
|
||||
Asc.Editor.callMethod("ResizeWindow", [settingsWindow.id, [variation.size[0] - 2, height]]); //2 is the border-width at the window
|
||||
}
|
||||
});
|
||||
settingsWindow.attachEvent('onChangeAction', function(data){
|
||||
AI.ActionsChange(data.id, data.model);
|
||||
});
|
||||
|
||||
@ -189,16 +189,10 @@ function hideErrorLabel() {
|
||||
|
||||
function onThemeChanged(theme) {
|
||||
window.Asc.plugin.onThemeChangedBase(theme);
|
||||
themeType = theme.type || 'light';
|
||||
|
||||
let classes = document.body.className.split(' ');
|
||||
classes.forEach(function(className) {
|
||||
if (className.indexOf('theme-') != -1) {
|
||||
document.body.classList.remove(className);
|
||||
}
|
||||
});
|
||||
document.body.classList.add(theme.name);
|
||||
document.body.classList.add('theme-type-' + themeType);
|
||||
|
||||
var themeType = theme.type || 'light';
|
||||
updateBodyThemeClasses(theme.type, theme.name);
|
||||
updateThemeVariables(theme);
|
||||
|
||||
let btnIcons = document.getElementsByClassName('icon');
|
||||
for (let i = 0; i < btnIcons.length; i++) {
|
||||
|
||||
@ -1,359 +0,0 @@
|
||||
(function(window, undefined)
|
||||
{
|
||||
function generateGuid()
|
||||
{
|
||||
if (!window.crypto || !window.crypto.getRandomValues)
|
||||
{
|
||||
function s4() {
|
||||
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
|
||||
}
|
||||
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
||||
}
|
||||
|
||||
var array = new Uint16Array(8);
|
||||
window.crypto.getRandomValues(array);
|
||||
var index = 0;
|
||||
function s4() {
|
||||
var value = 0x10000 + array[index++];
|
||||
return value.toString(16).substring(1);
|
||||
}
|
||||
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
||||
}
|
||||
|
||||
function translateItem(text) {
|
||||
return window.Asc.plugin.tr(text);
|
||||
};
|
||||
|
||||
window.Asc = window.Asc || {};
|
||||
var Asc = window.Asc;
|
||||
|
||||
Asc.Buttons = {};
|
||||
Asc.Buttons.ButtonsContextMenu = [];
|
||||
Asc.Buttons.ButtonsToolbar = [];
|
||||
|
||||
Asc.Buttons.registerContextMenu = function()
|
||||
{
|
||||
window.Asc.plugin.attachEvent("onContextMenuShow", function(options) {
|
||||
if (!options)
|
||||
return;
|
||||
|
||||
let items = {
|
||||
guid: window.Asc.plugin.guid,
|
||||
};
|
||||
for (let i = 0, len = Asc.Buttons.ButtonsContextMenu.length; i < len; i++)
|
||||
{
|
||||
let button = Asc.Buttons.ButtonsContextMenu[i];
|
||||
if (button.parent === null)
|
||||
{
|
||||
button.onContextMenuShow(options, items);
|
||||
}
|
||||
}
|
||||
|
||||
if (items.items)
|
||||
window.Asc.plugin.executeMethod("AddContextMenuItem", [items]);
|
||||
});
|
||||
};
|
||||
|
||||
Asc.Buttons.registerToolbarMenu = function()
|
||||
{
|
||||
let items = {
|
||||
guid : window.Asc.plugin.guid,
|
||||
tabs : []
|
||||
};
|
||||
|
||||
for (let i = 0, len = Asc.Buttons.ButtonsToolbar.length; i < len; i++)
|
||||
{
|
||||
let button = Asc.Buttons.ButtonsToolbar[i];
|
||||
if (button.parent === null)
|
||||
{
|
||||
button.toToolbar(items);
|
||||
}
|
||||
|
||||
if (!!button.menu) {
|
||||
for (item of button.menu) {
|
||||
if (!!item.onclick) {
|
||||
window.Asc.plugin.attachToolbarMenuClickEvent(item.id, item.onclick);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (items.tabs.length > 0)
|
||||
window.Asc.plugin.executeMethod("AddToolbarMenuItem", [items]);
|
||||
};
|
||||
|
||||
Asc.Buttons.updateToolbarMenu = function(id, name, buttons)
|
||||
{
|
||||
let buttonMainToolbar = new Asc.ButtonToolbar(null, id);
|
||||
buttonMainToolbar.text = name;
|
||||
|
||||
let items = {
|
||||
guid : window.Asc.plugin.guid,
|
||||
tabs : []
|
||||
};
|
||||
|
||||
buttonMainToolbar.childs = buttons;
|
||||
for (let i = 0, len = buttons.length; i < len; i++)
|
||||
buttons[i].parent = buttonMainToolbar;
|
||||
|
||||
buttonMainToolbar.toToolbar(items);
|
||||
|
||||
if (items.tabs.length > 0)
|
||||
window.Asc.plugin.executeMethod("UpdateToolbarMenuItem", [items]);
|
||||
};
|
||||
|
||||
var ToolbarButtonType = {
|
||||
Button : "button",
|
||||
BigButton : "big-button"
|
||||
};
|
||||
|
||||
var ItemType = {
|
||||
None : 0,
|
||||
ContextMenu : 1,
|
||||
Toolbar : 2
|
||||
};
|
||||
|
||||
function Button(parent, id)
|
||||
{
|
||||
this.itemType = ItemType.None;
|
||||
this.editors = ["word", "cell", "slide"];
|
||||
|
||||
this.id = (id === undefined) ? generateGuid() : id;
|
||||
|
||||
this.icons = null;
|
||||
|
||||
this.text = "";
|
||||
this.hint = null;
|
||||
this.data = "";
|
||||
|
||||
this.separator = false;
|
||||
this.lockInViewMode = true;
|
||||
this.enableToggle = false;
|
||||
this.disabled = false;
|
||||
this.removed = false;
|
||||
|
||||
this.parent = parent ? parent : null;
|
||||
this.childs = null;
|
||||
|
||||
if (this.parent)
|
||||
{
|
||||
if (!this.parent.childs)
|
||||
this.parent.childs = [];
|
||||
this.parent.childs.push(this);
|
||||
}
|
||||
}
|
||||
|
||||
Button.prototype.toItem = function()
|
||||
{
|
||||
let item = {
|
||||
id : this.id,
|
||||
text : translateItem(this.text)
|
||||
};
|
||||
|
||||
if (this.hint !== null)
|
||||
item.hint = translateItem(this.hint === "" ? this.hint : this.text);
|
||||
|
||||
if (this.separator)
|
||||
item.separator = true;
|
||||
|
||||
if (this.data)
|
||||
item.data = this.data;
|
||||
|
||||
if (this.lockInViewMode)
|
||||
item.lockInViewMode = true;
|
||||
|
||||
if (this.enableToggle)
|
||||
item.enableToggle = true;
|
||||
|
||||
if (this.disabled)
|
||||
item.disabled = true;
|
||||
else
|
||||
item.disabled = false;
|
||||
|
||||
if (this.removed)
|
||||
item.removed = true;
|
||||
|
||||
if (this.icons)
|
||||
item.icons = this.icons;
|
||||
|
||||
if (this.itemType === ItemType.Toolbar)
|
||||
item.type = this.type;
|
||||
|
||||
if (this.menu)
|
||||
item.items = this.menu.map(function(menuItem) {
|
||||
menuItem.text = translateItem(menuItem.text);
|
||||
return menuItem;
|
||||
});
|
||||
|
||||
if (this.split)
|
||||
item.split = true;
|
||||
|
||||
return item;
|
||||
};
|
||||
|
||||
Button.prototype.attachOnClick = function(handler)
|
||||
{
|
||||
};
|
||||
|
||||
Button.prototype.onClick = function()
|
||||
{
|
||||
console.log("BUTTON: " + this.text);
|
||||
};
|
||||
|
||||
function ButtonContextMenu(parent, id)
|
||||
{
|
||||
Button.call(this, parent, id);
|
||||
|
||||
this.itemType = ItemType.ContextMenu;
|
||||
this.showOnOptionsType = [];
|
||||
|
||||
Asc.Buttons.ButtonsContextMenu.push(this);
|
||||
}
|
||||
|
||||
ButtonContextMenu.prototype = Object.create(Button.prototype);
|
||||
ButtonContextMenu.prototype.constructor = ButtonContextMenu;
|
||||
|
||||
ButtonContextMenu.prototype.copy = function()
|
||||
{
|
||||
let ret = new ButtonContextMenu(this.parent, this.id);
|
||||
ret.editors = this.editors;
|
||||
|
||||
ret.separator = this.separator;
|
||||
ret.lockInViewMode = this.lockInViewMode;
|
||||
ret.enableToggle = this.enableToggle;
|
||||
ret.disabled = this.disabled;
|
||||
ret.showOnOptionsType = this.showOnOptionsType.slice();
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
ButtonContextMenu.prototype.addCheckers = function()
|
||||
{
|
||||
let len = arguments.length;
|
||||
this.showOnOptionsType = new Array(len);
|
||||
for (let i = 0; i < len; i++)
|
||||
this.showOnOptionsType[i] = arguments[i];
|
||||
};
|
||||
|
||||
ButtonContextMenu.prototype.attachOnClick = function(handler)
|
||||
{
|
||||
window.Asc.plugin.attachContextMenuClickEvent(this.id, handler);
|
||||
};
|
||||
|
||||
ButtonContextMenu.prototype.onContextMenuShowAnalyze = function(options, parent)
|
||||
{
|
||||
return false;
|
||||
};
|
||||
|
||||
ButtonContextMenu.prototype.onContextMenuShowExtendItem = function(options, item)
|
||||
{
|
||||
};
|
||||
|
||||
ButtonContextMenu.prototype.onContextMenuShow = function(options, parent)
|
||||
{
|
||||
if (this.onContextMenuShowAnalyze(options, parent))
|
||||
return;
|
||||
|
||||
let isSupport = false;
|
||||
for (let i = 0, len = this.editors.length; i < len; i++)
|
||||
{
|
||||
if (Asc.plugin.info.editorType === this.editors[i])
|
||||
{
|
||||
isSupport = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isSupport)
|
||||
return;
|
||||
|
||||
for (let i = 0, len = this.showOnOptionsType.length; i < len; i++)
|
||||
{
|
||||
if (options.type === this.showOnOptionsType[i] || this.showOnOptionsType[i] === "All")
|
||||
{
|
||||
if (!parent.items)
|
||||
parent.items = [];
|
||||
|
||||
let curItem = this.toItem();
|
||||
this.onContextMenuShowExtendItem(options, curItem);
|
||||
|
||||
if (this.childs)
|
||||
{
|
||||
for (let j = 0, childsLen = this.childs.length; j < childsLen; j++)
|
||||
{
|
||||
this.childs[j].onContextMenuShow(options, curItem);
|
||||
}
|
||||
}
|
||||
|
||||
parent.items.push(curItem);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function ButtonToolbar(parent, id)
|
||||
{
|
||||
Button.call(this, parent, id);
|
||||
|
||||
this.itemType = ItemType.Toolbar;
|
||||
this.type = ToolbarButtonType.BigButton;
|
||||
this.tab = "";
|
||||
|
||||
Asc.Buttons.ButtonsToolbar.push(this);
|
||||
}
|
||||
|
||||
ButtonToolbar.prototype = Object.create(Button.prototype);
|
||||
ButtonToolbar.prototype.constructor = ButtonToolbar;
|
||||
|
||||
ButtonToolbar.prototype.attachOnClick = function(handler)
|
||||
{
|
||||
window.Asc.plugin.attachToolbarMenuClickEvent(this.id, handler);
|
||||
};
|
||||
|
||||
ButtonToolbar.prototype.toItem = function(items)
|
||||
{
|
||||
let item = Button.prototype.toItem.call(this);
|
||||
item.type = this.type;
|
||||
return item;
|
||||
};
|
||||
|
||||
ButtonToolbar.prototype.toToolbar = function(items)
|
||||
{
|
||||
let currentItem = null;
|
||||
if (this.parent === null)
|
||||
{
|
||||
let tab = {
|
||||
id : this.id,
|
||||
text : translateItem(this.text),
|
||||
items : []
|
||||
};
|
||||
if (this.hint !== null)
|
||||
tab.hint = translateItem(this.hint === "" ? this.hint : this.text);
|
||||
|
||||
items.tabs.push(tab);
|
||||
|
||||
currentItem = tab;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentItem = this.toItem();
|
||||
|
||||
if (!items.items)
|
||||
items.items = [];
|
||||
|
||||
items.items.push(currentItem);
|
||||
}
|
||||
|
||||
if (this.childs)
|
||||
{
|
||||
for (let j = 0, childsLen = this.childs.length; j < childsLen; j++)
|
||||
{
|
||||
this.childs[j].toToolbar(currentItem);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Asc.ToolbarButtonType = ToolbarButtonType;
|
||||
Asc.ButtonContextMenu = ButtonContextMenu;
|
||||
Asc.ButtonToolbar = ButtonToolbar;
|
||||
})(window);
|
||||
@ -86,23 +86,34 @@
|
||||
"data" : request.body
|
||||
})
|
||||
}
|
||||
message.url = AI.PROXY_URL;
|
||||
if (AI.serverSettings){
|
||||
message.url = AI.serverSettings.proxy;
|
||||
request["headers"] = {
|
||||
"Authorization" : "Bearer " + Asc.plugin.info.jwt,
|
||||
}
|
||||
} else {
|
||||
message.url = AI.PROXY_URL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fetch(message.url, request)
|
||||
.then(function(response) {
|
||||
return response.json()
|
||||
})
|
||||
.then(function(data) {
|
||||
if (data.error)
|
||||
resolve({error: 1, message: data.error.message ? data.error.message : ((typeof data.error === "string") ? data.error : "")});
|
||||
else
|
||||
resolve({error: 0, data: data.data ? data.data : data});
|
||||
})
|
||||
.catch(function(error) {
|
||||
resolve({error: 1, message: error.message ? error.message : ""});
|
||||
});
|
||||
try {
|
||||
fetch(message.url, request)
|
||||
.then(function(response) {
|
||||
return response.json()
|
||||
})
|
||||
.then(function(data) {
|
||||
if (data.error)
|
||||
resolve({error: 1, message: data.error.message ? data.error.message : ((typeof data.error === "string") ? data.error : "")});
|
||||
else
|
||||
resolve({error: 0, data: data.data ? data.data : data});
|
||||
})
|
||||
.catch(function(error) {
|
||||
resolve({error: 1, message: error.message ? error.message : ""});
|
||||
});
|
||||
} catch (error) {
|
||||
resolve({error: 1, message: error.message ? error.message : ""});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -136,7 +147,7 @@
|
||||
body[i] = bodyPr[i];
|
||||
}
|
||||
|
||||
return provider.isUseProxy();
|
||||
return provider.isUseProxy() || AI.serverSettings;
|
||||
};
|
||||
|
||||
AI._getEndpointUrl = function(_provider, endpoint, model) {
|
||||
@ -279,10 +290,10 @@
|
||||
this.errorHandler(err);
|
||||
else {
|
||||
if (true) {
|
||||
await Asc.Library.SendError(err.message, -1);
|
||||
await Asc.Library.SendError(err.message, 0);
|
||||
} else {
|
||||
// since 8.3.0!!!
|
||||
await Asc.Editor.callMethod("ShowError", [err.message, -1]);
|
||||
await Asc.Editor.callMethod("ShowError", [err.message, 0]);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
@ -58,7 +58,11 @@
|
||||
AI.Storage.load = function() {
|
||||
let obj = null;
|
||||
try {
|
||||
obj = JSON.parse(window.localStorage.getItem(localStorageKey));
|
||||
if (AI.serverSettings) {
|
||||
obj = AI.serverSettings;
|
||||
} else {
|
||||
obj = JSON.parse(window.localStorage.getItem(localStorageKey));
|
||||
}
|
||||
} catch (e) {
|
||||
obj = AI.DEFAULT_SERVER_SETTINGS;
|
||||
|
||||
|
||||
@ -244,4 +244,6 @@
|
||||
|
||||
};
|
||||
|
||||
AI.serverSettings = null;
|
||||
|
||||
})();
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
function registerButtons(window, undefined)
|
||||
{
|
||||
window.AI = window.AI || {};
|
||||
var AI = window.AI;
|
||||
|
||||
function getToolBarButtonIcons(icon) {
|
||||
return "resources/icons/%theme-type%(light|dark)/big/" + icon + "%scale%(default).png";
|
||||
}
|
||||
@ -472,7 +475,7 @@ function registerButtons(window, undefined)
|
||||
window.buttonMainToolbar = buttonMainToolbar;
|
||||
window.getToolBarButtonIcons = getToolBarButtonIcons;
|
||||
|
||||
if (true)
|
||||
if (!AI.serverSettings)
|
||||
{
|
||||
let button1 = new Asc.ButtonToolbar(buttonMainToolbar);
|
||||
button1.text = "Settings";
|
||||
@ -485,7 +488,10 @@ function registerButtons(window, undefined)
|
||||
if (true)
|
||||
{
|
||||
let button1 = new Asc.ButtonToolbar(buttonMainToolbar);
|
||||
button1.separator = true;
|
||||
|
||||
if (!AI.serverSettings)
|
||||
button1.separator = true;
|
||||
|
||||
button1.text = "Chatbot";
|
||||
button1.icons = getToolBarButtonIcons("ask-ai");
|
||||
button1.attachOnClick(function(data){
|
||||
@ -548,8 +554,6 @@ function registerButtons(window, undefined)
|
||||
}
|
||||
|
||||
// register actions
|
||||
window.AI = window.AI || {};
|
||||
var AI = window.AI;
|
||||
|
||||
AI.ActionType = {
|
||||
Chat : "Chat",
|
||||
@ -629,7 +633,11 @@ function registerButtons(window, undefined)
|
||||
let obj = null;
|
||||
try
|
||||
{
|
||||
obj = JSON.parse(window.localStorage.getItem(actions_key));
|
||||
if (AI.serverSettings) {
|
||||
obj = AI.serverSettings.actions;
|
||||
} else {
|
||||
obj = JSON.parse(window.localStorage.getItem(actions_key));
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
@ -657,5 +665,5 @@ function registerButtons(window, undefined)
|
||||
}
|
||||
};
|
||||
|
||||
AI.ActionsLoad();
|
||||
AI.ActionsLoad();
|
||||
}
|
||||
|
||||
@ -14,15 +14,49 @@ var capabilitiesList = {
|
||||
|
||||
var scrollbarList = new PerfectScrollbar("#actions-list", {});
|
||||
|
||||
var heightUpdateConditions = {
|
||||
_updateActions: false,
|
||||
_updateModels: false,
|
||||
_translate: false,
|
||||
|
||||
_markReady: function(key) {
|
||||
heightUpdateConditions[key] = true;
|
||||
heightUpdateConditions.checkAllReady();
|
||||
},
|
||||
|
||||
updateActionsReady: function() {
|
||||
heightUpdateConditions._markReady('_updateActions');
|
||||
},
|
||||
updateModelsReady: function() {
|
||||
heightUpdateConditions._markReady('_updateModels');
|
||||
},
|
||||
translateReady: function() {
|
||||
heightUpdateConditions._markReady('_translate');
|
||||
},
|
||||
|
||||
checkAllReady: function() {
|
||||
if (
|
||||
heightUpdateConditions._updateActions &&
|
||||
heightUpdateConditions._updateModels &&
|
||||
heightUpdateConditions._translate
|
||||
) {
|
||||
updateWindowHeight();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
window.Asc.plugin.init = function() {
|
||||
window.Asc.plugin.sendToPlugin("onInit");
|
||||
window.Asc.plugin.attachEvent("onUpdateActions", function(list) {
|
||||
actionsList = list;
|
||||
renderActionsList();
|
||||
heightUpdateConditions.updateActionsReady();
|
||||
});
|
||||
window.Asc.plugin.attachEvent("onUpdateModels", function(list) {
|
||||
aiModelsList = list;
|
||||
updatedComboBoxes();
|
||||
heightUpdateConditions.updateModelsReady();
|
||||
});
|
||||
window.Asc.plugin.attachEvent("onThemeChanged", onThemeChanged);
|
||||
|
||||
@ -37,6 +71,8 @@ window.Asc.plugin.onTranslate = function () {
|
||||
elements.forEach(function(element) {
|
||||
element.innerText = window.Asc.plugin.tr(element.innerText);
|
||||
});
|
||||
|
||||
heightUpdateConditions.translateReady();
|
||||
};
|
||||
|
||||
window.addEventListener("resize", onResize);
|
||||
@ -44,16 +80,11 @@ onResize();
|
||||
|
||||
function onThemeChanged(theme) {
|
||||
window.Asc.plugin.onThemeChangedBase(theme);
|
||||
|
||||
themeType = theme.type || 'light';
|
||||
|
||||
var classes = document.body.className.split(' ');
|
||||
classes.forEach(function(className) {
|
||||
if (className.indexOf('theme-') != -1) {
|
||||
document.body.classList.remove(className);
|
||||
}
|
||||
});
|
||||
document.body.classList.add(theme.name);
|
||||
document.body.classList.add('theme-type-' + themeType);
|
||||
updateBodyThemeClasses(theme.type, theme.name);
|
||||
updateThemeVariables(theme);
|
||||
|
||||
$('#actions-list img').each(function() {
|
||||
var src = $(this).attr('src');
|
||||
var newSrc = src.replace(/(icons\/)([^\/]+)(\/)/, '$1' + themeType + '$3');
|
||||
@ -118,6 +149,45 @@ function renderActionsList() {
|
||||
scrollbarList.update();
|
||||
}
|
||||
|
||||
function updateWindowHeight() {
|
||||
var descriptionHeight = {
|
||||
default: parseFloat($('#description').css('line-height')),
|
||||
current: $('#description').height()
|
||||
};
|
||||
var listHeight = {
|
||||
default: $('#actions-list').height(),
|
||||
maxAllowed: 400,
|
||||
current: 0
|
||||
};
|
||||
var maxVisibleItems = 5;
|
||||
var bodyOverflow = $('body').css('overflow-y');
|
||||
$('body').css('overflow-y', 'hidden');
|
||||
|
||||
var isBreak = false;
|
||||
$('#actions-list .item').each(function(index, item) {
|
||||
if(isBreak) return false;
|
||||
|
||||
var itemHeight = $(item).outerHeight();
|
||||
if(index == maxVisibleItems-1) {
|
||||
itemHeight -= parseFloat($(item).css('padding-bottom'));
|
||||
isBreak = true;
|
||||
}
|
||||
|
||||
if(listHeight.current + itemHeight <= listHeight.maxAllowed) {
|
||||
listHeight.current += itemHeight;
|
||||
} else {
|
||||
isBreak = true;
|
||||
}
|
||||
});
|
||||
|
||||
if(listHeight.current > listHeight.default || descriptionHeight.current > descriptionHeight.default) {
|
||||
$('#actions-list').css('height', listHeight.current + 'px');
|
||||
scrollbarList.update();
|
||||
window.Asc.plugin.sendToPlugin("onUpdateHeight", document.body.scrollHeight + 2);
|
||||
}
|
||||
$('body').css('overflow-y', bodyOverflow);
|
||||
}
|
||||
|
||||
function toggleScrollbarPadding() {
|
||||
var actionsListEl = document.getElementById('actions-list');
|
||||
// Check if there is a scroll bar
|
||||
@ -157,7 +227,7 @@ function updatedComboBoxes() {
|
||||
},
|
||||
minimumResultsForSearch: Infinity,
|
||||
dropdownAutoWidth: true,
|
||||
width : 150
|
||||
width : 140
|
||||
});
|
||||
// TODO: If the active model is no longer in the list, set null and trigger an event to change the model.
|
||||
selectEl.val(action.model);
|
||||
|
||||
@ -129,18 +129,11 @@ onResize();
|
||||
|
||||
function onThemeChanged(theme) {
|
||||
window.Asc.plugin.onThemeChangedBase(theme);
|
||||
themeType = theme.type || 'light';
|
||||
|
||||
addCssVariables(theme);
|
||||
|
||||
var classes = document.body.className.split(' ');
|
||||
classes.forEach(function(className) {
|
||||
if (className.indexOf('theme-') != -1) {
|
||||
document.body.classList.remove(className);
|
||||
}
|
||||
});
|
||||
document.body.classList.add(theme.name);
|
||||
document.body.classList.add('theme-type-' + themeType);
|
||||
var themeType = theme.type || 'light';
|
||||
updateBodyThemeClasses(theme.type, theme.name);
|
||||
updateThemeVariables(theme);
|
||||
|
||||
$('img.icon').each(function() {
|
||||
var src = $(this).attr('src');
|
||||
var newSrc = src.replace(/(icons\/)([^\/]+)(\/)/, '$1' + themeType + '$3');
|
||||
@ -148,33 +141,6 @@ function onThemeChanged(theme) {
|
||||
});
|
||||
}
|
||||
|
||||
function addCssVariables(theme) {
|
||||
let colorRegex = /^(#([0-9a-f]{3}){1,2}|rgba?\([^\)]+\)|hsl\([^\)]+\))$/i;
|
||||
|
||||
let oldStyle = document.getElementById('theme-variables');
|
||||
if (oldStyle) {
|
||||
oldStyle.remove();
|
||||
}
|
||||
|
||||
let style = document.createElement('style');
|
||||
style.id = 'theme-variables';
|
||||
let cssVariables = ":root {\n";
|
||||
|
||||
for (let key in theme) {
|
||||
let value = theme[key];
|
||||
|
||||
if (colorRegex.test(value)) {
|
||||
let cssKey = '--' + key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
||||
cssVariables += ' ' + cssKey + ': ' + value + ';\n';
|
||||
}
|
||||
}
|
||||
|
||||
cssVariables += "}";
|
||||
|
||||
style.textContent = cssVariables;
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
|
||||
function getZoomSuffixForImage() {
|
||||
var ratio = Math.round(window.devicePixelRatio / 0.25) * 0.25;
|
||||
ratio = Math.max(ratio, 1);
|
||||
|
||||
37
sdkjs-plugins/content/ai/scripts/utils/theme.js
Normal file
37
sdkjs-plugins/content/ai/scripts/utils/theme.js
Normal file
@ -0,0 +1,37 @@
|
||||
function updateBodyThemeClasses(themeType, themeName) {
|
||||
var classes = document.body.className.split(' ');
|
||||
classes.forEach(function(className) {
|
||||
if (className.indexOf('theme-') != -1) {
|
||||
document.body.classList.remove(className);
|
||||
}
|
||||
});
|
||||
themeName && document.body.classList.add(themeName);
|
||||
themeType && document.body.classList.add('theme-type-' + themeType);
|
||||
}
|
||||
|
||||
function updateThemeVariables(theme) {
|
||||
let colorRegex = /^(#([0-9a-f]{3}){1,2}|rgba?\([^\)]+\)|hsl\([^\)]+\))$/i;
|
||||
|
||||
let oldStyle = document.getElementById('theme-variables');
|
||||
if (oldStyle) {
|
||||
oldStyle.remove();
|
||||
}
|
||||
|
||||
let style = document.createElement('style');
|
||||
style.id = 'theme-variables';
|
||||
let cssVariables = ":root {\n";
|
||||
|
||||
for (let key in theme) {
|
||||
let value = theme[key];
|
||||
|
||||
if (colorRegex.test(value)) {
|
||||
let cssKey = '--' + key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
||||
cssVariables += ' ' + cssKey + ': ' + value + ';\n';
|
||||
}
|
||||
}
|
||||
|
||||
cssVariables += "}";
|
||||
|
||||
style.textContent = cssVariables;
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
@ -32,7 +32,7 @@
|
||||
</head>
|
||||
<body class="noselect">
|
||||
<div>
|
||||
<label id="description" class="i18n">Add and select AI models for different tasks.</label>
|
||||
<div id="description" class="i18n">Add and select AI models for different tasks.</div>
|
||||
<div id="actions-list">
|
||||
<!-- Dynamic render items -->
|
||||
</div>
|
||||
@ -40,6 +40,7 @@
|
||||
<div id="edit-ai-models">
|
||||
<label class="i18n">Edit AI models</label>
|
||||
</div>
|
||||
<script type="text/javascript" src="scripts/utils/theme.js"></script>
|
||||
<script type="text/javascript" src="scripts/settings.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -76,6 +76,7 @@
|
||||
<div id="loader-title" class="i18n">Summarization...</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="scripts/utils/theme.js"></script>
|
||||
<script type="text/javascript" src="scripts/summarization.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
145
sdkjs-plugins/content/ai/translations/ar-SA.json
Normal file
145
sdkjs-plugins/content/ai/translations/ar-SA.json
Normal file
@ -0,0 +1,145 @@
|
||||
{
|
||||
"OK": "موافق",
|
||||
"Cancel": "إلغاء",
|
||||
|
||||
"Add and select AI models for different tasks.": ".أضيفوا نماذج الذكاء الاصطناعي واختاروا النموذج المناسب لكل مهمة",
|
||||
"Edit AI models": "حرّروا نماذج الذكاء الاصطناعي",
|
||||
"AI configuration": "إعدادات الذكاء الاصطناعي",
|
||||
"Available models": "النماذج المتاحة",
|
||||
"Text-Based": "النصوص",
|
||||
"Images": "الصور",
|
||||
"Embeddings": "التضمينات",
|
||||
"Audio": "الصوتيات",
|
||||
"Moderations": "الإشراف على المحتوى",
|
||||
"Realtime": "المهام الفورية",
|
||||
"Code": "الكود",
|
||||
"Models": "النماذج",
|
||||
"Models not found": "لم يتم العثور على نماذج",
|
||||
|
||||
"AI Models list" : "قائمة نماذج الذكاء الاصطناعي",
|
||||
"Add" : "إضافة",
|
||||
"Edit" : "تحرير",
|
||||
"Delete" : "حذف",
|
||||
|
||||
"Add AI Model" : "إضافة نموذج ذكاء اصطناعي",
|
||||
"Edit AI Model" : "تحرير نموذج ذكاء اصطناعي",
|
||||
"Model name" : "اسم النموذج",
|
||||
"Provider" : "المزوّد",
|
||||
"Name" : "الاسم",
|
||||
"URL" : "الرابط",
|
||||
"Key" : "المفتاح",
|
||||
"Update models list" : "تحديث قائمة النماذج",
|
||||
"Use model for" : "استخدم النموذج في:",
|
||||
"Text": "النصوص",
|
||||
"Audio Processing": "معالجة الصوت",
|
||||
"Content Moderation": "الإشراف على المحتوى",
|
||||
"Realtime Tasks": "المهام الفورية",
|
||||
"Coding Help": "المساعدة في البرمجة",
|
||||
"Visual Analysis": "التحليل البصري",
|
||||
"Updating": "جارٍ التحديث",
|
||||
"Your text" : "نصكم",
|
||||
"Target language" : "اللغة الهدف",
|
||||
"Summary result" : "النتيجة الملخصة",
|
||||
"Insert result as" : "إدراج النتيجة",
|
||||
"Summarize" : "تلخيص",
|
||||
"Insert" : "إدراج",
|
||||
"Summarization...": "جاري التلخيص…",
|
||||
"As review": "كمراجعة",
|
||||
"In comment": "كتعليق",
|
||||
"Replace original text": "استبدال النص الأصلي",
|
||||
"To the end of document": "في نهاية المستند",
|
||||
"Clear": "مسح",
|
||||
"Insert your text here or select the part of the text": "أدرجوا النص هنا أو حددوا الجزء المطلوب",
|
||||
"The AI output will be shown here": "سيتم عرض نتيجة الذكاء الاصطناعي هنا",
|
||||
|
||||
|
||||
"Loading..." : "جارٍ التحميل…",
|
||||
"Text analysis" : "تحليل النص",
|
||||
"Summarization" : "تلخيص",
|
||||
"Keywords" : "الكلمات المفتاحية",
|
||||
"Word analysis" : "تحليل الكلمات",
|
||||
"Explain text in comment" : "شرح النص كتعليق",
|
||||
"Explain text in hyperlink" : "شرح النص كرابط",
|
||||
"Translate" : "ترجمة",
|
||||
"Translation" : "الترجمة",
|
||||
"French" : "الفرنسية",
|
||||
"English" : "الإنجليزية",
|
||||
"German" : "الألمانية",
|
||||
"Chinese" : "الصينية",
|
||||
"Japanese" : "اليابانية",
|
||||
"Russian" : "الروسية",
|
||||
"Korean" : "الكورية",
|
||||
"Spanish" : "الإسبانية",
|
||||
"Italian" : "الإيطالية",
|
||||
"Generate image from text" : "إنشاء صورة من نص",
|
||||
"Settings" : "الإعدادات",
|
||||
"For work with this model we should save chat history and sent it into a request." : "للعمل مع هذا النموذج، يجب حفظ سجل المحادثة وإرساله ضمن الطلب.",
|
||||
"But we have a limit on the number of tokens in the request." : "لكن هناك حد لعدد الرموز المستخدمة في الطلب.",
|
||||
"That's why sometimes you should clear your chat history." : "لهذا السبب، قد تحتاجون أحيانًا إلى مسح سجل المحادثة.",
|
||||
"Clear history" : "مسح السجل",
|
||||
"Tokens in the request about: " : "الرموز في الطلب تقريبًا: ",
|
||||
"Total tokens are used in last request: " : "إجمالي الرموز المستخدمة في الطلب الأخير: ",
|
||||
"Chat" : "المحادثة",
|
||||
"Ask AI" : "اسألوا الذكاء الاصطناعي",
|
||||
"Model" : "النموذج",
|
||||
"tokens in your request." : "الرموز في طلبكم.",
|
||||
"You exceeded your current quota, please check your plan and billing details." : "لقد تجاوزتم الحصة المتاحة حاليًا. يُرجى التحقق من خطة اشتراككم وتفاصيل الفوترة.",
|
||||
"Too many tokens in your request.": "عدد كبير جدًا من الرموز في الطلب.",
|
||||
"Error:" : "خطأ:",
|
||||
"Generate image variation" : "إنشاء نسخة بديلة من الصورة",
|
||||
"Show hyperlink content" : "عرض محتوى الرابط",
|
||||
"Fix spelling & grammar": "تصحيح الإملاء والنحو",
|
||||
"Rewrite differently": "إعادة الصياغة بشكل مختلف",
|
||||
"Make longer": "جعل النص أطول",
|
||||
"Make shorter": "جعل النص أقصر",
|
||||
|
||||
"Chatbot": "روبوت المحادثة",
|
||||
"Ask AI a question about something...": "اطرحوا سؤالًا على الذكاء الاصطناعي حول أي موضوع...",
|
||||
"Thinking": "جارٍ التفكير",
|
||||
"Welcome": "مرحبًا بكم",
|
||||
"I'm here to assist you with all your text creation and editing needs. Feel free to ask me anything about your document or anything else that's on your mind.": "أنا هنا لمساعدتكم في جميع مهام الكتابة والتحرير. لا تترددوا في سؤالي عن مستنداتكم أو أي موضوع آخر يشغل بالكم.",
|
||||
"Let’s make your content shine together!": "فلنُبدع معًا في تحسين محتواكم!",
|
||||
"Copy": "نسخ",
|
||||
"Blog post about": "مقال مدونة عن",
|
||||
"Blog post": "مقال مدونة",
|
||||
"Press release about": "بيان صحفي عن",
|
||||
"Press release": "بيان صحفي",
|
||||
"Social media post about": "منشور على وسائل التواصل عن",
|
||||
"Social media post": "منشور على وسائل التواصل",
|
||||
"Brainstorm ideas for": "عصف ذهني للأفكار حول",
|
||||
"Brainstorm ideas": "عصف ذهني للأفكار",
|
||||
"Project proposal about": "اقتراح مشروع عن",
|
||||
"Project proposal": "اقتراح مشروع",
|
||||
"An essay about": "مقال عن",
|
||||
"An essay": "مقال",
|
||||
"Creative story about": "قصة إبداعية عن",
|
||||
"Creative story": "قصة إبداعية",
|
||||
"Make a plan about": "خطة حول",
|
||||
"Make a plan": "خطة",
|
||||
"Get advice about": "نصيحة حول",
|
||||
"Get advice": "نصيحة",
|
||||
"Ask AI anything": "اطرحوا أي سؤال على الذكاء الاصطناعي",
|
||||
"Generate new": "إنشاء جديد",
|
||||
"Something went wrong": "حدث خطأ ما",
|
||||
"Please try reloading the conversation": "يرجى إعادة تحميل المحادثة",
|
||||
|
||||
"This field is required": "هذا الحقل مطلوب",
|
||||
|
||||
"Custom providers": "المزودون المخصصون",
|
||||
"Back": "رجوع",
|
||||
"Connected custom providers": "المزودون المخصصون المتصلون",
|
||||
"The list is empty, press + to add the file": "القائمة فارغة، اضغطوا على + لإضافة الملف",
|
||||
"Enter the configuration for the AI model API in JS format. Provide the model name, endpoint URLs, and headers.": "أدخلوا إعدادات واجهة برمجة التطبيقات لنموذج الذكاء الاصطناعي بصيغة \"JavaScript\"، بما في ذلك اسم النموذج وروابط النهاية والرؤوس.",
|
||||
"Download template": "تنزيل القالب",
|
||||
"Invalid file format, please upload the .js file": "تنسيق الملف غير صالح، يرجى تحميل ملف بصيغة .js",
|
||||
"Error adding provider from file, please try again": "حدث خطأ أثناء إضافة المزود من الملف، يرجى المحاولة مرة أخرى",
|
||||
|
||||
"Translation settings": "إعدادات الترجمة",
|
||||
"Select language for AI translation.": "اختاروا اللغة لترجمة الذكاء الاصطناعي",
|
||||
"Image": "صورة",
|
||||
"Image to Text": "تحويل الصورة إلى نص",
|
||||
"Text to Image": "تحويل النص إلى صورة",
|
||||
"Image generation": "توليد الصور",
|
||||
"OCR": "التعرّف الضوئي على الحروف",
|
||||
"Vision": "الرؤية الحاسوبية"
|
||||
}
|
||||
@ -10,5 +10,6 @@
|
||||
"sr-Latn-RS",
|
||||
"ja-JA",
|
||||
"sq-AL",
|
||||
"it-IT"
|
||||
"it-IT",
|
||||
"ar-SA"
|
||||
]
|
||||
@ -50,6 +50,66 @@
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
|
||||
/* Themes style for List */
|
||||
.list {
|
||||
flex: 1;
|
||||
border: 1px solid;
|
||||
position: relative;
|
||||
}
|
||||
body.theme-classic-light .list {
|
||||
--list-border: #cfcfcf;
|
||||
--item-hover-bg: #d8dadc;
|
||||
--item-hover-color: #444;
|
||||
--item-selected-bg: #7d858c;
|
||||
--item-selected-color: #fff;
|
||||
}
|
||||
body.theme-light .list,
|
||||
body.theme-gray .list {
|
||||
--list-border: #c0c0c0;
|
||||
--item-hover-bg: #e0e0e0;
|
||||
--item-hover-color: rgba(0, 0, 0, 0.8);
|
||||
--item-selected-bg: #cbcbcb;
|
||||
--item-selected-color: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
body.theme-dark .list {
|
||||
--list-border: #666666;
|
||||
--item-hover-bg: #555;
|
||||
--item-hover-color: rgba(255, 255, 255, 0.8);
|
||||
--item-selected-bg: #707070;
|
||||
--item-selected-color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
body.theme-contrast-dark .list {
|
||||
--list-border: #696969;
|
||||
--item-hover-bg: #424242;
|
||||
--item-hover-color: #e8e8e8;
|
||||
--item-selected-bg: #666666;
|
||||
--item-selected-color: #e8e8e8;
|
||||
}
|
||||
|
||||
.list {
|
||||
border-color: #e1e1e1;
|
||||
border-color: var(--list-border);
|
||||
border-color: var(--border-regular-control);
|
||||
}
|
||||
.list .item:hover {
|
||||
background-color: #eaeaea;
|
||||
background-color: var(--item-hover-bg);
|
||||
background-color: var(--highlight-button-hover);
|
||||
|
||||
color: rgba(0, 0, 0, 0.8);
|
||||
color: var(--item-hover-color);
|
||||
color: var(--text-normal);
|
||||
}
|
||||
.list .item.selected {
|
||||
background-color: #e1e1e1;
|
||||
background-color: var(--item-selected-bg);
|
||||
background-color: var(--highlight-button-pressed);
|
||||
|
||||
color: rgba(0, 0, 0, 0.8);
|
||||
color: var(--item-selected-color);
|
||||
color: var(--text-normal-pressed);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="noselect">
|
||||
@ -109,19 +169,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="scripts/utils/theme.js"></script>
|
||||
<script>
|
||||
function onThemeChanged(theme) {
|
||||
window.Asc.plugin.onThemeChangedBase(theme);
|
||||
themeType = theme.type || 'light';
|
||||
|
||||
var classes = document.body.className.split(' ');
|
||||
classes.forEach(function(className) {
|
||||
if (className.indexOf('theme-') != -1) {
|
||||
document.body.classList.remove(className);
|
||||
}
|
||||
});
|
||||
document.body.classList.add(theme.name);
|
||||
document.body.classList.add('theme-type-' + themeType);
|
||||
updateBodyThemeClasses(theme.type, theme.name);
|
||||
updateThemeVariables(theme);
|
||||
}
|
||||
|
||||
window.Asc.plugin.init = function() {
|
||||
|
||||
@ -371,8 +371,9 @@
|
||||
}
|
||||
|
||||
if (!!button.menu) {
|
||||
for (item of button.menu) {
|
||||
if (!!item.onclick) {
|
||||
for (let indexItem in button.menu) {
|
||||
let item = button.menu.hasOwnProperty(indexItem) ? button.menu[indexItem] : null;
|
||||
if (item && !!item.onclick) {
|
||||
window.Asc.plugin.attachToolbarMenuClickEvent(item.id, item.onclick);
|
||||
}
|
||||
}
|
||||
@ -778,4 +779,3 @@
|
||||
Asc.ButtonToolbar = ButtonToolbar;
|
||||
Asc.ButtonContentControl = ButtonContentControl;
|
||||
})(window);
|
||||
|
||||
|
||||
@ -16,23 +16,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
(function(b,t){function v(a){b.Asc.plugin.ie_channel?b.Asc.plugin.ie_channel.postMessage(a):b.parent.postMessage(a,"*")}function q(a,c){if(!a||"object"!=typeof a&&"array"!=typeof a)return a;c=c===t?{}:c;for(var f in a)a.hasOwnProperty(f)&&(c[f]=a[f]&&"object"===typeof a[f]?q(a[f]):a[f]);return c}function m(a){var c=b.location.search,f=a+"=";a=c.indexOf(f);return 0<=a?(a+=f.length,f=c.indexOf("&",a),0>f&&(f=c.length),c.substring(a,f)):t}function l(){var a=m("windowID");a&&(b.Asc.plugin.windowID=a,
|
||||
b.Asc.plugin.guid||(b.Asc.plugin.guid=decodeURIComponent(m("guid"))));return t!==a?!0:!1}function n(a){if(b.Asc&&b.Asc.plugin)if(b.plugin_onMessage)b.Asc.supportOrigins[a.origin]&&b.plugin_onMessage(a);else if(b.Asc.plugin._initInternal&&"string"==typeof a.data){var c={};try{c=JSON.parse(a.data)}catch(f){c={}}"plugin_init"==c.type&&(b.Asc.supportOrigins[a.origin]=!0,b.Asc.plugin.ie_channel_check(a),eval(c.data))}}b.Asc=b.Asc||{};b.Asc.plugin={};b.Asc.plugin.ie_channel=null;b.Asc.plugin.ie_channel_check=
|
||||
function(a){var c=navigator.userAgent.toLowerCase();(-1<c.indexOf("msie")||-1<c.indexOf("trident"))&&a.ports&&a.ports[0]&&(this.ie_channel=a.ports[0])};b.Asc.plugin.tr_init=!1;b.Asc.plugin.tr=function(a){return a};b.Asc.scope={};b.Asc.scope.prototype={clear:function(){for(var a in b.Asc.scope)delete b.Asc.scope[a]}};b.onload=function(){if(b.Asc&&b.Asc.plugin){var a=new XMLHttpRequest;a.open("get","./config.json",!0);a.responseType="json";a.onload=function(){if(b.Asc&&b.Asc.plugin){if(404===a.status)return a.onerror();
|
||||
if(200==a.status||0==a.status&&4==a.readyState){var c=a.response;"string"==typeof c&&(c=JSON.parse(c));q(c,b.Asc.plugin);c={type:"initialize",guid:b.Asc.plugin.guid};l()&&(c.windowID=b.Asc.plugin.windowID);var f=document.body;f&&!0!==b.Asc.plugin.enableDrops&&(f.ondrop=function(h){h&&h.preventDefault&&h.preventDefault();return!1},f.ondragenter=function(h){h&&h.preventDefault&&h.preventDefault();return!1},f.ondragover=function(h){h&&h.preventDefault&&h.preventDefault();h&&h.dataTransfer&&(h.dataTransfer.dropEffect=
|
||||
"none");return!1});b.Asc.plugin._initInternal=!0;b.parent.postMessage(JSON.stringify(c),"*")}}};a.onerror=function(){if(b.Asc&&b.Asc.plugin&&l()){var c={type:"initialize",guid:b.Asc.plugin.guid};c.windowID=b.Asc.plugin.windowID;b.Asc.plugin._initInternal=!0;b.parent.postMessage(JSON.stringify(c),"*")}};a.send()}};b.Asc.supportOrigins={};b.Asc.supportOrigins[b.origin]=!0;b.addEventListener?b.addEventListener("message",n,!1):b.attachEvent("onmessage",n);b.Asc.plugin._attachCustomMenuClickEvent=function(a,
|
||||
c,f){this[a]||(this[a]={});this[a][c]=f};b.Asc.plugin._onCustomMenuClick=function(a,c){var f=t,h=c.indexOf("_oo_sep_");-1!==h&&(f=c.substring(h+8),c=c.substring(0,h));this[a]&&this[a][c]&&this[a][c].call(this,f)};b.Asc.plugin.attachContextMenuClickEvent=function(a,c){this._attachCustomMenuClickEvent("contextMenuEvents",a,c)};b.Asc.plugin.event_onContextMenuClick=function(a){this._onCustomMenuClick("contextMenuEvents",a)};b.Asc.plugin.attachToolbarMenuClickEvent=function(a,c){this._attachCustomMenuClickEvent("toolbarMenuEvents",
|
||||
a,c)};b.Asc.plugin.event_onToolbarMenuClick=function(a){this._onCustomMenuClick("toolbarMenuEvents",a)};b.Asc.plugin.event_onContentControlButtonClick=function(a){let c=a&&a.buttonId?a.buttonId:null;a=a&&a.contentControlId?a.contentControlId:null;c&&a&&this.ContentControlButtonEvents&&this.ContentControlButtonEvents[c]&&this.ContentControlButtonEvents[c].call(this,a)};b.Asc.plugin._attachContentControlButtonClickEvent=function(a,c){this.ContentControlButtonEvents||(this.ContentControlButtonEvents=
|
||||
{});this.ContentControlButtonEvents[a]=c};b.Asc.plugin.attachEvent=function(a,c){var f=b.Asc.plugin;f._events||(f._events={});f._events[a]=c};b.Asc.plugin.detachEvent=function(a){var c=b.Asc.plugin;c._events&&c._events[a]&&delete c._events[a]};b.Asc.plugin.onEvent=function(a,c){var f=b.Asc.plugin;f._events&&f._events[a]&&f._events[a].call(f,c)};b.Asc.plugin.attachEditorEvent=function(a,c){b.Asc.plugin["event_"+a]=c.bind(b.Asc.plugin);v(JSON.stringify({guid:b.Asc.plugin.guid,type:"attachEvent",name:a}))};
|
||||
b.Asc.plugin.detachEditorEvent=function(a){b.Asc.plugin["event_"+a]&&delete b.Asc.plugin["event_"+a];v(JSON.stringify({guid:b.Asc.plugin.guid,type:"detachEvent",name:a}))};b.onunload=function(){b.addEventListener?b.removeEventListener("message",n,!1):b.detachEvent("onmessage",n)}})(window,void 0);
|
||||
(function(b,t){function v(){function d(){return(65536+e[k++]).toString(16).substring(1)}if(!b.crypto||!b.crypto.getRandomValues){function g(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return g()+g()+"-"+g()+"-"+g()+"-"+g()+"-"+g()+g()+g()}var e=new Uint16Array(8);b.crypto.getRandomValues(e);var k=0;return d()+d()+"-"+d()+"-"+d()+"-"+d()+"-"+d()+d()+d()}function q(d){return b.Asc.plugin.tr(d)}function m(d,e){this.itemType=h.None;this.editors=["word","cell","slide"];this.id=
|
||||
e===t?v():e;this.icons=null;this.text="";this.hint=null;this.data="";this.separator=!1;this.lockInViewMode=!0;this.disabled=this.enableToggle=!1;this.parent=d?d:null;this.childs=null;this.parent&&(this.parent.childs||(this.parent.childs=[]),this.parent.childs.push(this))}function l(d,e){m.call(this,d,e);this.itemType=h.ContextMenu;this.showOnOptionsType=[];c.Buttons.ButtonsContextMenu.push(this)}function n(d,e){m.call(this,d,e);this.itemType=h.Toolbar;this.type=f.BigButton;this.tab="";c.Buttons.ButtonsToolbar.push(this)}
|
||||
function a(d,e){m.call(this,d,e);this.itemType=h.ContentControl;this.checker=null;0===c.Buttons.ButtonsContentControl.length&&c.Buttons.registerContentControl();c.Buttons.ButtonsContentControl.push(this)}b.Asc=b.Asc||{};var c=b.Asc;c.Buttons={};c.Buttons.ButtonsContextMenu=[];c.Buttons.ButtonsToolbar=[];c.Buttons.ButtonsContentControl=[];c.Buttons.registerContextMenu=function(){b.Asc.plugin.attachEvent("onContextMenuShow",function(d){if(d){var e={guid:b.Asc.plugin.guid};for(let k=0,g=c.Buttons.ButtonsContextMenu.length;k<
|
||||
g;k++){let p=c.Buttons.ButtonsContextMenu[k];if(null===p.parent)p.onContextMenuShow(d,e)}e.items&&b.Asc.plugin.executeMethod("AddContextMenuItem",[e])}})};c.Buttons.registerToolbarMenu=function(){let d={guid:b.Asc.plugin.guid,tabs:[]};for(let e=0,k=c.Buttons.ButtonsToolbar.length;e<k;e++){let g=c.Buttons.ButtonsToolbar[e];null===g.parent&&g.toToolbar(d);if(g.menu)for(item of g.menu)item.onclick&&b.Asc.plugin.attachToolbarMenuClickEvent(item.id,item.onclick)}0<d.tabs.length&&b.Asc.plugin.executeMethod("AddToolbarMenuItem",
|
||||
[d])};c.Buttons.registerContentControl=function(){b.Asc.plugin.attachEvent("onShowContentControlTrack",function(d){let e={guid:b.Asc.plugin.guid,items:{}},k=[];for(let g=0,p=c.Buttons.ButtonsContentControl.length;g<p;++g)k.push(c.Buttons.ButtonsContentControl[g].onShowTrack(d,e.items));Promise.all(k).then(function(){for(let g in e.items){b.Asc.plugin.executeMethod("AddContentControlButtons",[e]);break}})})};var f={Button:"button",BigButton:"big-button"},h={None:0,ContextMenu:1,Toolbar:2,ContentControl:3};
|
||||
m.prototype.toItem=function(){let d={id:this.id,text:q(this.text)};null!==this.hint&&(d.hint=q(""===this.hint?this.hint:this.text));this.separator&&(d.separator=!0);this.data&&(d.data=this.data);this.lockInViewMode&&(d.lockInViewMode=!0);this.enableToggle&&(d.enableToggle=!0);this.disabled&&(d.disabled=!0);this.icons&&(d.icons=this.icons);this.itemType===h.Toolbar&&(d.type=this.type);this.menu&&(d.items=this.menu.map(function(e){e.text=q(e.text);return e}));this.split&&(d.split=!0);return d};m.prototype.attachOnClick=
|
||||
function(d){};m.prototype.onClick=function(){console.log("BUTTON: "+this.text)};l.prototype=Object.create(m.prototype);l.prototype.constructor=l;l.prototype.copy=function(){let d=new l(this.parent,this.id);d.editors=this.editors;d.separator=this.separator;d.lockInViewMode=this.lockInViewMode;d.enableToggle=this.enableToggle;d.disabled=this.disabled;d.showOnOptionsType=this.showOnOptionsType.slice();return d};l.prototype.addCheckers=function(){let d=arguments.length;this.showOnOptionsType=Array(d);
|
||||
for(let e=0;e<d;e++)this.showOnOptionsType[e]=arguments[e]};l.prototype.attachOnClick=function(d){b.Asc.plugin.attachContextMenuClickEvent(this.id,d)};l.prototype.onContextMenuShowAnalyze=function(d,e){return!1};l.prototype.onContextMenuShowExtendItem=function(d,e){};l.prototype.onContextMenuShow=function(d,e){if(!this.onContextMenuShowAnalyze(d,e)){var k=!1;for(let g=0,p=this.editors.length;g<p;g++)if(c.plugin.info.editorType===this.editors[g]){k=!0;break}if(k)for(let g=0,p=this.showOnOptionsType.length;g<
|
||||
p;g++)if(d.type===this.showOnOptionsType[g]||"All"===this.showOnOptionsType[g]){e.items||(e.items=[]);k=this.toItem();this.onContextMenuShowExtendItem(d,k);if(this.childs)for(let r=0,x=this.childs.length;r<x;r++)this.childs[r].onContextMenuShow(d,k);e.items.push(k);break}}};n.prototype=Object.create(m.prototype);n.prototype.constructor=n;n.prototype.attachOnClick=function(d){b.Asc.plugin.attachToolbarMenuClickEvent(this.id,d)};n.prototype.toItem=function(d){d=m.prototype.toItem.call(this);d.type=
|
||||
this.type;return d};n.prototype.toToolbar=function(d){if(null===this.parent){var e={id:this.id,text:q(this.text),items:[]};null!==this.hint&&(e.hint=q(""===this.hint?this.hint:this.text));d.tabs.push(e)}else e=this.toItem(),d.items||(d.items=[]),d.items.push(e);if(this.childs)for(let k=0,g=this.childs.length;k<g;k++)this.childs[k].toToolbar(e)};a.prototype=Object.create(m.prototype);a.prototype.constructor=a;a.prototype.attachOnClick=function(d){b.Asc.plugin._attachContentControlButtonClickEvent(this.id,
|
||||
d)};a.prototype.addChecker=function(d){d&&"function"===typeof d&&(this.checker=d)};a.prototype.onShowTrack=function(d,e){let k=this.checker,g=[],p=this.toItem();for(let r=0,x=d.length;r<x;++r){let w=d[r];g.push((new Promise(function(u){if(k){let y=k(w);y instanceof Promise?y.then(function(z){u(z)}):u(!!y)}else u(!0)})).then(function(u){u&&(e[w]||(e[w]=[]),e[w].push(p))}))}return Promise.all(g)};c.ToolbarButtonType=f;c.ButtonContextMenu=l;c.ButtonToolbar=n;c.ButtonContentControl=a})(window);
|
||||
(function(a,t){function v(c){a.Asc.plugin.ie_channel?a.Asc.plugin.ie_channel.postMessage(c):a.parent.postMessage(c,"*")}function r(c,d){if(!c||"object"!=typeof c&&"array"!=typeof c)return c;d=d===t?{}:d;for(var g in c)c.hasOwnProperty(g)&&(d[g]=c[g]&&"object"===typeof c[g]?r(c[g]):c[g]);return d}function p(c){var d=a.location.search,g=c+"=";c=d.indexOf(g);return 0<=c?(c+=g.length,g=d.indexOf("&",c),0>g&&(g=d.length),d.substring(c,g)):t}function m(){var c=p("windowID");c&&(a.Asc.plugin.windowID=c,
|
||||
a.Asc.plugin.guid||(a.Asc.plugin.guid=decodeURIComponent(p("guid"))));return t!==c?!0:!1}function q(c){if(a.Asc&&a.Asc.plugin)if(a.plugin_onMessage)a.Asc.supportOrigins[c.origin]&&a.plugin_onMessage(c);else if(a.Asc.plugin._initInternal&&"string"==typeof c.data){var d={};try{d=JSON.parse(c.data)}catch(g){d={}}"plugin_init"==d.type&&(a.Asc.supportOrigins[c.origin]=!0,a.Asc.plugin.ie_channel_check(c),eval(d.data))}}a.Asc=a.Asc||{};a.Asc.plugin={};a.Asc.plugin.ie_channel=null;a.Asc.plugin.ie_channel_check=
|
||||
function(c){var d=navigator.userAgent.toLowerCase();(-1<d.indexOf("msie")||-1<d.indexOf("trident"))&&c.ports&&c.ports[0]&&(this.ie_channel=c.ports[0])};a.Asc.plugin.tr_init=!1;a.Asc.plugin.tr=function(c){return c};a.Asc.scope={};a.Asc.scope.prototype={clear:function(){for(var c in a.Asc.scope)delete a.Asc.scope[c]}};a.onload=function(){if(a.Asc&&a.Asc.plugin){var c=new XMLHttpRequest;c.open("get","./config.json",!0);c.responseType="json";c.onload=function(){if(a.Asc&&a.Asc.plugin){if(404===c.status)return c.onerror();
|
||||
if(200==c.status||0==c.status&&4==c.readyState){var d=c.response;"string"==typeof d&&(d=JSON.parse(d));r(d,a.Asc.plugin);d={type:"initialize",guid:a.Asc.plugin.guid};m()&&(d.windowID=a.Asc.plugin.windowID);var g=document.body;g&&!0!==a.Asc.plugin.enableDrops&&(g.ondrop=function(k){k&&k.preventDefault&&k.preventDefault();return!1},g.ondragenter=function(k){k&&k.preventDefault&&k.preventDefault();return!1},g.ondragover=function(k){k&&k.preventDefault&&k.preventDefault();k&&k.dataTransfer&&(k.dataTransfer.dropEffect=
|
||||
"none");return!1});a.Asc.plugin._initInternal=!0;a.parent.postMessage(JSON.stringify(d),"*")}}};c.onerror=function(){if(a.Asc&&a.Asc.plugin&&m()){var d={type:"initialize",guid:a.Asc.plugin.guid};d.windowID=a.Asc.plugin.windowID;a.Asc.plugin._initInternal=!0;a.parent.postMessage(JSON.stringify(d),"*")}};c.send()}};a.Asc.supportOrigins={};a.Asc.supportOrigins[a.origin]=!0;a.addEventListener?a.addEventListener("message",q,!1):a.attachEvent("onmessage",q);a.Asc.plugin._attachCustomMenuClickEvent=function(c,
|
||||
d,g){this[c]||(this[c]={});this[c][d]=g};a.Asc.plugin._onCustomMenuClick=function(c,d){var g=t,k=d.indexOf("_oo_sep_");-1!==k&&(g=d.substring(k+8),d=d.substring(0,k));this[c]&&this[c][d]&&this[c][d].call(this,g)};a.Asc.plugin.attachContextMenuClickEvent=function(c,d){this._attachCustomMenuClickEvent("contextMenuEvents",c,d)};a.Asc.plugin.event_onContextMenuClick=function(c){this._onCustomMenuClick("contextMenuEvents",c)};a.Asc.plugin.attachToolbarMenuClickEvent=function(c,d){this._attachCustomMenuClickEvent("toolbarMenuEvents",
|
||||
c,d)};a.Asc.plugin.event_onToolbarMenuClick=function(c){this._onCustomMenuClick("toolbarMenuEvents",c)};a.Asc.plugin.attachEvent=function(c,d){var g=a.Asc.plugin;g._events||(g._events={});g._events[c]=d};a.Asc.plugin.detachEvent=function(c){var d=a.Asc.plugin;d._events&&d._events[c]&&delete d._events[c]};a.Asc.plugin.onEvent=function(c,d){var g=a.Asc.plugin;g._events&&g._events[c]&&g._events[c].call(g,d)};a.Asc.plugin.attachEditorEvent=function(c,d){a.Asc.plugin["event_"+c]=d.bind(a.Asc.plugin);v(JSON.stringify({guid:a.Asc.plugin.guid,
|
||||
type:"attachEvent",name:c}))};a.Asc.plugin.detachEditorEvent=function(c){a.Asc.plugin["event_"+c]&&delete a.Asc.plugin["event_"+c];v(JSON.stringify({guid:a.Asc.plugin.guid,type:"detachEvent",name:c}))};a.onunload=function(){a.addEventListener?a.removeEventListener("message",q,!1):a.detachEvent("onmessage",q)}})(window,void 0);
|
||||
(function(a,t){function v(){function b(){return(65536+e[h++]).toString(16).substring(1)}if(!a.crypto||!a.crypto.getRandomValues){function f(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return f()+f()+"-"+f()+"-"+f()+"-"+f()+"-"+f()+f()+f()}var e=new Uint16Array(8);a.crypto.getRandomValues(e);var h=0;return b()+b()+"-"+b()+"-"+b()+"-"+b()+"-"+b()+b()+b()}function r(b){return a.Asc.plugin.tr(b)}function p(b,e){this.itemType=k.None;this.editors=["word","cell","slide"];this.id=
|
||||
e===t?v():e;this.icons=null;this.text="";this.hint=null;this.data="";this.separator=!1;this.lockInViewMode=!0;this.removed=this.disabled=this.enableToggle=!1;this.parent=b?b:null;this.childs=null;this.parent&&(this.parent.childs||(this.parent.childs=[]),this.parent.childs.push(this))}function m(b,e){p.call(this,b,e);this.itemType=k.ContextMenu;this.showOnOptionsType=[];d.Buttons.ButtonsContextMenu.push(this)}function q(b,e){p.call(this,b,e);this.itemType=k.Toolbar;this.type=g.BigButton;this.tab="";
|
||||
d.Buttons.ButtonsToolbar.push(this)}function c(b,e){p.call(this,b,e);this.itemType=k.ContentControl;this.checker=null;0===d.Buttons.ButtonsContentControl.length&&d.Buttons.registerContentControl();d.Buttons.ButtonsContentControl.push(this)}a.Asc=a.Asc||{};var d=a.Asc;d.Buttons={};d.Buttons.ButtonsContextMenu=[];d.Buttons.ButtonsToolbar=[];d.Buttons.ButtonsContentControl=[];d.Buttons.registerContextMenu=function(){a.Asc.plugin.attachEvent("onContextMenuShow",function(b){if(b){var e={guid:a.Asc.plugin.guid};
|
||||
for(let h=0,f=d.Buttons.ButtonsContextMenu.length;h<f;h++){let l=d.Buttons.ButtonsContextMenu[h];if(null===l.parent)l.onContextMenuShow(b,e)}e.items&&a.Asc.plugin.executeMethod("AddContextMenuItem",[e])}})};d.Buttons.registerToolbarMenu=function(){let b={guid:a.Asc.plugin.guid,tabs:[]};for(let e=0,h=d.Buttons.ButtonsToolbar.length;e<h;e++){let f=d.Buttons.ButtonsToolbar[e];null===f.parent&&f.toToolbar(b);if(f.menu)for(let l in f.menu){let n=f.menu.hasOwnProperty(l)?f.menu[l]:null;n&&n.onclick&&a.Asc.plugin.attachToolbarMenuClickEvent(n.id,
|
||||
n.onclick)}}0<b.tabs.length&&a.Asc.plugin.executeMethod("AddToolbarMenuItem",[b])};d.Buttons.updateToolbarMenu=function(b,e,h){b=new d.ButtonToolbar(null,b);b.text=e;e={guid:a.Asc.plugin.guid,tabs:[]};b.childs=h;for(let f=0,l=h.length;f<l;f++)h[f].parent=b;b.toToolbar(e);0<e.tabs.length&&a.Asc.plugin.executeMethod("UpdateToolbarMenuItem",[e])};d.Buttons.registerContentControl=function(){a.Asc.plugin.attachEditorEvent("onShowContentControlTrack",function(e){let h={guid:a.Asc.plugin.guid,items:{}},
|
||||
f=[];for(let l=0,n=d.Buttons.ButtonsContentControl.length;l<n;++l)f.push(d.Buttons.ButtonsContentControl[l].onShowTrack(e,h.items));Promise.all(f).then(function(){for(let l in h.items){a.Asc.plugin.executeMethod("AddContentControlButtons",[h]);break}})});a.Asc.plugin._attachContentControlButtonClickEvent=function(e,h){this.ContentControlButtonEvents||(this.ContentControlButtonEvents={});this.ContentControlButtonEvents[e]=h};let b=a.Asc.plugin;a.Asc.plugin.attachEditorEvent("onContentControlButtonClick",
|
||||
function(e){let h=e&&e.buttonId?e.buttonId:null;e=e&&e.contentControlId?e.contentControlId:null;h&&e&&b.ContentControlButtonEvents&&b.ContentControlButtonEvents[h]&&b.ContentControlButtonEvents[h].call(b,e)})};var g={Button:"button",BigButton:"big-button"},k={None:0,ContextMenu:1,Toolbar:2,ContentControl:3};p.prototype.toItem=function(){let b={id:this.id,text:r(this.text)};null!==this.hint&&(b.hint=r(""===this.hint?this.hint:this.text));this.separator&&(b.separator=!0);this.data&&(b.data=this.data);
|
||||
this.lockInViewMode&&(b.lockInViewMode=!0);this.enableToggle&&(b.enableToggle=!0);b.disabled=this.disabled?!0:!1;this.removed&&(b.removed=!0);this.icons&&(b.icons=this.icons);this.itemType===k.Toolbar&&(b.type=this.type);this.menu&&(b.items=this.menu.map(function(e){e.text=r(e.text);return e}));this.split&&(b.split=!0);return b};p.prototype.attachOnClick=function(b){};p.prototype.onClick=function(){console.log("BUTTON: "+this.text)};m.prototype=Object.create(p.prototype);m.prototype.constructor=m;
|
||||
m.prototype.copy=function(){let b=new m(this.parent,this.id);b.editors=this.editors;b.separator=this.separator;b.lockInViewMode=this.lockInViewMode;b.enableToggle=this.enableToggle;b.disabled=this.disabled;b.showOnOptionsType=this.showOnOptionsType.slice();return b};m.prototype.addCheckers=function(){let b=arguments.length;this.showOnOptionsType=Array(b);for(let e=0;e<b;e++)this.showOnOptionsType[e]=arguments[e]};m.prototype.attachOnClick=function(b){a.Asc.plugin.attachContextMenuClickEvent(this.id,
|
||||
b)};m.prototype.onContextMenuShowAnalyze=function(b,e){return!1};m.prototype.onContextMenuShowExtendItem=function(b,e){};m.prototype.onContextMenuShow=function(b,e){if(!this.onContextMenuShowAnalyze(b,e)){var h=!1;for(let f=0,l=this.editors.length;f<l;f++)if(d.plugin.info.editorType===this.editors[f]){h=!0;break}if(h)for(let f=0,l=this.showOnOptionsType.length;f<l;f++)if(b.type===this.showOnOptionsType[f]||"All"===this.showOnOptionsType[f]){e.items||(e.items=[]);h=this.toItem();this.onContextMenuShowExtendItem(b,
|
||||
h);if(this.childs)for(let n=0,x=this.childs.length;n<x;n++)this.childs[n].onContextMenuShow(b,h);e.items.push(h);break}}};q.prototype=Object.create(p.prototype);q.prototype.constructor=q;q.prototype.attachOnClick=function(b){a.Asc.plugin.attachToolbarMenuClickEvent(this.id,b)};q.prototype.toItem=function(b){b=p.prototype.toItem.call(this);b.type=this.type;return b};q.prototype.toToolbar=function(b){if(null===this.parent){var e={id:this.id,text:r(this.text),items:[]};null!==this.hint&&(e.hint=r(""===
|
||||
this.hint?this.hint:this.text));b.tabs.push(e)}else e=this.toItem(),b.items||(b.items=[]),b.items.push(e);if(this.childs)for(let h=0,f=this.childs.length;h<f;h++)this.childs[h].toToolbar(e)};c.prototype=Object.create(p.prototype);c.prototype.constructor=c;c.prototype.attachOnClick=function(b){a.Asc.plugin._attachContentControlButtonClickEvent(this.id,b)};c.prototype.addChecker=function(b){b&&"function"===typeof b&&(this.checker=b)};c.prototype.onShowTrack=function(b,e){let h=this.checker,f=[],l=this.toItem();
|
||||
for(let n=0,x=b.length;n<x;++n){let w=b[n];f.push((new Promise(function(u){if(h){let y=h(w);y instanceof Promise?y.then(function(z){u(z)}):u(!!y)}else u(!0)})).then(function(u){u&&(e[w]||(e[w]=[]),e[w].push(l))}))}return Promise.all(f)};d.ToolbarButtonType=g;d.ButtonContextMenu=m;d.ButtonToolbar=q;d.ButtonContentControl=c})(window);
|
||||
|
||||
Reference in New Issue
Block a user