mirror of
https://github.com/ONLYOFFICE/onlyoffice.github.io.git
synced 2026-04-07 14:04:30 +08:00
24
sdkjs-plugins/content/doc2md/2var.html
Normal file
24
sdkjs-plugins/content/doc2md/2var.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!--
|
||||
(c) Copyright Ascensio System SIA 2020
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.js"></script>
|
||||
<script src="scripts/2var.js"></script>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
@ -8,7 +8,7 @@ It is is compatible with [self-hosted](https://github.com/ONLYOFFICE/DocumentSer
|
||||
|
||||
## How to use
|
||||
|
||||
1. Find the plugin on the Plugins tab and click it.
|
||||
1. Find the plugin on the Plugins tab and click it or click add to context menu.
|
||||
2. Use the Markdown or HTML buttons in the sidebar window to convert your document to either Markdown or HTML.
|
||||
3. If you select part of the document, Docs to Markdown will convert only the selection. Otherwise, it will convert the entire document.
|
||||
|
||||
|
||||
@ -16,7 +16,8 @@
|
||||
"ru": "Преобразуйте отформатированные документы в Markdown или HTML.",
|
||||
"fr": "Convertissez votre document mis en forme en Markdown ou HTML.",
|
||||
"es": "Convierta sus documentos formateados a Markdown o HTML.",
|
||||
"de": "Konvertieren Sie formatierte Dokumente in Markdown oder HTML."
|
||||
"de": "Konvertieren Sie formatierte Dokumente in Markdown oder HTML.",
|
||||
"cs": "Převeďte své formátované dokumenty na Markdown nebo HTML."
|
||||
},
|
||||
"url": "index.html",
|
||||
"icons": [ "resources/light/icon.png", "resources/light/icon@2x.png" ],
|
||||
@ -83,6 +84,67 @@
|
||||
"categories": ["specAbilities", "work"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Add in context menu",
|
||||
"descriptionLocale": {
|
||||
"ru": "Добавить в контекстное меню",
|
||||
"fr": "Ajouter dans le menu contextuel",
|
||||
"es": "Agregar en el menú contextual",
|
||||
"de": "Im Kontextmenü hinzufügen",
|
||||
"cs": "Přidat do kontextového menu"
|
||||
},
|
||||
"url": "2var.html",
|
||||
"icons": [ "resources/light/icon.png", "resources/light/icon@2x.png" ],
|
||||
"icons2": [
|
||||
{
|
||||
"style" : "light",
|
||||
|
||||
"100%": {
|
||||
"normal": "resources/light/icon.png"
|
||||
},
|
||||
"125%": {
|
||||
"normal": "resources/light/icon@1.25x.png"
|
||||
},
|
||||
"150%": {
|
||||
"normal": "resources/light/icon@1.5x.png"
|
||||
},
|
||||
"175%": {
|
||||
"normal": "resources/light/icon@1.75x.png"
|
||||
},
|
||||
"200%": {
|
||||
"normal": "resources/light/icon@2x.png"
|
||||
}
|
||||
},
|
||||
{
|
||||
"style" : "dark",
|
||||
|
||||
"100%": {
|
||||
"normal": "resources/dark/icon.png"
|
||||
},
|
||||
"125%": {
|
||||
"normal": "resources/dark/icon@1.25x.png"
|
||||
},
|
||||
"150%": {
|
||||
"normal": "resources/dark/icon@1.5x.png"
|
||||
},
|
||||
"175%": {
|
||||
"normal": "resources/dark/icon@1.75x.png"
|
||||
},
|
||||
"200%": {
|
||||
"normal": "resources/dark/icon@2x.png"
|
||||
}
|
||||
}
|
||||
],
|
||||
"isViewer": true,
|
||||
"EditorsSupport": [ "word" ],
|
||||
"isVisual": false,
|
||||
"isModal": false,
|
||||
"isInsideMode": false,
|
||||
"initDataType": "none",
|
||||
"isUpdateOleOnResize": false,
|
||||
"initOnSelectionChanged": false,
|
||||
"events": ["onContextMenuShow", "onContextMenuClick"]
|
||||
},
|
||||
{
|
||||
"description": "About",
|
||||
"descriptionLocale": {
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>synonim</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-ui.js"></script>
|
||||
<link rel="stylesheet" href="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.css">
|
||||
|
||||
98
sdkjs-plugins/content/doc2md/scripts/2var.js
Normal file
98
sdkjs-plugins/content/doc2md/scripts/2var.js
Normal file
@ -0,0 +1,98 @@
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
(function(window, undefined){
|
||||
let modalWindow = null;
|
||||
|
||||
window.Asc.plugin.init = function(){};
|
||||
|
||||
function createWindow() {
|
||||
let location = window.location;
|
||||
let start = location.pathname.lastIndexOf('/') + 1;
|
||||
let file = location.pathname.substring(start);
|
||||
|
||||
// default settings for modal window
|
||||
let variation = {
|
||||
url : location.href.replace(file, 'index.html'),
|
||||
description : window.Asc.plugin.tr('Document to Markdown'),
|
||||
isVisual : true,
|
||||
isModal : true,
|
||||
EditorsSupport : ["word"],
|
||||
buttons : [],
|
||||
size : [600, 600]
|
||||
};
|
||||
|
||||
if (!modalWindow) {
|
||||
modalWindow = new window.Asc.PluginWindow();
|
||||
modalWindow.attachEvent("onWindowMessage", function(data){
|
||||
let oConfig = data.config;
|
||||
window.Asc.plugin.executeMethod('ConvertDocument', [oConfig.convertType, oConfig.htmlHeadings, oConfig.base64img, oConfig.demoteHeadings, oConfig.renderHTMLTags], function(sOutput) {
|
||||
modalWindow.command('onConverted', sOutput);
|
||||
});
|
||||
});
|
||||
}
|
||||
modalWindow.show(variation);
|
||||
};
|
||||
|
||||
window.Asc.plugin.button = function(id, windowId) {
|
||||
if (!modalWindow)
|
||||
return;
|
||||
|
||||
if (windowId) {
|
||||
switch (id) {
|
||||
case -1:
|
||||
default:
|
||||
// if we use close, it is unregister this window and we won't be able to receive messages from this window
|
||||
// window.Asc.plugin.init();
|
||||
// settingsWindow.close();
|
||||
// settingsWindow = null;
|
||||
window.Asc.plugin.executeMethod('CloseWindow', [windowId]);
|
||||
}
|
||||
}
|
||||
// this.executeCommand("close", "");
|
||||
};
|
||||
|
||||
function getMessage(key) {
|
||||
return window.Asc.plugin.tr(key.trim());
|
||||
};
|
||||
|
||||
function getContextMenuItems() {
|
||||
let settings = {
|
||||
guid: window.Asc.plugin.guid,
|
||||
items: [
|
||||
{
|
||||
id : 'onConvert',
|
||||
text : getMessage('Convert to Markdown or HTML')
|
||||
}
|
||||
]
|
||||
};
|
||||
return settings;
|
||||
};
|
||||
|
||||
window.Asc.plugin.attachContextMenuClickEvent('onConvert', function() {
|
||||
createWindow();
|
||||
});
|
||||
|
||||
|
||||
window.Asc.plugin.attachEvent('onContextMenuShow', function(options) {
|
||||
if (!options) return;
|
||||
|
||||
if (options.type === 'Selection' || options.type === 'Target')
|
||||
this.executeMethod('AddContextMenuItem', [getContextMenuItems()]);
|
||||
});
|
||||
|
||||
})(window, undefined);
|
||||
@ -15,244 +15,182 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
var Ps;
|
||||
(function(window, undefined){
|
||||
|
||||
var txt = "";
|
||||
var displayNoneClass = "display-none";
|
||||
var elements = null;
|
||||
var sHelpText = 'Choose Markdown or HTML. \r* Default: convert entire doc. \r* Select text to limit scope. \rFor more details, click the Docs link above.'
|
||||
var oConfig = {
|
||||
convertType : '',
|
||||
htmlHeadings : false,
|
||||
base64img : false,
|
||||
demoteHeadings : false,
|
||||
renderHTMLTags : false
|
||||
};
|
||||
var sCopiedInfo = 'Output copied to clipboard!';
|
||||
|
||||
function showLoader(elements, show) {
|
||||
switchClass(elements.loader, displayNoneClass, !show);
|
||||
}
|
||||
|
||||
function switchClass(el, className, add) {
|
||||
if (add) {
|
||||
el.classList.add(className);
|
||||
} else {
|
||||
el.classList.remove(className);
|
||||
}
|
||||
}
|
||||
|
||||
window.Asc.plugin.init = function()
|
||||
{
|
||||
SetSavedFromLocalStorage();
|
||||
};
|
||||
function SaveToLocalStorage() {
|
||||
localStorage.setItem($('#demote_headings').attr('data-id'), $('#demote_headings').prop('checked'));
|
||||
localStorage.setItem($('#html_headings').attr('data-id'), $('#html_headings').prop('checked'));
|
||||
localStorage.setItem($('#base64img').attr('data-id'), $('#base64img').prop('checked'));
|
||||
localStorage.setItem($('#render_html_tags').attr('data-id'), $('#render_html_tags').prop('checked'));
|
||||
localStorage.setItem($('#suppress_info').attr('data-id'), $('#suppress_info').prop('checked'));
|
||||
};
|
||||
function SetSavedFromLocalStorage() {
|
||||
var isDemoteHeadings = localStorage.getItem($('#demote_headings').attr('data-id'));
|
||||
if (isDemoteHeadings !== null) {
|
||||
if (isDemoteHeadings === true.toString())
|
||||
$('#demote_headings').prop("checked", true);
|
||||
else
|
||||
$('#demote_headings').prop("checked", false);
|
||||
}
|
||||
|
||||
var isHtmlHeadings = localStorage.getItem($('#html_headings').attr('data-id'));
|
||||
if (isHtmlHeadings !== null) {
|
||||
if (isHtmlHeadings === true.toString())
|
||||
$('#html_headings').prop("checked", true);
|
||||
else
|
||||
$('#html_headings').prop("checked", false);
|
||||
}
|
||||
|
||||
var isBase64 = localStorage.getItem($('#base64img').attr('data-id'));
|
||||
if (isBase64 !== null) {
|
||||
if (isBase64 === true.toString())
|
||||
$('#base64img').prop("checked", true);
|
||||
else
|
||||
$('#base64img').prop("checked", false);
|
||||
}
|
||||
|
||||
var isRenderHtmlTags = localStorage.getItem($('#render_html_tags').attr('data-id'));
|
||||
if (isRenderHtmlTags !== null) {
|
||||
if (isRenderHtmlTags === true.toString())
|
||||
$('#render_html_tags').prop("checked", true);
|
||||
else
|
||||
$('#render_html_tags').prop("checked", false);
|
||||
}
|
||||
|
||||
var isSuppressInfo = localStorage.getItem($('#suppress_info').attr('data-id'));
|
||||
if (isSuppressInfo !== null) {
|
||||
if (isSuppressInfo === true.toString())
|
||||
$('#suppress_info').prop("checked", true);
|
||||
else
|
||||
$('#suppress_info').prop("checked", false);
|
||||
}
|
||||
};
|
||||
window.Asc.plugin.onThemeChanged = function(theme)
|
||||
{
|
||||
window.Asc.plugin.onThemeChangedBase(theme);
|
||||
$('#hide-settings, #show-settings').css('border-bottom', '1px dashed ' + window.Asc.plugin.theme["text-normal"]);
|
||||
};
|
||||
function DelInvalidChars(arrParas) {
|
||||
for (var nPara = 0; nPara < arrParas.length; nPara++) {
|
||||
arrParas[nPara] = arrParas[nPara].replace(/#/gi, '');
|
||||
arrParas[nPara] = arrParas[nPara].replace(/&/gi, '');
|
||||
}
|
||||
};
|
||||
|
||||
function SplitText(sText) {
|
||||
var allParasInSelection = sText.split(/\n/);
|
||||
var allParsedParas = [];
|
||||
|
||||
for (var nStr = 0; nStr < allParasInSelection.length; nStr++) {
|
||||
if (allParasInSelection[nStr].search(/ /) === 0) {
|
||||
allParsedParas.push("");
|
||||
allParasInSelection[nStr] = allParasInSelection[nStr].replace(/ /, "");
|
||||
}
|
||||
var sSplited = allParasInSelection[nStr].split(/ /);
|
||||
|
||||
sSplited.forEach(function(item, i, sSplited) {
|
||||
allParsedParas.push(item);
|
||||
});
|
||||
}
|
||||
|
||||
return allParsedParas;
|
||||
}
|
||||
|
||||
function SetConfig(sConvertType) {
|
||||
oConfig.htmlHeadings = false;
|
||||
oConfig.base64img = false;
|
||||
oConfig.demoteHeadings = false;
|
||||
oConfig.renderHTMLTags = false;
|
||||
oConfig.suppressInfo = false;
|
||||
oConfig.convertType = sConvertType;
|
||||
|
||||
if (document.getElementById('demote_headings').checked) {
|
||||
oConfig.demoteHeadings = true;
|
||||
}
|
||||
if (document.getElementById('html_headings').checked) {
|
||||
oConfig.htmlHeadings = true;
|
||||
}
|
||||
if (document.getElementById('base64img').checked) {
|
||||
oConfig.base64img = true;
|
||||
}
|
||||
if (document.getElementById('render_html_tags').checked) {
|
||||
oConfig.renderHTMLTags = true;
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
document.getElementById("text-area").value = sHelpText;
|
||||
$('#show-settings').click(function() {
|
||||
$(this).hide();
|
||||
$('#hide-settings').show();
|
||||
$('#settings').slideToggle('fast');
|
||||
});
|
||||
$('#hide-settings').click(function() {
|
||||
$(this).hide();
|
||||
$('#show-settings').show();
|
||||
$('#settings').slideToggle('fast');
|
||||
});
|
||||
$('#btn-markwodn').click(function() {
|
||||
SetConfig('markdown');
|
||||
var sInfo = '';
|
||||
window.Asc.plugin.executeMethod('ConvertDocument', [oConfig.convertType, oConfig.htmlHeadings, oConfig.base64img, oConfig.demoteHeadings, oConfig.renderHTMLTags], function(sOutput) {
|
||||
document.getElementById("text-area").value = sInfo + sOutput;
|
||||
});
|
||||
SaveToLocalStorage();
|
||||
});
|
||||
$('#btn-html').click(function() {
|
||||
SetConfig('html');
|
||||
var sInfo = '';
|
||||
window.Asc.plugin.executeMethod('ConvertDocument', [oConfig.convertType, oConfig.htmlHeadings, oConfig.base64img, oConfig.demoteHeadings, oConfig.renderHTMLTags], function(sOutput) {
|
||||
document.getElementById("text-area").value = sInfo + sOutput;
|
||||
});
|
||||
SaveToLocalStorage();
|
||||
});
|
||||
|
||||
document.getElementById("btn-copy").onclick = function () {
|
||||
selectText('text-area');
|
||||
alert('Text was copied to buffer!');
|
||||
var oTextArea = document.getElementById('text-area');
|
||||
var sTemp = oTextArea.value;
|
||||
oTextArea.value = '';
|
||||
oTextArea.value = sTemp;
|
||||
}
|
||||
});
|
||||
function selectText(id) {
|
||||
var sel, range;
|
||||
var el = document.getElementById(id); //get element id
|
||||
if (window.getSelection && document.createRange) { //Browser compatibility
|
||||
el.select();
|
||||
sel = window.getSelection();
|
||||
document.execCommand("copy"); //copy
|
||||
sel.removeAllRanges(); //remove all ranges from selection
|
||||
}
|
||||
};
|
||||
|
||||
function updateScroll()
|
||||
{
|
||||
Ps && Ps.update();
|
||||
let sHelpText = 'Choose Markdown or HTML. \r* Default: convert entire doc. \r* Select text to limit scope. \rFor more details, click the Docs link above.'
|
||||
let oConfig = {
|
||||
convertType : '',
|
||||
htmlHeadings : false,
|
||||
base64img : false,
|
||||
demoteHeadings : false,
|
||||
renderHTMLTags : false
|
||||
};
|
||||
|
||||
window.Asc.plugin.button = function(id)
|
||||
{
|
||||
window.Asc.plugin.init = function() {
|
||||
SetSavedFromLocalStorage();
|
||||
};
|
||||
|
||||
function SaveToLocalStorage() {
|
||||
localStorage.setItem($('#demote_headings').attr('data-id'), $('#demote_headings').prop('checked'));
|
||||
localStorage.setItem($('#html_headings').attr('data-id'), $('#html_headings').prop('checked'));
|
||||
localStorage.setItem($('#base64img').attr('data-id'), $('#base64img').prop('checked'));
|
||||
localStorage.setItem($('#render_html_tags').attr('data-id'), $('#render_html_tags').prop('checked'));
|
||||
localStorage.setItem($('#suppress_info').attr('data-id'), $('#suppress_info').prop('checked'));
|
||||
};
|
||||
|
||||
function SetSavedFromLocalStorage() {
|
||||
let isDemoteHeadings = localStorage.getItem($('#demote_headings').attr('data-id'));
|
||||
if (isDemoteHeadings !== null) {
|
||||
if (isDemoteHeadings === true.toString())
|
||||
$('#demote_headings').prop("checked", true);
|
||||
else
|
||||
$('#demote_headings').prop("checked", false);
|
||||
}
|
||||
|
||||
let isHtmlHeadings = localStorage.getItem($('#html_headings').attr('data-id'));
|
||||
if (isHtmlHeadings !== null) {
|
||||
if (isHtmlHeadings === true.toString())
|
||||
$('#html_headings').prop("checked", true);
|
||||
else
|
||||
$('#html_headings').prop("checked", false);
|
||||
}
|
||||
|
||||
let isBase64 = localStorage.getItem($('#base64img').attr('data-id'));
|
||||
if (isBase64 !== null) {
|
||||
if (isBase64 === true.toString())
|
||||
$('#base64img').prop("checked", true);
|
||||
else
|
||||
$('#base64img').prop("checked", false);
|
||||
}
|
||||
|
||||
let isRenderHtmlTags = localStorage.getItem($('#render_html_tags').attr('data-id'));
|
||||
if (isRenderHtmlTags !== null) {
|
||||
if (isRenderHtmlTags === true.toString())
|
||||
$('#render_html_tags').prop("checked", true);
|
||||
else
|
||||
$('#render_html_tags').prop("checked", false);
|
||||
}
|
||||
|
||||
let isSuppressInfo = localStorage.getItem($('#suppress_info').attr('data-id'));
|
||||
if (isSuppressInfo !== null) {
|
||||
if (isSuppressInfo === true.toString())
|
||||
$('#suppress_info').prop("checked", true);
|
||||
else
|
||||
$('#suppress_info').prop("checked", false);
|
||||
}
|
||||
};
|
||||
|
||||
window.Asc.plugin.onThemeChanged = function(theme) {
|
||||
window.Asc.plugin.onThemeChangedBase(theme);
|
||||
$('#hide-settings, #show-settings').css('border-bottom', '1px dashed ' + window.Asc.plugin.theme["text-normal"]);
|
||||
};
|
||||
|
||||
function SetConfig(sConvertType) {
|
||||
oConfig.htmlHeadings = false;
|
||||
oConfig.base64img = false;
|
||||
oConfig.demoteHeadings = false;
|
||||
oConfig.renderHTMLTags = false;
|
||||
oConfig.suppressInfo = false;
|
||||
oConfig.convertType = sConvertType;
|
||||
|
||||
if (document.getElementById('demote_headings').checked) {
|
||||
oConfig.demoteHeadings = true;
|
||||
}
|
||||
if (document.getElementById('html_headings').checked) {
|
||||
oConfig.htmlHeadings = true;
|
||||
}
|
||||
if (document.getElementById('base64img').checked) {
|
||||
oConfig.base64img = true;
|
||||
}
|
||||
if (document.getElementById('render_html_tags').checked) {
|
||||
oConfig.renderHTMLTags = true;
|
||||
}
|
||||
};
|
||||
|
||||
function makeConvetration() {
|
||||
if (window.Asc.plugin.windowID) {
|
||||
window.Asc.plugin.sendToPlugin("onWindowMessage", {config: oConfig});
|
||||
} else {
|
||||
window.Asc.plugin.executeMethod('ConvertDocument', [oConfig.convertType, oConfig.htmlHeadings, oConfig.base64img, oConfig.demoteHeadings, oConfig.renderHTMLTags], function(sOutput) {
|
||||
document.getElementById("text-area").value = sOutput;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
document.getElementById("text-area").value = sHelpText;
|
||||
$('#show-settings').click(function() {
|
||||
$(this).hide();
|
||||
$('#hide-settings').show();
|
||||
$('#settings').slideToggle('fast');
|
||||
});
|
||||
$('#hide-settings').click(function() {
|
||||
$(this).hide();
|
||||
$('#show-settings').show();
|
||||
$('#settings').slideToggle('fast');
|
||||
});
|
||||
$('#btn-markwodn').click(function() {
|
||||
SetConfig('markdown');
|
||||
makeConvetration();
|
||||
SaveToLocalStorage();
|
||||
});
|
||||
$('#btn-html').click(function() {
|
||||
SetConfig('html');
|
||||
makeConvetration();
|
||||
SaveToLocalStorage();
|
||||
});
|
||||
|
||||
document.getElementById("btn-copy").onclick = function () {
|
||||
selectText('text-area');
|
||||
alert(getMessage('Text was copied to buffer!'));
|
||||
let oTextArea = document.getElementById('text-area');
|
||||
let sTemp = oTextArea.value;
|
||||
oTextArea.value = '';
|
||||
oTextArea.value = sTemp;
|
||||
}
|
||||
});
|
||||
|
||||
function selectText(id) {
|
||||
let sel;
|
||||
let el = document.getElementById(id); //get element id
|
||||
if (window.getSelection && document.createRange) { //Browser compatibility
|
||||
el.select();
|
||||
sel = window.getSelection();
|
||||
document.execCommand("copy"); //copy
|
||||
sel.removeAllRanges(); //remove all ranges from selection
|
||||
}
|
||||
};
|
||||
|
||||
window.Asc.plugin.button = function() {
|
||||
this.executeCommand("close", "");
|
||||
};
|
||||
|
||||
function IsLastTransate(arrParas) {
|
||||
if (arrParas.length !== translatedText.length)
|
||||
return false;
|
||||
for (var nPara = 0; nPara < arrParas.length; nPara++) {
|
||||
if (arrParas[nPara] !== translatedText[nPara])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
function getMessage(key) {
|
||||
return window.Asc.plugin.tr(key.trim());
|
||||
};
|
||||
|
||||
function RunTranslate(sText) {
|
||||
window.Asc.plugin.onTranslate = function() {
|
||||
let elements = document.getElementsByClassName("i18n");
|
||||
|
||||
var allParsedParas = SplitText(sText);
|
||||
DelInvalidChars(allParsedParas);
|
||||
if (IsLastTransate(allParsedParas))
|
||||
return false;
|
||||
var sParams = CreateParams(allParsedParas);
|
||||
var target_lang = GetTargetLang();
|
||||
if (window.Asc.plugin.translateManager.Help)
|
||||
document.getElementById("text-area").value = window.Asc.plugin.translateManager.Help;
|
||||
|
||||
document.getElementById('txt_shower').innerHTML = '';
|
||||
translatedText = [];
|
||||
Translate(apikey, target_lang, sParams);
|
||||
};
|
||||
function getMessage(key) {
|
||||
return window.Asc.plugin.tr(key.trim());
|
||||
};
|
||||
window.Asc.plugin.onTranslate = function()
|
||||
{
|
||||
var elements = document.getElementsByClassName("i18n");
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
let el = elements[i];
|
||||
if (el.attributes["placeholder"]) el.attributes["placeholder"].value = getMessage(el.attributes["placeholder"].value);
|
||||
if (el.innerText) el.innerText = getMessage(el.innerText);
|
||||
}
|
||||
};
|
||||
|
||||
if (window.Asc.plugin.translateManager.Help)
|
||||
document.getElementById("text-area").value = window.Asc.plugin.translateManager.Help;
|
||||
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
var el = elements[i];
|
||||
if (el.attributes["placeholder"]) el.attributes["placeholder"].value = getMessage(el.attributes["placeholder"].value);
|
||||
if (el.innerText) el.innerText = getMessage(el.innerText);
|
||||
}
|
||||
};
|
||||
window.Asc.plugin.onExternalMouseUp = function()
|
||||
{
|
||||
var evt = document.createEvent("MouseEvents");
|
||||
window.Asc.plugin.onExternalMouseUp = function() {
|
||||
let evt = document.createEvent("MouseEvents");
|
||||
evt.initMouseEvent("mouseup", true, true, window, 1, 0, 0, 0, 0,
|
||||
false, false, false, false, 0, null);
|
||||
|
||||
document.dispatchEvent(evt);
|
||||
};
|
||||
|
||||
window.Asc.plugin.attachEvent("onConverted", function(data){
|
||||
document.getElementById("text-area").value = data;
|
||||
});
|
||||
|
||||
})(window, undefined);
|
||||
|
||||
@ -7,5 +7,7 @@
|
||||
"HTML headings/IDs": "Nadpisy/ID HTML",
|
||||
"Create base64 images": "Vytvoření obrázků base64",
|
||||
"Suppress top comment": "Potlačit horní komentář",
|
||||
"Help": "Vyberte Markdown nebo HTML.\n* Výchozí: převod celého dokumentu.\n* Vyberte text pro omezení rozsahu."
|
||||
"Help": "Vyberte Markdown nebo HTML.\n* Výchozí: převod celého dokumentu.\n* Vyberte text pro omezení rozsahu.",
|
||||
"Text was copied to buffer!": "Text byl zkopírován do vyrovnávací paměti!",
|
||||
"Convert to Markdown or HTML": "Převést na Markdown nebo HTML"
|
||||
}
|
||||
@ -7,5 +7,7 @@
|
||||
"HTML headings/IDs": "HTML-Überschriften/IDs",
|
||||
"Create base64 images": "Base64-Bilder erstellen",
|
||||
"Suppress top comment": "Obersten Kommentar unterdrücken",
|
||||
"Help": "Wählen Sie Markdown oder HTML.\n* Standard: Konvertierung des gesamten Dokuments.\n* Wählen Sie Text, um den Umfang zu begrenzen."
|
||||
"Help": "Wählen Sie Markdown oder HTML.\n* Standard: Konvertierung des gesamten Dokuments.\n* Wählen Sie Text, um den Umfang zu begrenzen.",
|
||||
"Text was copied to buffer!": "Text wurde in den Puffer kopiert!",
|
||||
"Convert to Markdown or HTML": "In Markdown oder HTML konvertieren"
|
||||
}
|
||||
@ -7,5 +7,7 @@
|
||||
"HTML headings/IDs": "Encabezados/IDs HTML",
|
||||
"Create base64 images": "Crear imágenes en base64",
|
||||
"Suppress top comment": "Suprimir el comentario superior",
|
||||
"Help": "Elija Markdown o HTML.\n* Por defecto: convertir todo el documento.\n* Seleccione el texto para limitar el alcance."
|
||||
"Help": "Elija Markdown o HTML.\n* Por defecto: convertir todo el documento.\n* Seleccione el texto para limitar el alcance.",
|
||||
"Text was copied to buffer!": "El texto se copió en el búfer!",
|
||||
"Convert to Markdown or HTML": "Convertir a Markdown o HTML"
|
||||
}
|
||||
@ -7,5 +7,7 @@
|
||||
"HTML headings/IDs": "Titres/ID HTML",
|
||||
"Create base64 images": "Créer des images base64",
|
||||
"Suppress top comment": "Supprimer le commentaire supérieur",
|
||||
"Help": "Choisissez le format Markdown ou HTML.\n* Par défaut : convertissez tout le document.\n* Sélectionnez le texte pour limiter la portée."
|
||||
"Help": "Choisissez le format Markdown ou HTML.\n* Par défaut : convertissez tout le document.\n* Sélectionnez le texte pour limiter la portée.",
|
||||
"Text was copied to buffer!": "Le texte a été copié dans buffer!",
|
||||
"Convert to Markdown or HTML": "Convertir en démarque ou HTML"
|
||||
}
|
||||
@ -7,5 +7,7 @@
|
||||
"HTML headings/IDs": "Intestazioni/ID HTML",
|
||||
"Create base64 images": "Creare immagini base64",
|
||||
"Suppress top comment": "Sopprimere il commento superiore",
|
||||
"Help": "Scegliere Markdown o HTML.\n* Predefinito: convertire l'intero documento.\n* Selezionare il testo per limitare la portata."
|
||||
"Help": "Scegliere Markdown o HTML.\n* Predefinito: convertire l'intero documento.\n* Selezionare il testo per limitare la portata.",
|
||||
"Text was copied to buffer!": "Il testo è stato copiato nel buffer!",
|
||||
"Convert to Markdown or HTML": "Converti in Markdown o HTML"
|
||||
}
|
||||
@ -7,5 +7,7 @@
|
||||
"HTML headings/IDs": "HTMLの見出し/ID",
|
||||
"Create base64 images": "base64イメージの作成",
|
||||
"Suppress top comment": "トップコメントの抑制",
|
||||
"Help": "MarkdownまたはHTMLを選択します。\n* デフォルト:文書全体を変換します。\n* 範囲を限定するためにテキストを選択します。"
|
||||
"Help": "MarkdownまたはHTMLを選択します。\n* デフォルト:文書全体を変換します。\n* 範囲を限定するためにテキストを選択します。",
|
||||
"Text was copied to buffer!": "テキストがバッファにコピーされました!",
|
||||
"Convert to Markdown or HTML": "MarkdownまたはHTMLに変換する"
|
||||
}
|
||||
@ -7,5 +7,7 @@
|
||||
"HTML headings/IDs": "HTML-koppen/ID's",
|
||||
"Create base64 images": "Maak base64 afbeeldingen",
|
||||
"Suppress top comment": "Onderdruk commentaar bovenaan",
|
||||
"Help": "Kies Markdown of HTML.\n* Standaard: converteer hele doc.\n* Selecteer tekst om het bereik te beperken."
|
||||
"Help": "Kies Markdown of HTML.\n* Standaard: converteer hele doc.\n* Selecteer tekst om het bereik te beperken.",
|
||||
"Text was copied to buffer!": "Tekst is gekopieerd naar buffer!",
|
||||
"Convert to Markdown or HTML": "Converteren naar Markdown of HTML"
|
||||
}
|
||||
@ -7,5 +7,7 @@
|
||||
"HTML headings/IDs": "Títulos/IDs HTML",
|
||||
"Create base64 images": "Criar imagens base64",
|
||||
"Suppress top comment": "Suprimir comentário de topo",
|
||||
"Help": "Escolha Markdown ou HTML.\n* Predefinição: converter todo o doc.\n* Seleccionar texto para limitar o âmbito."
|
||||
"Help": "Escolha Markdown ou HTML.\n* Predefinição: converter todo o doc.\n* Seleccionar texto para limitar o âmbito.",
|
||||
"Text was copied to buffer!": "O texto foi copiado para o buffer!",
|
||||
"Convert to Markdown or HTML": "Converter para Markdown ou HTML"
|
||||
}
|
||||
@ -7,6 +7,7 @@
|
||||
"HTML headings/IDs": "HTML заголовки/идентификаторы",
|
||||
"Create base64 images": "Создание изображений base64",
|
||||
"Suppress top comment": "Убрать верхний комментарий",
|
||||
"Help": "Выберите Markdown или HTML.\n* По умолчанию: преобразовать весь документ.\n* Выберите текст, чтобы ограничить область применения."
|
||||
|
||||
"Help": "Выберите Markdown или HTML.\n* По умолчанию: преобразовать весь документ.\n* Выберите текст, чтобы ограничить область применения.",
|
||||
"Text was copied to buffer!": "Текст был скопирован в буфер!",
|
||||
"Convert to Markdown or HTML": "Преобразовать в Markdown или HTML"
|
||||
}
|
||||
@ -7,5 +7,7 @@
|
||||
"HTML headings/IDs": "HTML标题/IDs",
|
||||
"Create base64 images": "创建base64图像",
|
||||
"Suppress top comment": "抑制顶部评论",
|
||||
"Help": "选择Markdown或HTML。\n* 默认:转换整个文档。\n* 选择文本以限制范围。"
|
||||
"Help": "选择Markdown或HTML。\n* 默认:转换整个文档。\n* 选择文本以限制范围。",
|
||||
"Text was copied to buffer!": "文本被复制到缓冲区!",
|
||||
"Convert to Markdown or HTML": "转换为Markdown或HTML"
|
||||
}
|
||||
@ -74,6 +74,12 @@ function ApiRun(Run){}
|
||||
ApiRun.prototype = Object.create(ApiTextPr.prototype);
|
||||
ApiRun.prototype.constructor = ApiRun;
|
||||
|
||||
/**
|
||||
* Class representing a comment reply.
|
||||
* @constructor
|
||||
*/
|
||||
function ApiCommentReply(oParentComm, oCommentReply){}
|
||||
|
||||
/**
|
||||
* Class representing a Paragraph hyperlink.
|
||||
* @constructor
|
||||
@ -306,8 +312,8 @@ function ApiBlockLvlSdt(Sdt){}
|
||||
|
||||
/**
|
||||
* A border type which will be added to the document element.
|
||||
* * **"none"** - no border will be added to the created element or the selected element side.
|
||||
* * **"single"** - a single border will be added to the created element or the selected element side.
|
||||
* * <b>"none"</b> - no border will be added to the created element or the selected element side.
|
||||
* * <b>"single"</b> - a single border will be added to the created element or the selected element side.
|
||||
* @typedef {("none" | "single")} BorderType
|
||||
*/
|
||||
|
||||
@ -333,36 +339,36 @@ function ApiBlockLvlSdt(Sdt){}
|
||||
|
||||
/**
|
||||
* Header and footer types which can be applied to the document sections.
|
||||
* * **"default"** - a header or footer which can be applied to any default page.
|
||||
* * **"title"** - a header or footer which is applied to the title page.
|
||||
* * **"even"** - a header or footer which can be applied to even pages to distinguish them from the odd ones (which will be considered default).
|
||||
* * <b>"default"</b> - a header or footer which can be applied to any default page.
|
||||
* * <b>"title"</b> - a header or footer which is applied to the title page.
|
||||
* * <b>"even"</b> - a header or footer which can be applied to even pages to distinguish them from the odd ones (which will be considered default).
|
||||
* @typedef {("default" | "title" | "even")} HdrFtrType
|
||||
*/
|
||||
|
||||
/**
|
||||
* The possible values for the units of the width property are defined by a specific table or table cell width property.
|
||||
* * **"auto"** - sets the table or table cell width to auto width.
|
||||
* * **"twips"** - sets the table or table cell width to be measured in twentieths of a point.
|
||||
* * **"nul"** - sets the table or table cell width to be of a zero value.
|
||||
* * **"percent"** - sets the table or table cell width to be measured in percent to the parent container.
|
||||
* * <b>"auto"</b> - sets the table or table cell width to auto width.
|
||||
* * <b>"twips"</b> - sets the table or table cell width to be measured in twentieths of a point.
|
||||
* * <b>"nul"</b> - sets the table or table cell width to be of a zero value.
|
||||
* * <b>"percent"</b> - sets the table or table cell width to be measured in percent to the parent container.
|
||||
* @typedef {("auto" | "twips" | "nul" | "percent")} TableWidth
|
||||
*/
|
||||
|
||||
/**
|
||||
* This simple type specifies possible values for the table sections to which the current conditional formatting properties will be applied when this selected table style is used.
|
||||
* * **"topLeftCell"** - specifies that the table formatting is applied to the top left cell.
|
||||
* * **"topRightCell"** - specifies that the table formatting is applied to the top right cell.
|
||||
* * **"bottomLeftCell"** - specifies that the table formatting is applied to the bottom left cell.
|
||||
* * **"bottomRightCell"** - specifies that the table formatting is applied to the bottom right cell.
|
||||
* * **"firstRow"** - specifies that the table formatting is applied to the first row.
|
||||
* * **"lastRow"** - specifies that the table formatting is applied to the last row.
|
||||
* * **"firstColumn"** - specifies that the table formatting is applied to the first column. Any subsequent row which is in *table header* ({@link ApiTableRowPr#SetTableHeader}) will also use this conditional format.
|
||||
* * **"lastColumn"** - specifies that the table formatting is applied to the last column.
|
||||
* * **"bandedColumn"** - specifies that the table formatting is applied to odd numbered groupings of rows.
|
||||
* * **"bandedColumnEven"** - specifies that the table formatting is applied to even numbered groupings of rows.
|
||||
* * **"bandedRow"** - specifies that the table formatting is applied to odd numbered groupings of columns.
|
||||
* * **"bandedRowEven"** - specifies that the table formatting is applied to even numbered groupings of columns.
|
||||
* * **"wholeTable"** - specifies that the conditional formatting is applied to the whole table.
|
||||
* * <b>"topLeftCell"</b> - specifies that the table formatting is applied to the top left cell.
|
||||
* * <b>"topRightCell"</b> - specifies that the table formatting is applied to the top right cell.
|
||||
* * <b>"bottomLeftCell"</b> - specifies that the table formatting is applied to the bottom left cell.
|
||||
* * <b>"bottomRightCell"</b> - specifies that the table formatting is applied to the bottom right cell.
|
||||
* * <b>"firstRow"</b> - specifies that the table formatting is applied to the first row.
|
||||
* * <b>"lastRow"</b> - specifies that the table formatting is applied to the last row.
|
||||
* * <b>"firstColumn"</b> - specifies that the table formatting is applied to the first column. Any subsequent row which is in *table header* ({@link ApiTableRowPr#SetTableHeader}) will also use this conditional format.
|
||||
* * <b>"lastColumn"</b> - specifies that the table formatting is applied to the last column.
|
||||
* * <b>"bandedColumn"</b> - specifies that the table formatting is applied to odd numbered groupings of rows.
|
||||
* * <b>"bandedColumnEven"</b> - specifies that the table formatting is applied to even numbered groupings of rows.
|
||||
* * <b>"bandedRow"</b> - specifies that the table formatting is applied to odd numbered groupings of columns.
|
||||
* * <b>"bandedRowEven"</b> - specifies that the table formatting is applied to even numbered groupings of columns.
|
||||
* * <b>"wholeTable"</b> - specifies that the conditional formatting is applied to the whole table.
|
||||
* @typedef {("topLeftCell" | "topRightCell" | "bottomLeftCell" | "bottomRightCell" | "firstRow" | "lastRow" |
|
||||
* "firstColumn" | "lastColumn" | "bandedColumn" | "bandedColumnEven" | "bandedRow" | "bandedRowEven" |
|
||||
* "wholeTable")} TableStyleOverrideType
|
||||
@ -440,17 +446,17 @@ function ApiBlockLvlSdt(Sdt){}
|
||||
|
||||
/**
|
||||
* Possible values for the position of chart tick labels (either horizontal or vertical).
|
||||
* * **"none"** - not display the selected tick labels.
|
||||
* * **"nextTo"** - sets the position of the selected tick labels next to the main label.
|
||||
* * **"low"** - sets the position of the selected tick labels in the part of the chart with lower values.
|
||||
* * **"high"** - sets the position of the selected tick labels in the part of the chart with higher values.
|
||||
* * <b>"none"</b> - not display the selected tick labels.
|
||||
* * <b>"nextTo"</b> - sets the position of the selected tick labels next to the main label.
|
||||
* * <b>"low"</b> - sets the position of the selected tick labels in the part of the chart with lower values.
|
||||
* * <b>"high"</b> - sets the position of the selected tick labels in the part of the chart with higher values.
|
||||
* @typedef {("none" | "nextTo" | "low" | "high")} TickLabelPosition
|
||||
* **/
|
||||
|
||||
/**
|
||||
* The type of a fill which uses an image as a background.
|
||||
* * **"tile"** - if the image is smaller than the shape which is filled, the image will be tiled all over the created shape surface.
|
||||
* * **"stretch"** - if the image is smaller than the shape which is filled, the image will be stretched to fit the created shape surface.
|
||||
* * <b>"tile"</b> - if the image is smaller than the shape which is filled, the image will be tiled all over the created shape surface.
|
||||
* * <b>"stretch"</b> - if the image is smaller than the shape which is filled, the image will be stretched to fit the created shape surface.
|
||||
* @typedef {"tile" | "stretch"} BlipFillType
|
||||
* */
|
||||
|
||||
@ -509,71 +515,66 @@ function ApiBlockLvlSdt(Sdt){}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available values of the "numbered" reference type.
|
||||
* * **"pageNum"** - the page number of the numbered item.
|
||||
* * **"paraNum"** - the paragraph number of the numbered item.
|
||||
* * **"noCtxParaNum"** - an abbreviated paragraph number (the specific item of the numbered list only, e.g., instead of "4.1.1" you refer to "1" only).
|
||||
* * **"fullCtxParaNum"** - a full paragraph number, e.g., "4.1.1".
|
||||
* * **"text"** - the text value of the paragraph, e.g., if you have "4.1.1. Terms and Conditions", you refer to "Terms and Conditions" only.
|
||||
* * **"aboveBelow"** - the words "above" or "below" depending on the position of the item.
|
||||
* Available values of the "numbered" reference type:
|
||||
* * <b>"pageNum"</b> - the numbered item page number;
|
||||
* * <b>"paraNum"</b> - the numbered item paragraph number;
|
||||
* * <b>"noCtxParaNum"</b> - the abbreviated paragraph number (the specific item only, e.g. instead of "4.1.1" you refer to "1" only);
|
||||
* * <b>"fullCtxParaNum"</b> - the full paragraph number, e.g. "4.1.1";
|
||||
* * <b>"text"</b> - the paragraph text value, e.g. if you have "4.1.1. Terms and Conditions", you refer to "Terms and Conditions" only;
|
||||
* * <b>"aboveBelow"</b> - the words "above" or "below" depending on the item position.
|
||||
* @typedef {"pageNum" | "paraNum" | "noCtxParaNum" | "fullCtxParaNum" | "text" | "aboveBelow"} numberedRefTo
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available values of the "heading" reference type.
|
||||
* * **"text"** - the entire text of the heading.
|
||||
* * **"pageNum"** - the page number of the heading.
|
||||
* * **"headingNum"** - the sequence number of the heading.
|
||||
* * **"noCtxHeadingNum"** - an abbreviated heading number. Make sure the cursor point is in the section you are referencing to, e.g., you are in section 4 and you wish to refer to heading 4.B, so instead of "4.B" you receive "B" only.
|
||||
* * **"fullCtxHeadingNum"** - a full heading number even if the cursor point is in the same section.
|
||||
* * **"aboveBelow"** - the words "above" or "below" depending on the position of the item.
|
||||
* Available values of the "heading" reference type:
|
||||
* * <b>"text"</b> - the entire heading text;
|
||||
* * <b>"pageNum"</b> - the heading page number;
|
||||
* * <b>"headingNum"</b> - the heading sequence number;
|
||||
* * <b>"noCtxHeadingNum"</b> - the abbreviated heading number. Make sure the cursor pointer is in the section you are referencing to, e.g. you are in section 4 and you wish to refer to heading 4.B, so instead of "4.B" you receive "B" only;
|
||||
* * <b>"fullCtxHeadingNum"</b> - the full heading number even if the cursor pointer is in the same section;
|
||||
* * <b>"aboveBelow"</b> - the words "above" or "below" depending on the item position.
|
||||
* @typedef {"text" | "pageNum" | "headingNum" | "noCtxHeadingNum" | "fullCtxHeadingNum" | "aboveBelow"} headingRefTo
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available values of the "bookmark" reference type.
|
||||
* * **"text"** - the entire text of the bookmark.
|
||||
* * **"pageNum"** - the page number of the bookmark.
|
||||
* * **"paraNum"** - the paragraph number of the bookmark.
|
||||
* * **"noCtxParaNum"** - an abbreviated paragraph number (the specific item only, e.g., instead of "4.1.1" you refer to "1" only).
|
||||
* * **"fullCtxParaNum"** - a full paragraph number, e.g., "4.1.1".
|
||||
* * **"aboveBelow"** - the words "above" or "below" depending on the position of the item.
|
||||
* Available values of the "bookmark" reference type:
|
||||
* * <b>"text"</b> - the entire bookmark text;
|
||||
* * <b>"pageNum"</b> - the bookmark page number;
|
||||
* * <b>"paraNum"</b> - the bookmark paragraph number;
|
||||
* * <b>"noCtxParaNum"</b> - the abbreviated paragraph number (the specific item only, e.g. instead of "4.1.1" you refer to "1" only);
|
||||
* * <b>"fullCtxParaNum</b> - the full paragraph number, e.g. "4.1.1";
|
||||
* * <b>"aboveBelow"</b> - the words "above" or "below" depending on the item position.
|
||||
* @typedef {"text" | "pageNum" | "paraNum" | "noCtxParaNum" | "fullCtxParaNum" | "aboveBelow"} bookmarkRefTo
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available values of the "footnote" reference type.
|
||||
* * **"footnoteNum"** - the footnote number.
|
||||
* * **"pageNum"** - the page number of the footnote.
|
||||
* * **"aboveBelow"** - the words "above" or "below" depending on the position of the item.
|
||||
* * **"formFootnoteNum"** - the number of the footnote formatted as a footnote. The numbering of the actual footnotes is not affected.
|
||||
* Available values of the "footnote" reference type:
|
||||
* * <b>"footnoteNum"</b> - the footnote number;
|
||||
* * <b>"pageNum"</b> - the page number of the footnote;
|
||||
* * <b>"aboveBelow"</b> - the words "above" or "below" depending on the position of the item;
|
||||
* * <b>"formFootnoteNum"</b> - the form number formatted as a footnote. The numbering of the actual footnotes is not affected.
|
||||
* @typedef {"footnoteNum" | "pageNum" | "aboveBelow" | "formFootnoteNum"} footnoteRefTo
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available values of the "endnote" reference type.
|
||||
* * **"endnoteNum"** - the endnote number.
|
||||
* * **"pageNum"** - the page number of the endnote.
|
||||
* * **"aboveBelow"** - the words "above" or "below" depending on the position of the item.
|
||||
* * **"formEndnoteNum"** - the number of the endnote formatted as an endnote. The numbering of the actual endnotes is not affected.
|
||||
* Available values of the "endnote" reference type:
|
||||
* * <b>"endnoteNum"</b> - the endnote number;
|
||||
* * <b>"pageNum"</b> - the endnote page number;
|
||||
* * <b>"aboveBelow"</b> - the words "above" or "below" depending on the item position;
|
||||
* * <b>"formEndnoteNum"</b> - the form number formatted as an endnote. The numbering of the actual endnotes is not affected.
|
||||
* @typedef {"endnoteNum" | "pageNum" | "aboveBelow" | "formEndnoteNum"} endnoteRefTo
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available values of the "equation"/"figure"/"table" reference type.
|
||||
* * **"entireCaption"** - the full text of the caption.
|
||||
* * **"labelNumber"** - the label and object number only, e.g., "Table 1.1".
|
||||
* * **"captionText"** - the text of the caption only.
|
||||
* * **"pageNum"** - the page number containing the referenced object.
|
||||
* * **"aboveBelow"** - the words "above" or "below" depending on the position of the item.
|
||||
* Available values of the "equation"/"figure"/"table" reference type:
|
||||
* * <b>"entireCaption"</b>- the entire caption text;
|
||||
* * <b>"labelNumber"</b> - the label and object number only, e.g. "Table 1.1";
|
||||
* * <b>"captionText"</b> - the caption text only;
|
||||
* * <b>"pageNum"</b> - the page number containing the referenced object;
|
||||
* * <b>"aboveBelow"</b> - the words "above" or "below" depending on the item position.
|
||||
* @typedef {"entireCaption" | "labelNumber" | "captionText" | "pageNum" | "aboveBelow"} captionRefTo
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available caption labels.
|
||||
* @typedef {"Equation" | "Figure" | "Table"} CaptionLabel
|
||||
*/
|
||||
|
||||
/**
|
||||
* Axis position in the chart.
|
||||
* @typedef {("top" | "bottom" | "right" | "left")} AxisPos
|
||||
@ -592,6 +593,87 @@ function ApiBlockLvlSdt(Sdt){}
|
||||
* @typedef {ApiTextForm | ApiComboBoxForm | ApiCheckBoxForm | ApiPictureForm | ApiComplexForm} ApiForm
|
||||
*/
|
||||
|
||||
/**
|
||||
* Possible values for the caption numbering format.
|
||||
* * <b>"ALPHABETIC"</b> - upper letter.
|
||||
* * <b>"alphabetic"</b> - lower letter.
|
||||
* * <b>"Roman"</b> - upper Roman.
|
||||
* * <b>"roman"</b> - lower Roman.
|
||||
* * <b>"Arabic"</b> - arabic.
|
||||
* @typedef {("ALPHABETIC" | "alphabetic" | "Roman" | "roman" | "Arabic")} CaptionNumberingFormat
|
||||
* **/
|
||||
|
||||
/**
|
||||
* Possible values for the caption separator.
|
||||
* * <b>"hyphen"</b> - the "-" punctuation mark.
|
||||
* * <b>"period"</b> - the "." punctuation mark.
|
||||
* * <b>"colon"</b> - the ":" punctuation mark.
|
||||
* * <b>"longDash"</b> - the "—" punctuation mark.
|
||||
* * <b>"dash"</b> - the "-" punctuation mark.
|
||||
* @typedef {("hyphen" | "period" | "colon" | "longDash" | "dash")} CaptionSep
|
||||
* **/
|
||||
|
||||
/**
|
||||
* Possible values for the caption label.
|
||||
* @typedef {("Table" | "Equation" | "Figure")} CaptionLabel
|
||||
* **/
|
||||
|
||||
/**
|
||||
* Table of contents properties.
|
||||
* @typedef {Object} TocPr
|
||||
* @property {boolean} [ShowPageNums=true] - Specifies whether to show page numbers in the table of contents.
|
||||
* @property {boolean} [RightAlgn=true] - Specifies whether to right-align page numbers in the table of contents.
|
||||
* @property {TocLeader} [LeaderType="dot"] - The leader type in the table of contents.
|
||||
* @property {boolean} [FormatAsLinks=true] - Specifies whether to format the table of contents as links.
|
||||
* @property {TocBuildFromPr} [BuildFrom={OutlineLvls=9}] - Specifies whether to generate the table of contents from the outline levels or the specified styles.
|
||||
* @property {TocStyle} [TocStyle="standard"] - The table of contents style type.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Table of figures properties.
|
||||
* @typedef {Object} TofPr
|
||||
* @property {boolean} [ShowPageNums=true] - Specifies whether to show page numbers in the table of figures.
|
||||
* @property {boolean} [RightAlgn=true] - Specifies whether to right-align page numbers in the table of figures.
|
||||
* @property {TocLeader} [LeaderType="dot"] - The leader type in the table of figures.
|
||||
* @property {boolean} [FormatAsLinks=true] - Specifies whether to format the table of figures as links.
|
||||
* @property {CaptionLabel | string} [BuildFrom="Figure"] - Specifies whether to generate the table of figures based on the specified caption label or the paragraph style name used (for example, "Heading 1").
|
||||
* @property {boolean} [LabelNumber=true] - Specifies whether to include the label and number in the table of figures.
|
||||
* @property {TofStyle} [TofStyle="distinctive"] - The table of figures style type.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Table of contents properties which specify whether to generate the table of contents from the outline levels or the specified styles.
|
||||
* @typedef {Object} TocBuildFromPr
|
||||
* @property {number} [OutlineLvls=9] - Maximum number of levels in the table of contents.
|
||||
* @property {TocStyleLvl[]} StylesLvls - Style levels (for example, [{Name: "Heading 1", Lvl: 2}, {Name: "Heading 2", Lvl: 3}]).
|
||||
* <note>If StylesLvls.length > 0, then the OutlineLvls property will be ignored.</note>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Table of contents style levels.
|
||||
* @typedef {Object} TocStyleLvl
|
||||
* @property {string} Name - Style name (for example, "Heading 1").
|
||||
* @property {number} Lvl - Level which will be applied to the specified style in the table of contents.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Possible values for the table of contents leader:
|
||||
* * <b>"dot"</b> - "......."
|
||||
* * <b>"dash"</b> - "-------"
|
||||
* * <b>"underline"</b> - "_______"
|
||||
* @typedef {("dot" | "dash" | "underline" | "none")} TocLeader
|
||||
* **/
|
||||
|
||||
/**
|
||||
* Possible values for the table of contents style.
|
||||
* @typedef {("simple" | "online" | "standard" | "modern" | "classic")} TocStyle
|
||||
* **/
|
||||
|
||||
/**
|
||||
* Possible values for the table of figures style.
|
||||
* @typedef {("simple" | "online" | "classic" | "distinctive" | "centered" | "formal")} TofStyle
|
||||
* **/
|
||||
|
||||
/**
|
||||
* The 1000th of a percent (100000 = 100%).
|
||||
* @typedef {number} PositivePercentage
|
||||
@ -1050,7 +1132,7 @@ ApiRun.prototype.SetDoubleStrikeout = function(isDoubleStrikeout){ return new Ap
|
||||
/**
|
||||
* Sets the text color to the current text run.
|
||||
* @memberof ApiRun
|
||||
* @typeofeditors ["CDE", "CSE", "CPE"]
|
||||
* @typeofeditors ["CSE", "CPE"]
|
||||
* @param {ApiFill} oApiFill - The color or pattern used to fill the text color.
|
||||
* @returns {ApiTextPr}
|
||||
*/
|
||||
@ -1308,7 +1390,7 @@ ApiTextPr.prototype.SetSmallCaps = function(isSmallCaps){ return new ApiTextPr()
|
||||
/**
|
||||
* Sets the text color to the current text run.
|
||||
* @memberof ApiTextPr
|
||||
* @typeofeditors ["CDE", "CPE", "CSE"]
|
||||
* @typeofeditors ["CSE", "CPE"]
|
||||
* @param {ApiFill} oApiFill - The color or pattern used to fill the text color.
|
||||
* @returns {ApiTextPr} - this text properties.
|
||||
*/
|
||||
@ -1317,7 +1399,7 @@ ApiTextPr.prototype.SetFill = function(oApiFill){ return new ApiTextPr(); };
|
||||
/**
|
||||
* Sets the text fill to the current text run.
|
||||
* @memberof ApiTextPr
|
||||
* @typeofeditors ["CDE", "CPE", "CSE"]
|
||||
* @typeofeditors ["CSE", "CPE", "CSE"]
|
||||
* @param {ApiFill} oApiFill - The color or pattern used to fill the text color.
|
||||
* @returns {ApiTextPr} - this text properties.
|
||||
*/
|
||||
@ -1326,7 +1408,7 @@ ApiTextPr.prototype.SetTextFill = function(oApiFill){ return new ApiTextPr(); };
|
||||
/**
|
||||
* Sets the text outline to the current text run.
|
||||
* @memberof ApiTextPr
|
||||
* @typeofeditors ["CDE", "CPE", "CSE"]
|
||||
* @typeofeditors ["CSE", "CPE", "CSE"]
|
||||
* @param {ApiStroke} oStroke - The stroke used to create the text outline.
|
||||
* @returns {ApiTextPr} - this text properties.
|
||||
*/
|
||||
@ -1747,17 +1829,17 @@ function ApiTableCell(oCell){}
|
||||
|
||||
/**
|
||||
* Possible values for the position of chart tick labels (either horizontal or vertical).
|
||||
* * **"none"** - not display the selected tick labels.
|
||||
* * **"nextTo"** - set the position of the selected tick labels next to the main label.
|
||||
* * **"low"** - set the position of the selected tick labels in the part of the chart with lower values.
|
||||
* * **"high"** - set the position of the selected tick labels in the part of the chart with higher values.
|
||||
* * <b>"none"</b> - not display the selected tick labels.
|
||||
* * <b>"nextTo"</b> - set the position of the selected tick labels next to the main label.
|
||||
* * <b>"low"</b> - set the position of the selected tick labels in the part of the chart with lower values.
|
||||
* * <b>"high"</b> - set the position of the selected tick labels in the part of the chart with higher values.
|
||||
* @typedef {("none" | "nextTo" | "low" | "high")} TickLabelPosition
|
||||
* **/
|
||||
|
||||
/**
|
||||
* The type of a fill which uses an image as a background.
|
||||
* * **"tile"** - if the image is smaller than the shape which is filled, the image will be tiled all over the created shape surface.
|
||||
* * **"stretch"** - if the image is smaller than the shape which is filled, the image will be stretched to fit the created shape surface.
|
||||
* * <b>"tile"</b> - if the image is smaller than the shape which is filled, the image will be tiled all over the created shape surface.
|
||||
* * <b>"stretch"</b> - if the image is smaller than the shape which is filled, the image will be stretched to fit the created shape surface.
|
||||
* @typedef {"tile" | "stretch"} BlipFillType
|
||||
* */
|
||||
|
||||
@ -2003,7 +2085,7 @@ ApiTableCell.prototype.SetVerticalAlign = function(sType){};
|
||||
* The callback function which is called when the specified range of the current sheet changes.
|
||||
* <note>Please note that the event is not called for the undo/redo operations.</note>
|
||||
* @event Api#onWorksheetChange
|
||||
* @property {ApiRange} range - The modified range represented as the ApiRange object.
|
||||
* @param {ApiRange} range - The modified range represented as the ApiRange object.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -2142,10 +2224,10 @@ ApiOleObject.prototype.constructor = ApiOleObject;
|
||||
|
||||
/**
|
||||
* Possible values for the position of chart tick labels (either horizontal or vertical).
|
||||
* * **"none"** - does not display the selected tick labels.
|
||||
* * **"nextTo"** - sets the position of the selected tick labels next to the main label.
|
||||
* * **"low"** - sets the position of the selected tick labels in the part of the chart with lower values.
|
||||
* * **"high"** - sets the position of the selected tick labels in the part of the chart with higher values.
|
||||
* * <b>"none"</b> - does not display the selected tick labels.
|
||||
* * <b>"nextTo"</b> - sets the position of the selected tick labels next to the main label.
|
||||
* * <b>"low"</b> - sets the position of the selected tick labels in the part of the chart with lower values.
|
||||
* * <b>"high"</b> - sets the position of the selected tick labels in the part of the chart with higher values.
|
||||
* @typedef {("none" | "nextTo" | "low" | "high")} TickLabelPosition
|
||||
* **/
|
||||
|
||||
@ -2202,7 +2284,7 @@ function ApiName(DefName) {}
|
||||
* @constructor
|
||||
* @property {string} Text - Returns the text from the first cell in range.
|
||||
*/
|
||||
function ApiComment(comment, ws) {}
|
||||
function ApiComment(comment, wb) {}
|
||||
|
||||
/**
|
||||
* Class representing the areas.
|
||||
@ -2445,6 +2527,22 @@ ApiInterface.prototype["attachEvent"] = ApiInterface.prototype.attachEvent;{};
|
||||
*/
|
||||
ApiInterface.prototype["detachEvent"] = ApiInterface.prototype.detachEvent;{};
|
||||
|
||||
/**
|
||||
* Returns an array of ApiComment objects.
|
||||
* @memberof ApiInterface
|
||||
* @typeofeditors ["CSE"]
|
||||
* @returns {ApiComment[]}
|
||||
*/
|
||||
ApiInterface.prototype.GetComments = function () { return [new ApiComment()]; };
|
||||
|
||||
/**
|
||||
* Returns an array of ApiComment objects.
|
||||
* @memberof ApiInterface
|
||||
* @typeofeditors ["CSE"]
|
||||
* @returns {ApiComment[]}
|
||||
*/
|
||||
ApiInterface.prototype.Comments = ApiInterface.prototype.GetComments ();
|
||||
|
||||
/**
|
||||
* Returns the state of sheet visibility.
|
||||
* @memberof ApiWorksheet
|
||||
@ -2623,10 +2721,11 @@ ApiWorksheet.prototype.Index = ApiWorksheet.prototype.GetIndex ();
|
||||
* from a single row - <b>A1:E1</b>, or cells from a single column - <b>A1:A10</b>, or cells from several rows and columns - <b>A1:E10</b>.
|
||||
* @memberof ApiWorksheet
|
||||
* @typeofeditors ["CSE"]
|
||||
* @param {string} sRange - The range of cells from the current sheet.
|
||||
* @param {string | ApiRange} Range1 - The range of cells from the current sheet.
|
||||
* @param {string | ApiRange} Range2 - The range of cells from the current sheet.
|
||||
* @returns {ApiRange | null} - returns null if such a range does not exist.
|
||||
*/
|
||||
ApiWorksheet.prototype.GetRange = function (sRange) { return new ApiRange(); };
|
||||
ApiWorksheet.prototype.GetRange = function (Range1, Range2) { return new ApiRange(); };
|
||||
|
||||
/**
|
||||
* Returns an object that represents the selected range of the current sheet using the <b>row/column</b> coordinates for the cell selection.
|
||||
@ -2922,10 +3021,11 @@ ApiWorksheet.prototype.Delete = function () {};
|
||||
* @typeofeditors ["CSE"]
|
||||
* @param {string} sRange - The range where the hyperlink will be added to.
|
||||
* @param {string} sAddress - The link address.
|
||||
* @param {string} subAddress - The link subaddress to insert internal sheet hyperlinks.
|
||||
* @param {string} sScreenTip - The screen tip text.
|
||||
* @param {string} sTextToDisplay - The link text that will be displayed on the sheet.
|
||||
* */
|
||||
ApiWorksheet.prototype.SetHyperlink = function (sRange, sAddress, sScreenTip, sTextToDisplay){};
|
||||
ApiWorksheet.prototype.SetHyperlink = function (sRange, sAddress, subAddress, sScreenTip, sTextToDisplay) {};
|
||||
|
||||
/**
|
||||
* Creates a chart of the specified type from the selected data range of the current sheet.
|
||||
@ -3913,25 +4013,6 @@ ApiDrawing.prototype.GetWidth = function(){ return new EMU(); };
|
||||
*/
|
||||
ApiDrawing.prototype.GetHeight = function(){ return new EMU(); };
|
||||
|
||||
/**
|
||||
* Returns the lock value for the specified lock type of the current drawing.
|
||||
* @typeofeditors ["CSE"]
|
||||
* @param {"noGrp" | "noUngrp" | "noSelect" | "noRot" | "noChangeAspect" | "noMove" | "noResize" | "noEditPoints" | "noAdjustHandles"
|
||||
* | "noChangeArrowheads" | "noChangeShapeType" | "noDrilldown" | "noTextEdit" | "noCrop" | "txBox"} sType - Lock type in the string format.
|
||||
* @returns {bool}
|
||||
*/
|
||||
ApiDrawing.prototype.GetLockValue = function(sType){ return true; };
|
||||
|
||||
/**
|
||||
* Sets the lock value to the specified lock type of the current drawing.
|
||||
* @typeofeditors ["CSE"]
|
||||
* @param {"noGrp" | "noUngrp" | "noSelect" | "noRot" | "noChangeAspect" | "noMove" | "noResize" | "noEditPoints" | "noAdjustHandles"
|
||||
* | "noChangeArrowheads" | "noChangeShapeType" | "noDrilldown" | "noTextEdit" | "noCrop" | "txBox"} sType - Lock type in the string format.
|
||||
* @param {bool} bValue - Specifies if the specified lock is applied to the current drawing.
|
||||
* @returns {bool}
|
||||
*/
|
||||
ApiDrawing.prototype.SetLockValue = function(sType, bValue){ return true; };
|
||||
|
||||
/**
|
||||
* Returns a type of the ApiImage class.
|
||||
* @memberof ApiImage
|
||||
|
||||
@ -92,6 +92,18 @@ function ApiRun(Run){}
|
||||
ApiRun.prototype = Object.create(ApiTextPr.prototype);
|
||||
ApiRun.prototype.constructor = ApiRun;
|
||||
|
||||
/**
|
||||
* Class representing a comment.
|
||||
* @constructor
|
||||
*/
|
||||
function ApiComment(oComment){}
|
||||
|
||||
/**
|
||||
* Class representing a comment reply.
|
||||
* @constructor
|
||||
*/
|
||||
function ApiCommentReply(oParentComm, oCommentReply){}
|
||||
|
||||
/**
|
||||
* Class representing a Paragraph hyperlink.
|
||||
* @constructor
|
||||
@ -324,8 +336,8 @@ function ApiBlockLvlSdt(Sdt){}
|
||||
|
||||
/**
|
||||
* A border type which will be added to the document element.
|
||||
* * **"none"** - no border will be added to the created element or the selected element side.
|
||||
* * **"single"** - a single border will be added to the created element or the selected element side.
|
||||
* * <b>"none"</b> - no border will be added to the created element or the selected element side.
|
||||
* * <b>"single"</b> - a single border will be added to the created element or the selected element side.
|
||||
* @typedef {("none" | "single")} BorderType
|
||||
*/
|
||||
|
||||
@ -351,36 +363,36 @@ function ApiBlockLvlSdt(Sdt){}
|
||||
|
||||
/**
|
||||
* Header and footer types which can be applied to the document sections.
|
||||
* * **"default"** - a header or footer which can be applied to any default page.
|
||||
* * **"title"** - a header or footer which is applied to the title page.
|
||||
* * **"even"** - a header or footer which can be applied to even pages to distinguish them from the odd ones (which will be considered default).
|
||||
* * <b>"default"</b> - a header or footer which can be applied to any default page.
|
||||
* * <b>"title"</b> - a header or footer which is applied to the title page.
|
||||
* * <b>"even"</b> - a header or footer which can be applied to even pages to distinguish them from the odd ones (which will be considered default).
|
||||
* @typedef {("default" | "title" | "even")} HdrFtrType
|
||||
*/
|
||||
|
||||
/**
|
||||
* The possible values for the units of the width property are defined by a specific table or table cell width property.
|
||||
* * **"auto"** - sets the table or table cell width to auto width.
|
||||
* * **"twips"** - sets the table or table cell width to be measured in twentieths of a point.
|
||||
* * **"nul"** - sets the table or table cell width to be of a zero value.
|
||||
* * **"percent"** - sets the table or table cell width to be measured in percent to the parent container.
|
||||
* * <b>"auto"</b> - sets the table or table cell width to auto width.
|
||||
* * <b>"twips"</b> - sets the table or table cell width to be measured in twentieths of a point.
|
||||
* * <b>"nul"</b> - sets the table or table cell width to be of a zero value.
|
||||
* * <b>"percent"</b> - sets the table or table cell width to be measured in percent to the parent container.
|
||||
* @typedef {("auto" | "twips" | "nul" | "percent")} TableWidth
|
||||
*/
|
||||
|
||||
/**
|
||||
* This simple type specifies possible values for the table sections to which the current conditional formatting properties will be applied when this selected table style is used.
|
||||
* * **"topLeftCell"** - specifies that the table formatting is applied to the top left cell.
|
||||
* * **"topRightCell"** - specifies that the table formatting is applied to the top right cell.
|
||||
* * **"bottomLeftCell"** - specifies that the table formatting is applied to the bottom left cell.
|
||||
* * **"bottomRightCell"** - specifies that the table formatting is applied to the bottom right cell.
|
||||
* * **"firstRow"** - specifies that the table formatting is applied to the first row.
|
||||
* * **"lastRow"** - specifies that the table formatting is applied to the last row.
|
||||
* * **"firstColumn"** - specifies that the table formatting is applied to the first column. Any subsequent row which is in *table header* ({@link ApiTableRowPr#SetTableHeader}) will also use this conditional format.
|
||||
* * **"lastColumn"** - specifies that the table formatting is applied to the last column.
|
||||
* * **"bandedColumn"** - specifies that the table formatting is applied to odd numbered groupings of rows.
|
||||
* * **"bandedColumnEven"** - specifies that the table formatting is applied to even numbered groupings of rows.
|
||||
* * **"bandedRow"** - specifies that the table formatting is applied to odd numbered groupings of columns.
|
||||
* * **"bandedRowEven"** - specifies that the table formatting is applied to even numbered groupings of columns.
|
||||
* * **"wholeTable"** - specifies that the conditional formatting is applied to the whole table.
|
||||
* * <b>"topLeftCell"</b> - specifies that the table formatting is applied to the top left cell.
|
||||
* * <b>"topRightCell"</b> - specifies that the table formatting is applied to the top right cell.
|
||||
* * <b>"bottomLeftCell"</b> - specifies that the table formatting is applied to the bottom left cell.
|
||||
* * <b>"bottomRightCell"</b> - specifies that the table formatting is applied to the bottom right cell.
|
||||
* * <b>"firstRow"</b> - specifies that the table formatting is applied to the first row.
|
||||
* * <b>"lastRow"</b> - specifies that the table formatting is applied to the last row.
|
||||
* * <b>"firstColumn"</b> - specifies that the table formatting is applied to the first column. Any subsequent row which is in *table header* ({@link ApiTableRowPr#SetTableHeader}) will also use this conditional format.
|
||||
* * <b>"lastColumn"</b> - specifies that the table formatting is applied to the last column.
|
||||
* * <b>"bandedColumn"</b> - specifies that the table formatting is applied to odd numbered groupings of rows.
|
||||
* * <b>"bandedColumnEven"</b> - specifies that the table formatting is applied to even numbered groupings of rows.
|
||||
* * <b>"bandedRow"</b> - specifies that the table formatting is applied to odd numbered groupings of columns.
|
||||
* * <b>"bandedRowEven"</b> - specifies that the table formatting is applied to even numbered groupings of columns.
|
||||
* * <b>"wholeTable"</b> - specifies that the conditional formatting is applied to the whole table.
|
||||
* @typedef {("topLeftCell" | "topRightCell" | "bottomLeftCell" | "bottomRightCell" | "firstRow" | "lastRow" |
|
||||
* "firstColumn" | "lastColumn" | "bandedColumn" | "bandedColumnEven" | "bandedRow" | "bandedRowEven" |
|
||||
* "wholeTable")} TableStyleOverrideType
|
||||
@ -458,17 +470,17 @@ function ApiBlockLvlSdt(Sdt){}
|
||||
|
||||
/**
|
||||
* Possible values for the position of chart tick labels (either horizontal or vertical).
|
||||
* * **"none"** - not display the selected tick labels.
|
||||
* * **"nextTo"** - sets the position of the selected tick labels next to the main label.
|
||||
* * **"low"** - sets the position of the selected tick labels in the part of the chart with lower values.
|
||||
* * **"high"** - sets the position of the selected tick labels in the part of the chart with higher values.
|
||||
* * <b>"none"</b> - not display the selected tick labels.
|
||||
* * <b>"nextTo"</b> - sets the position of the selected tick labels next to the main label.
|
||||
* * <b>"low"</b> - sets the position of the selected tick labels in the part of the chart with lower values.
|
||||
* * <b>"high"</b> - sets the position of the selected tick labels in the part of the chart with higher values.
|
||||
* @typedef {("none" | "nextTo" | "low" | "high")} TickLabelPosition
|
||||
* **/
|
||||
|
||||
/**
|
||||
* The type of a fill which uses an image as a background.
|
||||
* * **"tile"** - if the image is smaller than the shape which is filled, the image will be tiled all over the created shape surface.
|
||||
* * **"stretch"** - if the image is smaller than the shape which is filled, the image will be stretched to fit the created shape surface.
|
||||
* * <b>"tile"</b> - if the image is smaller than the shape which is filled, the image will be tiled all over the created shape surface.
|
||||
* * <b>"stretch"</b> - if the image is smaller than the shape which is filled, the image will be stretched to fit the created shape surface.
|
||||
* @typedef {"tile" | "stretch"} BlipFillType
|
||||
* */
|
||||
|
||||
@ -527,71 +539,66 @@ function ApiBlockLvlSdt(Sdt){}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available values of the "numbered" reference type.
|
||||
* * **"pageNum"** - the page number of the numbered item.
|
||||
* * **"paraNum"** - the paragraph number of the numbered item.
|
||||
* * **"noCtxParaNum"** - an abbreviated paragraph number (the specific item of the numbered list only, e.g., instead of "4.1.1" you refer to "1" only).
|
||||
* * **"fullCtxParaNum"** - a full paragraph number, e.g., "4.1.1".
|
||||
* * **"text"** - the text value of the paragraph, e.g., if you have "4.1.1. Terms and Conditions", you refer to "Terms and Conditions" only.
|
||||
* * **"aboveBelow"** - the words "above" or "below" depending on the position of the item.
|
||||
* Available values of the "numbered" reference type:
|
||||
* * <b>"pageNum"</b> - the numbered item page number;
|
||||
* * <b>"paraNum"</b> - the numbered item paragraph number;
|
||||
* * <b>"noCtxParaNum"</b> - the abbreviated paragraph number (the specific item only, e.g. instead of "4.1.1" you refer to "1" only);
|
||||
* * <b>"fullCtxParaNum"</b> - the full paragraph number, e.g. "4.1.1";
|
||||
* * <b>"text"</b> - the paragraph text value, e.g. if you have "4.1.1. Terms and Conditions", you refer to "Terms and Conditions" only;
|
||||
* * <b>"aboveBelow"</b> - the words "above" or "below" depending on the item position.
|
||||
* @typedef {"pageNum" | "paraNum" | "noCtxParaNum" | "fullCtxParaNum" | "text" | "aboveBelow"} numberedRefTo
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available values of the "heading" reference type.
|
||||
* * **"text"** - the entire text of the heading.
|
||||
* * **"pageNum"** - the page number of the heading.
|
||||
* * **"headingNum"** - the sequence number of the heading.
|
||||
* * **"noCtxHeadingNum"** - an abbreviated heading number. Make sure the cursor point is in the section you are referencing to, e.g., you are in section 4 and you wish to refer to heading 4.B, so instead of "4.B" you receive "B" only.
|
||||
* * **"fullCtxHeadingNum"** - a full heading number even if the cursor point is in the same section.
|
||||
* * **"aboveBelow"** - the words "above" or "below" depending on the position of the item.
|
||||
* Available values of the "heading" reference type:
|
||||
* * <b>"text"</b> - the entire heading text;
|
||||
* * <b>"pageNum"</b> - the heading page number;
|
||||
* * <b>"headingNum"</b> - the heading sequence number;
|
||||
* * <b>"noCtxHeadingNum"</b> - the abbreviated heading number. Make sure the cursor pointer is in the section you are referencing to, e.g. you are in section 4 and you wish to refer to heading 4.B, so instead of "4.B" you receive "B" only;
|
||||
* * <b>"fullCtxHeadingNum"</b> - the full heading number even if the cursor pointer is in the same section;
|
||||
* * <b>"aboveBelow"</b> - the words "above" or "below" depending on the item position.
|
||||
* @typedef {"text" | "pageNum" | "headingNum" | "noCtxHeadingNum" | "fullCtxHeadingNum" | "aboveBelow"} headingRefTo
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available values of the "bookmark" reference type.
|
||||
* * **"text"** - the entire text of the bookmark.
|
||||
* * **"pageNum"** - the page number of the bookmark.
|
||||
* * **"paraNum"** - the paragraph number of the bookmark.
|
||||
* * **"noCtxParaNum"** - an abbreviated paragraph number (the specific item only, e.g., instead of "4.1.1" you refer to "1" only).
|
||||
* * **"fullCtxParaNum"** - a full paragraph number, e.g., "4.1.1".
|
||||
* * **"aboveBelow"** - the words "above" or "below" depending on the position of the item.
|
||||
* Available values of the "bookmark" reference type:
|
||||
* * <b>"text"</b> - the entire bookmark text;
|
||||
* * <b>"pageNum"</b> - the bookmark page number;
|
||||
* * <b>"paraNum"</b> - the bookmark paragraph number;
|
||||
* * <b>"noCtxParaNum"</b> - the abbreviated paragraph number (the specific item only, e.g. instead of "4.1.1" you refer to "1" only);
|
||||
* * <b>"fullCtxParaNum</b> - the full paragraph number, e.g. "4.1.1";
|
||||
* * <b>"aboveBelow"</b> - the words "above" or "below" depending on the item position.
|
||||
* @typedef {"text" | "pageNum" | "paraNum" | "noCtxParaNum" | "fullCtxParaNum" | "aboveBelow"} bookmarkRefTo
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available values of the "footnote" reference type.
|
||||
* * **"footnoteNum"** - the footnote number.
|
||||
* * **"pageNum"** - the page number of the footnote.
|
||||
* * **"aboveBelow"** - the words "above" or "below" depending on the position of the item.
|
||||
* * **"formFootnoteNum"** - the number of the footnote formatted as a footnote. The numbering of the actual footnotes is not affected.
|
||||
* Available values of the "footnote" reference type:
|
||||
* * <b>"footnoteNum"</b> - the footnote number;
|
||||
* * <b>"pageNum"</b> - the page number of the footnote;
|
||||
* * <b>"aboveBelow"</b> - the words "above" or "below" depending on the position of the item;
|
||||
* * <b>"formFootnoteNum"</b> - the form number formatted as a footnote. The numbering of the actual footnotes is not affected.
|
||||
* @typedef {"footnoteNum" | "pageNum" | "aboveBelow" | "formFootnoteNum"} footnoteRefTo
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available values of the "endnote" reference type.
|
||||
* * **"endnoteNum"** - the endnote number.
|
||||
* * **"pageNum"** - the page number of the endnote.
|
||||
* * **"aboveBelow"** - the words "above" or "below" depending on the position of the item.
|
||||
* * **"formEndnoteNum"** - the number of the endnote formatted as an endnote. The numbering of the actual endnotes is not affected.
|
||||
* Available values of the "endnote" reference type:
|
||||
* * <b>"endnoteNum"</b> - the endnote number;
|
||||
* * <b>"pageNum"</b> - the endnote page number;
|
||||
* * <b>"aboveBelow"</b> - the words "above" or "below" depending on the item position;
|
||||
* * <b>"formEndnoteNum"</b> - the form number formatted as an endnote. The numbering of the actual endnotes is not affected.
|
||||
* @typedef {"endnoteNum" | "pageNum" | "aboveBelow" | "formEndnoteNum"} endnoteRefTo
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available values of the "equation"/"figure"/"table" reference type.
|
||||
* * **"entireCaption"** - the full text of the caption.
|
||||
* * **"labelNumber"** - the label and object number only, e.g., "Table 1.1".
|
||||
* * **"captionText"** - the text of the caption only.
|
||||
* * **"pageNum"** - the page number containing the referenced object.
|
||||
* * **"aboveBelow"** - the words "above" or "below" depending on the position of the item.
|
||||
* Available values of the "equation"/"figure"/"table" reference type:
|
||||
* * <b>"entireCaption"</b>- the entire caption text;
|
||||
* * <b>"labelNumber"</b> - the label and object number only, e.g. "Table 1.1";
|
||||
* * <b>"captionText"</b> - the caption text only;
|
||||
* * <b>"pageNum"</b> - the page number containing the referenced object;
|
||||
* * <b>"aboveBelow"</b> - the words "above" or "below" depending on the item position.
|
||||
* @typedef {"entireCaption" | "labelNumber" | "captionText" | "pageNum" | "aboveBelow"} captionRefTo
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available caption labels.
|
||||
* @typedef {"Equation" | "Figure" | "Table"} CaptionLabel
|
||||
*/
|
||||
|
||||
/**
|
||||
* Axis position in the chart.
|
||||
* @typedef {("top" | "bottom" | "right" | "left")} AxisPos
|
||||
@ -610,6 +617,87 @@ function ApiBlockLvlSdt(Sdt){}
|
||||
* @typedef {ApiTextForm | ApiComboBoxForm | ApiCheckBoxForm | ApiPictureForm | ApiComplexForm} ApiForm
|
||||
*/
|
||||
|
||||
/**
|
||||
* Possible values for the caption numbering format.
|
||||
* * <b>"ALPHABETIC"</b> - upper letter.
|
||||
* * <b>"alphabetic"</b> - lower letter.
|
||||
* * <b>"Roman"</b> - upper Roman.
|
||||
* * <b>"roman"</b> - lower Roman.
|
||||
* * <b>"Arabic"</b> - arabic.
|
||||
* @typedef {("ALPHABETIC" | "alphabetic" | "Roman" | "roman" | "Arabic")} CaptionNumberingFormat
|
||||
* **/
|
||||
|
||||
/**
|
||||
* Possible values for the caption separator.
|
||||
* * <b>"hyphen"</b> - the "-" punctuation mark.
|
||||
* * <b>"period"</b> - the "." punctuation mark.
|
||||
* * <b>"colon"</b> - the ":" punctuation mark.
|
||||
* * <b>"longDash"</b> - the "—" punctuation mark.
|
||||
* * <b>"dash"</b> - the "-" punctuation mark.
|
||||
* @typedef {("hyphen" | "period" | "colon" | "longDash" | "dash")} CaptionSep
|
||||
* **/
|
||||
|
||||
/**
|
||||
* Possible values for the caption label.
|
||||
* @typedef {("Table" | "Equation" | "Figure")} CaptionLabel
|
||||
* **/
|
||||
|
||||
/**
|
||||
* Table of contents properties.
|
||||
* @typedef {Object} TocPr
|
||||
* @property {boolean} [ShowPageNums=true] - Specifies whether to show page numbers in the table of contents.
|
||||
* @property {boolean} [RightAlgn=true] - Specifies whether to right-align page numbers in the table of contents.
|
||||
* @property {TocLeader} [LeaderType="dot"] - The leader type in the table of contents.
|
||||
* @property {boolean} [FormatAsLinks=true] - Specifies whether to format the table of contents as links.
|
||||
* @property {TocBuildFromPr} [BuildFrom={OutlineLvls=9}] - Specifies whether to generate the table of contents from the outline levels or the specified styles.
|
||||
* @property {TocStyle} [TocStyle="standard"] - The table of contents style type.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Table of figures properties.
|
||||
* @typedef {Object} TofPr
|
||||
* @property {boolean} [ShowPageNums=true] - Specifies whether to show page numbers in the table of figures.
|
||||
* @property {boolean} [RightAlgn=true] - Specifies whether to right-align page numbers in the table of figures.
|
||||
* @property {TocLeader} [LeaderType="dot"] - The leader type in the table of figures.
|
||||
* @property {boolean} [FormatAsLinks=true] - Specifies whether to format the table of figures as links.
|
||||
* @property {CaptionLabel | string} [BuildFrom="Figure"] - Specifies whether to generate the table of figures based on the specified caption label or the paragraph style name used (for example, "Heading 1").
|
||||
* @property {boolean} [LabelNumber=true] - Specifies whether to include the label and number in the table of figures.
|
||||
* @property {TofStyle} [TofStyle="distinctive"] - The table of figures style type.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Table of contents properties which specify whether to generate the table of contents from the outline levels or the specified styles.
|
||||
* @typedef {Object} TocBuildFromPr
|
||||
* @property {number} [OutlineLvls=9] - Maximum number of levels in the table of contents.
|
||||
* @property {TocStyleLvl[]} StylesLvls - Style levels (for example, [{Name: "Heading 1", Lvl: 2}, {Name: "Heading 2", Lvl: 3}]).
|
||||
* <note>If StylesLvls.length > 0, then the OutlineLvls property will be ignored.</note>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Table of contents style levels.
|
||||
* @typedef {Object} TocStyleLvl
|
||||
* @property {string} Name - Style name (for example, "Heading 1").
|
||||
* @property {number} Lvl - Level which will be applied to the specified style in the table of contents.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Possible values for the table of contents leader:
|
||||
* * <b>"dot"</b> - "......."
|
||||
* * <b>"dash"</b> - "-------"
|
||||
* * <b>"underline"</b> - "_______"
|
||||
* @typedef {("dot" | "dash" | "underline" | "none")} TocLeader
|
||||
* **/
|
||||
|
||||
/**
|
||||
* Possible values for the table of contents style.
|
||||
* @typedef {("simple" | "online" | "standard" | "modern" | "classic")} TocStyle
|
||||
* **/
|
||||
|
||||
/**
|
||||
* Possible values for the table of figures style.
|
||||
* @typedef {("simple" | "online" | "classic" | "distinctive" | "centered" | "formal")} TofStyle
|
||||
* **/
|
||||
|
||||
/**
|
||||
* The 1000th of a percent (100000 = 100%).
|
||||
* @typedef {number} PositivePercentage
|
||||
@ -1069,7 +1157,7 @@ ApiRun.prototype.SetDoubleStrikeout = function(isDoubleStrikeout){ return new Ap
|
||||
/**
|
||||
* Sets the text color to the current text run.
|
||||
* @memberof ApiRun
|
||||
* @typeofeditors ["CDE", "CSE", "CPE"]
|
||||
* @typeofeditors ["CSE", "CPE"]
|
||||
* @param {ApiFill} oApiFill - The color or pattern used to fill the text color.
|
||||
* @returns {ApiTextPr}
|
||||
*/
|
||||
@ -1336,7 +1424,7 @@ ApiTextPr.prototype.SetSmallCaps = function(isSmallCaps){ return new ApiTextPr()
|
||||
/**
|
||||
* Sets the text color to the current text run.
|
||||
* @memberof ApiTextPr
|
||||
* @typeofeditors ["CDE", "CPE", "CSE"]
|
||||
* @typeofeditors ["CSE", "CPE"]
|
||||
* @param {ApiFill} oApiFill - The color or pattern used to fill the text color.
|
||||
* @returns {ApiTextPr} - this text properties.
|
||||
*/
|
||||
@ -1345,7 +1433,7 @@ ApiTextPr.prototype.SetFill = function(oApiFill){ return new ApiTextPr(); };
|
||||
/**
|
||||
* Sets the text fill to the current text run.
|
||||
* @memberof ApiTextPr
|
||||
* @typeofeditors ["CDE", "CPE", "CSE"]
|
||||
* @typeofeditors ["CSE", "CPE", "CSE"]
|
||||
* @param {ApiFill} oApiFill - The color or pattern used to fill the text color.
|
||||
* @returns {ApiTextPr} - this text properties.
|
||||
*/
|
||||
@ -1354,7 +1442,7 @@ ApiTextPr.prototype.SetTextFill = function(oApiFill){ return new ApiTextPr(); };
|
||||
/**
|
||||
* Sets the text outline to the current text run.
|
||||
* @memberof ApiTextPr
|
||||
* @typeofeditors ["CDE", "CPE", "CSE"]
|
||||
* @typeofeditors ["CSE", "CPE", "CSE"]
|
||||
* @param {ApiStroke} oStroke - The stroke used to create the text outline.
|
||||
* @returns {ApiTextPr} - this text properties.
|
||||
*/
|
||||
@ -1813,17 +1901,17 @@ function ApiTableCell(oCell){}
|
||||
|
||||
/**
|
||||
* Possible values for the position of chart tick labels (either horizontal or vertical).
|
||||
* * **"none"** - not display the selected tick labels.
|
||||
* * **"nextTo"** - set the position of the selected tick labels next to the main label.
|
||||
* * **"low"** - set the position of the selected tick labels in the part of the chart with lower values.
|
||||
* * **"high"** - set the position of the selected tick labels in the part of the chart with higher values.
|
||||
* * <b>"none"</b> - not display the selected tick labels.
|
||||
* * <b>"nextTo"</b> - set the position of the selected tick labels next to the main label.
|
||||
* * <b>"low"</b> - set the position of the selected tick labels in the part of the chart with lower values.
|
||||
* * <b>"high"</b> - set the position of the selected tick labels in the part of the chart with higher values.
|
||||
* @typedef {("none" | "nextTo" | "low" | "high")} TickLabelPosition
|
||||
* **/
|
||||
|
||||
/**
|
||||
* The type of a fill which uses an image as a background.
|
||||
* * **"tile"** - if the image is smaller than the shape which is filled, the image will be tiled all over the created shape surface.
|
||||
* * **"stretch"** - if the image is smaller than the shape which is filled, the image will be stretched to fit the created shape surface.
|
||||
* * <b>"tile"</b> - if the image is smaller than the shape which is filled, the image will be tiled all over the created shape surface.
|
||||
* * <b>"stretch"</b> - if the image is smaller than the shape which is filled, the image will be stretched to fit the created shape surface.
|
||||
* @typedef {"tile" | "stretch"} BlipFillType
|
||||
* */
|
||||
|
||||
@ -2064,14 +2152,6 @@ ApiInterface.prototype.Save = function () {};
|
||||
*/
|
||||
ApiInterface.prototype.CreateWordArt = function(oTextPr, sText, sTransform, oFill, oStroke, nRotAngle, nWidth, nHeight, nIndLeft, nIndTop) { return new ApiDrawing(); };
|
||||
|
||||
/**
|
||||
* Converts the specified JSON object into the Document Builder object of the corresponding type.
|
||||
* @memberof ApiInterface
|
||||
* @param {JSON} sMessage - The JSON object to convert.
|
||||
* @typeofeditors ["CPE"]
|
||||
*/
|
||||
ApiInterface.prototype.FromJSON = function(sMessage){};
|
||||
|
||||
/**
|
||||
* Subscribes to the specified event and calls the callback function when the event fires.
|
||||
* @memberof ApiInterface
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,7 @@ License File: jQuery.license
|
||||
License: MIT
|
||||
License File: Select2.license
|
||||
|
||||
|
||||
3. GPT-3-Encoder is a Javascript BPE Encoder Decoder for GPT-2 / GPT-3. (https://github.com/latitudegames/GPT-3-Encoder/)
|
||||
|
||||
License: MIT
|
||||
|
||||
@ -4,7 +4,7 @@ The ChatGPT API can be applied to virtually any task that involves understanding
|
||||
|
||||
The plugin uses the [OpenAI](https://openai.com/) engine.
|
||||
|
||||
It is called "ChatGPT " in the interface and isn't installed by default in cloud, [self-hosted](https://github.com/ONLYOFFICE/DocumentServer) and [desktop version](https://github.com/ONLYOFFICE/DesktopEditors) of ONLYOFFICE editors.
|
||||
It is called "ChatGPT" in the interface and isn't installed by default in cloud, [self-hosted](https://github.com/ONLYOFFICE/DocumentServer) and [desktop version](https://github.com/ONLYOFFICE/DesktopEditors) of ONLYOFFICE editors.
|
||||
|
||||
## How to use
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
<div id="div_content" class="div_main div_content hidden">
|
||||
<div class="div_form">
|
||||
<div>
|
||||
<textarea id="textarea" class="form-control" style="width: 100%;" spellcheck="false"></textarea>
|
||||
<textarea id="textarea" class="form-control prompt" style="width: 100%;"></textarea>
|
||||
</div>
|
||||
<div >
|
||||
<div id="div_modal" class="div_modal hidden form-control">
|
||||
|
||||
@ -25,11 +25,11 @@ html, body {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
.prompt {
|
||||
height: 240px !important;
|
||||
}
|
||||
|
||||
textarea::selection {
|
||||
.prompt::selection {
|
||||
background: #D8DADC; /* WebKit/Blink Browsers */
|
||||
color: #444444;
|
||||
}
|
||||
|
||||
@ -40,9 +40,13 @@
|
||||
'text-davinci-002' : true,
|
||||
'text-davinci-001' : true,
|
||||
'davinchi-instruct-beta' : true,
|
||||
'davinchi:2020-05-03' : true
|
||||
'davinchi:2020-05-03' : true,
|
||||
|
||||
'gpt-3.5-turbo': true
|
||||
};
|
||||
|
||||
// let arr = [];
|
||||
|
||||
window.Asc.plugin.init = function() {
|
||||
if (isIE) {
|
||||
bCreateLoader = false;
|
||||
@ -52,7 +56,7 @@
|
||||
} else {
|
||||
bCreateLoader = true;
|
||||
};
|
||||
apiKey = localStorage.getItem('OpenAiApiKey') || null;
|
||||
apiKey = localStorage.getItem('OpenAIApiKey') || null;
|
||||
addSlidersListeners();
|
||||
addTitlelisteners();
|
||||
initElements();
|
||||
@ -87,7 +91,7 @@
|
||||
errTimeout = null;
|
||||
clearMainError();
|
||||
}
|
||||
localStorage.removeItem('OpenAiApiKey');
|
||||
localStorage.removeItem('OpenAIApiKey');
|
||||
elements.apiKeyField.value = apiKey;
|
||||
apiKey = '';
|
||||
elements.divContent.classList.add('hidden');
|
||||
@ -157,13 +161,19 @@
|
||||
|
||||
elements.btnSubmit.onclick = function() {
|
||||
let settings = getSettings();
|
||||
if (!settings.prompt.length) {
|
||||
if (!settings.prompt.length && !settings.messages.length) {
|
||||
elements.textArea.classList.add('error_border');
|
||||
return;
|
||||
};
|
||||
createLoader();
|
||||
let url = 'https://api.openai.com/v1/completions'
|
||||
if (settings.messages) {
|
||||
url = 'https://api.openai.com/v1/chat/completions'
|
||||
// arr.push(...settings.messages);
|
||||
// settings.messages = arr;
|
||||
}
|
||||
|
||||
fetch('https://api.openai.com/v1/completions', {
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@ -178,7 +188,9 @@
|
||||
if (data.error)
|
||||
throw data.error
|
||||
|
||||
let text = data.choices[0].text;
|
||||
let text = data.choices[0].text || data.choices[0].message.content;
|
||||
// if (data.choices[0].message)
|
||||
// arr.push({role: data.choices[0].message.role, content: text});
|
||||
let textColor = '';
|
||||
if (!text.includes('</')) {
|
||||
// it's necessary because "PasteHtml" method ignores "\n" and we are trying to replace it on "<br>" when we don't have a html code in answer
|
||||
@ -270,11 +282,11 @@
|
||||
function addTitlelisteners() {
|
||||
let divs = document.querySelectorAll('.div_parametr');
|
||||
divs.forEach(function(div) {
|
||||
div.addEventListener('mouseenter', function handleClick(event) {
|
||||
div.addEventListener('mouseenter', function (event) {
|
||||
event.target.children[0].classList.remove('hidden');
|
||||
});
|
||||
|
||||
div.addEventListener('mouseleave', function handleClick(event) {
|
||||
div.addEventListener('mouseleave', function (event) {
|
||||
event.target.children[0].classList.add('hidden');
|
||||
});
|
||||
});
|
||||
@ -311,7 +323,8 @@
|
||||
$('#sel_models').select2({
|
||||
data : arrModels
|
||||
}).on('select2:select', function(e) {
|
||||
maxTokens = e.params.data.id.includes('text-davinci-003') ? 4000: 2000;
|
||||
let model = $('#sel_models').val();
|
||||
maxTokens = (model === 'gpt-3.5-turbo' || model === 'text-davinci-003') ? 4000 : 2000;
|
||||
checkLen();
|
||||
});
|
||||
|
||||
@ -321,7 +334,7 @@
|
||||
var newOption = new Option('text-davinci-003', 'text-davinci-003', true, true);
|
||||
$('#sel_models').append(newOption).trigger('change');
|
||||
}
|
||||
localStorage.setItem('OpenAiApiKey', apiKey);
|
||||
localStorage.setItem('OpenAIApiKey', apiKey);
|
||||
elements.divContent.classList.remove('hidden');
|
||||
})
|
||||
.catch(function(error) {
|
||||
@ -340,8 +353,12 @@
|
||||
function getSettings() {
|
||||
let obj = {
|
||||
model : $('#sel_models').val(),
|
||||
prompt : elements.textArea.value.trim(),
|
||||
};
|
||||
if (obj.model.includes('turbo')) {
|
||||
obj.messages = [{role: "user", content: elements.textArea.value.trim()}]
|
||||
} else {
|
||||
obj.prompt = elements.textArea.value.trim()
|
||||
}
|
||||
let temp = Number(elements.inpTempSl.value);
|
||||
obj.temperature = ( temp < 0 ? 0 : ( temp > 1 ? 1 : temp ) );
|
||||
let len = Number(elements.inpLenSl.value);
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
<a id="link_newPlugin" class="link_submit" target="blank" href="https://github.com/ONLYOFFICE/onlyoffice.github.io/pulls">Submit your own plugin</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="toolbar_tools">
|
||||
<div id="toolbar_tools" class="toolbar_tools">
|
||||
<button id="btn_updateAll" class="btn-text-default btn_update hidden" onclick="onClickUpdateAll()">Update All</button>
|
||||
<div>
|
||||
<span id="span_categories">Categories</span>
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
"isSystem" : false,
|
||||
"initDataType" : "none",
|
||||
"isUpdateOleOnResize" : false,
|
||||
"size" : [660, 570],
|
||||
"size" : [608, 570],
|
||||
"buttons" : []
|
||||
}
|
||||
]
|
||||
|
||||
@ -29,5 +29,8 @@
|
||||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAACvSURBVDhPrZNRDoIwEER7COA6HgJPpAnHM4oXQdFE/VDfNrsfpQvGhkneT2dmky40rK77pq6ggx4eyhF2UGnMF4EWBvjMcIFW46nEgLcGl5BMOoSDGmR6EjZNz0GyjdbjALlfFjR5HnRajwNkSVnI5HnQaz0OkE1nIZPnwVPrxQNGrc9f4Qcnra+zxAbKP6OIg/IfyYSxhasGPcTzyyYC9pjO8IIbHGAPy4/pf4XwBSVejZ5wzd0zAAAAAElFTkSuQmCC"/>
|
||||
<label id="lb_notification" class="header" style="margin-left: 5px;">This version of "Plugin Manager" is not official.</label>
|
||||
</div>
|
||||
<div id="div_noIternet" class="hidden" style="position: absolute;">
|
||||
<label id="lb_noInternet" class="form-control lab noselect">No Internet Connection.</label>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
38
store/plugin/modal.html
Normal file
38
store/plugin/modal.html
Normal file
@ -0,0 +1,38 @@
|
||||
<!--
|
||||
(c) Copyright Ascensio System SIA 2020
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Notification</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-ui.js"></script>
|
||||
<link rel="stylesheet" href="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.css">
|
||||
<link rel="stylesheet" href="resources/css/styles.css">
|
||||
<script type="text/javascript" src="scripts/modal.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="modal">
|
||||
<div class="warning">
|
||||
<div class="img_warning"></div>
|
||||
<label class="i18n question">Do you want to completely remove this plugin?</label>
|
||||
</div>
|
||||
<div class="info">
|
||||
<label class="i18n">If you choose "No", you will be able to restore this plugin later in the marketplace.</label>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -19,4 +19,28 @@ html, body {
|
||||
}
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
.lab{
|
||||
border: none !important;
|
||||
background-color: transparent !important;
|
||||
font-size: 15px !important;
|
||||
}
|
||||
.img_warning {
|
||||
background: url(../img/warnings_s.svg) no-repeat center;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
.modal {
|
||||
margin: 10px;
|
||||
}
|
||||
.warning {
|
||||
display: flex;
|
||||
/* justify-content: center; */
|
||||
align-items: center;
|
||||
}
|
||||
.question {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.info {
|
||||
margin-top: 10px;
|
||||
}
|
||||
6
store/plugin/resources/img/warnings_s.svg
Normal file
6
store/plugin/resources/img/warnings_s.svg
Normal file
@ -0,0 +1,6 @@
|
||||
<svg width="40" height="40" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="attention" >
|
||||
<path d="M3.25245 31.1904L18.366 4.94276C19.0898 3.68575 20.9102 3.68575 21.634 4.94275L36.7475 31.1904C37.4678 32.4412 36.5612 34 35.1136 34H4.88642C3.43881 34 2.53225 32.4412 3.25245 31.1904Z" fill="#FFD112"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M21 25H19L18 18V12H22V18L21 25ZM22 31H18V27H22V31Z" fill="white"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 503 B |
@ -6,7 +6,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -16,34 +16,43 @@
|
||||
*
|
||||
*/
|
||||
(function(window, undefined) {
|
||||
const isDesktop = window.AscDesktopEditor !== undefined;
|
||||
let isOnline = isDesktop ? true : null;
|
||||
let isInit = false;
|
||||
let interval = null;
|
||||
if (!isDesktop)
|
||||
checkInternet();
|
||||
|
||||
// create iframe
|
||||
const iframe = document.createElement("iframe");
|
||||
|
||||
let modalWindow = null;
|
||||
let removeGuid = null;
|
||||
let BFrameReady = false;
|
||||
let BPluginReady = false;
|
||||
let editorVersion = null;
|
||||
let marketplaceURl = null;
|
||||
const OOMarketplaceUrl = 'https://onlyoffice.github.io/store/index.html';
|
||||
const OOMarketplaceUrl = isDesktop ? './store/index.html' : 'https://onlyoffice.github.io/store/index.html';
|
||||
try {
|
||||
// for incognito mode
|
||||
marketplaceURl = localStorage.getItem('DeveloperMarketplaceUrl') || OOMarketplaceUrl;
|
||||
} catch (err) {
|
||||
marketplaceURl = 'https://onlyoffice.github.io/store/index.html';
|
||||
marketplaceURl = OOMarketplaceUrl;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
let pageUrl = marketplaceURl;
|
||||
iframe.src = pageUrl + window.location.search;
|
||||
document.body.appendChild(iframe);
|
||||
iframe.onload = function() {
|
||||
BFrameReady = true;
|
||||
if (BPluginReady)
|
||||
postMessage( JSON.stringify( { type: 'PluginReady', version: editorVersion } ) );
|
||||
};
|
||||
});
|
||||
|
||||
window.Asc.plugin.init = function() {
|
||||
isInit = true;
|
||||
if (typeof isOnline === 'boolean') {
|
||||
initPlugin();
|
||||
}
|
||||
};
|
||||
|
||||
window.Asc.plugin.init = function() {
|
||||
function postMessage(message) {
|
||||
iframe.contentWindow.postMessage(JSON.stringify(message), "*");
|
||||
};
|
||||
|
||||
function initPlugin() {
|
||||
document.body.appendChild(iframe);
|
||||
// resize window
|
||||
if (marketplaceURl !== OOMarketplaceUrl)
|
||||
document.getElementById('notification').classList.remove('hidden');
|
||||
@ -53,24 +62,59 @@
|
||||
editorVersion = version;
|
||||
BPluginReady = true;
|
||||
if (BFrameReady)
|
||||
postMessage( JSON.stringify( { type: 'PluginReady', version: editorVersion } ) );
|
||||
postMessage( { type: 'PluginReady', version: editorVersion } );
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
function postMessage(message) {
|
||||
iframe.contentWindow.postMessage(message, "*");
|
||||
let divNoInt = document.getElementById('div_noIternet');
|
||||
// send message that plugin is ready
|
||||
if (isOnline) {
|
||||
let style = document.getElementsByTagName('head')[0].lastChild;
|
||||
let pageUrl = marketplaceURl;
|
||||
iframe.src = pageUrl + window.location.search;
|
||||
iframe.onload = function() {
|
||||
BFrameReady = true;
|
||||
if (BPluginReady) {
|
||||
if (!divNoInt.classList.contains('hidden')) {
|
||||
divNoInt.classList.add('hidden');
|
||||
clearInterval(interval);
|
||||
interval = null;
|
||||
}
|
||||
postMessage( { type: 'Theme', theme: window.Asc.plugin.theme, style : style.innerHTML } );
|
||||
postMessage( { type: 'PluginReady', version: editorVersion } );
|
||||
}
|
||||
};
|
||||
} else {
|
||||
divNoInt.classList.remove('hidden');
|
||||
if (!interval) {
|
||||
interval = setInterval(function() {
|
||||
checkInternet();
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.Asc.plugin.button = function(id) {
|
||||
if (id == 'back') {
|
||||
window.Asc.plugin.button = function(id, windowID) {
|
||||
if (modalWindow && windowID) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
removePlugin(false);
|
||||
break;
|
||||
case 1:
|
||||
removePlugin(true);
|
||||
break;
|
||||
default:
|
||||
postMessage( {type: 'Removed', guid: ''} );
|
||||
break;
|
||||
}
|
||||
window.Asc.plugin.executeMethod('CloseWindow', [windowID]);
|
||||
} else if (id == 'back') {
|
||||
window.Asc.plugin.executeMethod('ShowButton',['back', false]);
|
||||
if (iframe && iframe.contentWindow)
|
||||
postMessage( JSON.stringify( { type: 'onClickBack' } ) );
|
||||
postMessage( { type: 'onClickBack' } );
|
||||
} else {
|
||||
this.executeCommand("close", "");
|
||||
this.executeCommand('close', '');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
window.addEventListener("message", function(message) {
|
||||
// getting messages from marketplace
|
||||
@ -78,23 +122,30 @@
|
||||
|
||||
switch (data.type) {
|
||||
case 'getInstalled':
|
||||
// данное сообщение используется только при инициализации плагина и по умолчанию идёт парсинг и отрисовка плагинов из стора
|
||||
// добавлен флаг updateInstalled - в этом случае не загружаем плагины из стора повторно, работаем только с установленными
|
||||
|
||||
window.Asc.plugin.executeMethod("GetInstalledPlugins", null, function(result) {
|
||||
postMessage( JSON.stringify( { type: 'InstalledPlugins', data: result } ) );
|
||||
postMessage({ type: 'InstalledPlugins', data: result, updateInstalled: data.updateInstalled } );
|
||||
});
|
||||
break;
|
||||
case 'install':
|
||||
window.Asc.plugin.executeMethod("InstallPlugin", [data.config, data.guid], function(result) {
|
||||
postMessage( JSON.stringify(result) );
|
||||
postMessage(result);
|
||||
});
|
||||
break;
|
||||
case 'remove':
|
||||
window.Asc.plugin.executeMethod("RemovePlugin", [data.guid], function(result) {
|
||||
postMessage( JSON.stringify(result) );
|
||||
});
|
||||
removeGuid = data.guid;
|
||||
if ( Number( editorVersion.split('.').join('') < 740) )
|
||||
removePlugin(true);
|
||||
else if ( !data.backup )
|
||||
removePlugin(data.backup);
|
||||
else
|
||||
createWindow();
|
||||
break;
|
||||
case 'update':
|
||||
window.Asc.plugin.executeMethod("UpdatePlugin", [data.config, data.guid], function(result) {
|
||||
postMessage( JSON.stringify(result) );
|
||||
postMessage(result);
|
||||
});
|
||||
break;
|
||||
case 'showButton' :
|
||||
@ -107,7 +158,7 @@
|
||||
window.Asc.plugin.onExternalMouseUp = function() {
|
||||
// mouse up event outside the plugin window
|
||||
if (iframe && iframe.contentWindow) {
|
||||
postMessage( JSON.stringify( { type: 'onExternalMouseUp' } ) );
|
||||
postMessage( { type: 'onExternalMouseUp' } );
|
||||
}
|
||||
};
|
||||
|
||||
@ -119,14 +170,92 @@
|
||||
window.Asc.plugin.onThemeChangedBase(theme);
|
||||
let style = document.getElementsByTagName('head')[0].lastChild;
|
||||
if (iframe && iframe.contentWindow)
|
||||
postMessage( JSON.stringify( { type: 'Theme', theme: theme, style : style.innerHTML } ) );
|
||||
postMessage( { type: 'Theme', theme: theme, style : style.innerHTML } );
|
||||
};
|
||||
|
||||
window.Asc.plugin.onTranslate = function()
|
||||
{
|
||||
window.Asc.plugin.onTranslate = function() {
|
||||
let label = document.getElementById('lb_notification');
|
||||
if (label)
|
||||
label.innerHTML = window.Asc.plugin.tr('This version of "Plugin Manager" is not official.');
|
||||
label.innerHTML = window.Asc.plugin.tr(label.innerHTML);
|
||||
|
||||
label = document.getElementById('lb_noInternet');
|
||||
if (label)
|
||||
label.innerHTML = window.Asc.plugin.tr(label.innerHTML);
|
||||
};
|
||||
|
||||
function checkInternet() {
|
||||
try {
|
||||
let xhr = new XMLHttpRequest();
|
||||
let url = 'https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice.github.io/master/store/translations/langs.json';
|
||||
xhr.open('GET', url, true);
|
||||
|
||||
xhr.onload = function () {
|
||||
if (this.readyState == 4) {
|
||||
if (this.status >= 200 && this.status < 300) {
|
||||
isOnline = true;
|
||||
if (isInit)
|
||||
initPlugin();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onerror = function (err) {
|
||||
isOnline = false;
|
||||
if (isInit)
|
||||
initPlugin();
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
} catch (error) {
|
||||
isOnline = false;
|
||||
if (isInit)
|
||||
initPlugin();
|
||||
}
|
||||
};
|
||||
|
||||
function createWindow() {
|
||||
let location = window.location;
|
||||
let start = location.pathname.lastIndexOf('/') + 1;
|
||||
let file = location.pathname.substring(start);
|
||||
|
||||
let variation = {
|
||||
url : location.href.replace(file, 'modal.html'),
|
||||
description : window.Asc.plugin.tr('Warning'),
|
||||
isVisual : true,
|
||||
isModal : true,
|
||||
EditorsSupport : ['word', 'cell', 'slide'],
|
||||
size : [350, 100],
|
||||
buttons : [
|
||||
{
|
||||
'text': window.Asc.plugin.tr('Yes'),
|
||||
'primary': true
|
||||
},
|
||||
{
|
||||
'text': window.Asc.plugin.tr('No'),
|
||||
'primary': false
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
if (!modalWindow) {
|
||||
modalWindow = new window.Asc.PluginWindow();
|
||||
modalWindow.attachEvent('onWindowMessage', function(data){
|
||||
let oConfig = data.config;
|
||||
window.Asc.plugin.executeMethod('ConvertDocument', [oConfig.convertType, oConfig.htmlHeadings, oConfig.base64img, oConfig.demoteHeadings, oConfig.renderHTMLTags], function(sOutput) {
|
||||
modalWindow.command('onConverted', sOutput);
|
||||
});
|
||||
});
|
||||
}
|
||||
modalWindow.show(variation);
|
||||
};
|
||||
|
||||
function removePlugin(backup) {
|
||||
if (removeGuid)
|
||||
window.Asc.plugin.executeMethod('RemovePlugin', [removeGuid, backup], function(result) {
|
||||
postMessage(result);
|
||||
});
|
||||
|
||||
removeGuid = null;
|
||||
};
|
||||
|
||||
})(window, undefined);
|
||||
|
||||
34
store/plugin/scripts/modal.js
Normal file
34
store/plugin/scripts/modal.js
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
(function(window, undefined) {
|
||||
|
||||
window.Asc.plugin.init = function() {};
|
||||
|
||||
window.Asc.plugin.onThemeChanged = function(theme) {
|
||||
window.Asc.plugin.onThemeChangedBase(theme);
|
||||
};
|
||||
|
||||
window.Asc.plugin.onTranslate = function() {
|
||||
let elements = document.getElementsByClassName('i18n');
|
||||
|
||||
for (let index = 0; index < elements.length; index++) {
|
||||
const element = elements[index];
|
||||
element.innerHTML = window.Asc.plugin.tr(element.innerHTML);
|
||||
}
|
||||
};
|
||||
})(window, undefined);
|
||||
@ -1,3 +1,9 @@
|
||||
{
|
||||
"This version of \"Plugin Manager\" is not official." : "Tato verze \"Správce pluginů\" není oficiální."
|
||||
"This version of \"Plugin Manager\" is not official." : "Tato verze \"Správce pluginů\" není oficiální.",
|
||||
"No Internet Connection.": "Žádné Připojení K Internetu.",
|
||||
"Warning" : "Varování",
|
||||
"Yes" : "Ano",
|
||||
"No" : "Ne",
|
||||
"Do you want to completely remove this plugin?" : "Chcete tento plugin úplně odstranit?",
|
||||
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Pokud zvolíte \"Ne\", budete moci tento plugin obnovit později na Správce Pluginů."
|
||||
}
|
||||
@ -1,3 +1,9 @@
|
||||
{
|
||||
"This version of \"Plugin Manager\" is not official." : "Diese Version von \"Plugin Manager\" ist nicht offiziell."
|
||||
"This version of \"Plugin Manager\" is not official." : "Diese Version von \"Plugin Manager\" ist nicht offiziell.",
|
||||
"No Internet Connection.": "Keine Internetverbindung.",
|
||||
"Warning" : "Warnung",
|
||||
"Yes" : "Ja",
|
||||
"No" : "Nein",
|
||||
"Do you want to completely remove this plugin?" : "Möchten Sie dieses Plugin vollständig entfernen?",
|
||||
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Wenn Sie \"Nein\" wählen, können Sie dieses Plugin später auf dem Plugin-Verwaltung wiederherstellen."
|
||||
}
|
||||
@ -1,3 +1,9 @@
|
||||
{
|
||||
"This version of \"Plugin Manager\" is not official." : "Esta versión de \"Plugin Manager\" no es oficial."
|
||||
"This version of \"Plugin Manager\" is not official." : "Esta versión de \"Plugin Manager\" no es oficial.",
|
||||
"No Internet Connection.": "Sin Conexión a Internet.",
|
||||
"Warning" : "Advertencia",
|
||||
"Yes" : "Sí",
|
||||
"No" : "No",
|
||||
"Do you want to completely remove this plugin?" : "¿Quieres eliminar por completo este plugin?",
|
||||
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Si elige \"No\", podrá restaurar este complemento más adelante en el Administrador de Complementos."
|
||||
}
|
||||
@ -1,3 +1,9 @@
|
||||
{
|
||||
"This version of \"Plugin Manager\" is not official." : "Cette version de \"Plugin Manager\" n'est pas officielle.."
|
||||
"This version of \"Plugin Manager\" is not official." : "Cette version de \"Plugin Manager\" n'est pas officielle.",
|
||||
"No Internet Connection.": "Pas De Connexion Internet.",
|
||||
"Warning" : "Avertissement",
|
||||
"Yes" : "Oui",
|
||||
"No" : "Aucun",
|
||||
"Do you want to completely remove this plugin?" : "Voulez-vous supprimer complètement ce plugin?",
|
||||
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Si vous choisissez \"Aucun\", vous pourrez restaurer ce plugin plus tard sur le Gestionnaire de Plugins."
|
||||
}
|
||||
@ -1,3 +1,9 @@
|
||||
{
|
||||
"This version of \"Plugin Manager\" is not official." : "Эта версия \"Менеджера Плагинов\" не является официальной."
|
||||
"This version of \"Plugin Manager\" is not official." : "Эта версия \"Менеджера Плагинов\" не является официальной.",
|
||||
"No Internet Connection.": "Отсутствует соединение с интернетом.",
|
||||
"Warning" : "Предупреждение",
|
||||
"Yes" : "Да",
|
||||
"No" : "Нет",
|
||||
"Do you want to completely remove this plugin?" : "Вы хотите полность удалить этот плагин?",
|
||||
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Если вы выберете \"Нет\", вы сможете восстановить этот плагин позже в Менеджере плагинов."
|
||||
}
|
||||
@ -17,6 +17,12 @@
|
||||
*/
|
||||
|
||||
let start = Date.now();
|
||||
let isPluginLoading = false; // flag plugins loading
|
||||
const isDesktop = window.AscDesktopEditor !== undefined; // desktop detecting
|
||||
let isOnline = true; // flag internet connection
|
||||
isDesktop && checkInternet(); // check internet connection (only for desktop)
|
||||
let interval = null; // interval for checking internet connection (if it doesn't work on launch)
|
||||
const OOMarketplaceUrl = 'https://onlyoffice.github.io/'; // url to oficial store (for local version store in desktop)
|
||||
let current = {index: 0, screenshots: [], url: ''}; // selected plugin (for plugin view)
|
||||
let searchTimeout = null; // timeot for search
|
||||
let founded = []; // last founded elemens (for not to redraw if a result is the same)
|
||||
@ -26,11 +32,9 @@ let allPlugins; // list of
|
||||
let installedPlugins; // list of intalled plugins
|
||||
const configUrl = './config.json'; // url to config.json
|
||||
const elements = {}; // all elements
|
||||
const isDesktop = window.AscDesktopEditor !== undefined; // desktop detecting
|
||||
const guidMarkeplace = 'asc.{AA2EA9B6-9EC2-415F-9762-634EE8D9A95E}'; // guid marketplace
|
||||
const guidSettings = 'asc.{8D67F3C5-7736-4BAE-A0F2-8C7127DC4BB8}'; // guid settings plugins
|
||||
let editorVersion = null; // edior current version
|
||||
let isPluginLoading = false; // flag plugins loading
|
||||
let loader; // loader
|
||||
let themeType = detectThemeType(); // current theme
|
||||
const lang = detectLanguage(); // current language
|
||||
@ -61,7 +65,11 @@ const languages = [ // list of
|
||||
['ru-RU', 'ru', 'Russian'],
|
||||
['zh-ZH', 'zh', 'Chinese']
|
||||
];
|
||||
let versionWarning = "This plugin will only work in a newer version of the editor.";
|
||||
const messages = {
|
||||
versionWarning: 'This plugin will only work in a newer version of the editor.',
|
||||
linkManually: 'Install plugin manually',
|
||||
linkPR: 'Submit your own plugin',
|
||||
};
|
||||
const isIE = (navigator.userAgent.toLowerCase().indexOf("msie") > -1 ||
|
||||
navigator.userAgent.toLowerCase().indexOf("trident") > -1 ||
|
||||
navigator.userAgent.toLowerCase().indexOf("edge") > -1);
|
||||
@ -100,7 +108,8 @@ const ioUrl = location.href.substring(0, pos);
|
||||
// get translation file
|
||||
getTranslation();
|
||||
// fetch all plugins from config
|
||||
fetchAllPlugins();
|
||||
if (!isDesktop)
|
||||
fetchAllPlugins(true, false);
|
||||
|
||||
window.onload = function() {
|
||||
let rule = '\n.asc-plugin-loader{background-color:' + (themeType == 'light' ? '#ffffff' : '#333333') + ';padding: 10px;display: flex;justify-content: center;align-items: center;border-radius: 5px;}\n'
|
||||
@ -125,12 +134,12 @@ window.onload = function() {
|
||||
|
||||
elements.btnMyPlugins.onclick = function(event) {
|
||||
// click on my plugins button
|
||||
toogleView(event.target, elements.btnMarketplace, 'Install plugin manually', false);
|
||||
toogleView(event.target, elements.btnMarketplace, messages.linkManually, false, false);
|
||||
};
|
||||
|
||||
elements.btnMarketplace.onclick = function(event) {
|
||||
// click on marketplace button
|
||||
toogleView(event.target, elements.btnMyPlugins, 'Submit your own plugin', true);
|
||||
toogleView(event.target, elements.btnMyPlugins, messages.linkPR, true, false);
|
||||
};
|
||||
|
||||
// elements.arrow.onclick = onClickBack;
|
||||
@ -184,19 +193,22 @@ window.addEventListener('message', function(message) {
|
||||
let installed;
|
||||
switch (message.type) {
|
||||
case 'InstalledPlugins':
|
||||
// TODO maybe we should get images as base64 in this method (but we should support theme and scale, maybe send array)
|
||||
if (message.data) {
|
||||
// filter installed plugins (delete removed, that are in store and some system plugins)
|
||||
installedPlugins = message.data.filter(function(el) {
|
||||
return (el.guid !== guidMarkeplace && el.guid !== guidSettings);
|
||||
return (el.guid !== guidMarkeplace && el.guid !== guidSettings && !( el.removed && el.obj.baseUrl.includes(ioUrl) ));
|
||||
});
|
||||
sortPlugins(false, true, 'name');
|
||||
sortPlugins(false, true, 'start');
|
||||
} else {
|
||||
installedPlugins = [];
|
||||
}
|
||||
|
||||
// console.log('getInstalledPlugins: ' + (Date.now() - start));
|
||||
if (allPlugins)
|
||||
getAllPluginsData();
|
||||
|
||||
if (message.updateInstalled)
|
||||
showListofPlugins(false);
|
||||
else if ( allPlugins || (isDesktop && !isOnline) )
|
||||
getAllPluginsData(true, false);
|
||||
|
||||
break;
|
||||
case 'Installed':
|
||||
@ -217,9 +229,14 @@ window.addEventListener('message', function(message) {
|
||||
removed: false
|
||||
}
|
||||
);
|
||||
sortPlugins(false, true, 'name');
|
||||
// sortPlugins(false, true, 'name');
|
||||
} else if (installed) {
|
||||
installed.removed = false;
|
||||
if (installed.obj.backup) {
|
||||
// нужно обновить список установленных плагинов, чтобы ссылки на ресурсы были правильными
|
||||
sendMessage({ type: 'getInstalled', updateInstalled: true }, '*');
|
||||
}
|
||||
else
|
||||
installed.removed = false;
|
||||
}
|
||||
|
||||
changeAfterInstallOrRemove(true, message.guid);
|
||||
@ -257,17 +274,25 @@ window.addEventListener('message', function(message) {
|
||||
toogleLoader(false);
|
||||
return;
|
||||
}
|
||||
plugin = findPlugin(true, message.guid);
|
||||
installed = findPlugin(false, message.guid);
|
||||
|
||||
let bUpdate = false;
|
||||
let bHasLocal = false;
|
||||
let needBackup = message.backup;
|
||||
|
||||
plugin = findPlugin(true, message.guid);
|
||||
installed = findPlugin(false, message.guid);
|
||||
|
||||
if (installed) {
|
||||
bHasLocal = !installed.obj.baseUrl.includes(ioUrl);
|
||||
if (plugin && !bHasLocal) {
|
||||
if (plugin && (!bHasLocal || !needBackup) ) {
|
||||
installedPlugins = installedPlugins.filter(function(el){return el.guid !== message.guid});
|
||||
bUpdate = true;
|
||||
} else {
|
||||
installed.removed = true;
|
||||
|
||||
// нужно обновить список установленных плагинов, чтобы ссылки на ресурсы были правильными
|
||||
if (isDesktop)
|
||||
sendMessage({ type: 'getInstalled', updateInstalled: true }, '*');
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,17 +361,19 @@ window.addEventListener('message', function(message) {
|
||||
};
|
||||
}, false);
|
||||
|
||||
function fetchAllPlugins() {
|
||||
function fetchAllPlugins(bFirstRender, bConnectionRestored) {
|
||||
// function for fetching all plugins from config
|
||||
clearInterval(interval);
|
||||
interval = null;
|
||||
isPluginLoading = true;
|
||||
makeRequest(configUrl).then(
|
||||
function(response) {
|
||||
allPlugins = JSON.parse(response);
|
||||
if (installedPlugins)
|
||||
getAllPluginsData();
|
||||
getAllPluginsData(bFirstRender, bConnectionRestored);
|
||||
},
|
||||
function(err) {
|
||||
createError(new Error('Problem with loading markeplace config.'));
|
||||
createError( new Error( getTranslated( 'Problem with loading markeplace config.' ) ) );
|
||||
isPluginLoading = false;
|
||||
allPlugins = [];
|
||||
showMarketplace();
|
||||
@ -452,18 +479,19 @@ function toogleLoader(show, text) {
|
||||
} else if(!loader) {
|
||||
document.getElementById('loader-container').classList.remove('hidden');
|
||||
loader && (loader.remove ? loader.remove() : $('#loader-container')[0].removeChild(loader));
|
||||
loader = showLoader($('#loader-container')[0], (translate[text] || text) + '...');
|
||||
loader = showLoader($('#loader-container')[0], ( getTranslated(text) ) + '...');
|
||||
}
|
||||
};
|
||||
|
||||
function getAllPluginsData() {
|
||||
function getAllPluginsData(bFirstRender, bConnectionRestored) {
|
||||
// get config file for each item in config.json
|
||||
isPluginLoading = true;
|
||||
let count = 0;
|
||||
let Unloaded = [];
|
||||
let url = isDesktop ? OOMarketplaceUrl : ioUrl;
|
||||
allPlugins.forEach(function(pluginUrl, i, arr) {
|
||||
count++;
|
||||
pluginUrl = (pluginUrl.indexOf(":/\/") == -1) ? ioUrl + 'sdkjs-plugins/content/' + pluginUrl + '/' : pluginUrl;
|
||||
pluginUrl = (pluginUrl.indexOf(":/\/") == -1) ? url + 'sdkjs-plugins/content/' + pluginUrl + '/' : pluginUrl;
|
||||
let confUrl = pluginUrl + 'config.json';
|
||||
makeRequest(confUrl).then(
|
||||
function(response) {
|
||||
@ -477,17 +505,20 @@ function getAllPluginsData() {
|
||||
removeUnloaded(Unloaded);
|
||||
sortPlugins(true, false, 'name');
|
||||
isPluginLoading = false;
|
||||
showMarketplace();
|
||||
if (bFirstRender)
|
||||
showMarketplace();
|
||||
else if (bConnectionRestored)
|
||||
toogleView(elements.btnMarketplace, elements.btnMyPlugins, messages.linkPR, true, true);
|
||||
}
|
||||
makeRequest(pluginUrl + 'translations/langs.json').then(
|
||||
function(response) {
|
||||
let supportedLangs = [ ( translate['English'] || 'English' ) ];
|
||||
let supportedLangs = [ getTranslated('English') ];
|
||||
let arr = JSON.parse(response);
|
||||
arr.forEach(function(full) {
|
||||
let short = full.split('-')[0];
|
||||
for (let i = 0; i < languages.length; i++) {
|
||||
if (languages[i][0] == short || languages[i][1] == short) {
|
||||
supportedLangs.push( ( translate[languages[i][2]] || languages[i][2] ) );
|
||||
supportedLangs.push( getTranslated( languages[i][2] ) );
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -495,7 +526,7 @@ function getAllPluginsData() {
|
||||
config.languages = supportedLangs;
|
||||
},
|
||||
function(error) {
|
||||
// nothing to do
|
||||
config.languages = [ getTranslated('English') ];
|
||||
}
|
||||
)
|
||||
},
|
||||
@ -507,18 +538,77 @@ function getAllPluginsData() {
|
||||
removeUnloaded(Unloaded);
|
||||
sortPlugins(true, false, 'name');
|
||||
isPluginLoading = false;
|
||||
showMarketplace();
|
||||
if (bFirstRender)
|
||||
showMarketplace();
|
||||
else if (bConnectionRestored)
|
||||
toogleView(elements.btnMarketplace, elements.btnMyPlugins, messages.linkPR, true, true);
|
||||
}
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
if (isDesktop && installedPlugins && bFirstRender) {
|
||||
isPluginLoading = false;
|
||||
getInstalledLanguages();
|
||||
showMarketplace();
|
||||
}
|
||||
};
|
||||
|
||||
function getInstalledLanguages() {
|
||||
installedPlugins.forEach(function(pl) {
|
||||
makeRequest(pl.obj.baseUrl + 'translations/langs.json').then(
|
||||
function(response) {
|
||||
let supportedLangs = [ getTranslated('English') ];
|
||||
let arr = JSON.parse(response);
|
||||
arr.forEach(function(full) {
|
||||
let short = full.split('-')[0];
|
||||
for (let i = 0; i < languages.length; i++) {
|
||||
if (languages[i][0] == short || languages[i][1] == short) {
|
||||
supportedLangs.push( getTranslated( languages[i][2] ) );
|
||||
}
|
||||
}
|
||||
});
|
||||
if (supportedLangs.length > 1)
|
||||
pl.obj.languages = supportedLangs;
|
||||
},
|
||||
function(error) {
|
||||
pl.obj.languages = [ getTranslated('English') ];
|
||||
}
|
||||
)
|
||||
});
|
||||
};
|
||||
|
||||
function showListofPlugins(bAll, sortedArr) {
|
||||
// show list of plugins
|
||||
$('.div_notification').remove();
|
||||
$('.div_item').remove();
|
||||
let arr = ( sortedArr ? sortedArr : (bAll ? allPlugins : installedPlugins) );
|
||||
let arr = (sortedArr ? sortedArr : (bAll ? allPlugins : installedPlugins));
|
||||
|
||||
// получаем список backup плагинов
|
||||
if (!bAll && isDesktop) {
|
||||
var _pluginsTmp = JSON.parse(window["AscDesktopEditor"]["GetBackupPlugins"]());
|
||||
|
||||
if (_pluginsTmp.length) {
|
||||
var len = _pluginsTmp[0]["pluginsData"].length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
let plugin = _pluginsTmp[0]["pluginsData"][i];
|
||||
plugin.baseUrl = _pluginsTmp[0]["url"] + plugin.guid.replace('asc.', '') + '/';
|
||||
|
||||
installed = findPlugin(false, plugin.guid);
|
||||
|
||||
if (!installed) {
|
||||
installedPlugins.push({
|
||||
"baseUrl": _pluginsTmp[0]["url"],
|
||||
"guid": plugin.guid,
|
||||
"canRemoved": true,
|
||||
"obj": plugin,
|
||||
"removed": true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (arr.length) {
|
||||
arr.forEach(function(plugin) {
|
||||
if (plugin && plugin.guid)
|
||||
@ -536,6 +626,25 @@ function showListofPlugins(bAll, sortedArr) {
|
||||
}
|
||||
};
|
||||
|
||||
function getPluginVersion(text)
|
||||
{
|
||||
let factor = 1000;
|
||||
let major = 1;
|
||||
let minor = 0;
|
||||
let build = 0;
|
||||
|
||||
if (text && text.split)
|
||||
{
|
||||
let arValues = text.split('.');
|
||||
let count = arValues.length;
|
||||
if (count > 0) major = parseInt(arValues[0]);
|
||||
if (count > 1) minor = parseInt(arValues[1]);
|
||||
if (count > 2) build = parseInt(arValues[2]);
|
||||
}
|
||||
|
||||
return major * factor * factor + minor * factor + build;
|
||||
}
|
||||
|
||||
function createPluginDiv(plugin, bInstalled) {
|
||||
// this function creates div (preview) for plugins
|
||||
let div = document.createElement('div');
|
||||
@ -573,10 +682,10 @@ function createPluginDiv(plugin, bInstalled) {
|
||||
}
|
||||
|
||||
let bHasUpdate = false;
|
||||
let bRemoved = (installed && !installed.removed);
|
||||
let bRemoved = (installed && installed.removed);
|
||||
if (bCheckUpdate && installed && plugin) {
|
||||
const installedV = (installed.obj.version ? Number( installed.obj.version.split('.').join('') ) : 1);
|
||||
const lastV = (plugin.version ? Number( plugin.version.split('.').join('') ) : installedV);
|
||||
const installedV = getPluginVersion(installed.obj.version);
|
||||
const lastV = getPluginVersion(plugin.version);
|
||||
if (lastV > installedV) {
|
||||
bHasUpdate = true;
|
||||
plugin.bHasUpdate = true;
|
||||
@ -589,7 +698,7 @@ function createPluginDiv(plugin, bInstalled) {
|
||||
let name = (bTranslate && plugin.nameLocale && plugin.nameLocale[shortLang]) ? plugin.nameLocale[shortLang] : plugin.name;
|
||||
let description = (bTranslate && variation.descriptionLocale && variation.descriptionLocale[shortLang]) ? variation.descriptionLocale[shortLang] : variation.description;
|
||||
let bg = variation.store && variation.store.background ? variation.store.background[themeType] : defaultBG;
|
||||
let additional = bNotAvailable ? 'disabled title="' + versionWarning + '"' : '';
|
||||
let additional = bNotAvailable ? 'disabled title="' + getTranslated(messages.versionWarning) + '"' : '';
|
||||
let template = '<div class="div_image" style="background: ' + bg + '">' +
|
||||
'<img id="img_'+plugin.guid+'" class="plugin_icon" style="display:none" data-guid="' + plugin.guid + '" src="' + getImageUrl(plugin.guid, false, true, ('img_' + plugin.guid) ) + '">' +
|
||||
'</div>' +
|
||||
@ -599,12 +708,12 @@ function createPluginDiv(plugin, bInstalled) {
|
||||
'</div>' +
|
||||
'<div class="div_footer">' +
|
||||
(bHasUpdate
|
||||
? '<span class="span_update ' + (bRemoved ? "" : "hidden") + '">' + translate["Update"] + '</span>'
|
||||
? '<span class="span_update ' + (!bRemoved ? "" : "hidden") + '">' + getTranslated("Update") + '</span>'
|
||||
: ''
|
||||
)+''+
|
||||
( (bRemoved)
|
||||
? (installed.canRemoved ? '<button class="btn-text-default btn_item btn_remove" onclick="onClickRemove(event.target, event)" ' + (bNotAvailable ? "dataDisabled=\"disabled\"" : "") +'>' + translate["Remove"] + '</button>' : '<div style="height:20px"></div>')
|
||||
: '<button class="btn_item btn-text-default btn_install" onclick="onClickInstall(event.target, event)"' + additional + '>' + translate["Install"] + '</button>'
|
||||
( (installed && !bRemoved)
|
||||
? (installed.canRemoved ? '<button class="btn-text-default btn_item btn_remove" onclick="onClickRemove(event.target, event)" ' + (bNotAvailable ? "dataDisabled=\"disabled\"" : "") +'>' + getTranslated("Remove") + '</button>' : '<div style="height:20px"></div>')
|
||||
: '<button class="btn_item btn-text-default btn_install" onclick="onClickInstall(event.target, event)"' + additional + '>' + getTranslated("Install") + '</button>'
|
||||
)
|
||||
+
|
||||
'</div>';
|
||||
@ -618,7 +727,6 @@ function onClickInstall(target, event) {
|
||||
// click install button
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(toogleLoader, 200, true, "Installation");
|
||||
// toogleLoader(true, "Installation");
|
||||
let guid = target.parentNode.parentNode.getAttribute('data-guid');
|
||||
let plugin = findPlugin(true, guid);
|
||||
let installed = findPlugin(false, guid);
|
||||
@ -635,7 +743,6 @@ function onClickUpdate(target) {
|
||||
// click update button
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(toogleLoader, 200, true, "Updating");
|
||||
// toogleLoader(true, "Updating");
|
||||
let guid = target.parentElement.parentElement.parentElement.getAttribute('data-guid');
|
||||
let plugin = findPlugin(true, guid);
|
||||
updateCount++;
|
||||
@ -653,15 +760,23 @@ function onClickRemove(target, event) {
|
||||
// click remove button
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(toogleLoader, 200, true, "Removal");
|
||||
// toogleLoader(true, "Removal");
|
||||
let guid = target.parentNode.parentNode.getAttribute('data-guid');
|
||||
let message = {
|
||||
type : 'remove',
|
||||
guid : guid
|
||||
guid : guid,
|
||||
backup : needBackupPlugin(guid)
|
||||
};
|
||||
sendMessage(message);
|
||||
};
|
||||
|
||||
function needBackupPlugin(guid) {
|
||||
// проверяем установленный плагин:
|
||||
// если плагин есть в стор ( и его версия <= ? ), то можем удалить, пользователь сможет поставить актуальную версию
|
||||
// если плагина нет в стор, нужно его хранить у пользователя с возможностью восстановления
|
||||
|
||||
return isDesktop ? findPlugin(true, guid) == undefined : false;
|
||||
}
|
||||
|
||||
function onClickUpdateAll() {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(toogleLoader, 200, true, "Updating");
|
||||
@ -693,14 +808,14 @@ function onClickItem() {
|
||||
|
||||
let installed = findPlugin(false, guid);
|
||||
let plugin = findPlugin(true, guid);
|
||||
if (!plugin) {
|
||||
if ( !plugin || ( isDesktop && installed ) ) {
|
||||
elements.divGitLink.classList.add('hidden');
|
||||
plugin = installed.obj;
|
||||
} else {
|
||||
elements.divGitLink.classList.remove('hidden');
|
||||
}
|
||||
|
||||
let bCorrectUrl = ( !plugin.baseUrl.includes('http://') && !plugin.baseUrl.includes('file:') );
|
||||
let bCorrectUrl = isDesktop || ( !plugin.baseUrl.includes('http://') && !plugin.baseUrl.includes('file:') && !plugin.baseUrl.includes('../'));
|
||||
|
||||
if (bCorrectUrl && plugin.variations[0].store && plugin.variations[0].store.screenshots && plugin.variations[0].store.screenshots.length) {
|
||||
current.screenshots = plugin.variations[0].store.screenshots;
|
||||
@ -744,18 +859,16 @@ function onClickItem() {
|
||||
elements.spanLanguages.innerText = '';
|
||||
elements.divLanguages.classList.add('hidden');
|
||||
}
|
||||
// TODO добаить здесь языки (при получении информации о плагинах, надо смотреть на то есть ли файл langs.json и из него брать информацию о языках
|
||||
// если этого файла нет, то поле языки не показывается.
|
||||
|
||||
let pluginUrl = plugin.baseUrl.replace('https://onlyoffice.github.io/', 'https://github.com/ONLYOFFICE/onlyoffice.github.io/tree/master/');
|
||||
|
||||
// TODO problem with plugins icons (different margin from top)
|
||||
elements.divSelected.setAttribute('data-guid', guid);
|
||||
// пришлось временно сделать так: потому что некоторые новые иконки для стора слишком больше для этого метса
|
||||
// we do this, because new icons for store are too big for use it in this window.
|
||||
let tmp = getImageUrl(guid, true, true, 'img_icon');
|
||||
elements.imgIcon.setAttribute('src', tmp);
|
||||
elements.spanName.innerHTML = this.children[1].children[0].innerText;
|
||||
elements.spanOffered.innerHTML = offered;
|
||||
elements.spanOffered.innerHTML = plugin.offered || offered;
|
||||
elements.spanSelectedDescr.innerHTML = this.children[1].children[1].innerText;
|
||||
elements.linkPlugin.setAttribute('href', pluginUrl);
|
||||
|
||||
@ -779,7 +892,7 @@ function onClickItem() {
|
||||
|
||||
if (pluginDiv.lastChild.lastChild.hasAttribute('disabled')) {// || pluginDiv.lastChild.lastChild.hasAttribute('dataDisabled')) {
|
||||
elements.btnInstall.setAttribute('disabled','');
|
||||
elements.btnInstall.setAttribute('title', versionWarning);
|
||||
elements.btnInstall.setAttribute('title', getTranslated(messages.versionWarning));
|
||||
}
|
||||
else {
|
||||
elements.btnInstall.removeAttribute('disabled');
|
||||
@ -840,7 +953,7 @@ function createNotification(text) {
|
||||
div.className = 'div_notification';
|
||||
let span = document.createElement('span');
|
||||
span.className = 'span_notification';
|
||||
span.innerHTML = translate[text] || text;
|
||||
span.innerHTML = getTranslated(text);
|
||||
div.appendChild(span);
|
||||
elements.divMain.appendChild(div);
|
||||
};
|
||||
@ -956,70 +1069,73 @@ function getTranslation() {
|
||||
onTranslate();
|
||||
},
|
||||
function(err) {
|
||||
createError(new Error('Cannot load translation for current language.'));
|
||||
createDefaultTranslations();
|
||||
createError( new Error( getTranslated( 'Cannot load translation for current language.' ) ) );
|
||||
isTranslationLoading = false;
|
||||
showMarketplace();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
createDefaultTranslations();
|
||||
isTranslationLoading = false;
|
||||
showMarketplace();
|
||||
}
|
||||
},
|
||||
function(err) {
|
||||
createError(new Error('Cannot load translations list file.'));
|
||||
createDefaultTranslations();
|
||||
createError( new Error( getTranslated( 'Cannot load translations list file.' ) ) );
|
||||
isTranslationLoading = false;
|
||||
showMarketplace();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
createDefaultTranslations();
|
||||
isTranslationLoading = false;
|
||||
showMarketplace();
|
||||
}
|
||||
};
|
||||
|
||||
function onTranslate() {
|
||||
isTranslationLoading = false;
|
||||
// translates elements on current language
|
||||
elements.linkNewPlugin.innerHTML = translate['Submit your own plugin'];
|
||||
elements.btnMyPlugins.innerHTML = translate['My plugins'];
|
||||
elements.btnMarketplace.innerHTML = translate['Marketplace'];
|
||||
elements.btnInstall.innerHTML = translate['Install'];
|
||||
elements.btnRemove.innerHTML = translate['Remove'];
|
||||
elements.btnUpdate.innerHTML = translate['Update'];
|
||||
elements.btnUpdateAll.innerHTML = translate['Update All'];
|
||||
elements.inpSearch.placeholder = translate['Search plugins'] + '...';
|
||||
document.getElementById('lbl_header').innerHTML = translate['Manage plugins'];
|
||||
document.getElementById('span_offered_caption').innerHTML = translate['Offered by'] + ': ';
|
||||
document.getElementById('span_overview').innerHTML = translate['Overview'];
|
||||
document.getElementById('span_info').innerHTML = translate['Info & Support'];
|
||||
document.getElementById('span_lern').innerHTML = translate['Learn how to use'] + ' ';
|
||||
document.getElementById('span_lern_plugin').innerHTML = translate['the plugin in'] + ' ';
|
||||
document.getElementById('span_contribute').innerHTML = translate['Contribute'] + ' ';
|
||||
document.getElementById('span_contribute_end').innerHTML = translate['to the plugin developmen or report an issue on'] + ' ';
|
||||
document.getElementById('span_help').innerHTML = translate['Get help'] + ' ';
|
||||
document.getElementById('span_help_end').innerHTML = translate['with the plugin functionality on our forum.'];
|
||||
document.getElementById('span_create').innerHTML = translate['Create a new plugin using'] + ' ';
|
||||
document.getElementById('span_ver_caption').innerHTML = translate['Version'] + ': ';
|
||||
document.getElementById('span_min_ver_caption').innerHTML = translate['The minimum supported editors version'] + ': ';
|
||||
document.getElementById('span_langs_caption').innerHTML = translate['Languages'] + ': ';
|
||||
document.getElementById('span_categories').innerHTML = translate['Categories'];
|
||||
document.getElementById('opt_all').innerHTML = translate['All'];
|
||||
document.getElementById('opt_rec').innerHTML = translate['Recommended'];
|
||||
document.getElementById('opt_dev').innerHTML = translate['Developer tools'];
|
||||
document.getElementById('opt_work').innerHTML = translate['Work'];
|
||||
document.getElementById('opt_enter').innerHTML = translate['Entertainment'];
|
||||
document.getElementById('opt_com').innerHTML = translate['Communication'];
|
||||
document.getElementById('opt_spec').innerHTML = translate['Special abilities'];
|
||||
versionWarning = translate[versionWarning];
|
||||
elements.linkNewPlugin.innerHTML = getTranslated(messages.linkPR);
|
||||
elements.btnMyPlugins.innerHTML = getTranslated('My plugins');
|
||||
elements.btnMarketplace.innerHTML = getTranslated('Marketplace');
|
||||
elements.btnInstall.innerHTML = getTranslated('Install');
|
||||
elements.btnRemove.innerHTML = getTranslated('Remove');
|
||||
elements.btnUpdate.innerHTML = getTranslated('Update');
|
||||
elements.btnUpdateAll.innerHTML = getTranslated('Update All');
|
||||
elements.inpSearch.placeholder = getTranslated('Search plugins') + '...';
|
||||
document.getElementById('lbl_header').innerHTML = getTranslated('Manage plugins');
|
||||
document.getElementById('span_offered_caption').innerHTML = getTranslated('Offered by') + ': ';
|
||||
document.getElementById('span_overview').innerHTML = getTranslated('Overview');
|
||||
document.getElementById('span_info').innerHTML = getTranslated('Info & Support');
|
||||
document.getElementById('span_lern').innerHTML = getTranslated('Learn how to use') + ' ';
|
||||
document.getElementById('span_lern_plugin').innerHTML = getTranslated('the plugin in') + ' ';
|
||||
document.getElementById('span_contribute').innerHTML = getTranslated('Contribute') + ' ';
|
||||
document.getElementById('span_contribute_end').innerHTML = getTranslated('to the plugin developmen or report an issue on') + ' ';
|
||||
document.getElementById('span_help').innerHTML = getTranslated('Get help') + ' ';
|
||||
document.getElementById('span_help_end').innerHTML = getTranslated('with the plugin functionality on our forum.');
|
||||
document.getElementById('span_create').innerHTML = getTranslated('Create a new plugin using') + ' ';
|
||||
document.getElementById('span_ver_caption').innerHTML = getTranslated('Version') + ': ';
|
||||
document.getElementById('span_min_ver_caption').innerHTML = getTranslated('The minimum supported editors version') + ': ';
|
||||
document.getElementById('span_langs_caption').innerHTML = getTranslated('Languages') + ': ';
|
||||
document.getElementById('span_categories').innerHTML = getTranslated('Categories');
|
||||
document.getElementById('opt_all').innerHTML = getTranslated('All');
|
||||
document.getElementById('opt_rec').innerHTML = getTranslated('Recommended');
|
||||
document.getElementById('opt_dev').innerHTML = getTranslated('Developer tools');
|
||||
document.getElementById('opt_work').innerHTML = getTranslated('Work');
|
||||
document.getElementById('opt_enter').innerHTML = getTranslated('Entertainment');
|
||||
document.getElementById('opt_com').innerHTML = getTranslated('Communication');
|
||||
document.getElementById('opt_spec').innerHTML = getTranslated('Special abilities');
|
||||
showMarketplace();
|
||||
};
|
||||
|
||||
function showMarketplace() {
|
||||
// show main window to user
|
||||
if (!isPluginLoading && !isTranslationLoading && !isFrameLoading) {
|
||||
// filter installed plugins (delete removed, that are in store)
|
||||
installedPlugins = installedPlugins.filter(function(plugin) {
|
||||
return !( plugin.removed && plugin.obj.baseUrl.includes(ioUrl) );
|
||||
});
|
||||
if (!isPluginLoading && !isTranslationLoading && !isFrameLoading && installedPlugins) {
|
||||
createSelect();
|
||||
showListofPlugins(true);
|
||||
if (isOnline)
|
||||
showListofPlugins(isOnline);
|
||||
else
|
||||
toogleView(elements.btnMyPlugins, elements.btnMarketplace, messages.linkManually, false, false);
|
||||
|
||||
toogleLoader(false);
|
||||
catFiltred = allPlugins;
|
||||
// elements.divBody.classList.remove('hidden');
|
||||
@ -1047,7 +1163,6 @@ function createSelect() {
|
||||
|
||||
function getImageUrl(guid, bNotForStore, bSetSize, id) {
|
||||
// get icon url for current plugin (according to theme and scale)
|
||||
// TODO change it when we will be able show icons for installed plugins
|
||||
let iconScale = '/icon.png';
|
||||
switch (scale.percent) {
|
||||
case '125%':
|
||||
@ -1065,25 +1180,42 @@ function getImageUrl(guid, bNotForStore, bSetSize, id) {
|
||||
}
|
||||
let curIcon = './resources/img/defaults/' + (bNotForStore ? ('info/' + themeType) : 'card') + iconScale;
|
||||
let plugin;
|
||||
if (allPlugins) {
|
||||
plugin = findPlugin(true, guid);
|
||||
}
|
||||
// We have a problem with "http" and "file" routes.
|
||||
// In desktop we have a local installed marketplace. It's why we use local routes only for desktop.
|
||||
let baseUrl;
|
||||
|
||||
if (!plugin && installedPlugins) {
|
||||
if (installedPlugins) {
|
||||
plugin = findPlugin(false, guid);
|
||||
if (plugin)
|
||||
if (plugin) {
|
||||
let start;
|
||||
if (isDesktop) {
|
||||
baseUrl = plugin.obj.baseUrl;
|
||||
} else {
|
||||
baseUrl = plugin.baseUrl;
|
||||
start = baseUrl.indexOf('web-apps');
|
||||
baseUrl = baseUrl.substring(0, start);
|
||||
start = plugin.obj.baseUrl.indexOf('sdkjs-plugins');
|
||||
baseUrl += plugin.obj.baseUrl.substring(start);
|
||||
}
|
||||
plugin = plugin.obj;
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin && plugin.baseUrl.includes('https://')) {
|
||||
if ( ( !plugin || ( !baseUrl.includes('https://') && !isDesktop ) ) && allPlugins) {
|
||||
plugin = findPlugin(true, guid);
|
||||
if (plugin)
|
||||
baseUrl = plugin.baseUrl;
|
||||
}
|
||||
// github doesn't allow to use "http" or "file" as the URL for an image
|
||||
if ( plugin && ( baseUrl.includes('https://') || isDesktop) ) {
|
||||
let variation = plugin.variations[0];
|
||||
|
||||
if (!bNotForStore && variation.store && variation.store.icons) {
|
||||
// иконки в конфиге у объекта стор (работаем только по новой схеме)
|
||||
// это будет объект с двумя полями для темной и светлой темы, которые будут указывать путь до папки в которой хранятся иконки
|
||||
curIcon = plugin.baseUrl + variation.store.icons[themeType] + iconScale;
|
||||
// icons are in config of store field (work only with new scheme)
|
||||
// it's an object with 2 fields (for dark and light theme), which contain route to icons folder
|
||||
curIcon = baseUrl + variation.store.icons[themeType] + iconScale;
|
||||
} else if (variation.icons2) {
|
||||
// это старая схема и тут может быть массив с объектами у которых есть поле темы, так и массив из одного объекта у которого нет поля темы
|
||||
// it's old scheme. There could be an array with objects which have theme field or an array from one object without theme field
|
||||
let icon = variation.icons2[0];
|
||||
for (let i = 1; i < variation.icons2.length; i++) {
|
||||
if ( themeType.includes(variation.icons2[i].style) ) {
|
||||
@ -1091,18 +1223,18 @@ function getImageUrl(guid, bNotForStore, bSetSize, id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
curIcon = plugin.baseUrl + icon[scale.percent].normal;
|
||||
curIcon = baseUrl + icon[scale.percent].normal;
|
||||
} else if (variation.icons) {
|
||||
// тут может быть как старая так и новая схема
|
||||
// в старой схеме это будет массив со строками или объект по типу icons2 из блока выше
|
||||
// это будет объект с двумя полями для темной и светлой темы, которые будут указывать путь до папки в которой хранятся иконкио
|
||||
// there could be old and new scheme
|
||||
// there will be a string array or object like icons2 above (old scheme)
|
||||
// there will be a object with 2 fields (for dark and light theme), which contain route to icons folder (new scheme)
|
||||
if (!Array.isArray(variation.icons)) {
|
||||
// новая схема
|
||||
curIcon = plugin.baseUrl + variation.icons[themeType] + iconScale;
|
||||
// new scheme
|
||||
curIcon = baseUrl + variation.icons[themeType] + iconScale;
|
||||
} else {
|
||||
// старая схема
|
||||
// old scheme
|
||||
if (typeof(variation.icons[0]) == 'object' ) {
|
||||
// старая схема и icons это объект как icons2 в блоке выше
|
||||
// old scheme and icons like icons2 above
|
||||
let icon = variation.icons[0];
|
||||
for (let i = 1; i < variation.icons.length; i++) {
|
||||
if ( themeType.includes(variation.icons[i].style) ) {
|
||||
@ -1110,10 +1242,10 @@ function getImageUrl(guid, bNotForStore, bSetSize, id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
curIcon = plugin.baseUrl + icon[scale.percent].normal;
|
||||
curIcon = baseUrl + icon[scale.percent].normal;
|
||||
} else {
|
||||
// старая схема и icons это массив со строками
|
||||
curIcon = plugin.baseUrl + (scale.value >= 1.2 ? variation.icons[1] : variation.icons[0]);
|
||||
// old scheme and icons is a string array
|
||||
curIcon = baseUrl + (scale.value >= 1.2 ? variation.icons[1] : variation.icons[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1160,23 +1292,55 @@ function getUrlSearchValue(key) {
|
||||
return res;
|
||||
};
|
||||
|
||||
function toogleView(current, oldEl, text, bAll) {
|
||||
if ( !current.classList.contains('btn_toolbar_active') ) {
|
||||
function toogleView(current, oldEl, text, bAll, bForce) {
|
||||
if ( !current.classList.contains('btn_toolbar_active') || bForce ) {
|
||||
elements.inpSearch.value = '';
|
||||
founded = [];
|
||||
oldEl.classList.remove('btn_toolbar_active');
|
||||
current.classList.add('btn_toolbar_active');
|
||||
elements.linkNewPlugin.innerHTML = translate[text] || text;
|
||||
if (document.getElementById('select_categories').value == 'all') {
|
||||
showListofPlugins(bAll);
|
||||
catFiltred = bAll ? allPlugins : installedPlugins;
|
||||
elements.linkNewPlugin.innerHTML = getTranslated(text);
|
||||
let toolbar = document.getElementById('toolbar_tools');
|
||||
if (bAll && (!isOnline || isPluginLoading) ) {
|
||||
$('.div_notification').remove();
|
||||
$('.div_item').remove();
|
||||
setTimeout(function(){if (Ps) Ps.update()});
|
||||
toolbar.classList.add('hidden');
|
||||
createNotification('No Internet Connection.')
|
||||
} else {
|
||||
filterByCategory(document.getElementById('select_categories').value);
|
||||
toolbar.classList.remove('hidden');
|
||||
if (document.getElementById('select_categories').value == 'all') {
|
||||
showListofPlugins(bAll);
|
||||
catFiltred = bAll ? allPlugins : installedPlugins;
|
||||
} else {
|
||||
filterByCategory(document.getElementById('select_categories').value);
|
||||
}
|
||||
}
|
||||
elements.linkNewPlugin.href = bAll ? "https://github.com/ONLYOFFICE/onlyoffice.github.io/pulls" : "https://api.onlyoffice.com/plugin/installation";
|
||||
|
||||
if (isDesktop && !bAll) {
|
||||
elements.linkNewPlugin.href = "#";
|
||||
elements.linkNewPlugin.onclick = function (e) {
|
||||
e.preventDefault();
|
||||
installPluginManually();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function installPluginManually() {
|
||||
window["AscDesktopEditor"]["OpenFilenameDialog"]("plugin", false, function (_file) {
|
||||
var file = _file;
|
||||
if (Array.isArray(file))
|
||||
file = file[0];
|
||||
|
||||
let result = window["AscDesktopEditor"]["PluginInstall"](file);
|
||||
if (result) {
|
||||
// нужно обновить список установленных плагинов
|
||||
sendMessage({ type: 'getInstalled', updateInstalled: true }, '*');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function sortPlugins(bAll, bInst, type) {
|
||||
switch (type) {
|
||||
case 'raiting':
|
||||
@ -1185,6 +1349,22 @@ function sortPlugins(bAll, bInst, type) {
|
||||
case 'instalations':
|
||||
// todo
|
||||
break;
|
||||
case 'start':
|
||||
if (bInst) {
|
||||
let protected = [];
|
||||
let removed = [];
|
||||
let arr = [];
|
||||
installedPlugins.forEach(function(pl){
|
||||
if (!pl.canRemoved)
|
||||
protected.push(pl);
|
||||
else if (pl.removed)
|
||||
removed.push(pl);
|
||||
else
|
||||
arr.push(pl);
|
||||
});
|
||||
installedPlugins = protected.concat(arr, removed);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (bAll) {
|
||||
@ -1250,20 +1430,6 @@ function filterByCategory(category) {
|
||||
makeSearch(elements.inpSearch.value.trim().toLowerCase());
|
||||
};
|
||||
|
||||
function createDefaultTranslations() {
|
||||
translate = {
|
||||
"Submit your own plugin": "Submit your own plugin",
|
||||
"Install plugin manually": "Install plugin manually",
|
||||
"Install": "Install",
|
||||
"Remove": "Remove",
|
||||
"Update": "Update",
|
||||
"Problem with loading plugins." : "Problem with loading plugins.",
|
||||
"No installed plugins." : "No installed plugins."
|
||||
};
|
||||
isTranslationLoading = false;
|
||||
showMarketplace();
|
||||
};
|
||||
|
||||
function removeUnloaded(unloaded) {
|
||||
unloaded.forEach(function(el){
|
||||
allPlugins.splice(el, 1);
|
||||
@ -1279,7 +1445,7 @@ function findPlugin(bAll, guid) {
|
||||
|
||||
function changeAfterInstallOrRemove(bInstall, guid, bHasLocal) {
|
||||
let btn = this.document.getElementById(guid).lastChild.lastChild;
|
||||
btn.innerHTML = translate[ ( bInstall ? 'Remove' : 'Install' ) ];
|
||||
btn.innerHTML = getTranslated( ( bInstall ? 'Remove' : 'Install' ) );
|
||||
btn.classList.add( ( bInstall ? 'btn_remove' : 'btn_install' ) );
|
||||
btn.classList.remove( ( bInstall ? 'btn_install' : 'btn_remove' ) );
|
||||
btn.onclick = function(e) {
|
||||
@ -1290,7 +1456,7 @@ function changeAfterInstallOrRemove(bInstall, guid, bHasLocal) {
|
||||
};
|
||||
// We need to keep the ability to install the local version that has been removed (maybe we should change the button)
|
||||
if ( !bInstall && btn.hasAttribute('dataDisabled') && !bHasLocal ) {
|
||||
btn.setAttribute('title', versionWarning);
|
||||
btn.setAttribute('title', getTranslated(messages.versionWarning));
|
||||
btn.setAttribute('disabled', '');
|
||||
}
|
||||
|
||||
@ -1310,4 +1476,43 @@ function changeAfterInstallOrRemove(bInstall, guid, bHasLocal) {
|
||||
else
|
||||
this.document.getElementById('btn_update').classList.add('hidden');
|
||||
}
|
||||
};
|
||||
|
||||
function checkInternet() {
|
||||
try {
|
||||
let xhr = new XMLHttpRequest();
|
||||
let url = 'https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice.github.io/master/store/translations/langs.json';
|
||||
xhr.open('GET', url, true);
|
||||
|
||||
xhr.onload = function () {
|
||||
if (this.readyState == 4) {
|
||||
if (this.status >= 200 && this.status < 300) {
|
||||
isOnline = true;
|
||||
fetchAllPlugins(interval === null, elements.btnMarketplace.classList.contains('btn_toolbar_active'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onerror = function (err) {
|
||||
handeNoInternet();
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
} catch (error) {
|
||||
handeNoInternet();
|
||||
}
|
||||
};
|
||||
|
||||
function handeNoInternet() {
|
||||
isOnline = false;
|
||||
allPlugins = [];
|
||||
if (!interval) {
|
||||
interval = setInterval(function() {
|
||||
checkInternet();
|
||||
}, 5000);
|
||||
}
|
||||
};
|
||||
|
||||
function getTranslated(text) {
|
||||
return translate[text] || text;
|
||||
};
|
||||
@ -47,5 +47,8 @@
|
||||
"Communication": "Komunikace",
|
||||
"Special abilities": "Speciální schopnosti",
|
||||
"The minimum supported editors version" : "Minimální podporovaná verze editorů",
|
||||
"This plugin will only work in a newer version of the editor.": "Dieses Plugin funktioniert nur in einer neueren Version des Editors."
|
||||
"This plugin will only work in a newer version of the editor.": "Dieses Plugin funktioniert nur in einer neueren Version des Editors.",
|
||||
"Nothing was found for this query.": "Pro tento dotaz nebylo nic nalezeno.",
|
||||
"No Internet Connection.": "Žádné Připojení K Internetu.",
|
||||
"Problem with loading plugin config.\nConfig: " : "Problém s načítáním plugin config.\nConfig:"
|
||||
}
|
||||
@ -47,5 +47,8 @@
|
||||
"Communication": "Kommunikation",
|
||||
"Special abilities": "Spezialfähigkeiten",
|
||||
"The minimum supported editors version" : "Die minimal unterstützte Editorversion",
|
||||
"This plugin will only work in a newer version of the editor.": "Dieses Plugin funktioniert nur in einer neueren Version des Editors."
|
||||
"This plugin will only work in a newer version of the editor.": "Dieses Plugin funktioniert nur in einer neueren Version des Editors.",
|
||||
"Nothing was found for this query.": "Für diese Abfrage wurde nichts gefunden.",
|
||||
"No Internet Connection.": "Keine Internetverbindung.",
|
||||
"Problem with loading plugin config.\nConfig: " : "Problem beim Laden der Plugin-Konfiguration.\nKonfiguration:"
|
||||
}
|
||||
@ -47,5 +47,8 @@
|
||||
"Communication": "Comunicar",
|
||||
"Special abilities": "Habilidades especiales",
|
||||
"The minimum supported editors version" : "La versión mínima de editores admitidos",
|
||||
"This plugin will only work in a newer version of the editor.": "Este complemento solo funcionará en una versión más reciente del editor."
|
||||
"This plugin will only work in a newer version of the editor.": "Este complemento solo funcionará en una versión más reciente del editor.",
|
||||
"Nothing was found for this query.": "No se encontró nada para esta consulta.",
|
||||
"No Internet Connection.": "Sin Conexión a Internet.",
|
||||
"Problem with loading plugin config.\nConfig: " : "Problema al cargar la configuración del complemento.\nConfig: "
|
||||
}
|
||||
@ -47,5 +47,8 @@
|
||||
"Communication": "Communication",
|
||||
"Special abilities": "Capacités spéciales",
|
||||
"The minimum supported editors version" : "La version minimale des éditeurs pris en charge",
|
||||
"This plugin will only work in a newer version of the editor.": "Ce plugin ne fonctionnera que dans une version plus récente de l'éditeur."
|
||||
"This plugin will only work in a newer version of the editor.": "Ce plugin ne fonctionnera que dans une version plus récente de l'éditeur.",
|
||||
"Nothing was found for this query.": "Rien n'a été trouvé pour cette requête.",
|
||||
"No Internet Connection.": "Pas De Connexion Internet.",
|
||||
"Problem with loading plugin config.\nConfig: " : "Problème de chargement de la configuration du plugin.\nConfig: "
|
||||
}
|
||||
@ -47,5 +47,8 @@
|
||||
"Communication": "Коммуникация",
|
||||
"Special abilities": "Специальные возможности",
|
||||
"The minimum supported editors version" : "Минимальная поддерживаемая версия редактора",
|
||||
"This plugin will only work in a newer version of the editor.": "Этот плагин будет работать только в более новой версии редактора."
|
||||
"This plugin will only work in a newer version of the editor.": "Этот плагин будет работать только в более новой версии редактора.",
|
||||
"Nothing was found for this query.": "По этому запросу ничего не найдено.",
|
||||
"No Internet Connection.": "Нет подключения к Интернету.",
|
||||
"Problem with loading plugin config.\nConfig: " : "Проблема с загрузкой конфигурации плагина.\nКонфиг: "
|
||||
}
|
||||
Reference in New Issue
Block a user