diff --git a/sdkjs-plugins/content/ai/CHANGELOG.md b/sdkjs-plugins/content/ai/CHANGELOG.md index 93dffda5..1afcdd5c 100644 --- a/sdkjs-plugins/content/ai/CHANGELOG.md +++ b/sdkjs-plugins/content/ai/CHANGELOG.md @@ -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. diff --git a/sdkjs-plugins/content/ai/aiModelEdit.html b/sdkjs-plugins/content/ai/aiModelEdit.html index c437cea3..d1ada6dc 100644 --- a/sdkjs-plugins/content/ai/aiModelEdit.html +++ b/sdkjs-plugins/content/ai/aiModelEdit.html @@ -108,6 +108,7 @@ Custom providers + diff --git a/sdkjs-plugins/content/ai/aiModelsList.html b/sdkjs-plugins/content/ai/aiModelsList.html index 661565e5..19f3ca32 100644 --- a/sdkjs-plugins/content/ai/aiModelsList.html +++ b/sdkjs-plugins/content/ai/aiModelsList.html @@ -44,6 +44,7 @@ + diff --git a/sdkjs-plugins/content/ai/chat.html b/sdkjs-plugins/content/ai/chat.html index aef89ee8..70458373 100644 --- a/sdkjs-plugins/content/ai/chat.html +++ b/sdkjs-plugins/content/ai/chat.html @@ -27,6 +27,7 @@ limitations under the License. + diff --git a/sdkjs-plugins/content/ai/components/ListView/style.css b/sdkjs-plugins/content/ai/components/ListView/style.css index 85816076..6b654081 100644 --- a/sdkjs-plugins/content/ai/components/ListView/style.css +++ b/sdkjs-plugins/content/ai/components/ListView/style.css @@ -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); } \ No newline at end of file diff --git a/sdkjs-plugins/content/ai/components/Tooltip/style.css b/sdkjs-plugins/content/ai/components/Tooltip/style.css index 77dea036..9b065ab7 100644 --- a/sdkjs-plugins/content/ai/components/Tooltip/style.css +++ b/sdkjs-plugins/content/ai/components/Tooltip/style.css @@ -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); } \ No newline at end of file diff --git a/sdkjs-plugins/content/ai/config.json b/sdkjs-plugins/content/ai/config.json index 8115dc14..afbbad24 100644 --- a/sdkjs-plugins/content/ai/config.json +++ b/sdkjs-plugins/content/ai/config.json @@ -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": { diff --git a/sdkjs-plugins/content/ai/customProviders.html b/sdkjs-plugins/content/ai/customProviders.html index f0551e5b..c2aa87f1 100644 --- a/sdkjs-plugins/content/ai/customProviders.html +++ b/sdkjs-plugins/content/ai/customProviders.html @@ -51,6 +51,7 @@ + diff --git a/sdkjs-plugins/content/ai/index.html b/sdkjs-plugins/content/ai/index.html index c987ca22..3f2a0daf 100644 --- a/sdkjs-plugins/content/ai/index.html +++ b/sdkjs-plugins/content/ai/index.html @@ -18,7 +18,8 @@ AI Constructor - + + @@ -31,7 +32,6 @@ - diff --git a/sdkjs-plugins/content/ai/resources/styles/aiModelEdit.css b/sdkjs-plugins/content/ai/resources/styles/aiModelEdit.css index 47681bfc..06114300 100644 --- a/sdkjs-plugins/content/ai/resources/styles/aiModelEdit.css +++ b/sdkjs-plugins/content/ai/resources/styles/aiModelEdit.css @@ -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 { diff --git a/sdkjs-plugins/content/ai/resources/styles/aiModelsList.css b/sdkjs-plugins/content/ai/resources/styles/aiModelsList.css index 5e4616a5..f1f1728d 100644 --- a/sdkjs-plugins/content/ai/resources/styles/aiModelsList.css +++ b/sdkjs-plugins/content/ai/resources/styles/aiModelsList.css @@ -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; -} diff --git a/sdkjs-plugins/content/ai/resources/styles/chat.css b/sdkjs-plugins/content/ai/resources/styles/chat.css index f9bfe522..95427a21 100644 --- a/sdkjs-plugins/content/ai/resources/styles/chat.css +++ b/sdkjs-plugins/content/ai/resources/styles/chat.css @@ -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); } diff --git a/sdkjs-plugins/content/ai/resources/styles/common.css b/sdkjs-plugins/content/ai/resources/styles/common.css index 701ae5c0..ed188cb3 100644 --- a/sdkjs-plugins/content/ai/resources/styles/common.css +++ b/sdkjs-plugins/content/ai/resources/styles/common.css @@ -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; -} \ No newline at end of file diff --git a/sdkjs-plugins/content/ai/resources/styles/settings.css b/sdkjs-plugins/content/ai/resources/styles/settings.css index eedfd87d..042372c9 100644 --- a/sdkjs-plugins/content/ai/resources/styles/settings.css +++ b/sdkjs-plugins/content/ai/resources/styles/settings.css @@ -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; diff --git a/sdkjs-plugins/content/ai/resources/styles/summarization.css b/sdkjs-plugins/content/ai/resources/styles/summarization.css index 349fa4e5..07254db9 100644 --- a/sdkjs-plugins/content/ai/resources/styles/summarization.css +++ b/sdkjs-plugins/content/ai/resources/styles/summarization.css @@ -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; diff --git a/sdkjs-plugins/content/ai/scripts/aiModelEdit.js b/sdkjs-plugins/content/ai/scripts/aiModelEdit.js index ebdff95b..32d818e9 100644 --- a/sdkjs-plugins/content/ai/scripts/aiModelEdit.js +++ b/sdkjs-plugins/content/ai/scripts/aiModelEdit.js @@ -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'); diff --git a/sdkjs-plugins/content/ai/scripts/aiModelsList.js b/sdkjs-plugins/content/ai/scripts/aiModelsList.js index 5ad451e1..6431f787 100644 --- a/sdkjs-plugins/content/ai/scripts/aiModelsList.js +++ b/sdkjs-plugins/content/ai/scripts/aiModelsList.js @@ -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]; diff --git a/sdkjs-plugins/content/ai/scripts/chat.js b/sdkjs-plugins/content/ai/scripts/chat.js index 69d550b0..236a3175 100644 --- a/sdkjs-plugins/content/ai/scripts/chat.js +++ b/sdkjs-plugins/content/ai/scripts/chat.js @@ -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(); diff --git a/sdkjs-plugins/content/ai/scripts/code.js b/sdkjs-plugins/content/ai/scripts/code.js index eab485c6..d156147c 100644 --- a/sdkjs-plugins/content/ai/scripts/code.js +++ b/sdkjs-plugins/content/ai/scripts/code.js @@ -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); }); diff --git a/sdkjs-plugins/content/ai/scripts/customProviders.js b/sdkjs-plugins/content/ai/scripts/customProviders.js index ce20ade7..7ff6ff52 100644 --- a/sdkjs-plugins/content/ai/scripts/customProviders.js +++ b/sdkjs-plugins/content/ai/scripts/customProviders.js @@ -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++) { diff --git a/sdkjs-plugins/content/ai/scripts/engine/buttons.js b/sdkjs-plugins/content/ai/scripts/engine/buttons.js deleted file mode 100644 index dbfcbd0c..00000000 --- a/sdkjs-plugins/content/ai/scripts/engine/buttons.js +++ /dev/null @@ -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); diff --git a/sdkjs-plugins/content/ai/scripts/engine/engine.js b/sdkjs-plugins/content/ai/scripts/engine/engine.js index e3c99ac3..555a7615 100644 --- a/sdkjs-plugins/content/ai/scripts/engine/engine.js +++ b/sdkjs-plugins/content/ai/scripts/engine/engine.js @@ -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; diff --git a/sdkjs-plugins/content/ai/scripts/engine/local_storage.js b/sdkjs-plugins/content/ai/scripts/engine/local_storage.js index 6c81b3e0..4d405d26 100644 --- a/sdkjs-plugins/content/ai/scripts/engine/local_storage.js +++ b/sdkjs-plugins/content/ai/scripts/engine/local_storage.js @@ -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; diff --git a/sdkjs-plugins/content/ai/scripts/engine/providers/base.js b/sdkjs-plugins/content/ai/scripts/engine/providers/base.js index 000166f6..c4d93673 100644 --- a/sdkjs-plugins/content/ai/scripts/engine/providers/base.js +++ b/sdkjs-plugins/content/ai/scripts/engine/providers/base.js @@ -244,4 +244,6 @@ }; + AI.serverSettings = null; + })(); diff --git a/sdkjs-plugins/content/ai/scripts/engine/register.js b/sdkjs-plugins/content/ai/scripts/engine/register.js index 9753cb41..a1716211 100644 --- a/sdkjs-plugins/content/ai/scripts/engine/register.js +++ b/sdkjs-plugins/content/ai/scripts/engine/register.js @@ -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(); } diff --git a/sdkjs-plugins/content/ai/scripts/settings.js b/sdkjs-plugins/content/ai/scripts/settings.js index 405296a2..9bae140b 100644 --- a/sdkjs-plugins/content/ai/scripts/settings.js +++ b/sdkjs-plugins/content/ai/scripts/settings.js @@ -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); diff --git a/sdkjs-plugins/content/ai/scripts/summarization.js b/sdkjs-plugins/content/ai/scripts/summarization.js index 627a58cd..7f3390a9 100644 --- a/sdkjs-plugins/content/ai/scripts/summarization.js +++ b/sdkjs-plugins/content/ai/scripts/summarization.js @@ -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); diff --git a/sdkjs-plugins/content/ai/scripts/utils/theme.js b/sdkjs-plugins/content/ai/scripts/utils/theme.js new file mode 100644 index 00000000..b651331f --- /dev/null +++ b/sdkjs-plugins/content/ai/scripts/utils/theme.js @@ -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); +} \ No newline at end of file diff --git a/sdkjs-plugins/content/ai/settings.html b/sdkjs-plugins/content/ai/settings.html index d2548116..4867723a 100644 --- a/sdkjs-plugins/content/ai/settings.html +++ b/sdkjs-plugins/content/ai/settings.html @@ -32,7 +32,7 @@
- +
Add and select AI models for different tasks.
@@ -40,6 +40,7 @@
+ diff --git a/sdkjs-plugins/content/ai/summarization.html b/sdkjs-plugins/content/ai/summarization.html index 403daadb..c0e91526 100644 --- a/sdkjs-plugins/content/ai/summarization.html +++ b/sdkjs-plugins/content/ai/summarization.html @@ -76,6 +76,7 @@
Summarization...
+ diff --git a/sdkjs-plugins/content/ai/translations/ar-SA.json b/sdkjs-plugins/content/ai/translations/ar-SA.json new file mode 100644 index 00000000..cc3a8e1c --- /dev/null +++ b/sdkjs-plugins/content/ai/translations/ar-SA.json @@ -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": "الرؤية الحاسوبية" +} \ No newline at end of file diff --git a/sdkjs-plugins/content/ai/translations/langs.json b/sdkjs-plugins/content/ai/translations/langs.json index 9912bfeb..439cb899 100644 --- a/sdkjs-plugins/content/ai/translations/langs.json +++ b/sdkjs-plugins/content/ai/translations/langs.json @@ -10,5 +10,6 @@ "sr-Latn-RS", "ja-JA", "sq-AL", - "it-IT" + "it-IT", + "ar-SA" ] \ No newline at end of file diff --git a/sdkjs-plugins/content/ai/translationsettings.html b/sdkjs-plugins/content/ai/translationsettings.html index 5fc780cd..ce3536e6 100644 --- a/sdkjs-plugins/content/ai/translationsettings.html +++ b/sdkjs-plugins/content/ai/translationsettings.html @@ -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); + } @@ -109,19 +169,13 @@ +