mirror of
https://github.com/ONLYOFFICE/onlyoffice.github.io.git
synced 2026-04-07 14:04:30 +08:00
Use onPluginUpdateToolbarMenu event
This commit is contained in:
@ -40,6 +40,7 @@ async function GetOldCustomFunctions() {
|
||||
}
|
||||
|
||||
window.Asc.plugin.init = async function() {
|
||||
initWithTranslate();
|
||||
clearChatState();
|
||||
|
||||
let editorVersion = await Asc.Library.GetEditorVersion();
|
||||
@ -131,13 +132,25 @@ window.Asc.plugin.init = async function() {
|
||||
}
|
||||
|
||||
if (Asc.plugin.info.editorSubType === "pdf") {
|
||||
window.Asc.plugin.attachEditorEvent("onChangeRestrictions", function(value){
|
||||
let disabled = (value & 0x80) !== 0;
|
||||
if (window.buttonOCRPage.disabled !== disabled)
|
||||
window.buttonOCRPage.disabled = disabled;
|
||||
Asc.Buttons.updateToolbarMenu(window.buttonMainToolbar.id, window.buttonMainToolbar.name, [window.buttonOCRPage]);
|
||||
});
|
||||
|
||||
let restriction = Asc.plugin.info.restrictions;
|
||||
if (undefined === restriction)
|
||||
restriction = 0;
|
||||
|
||||
let buttonOCRPage = new Asc.ButtonToolbar(window.buttonMainToolbar);
|
||||
let buttonOCRPage = new Asc.ButtonToolbar(null);
|
||||
buttonOCRPage.text = "OCR";
|
||||
buttonOCRPage.icons = window.getToolBarButtonIcons("settings");
|
||||
window.buttonOCRPage = buttonOCRPage;
|
||||
|
||||
if (0x80 & restriction)
|
||||
buttonOCRPage.disabled = true;
|
||||
|
||||
buttonOCRPage.attachOnClick(async function(data){
|
||||
let requestEngine = AI.Request.create(AI.ActionType.OCR);
|
||||
if (!requestEngine)
|
||||
@ -160,10 +173,10 @@ window.Asc.plugin.init = async function() {
|
||||
html : Asc.Library.ConvertMdToHTML(result)
|
||||
}]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
initWithTranslate();
|
||||
Asc.Buttons.updateToolbarMenu(window.buttonMainToolbar.id, window.buttonMainToolbar.name, [buttonOCRPage]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.Asc.plugin.onTranslate = function() {
|
||||
|
||||
@ -82,6 +82,26 @@
|
||||
window.Asc.plugin.executeMethod("AddToolbarMenuItem", [items]);
|
||||
};
|
||||
|
||||
Asc.Buttons.updateToolbarMenu = function(id, name, buttons)
|
||||
{
|
||||
let buttonMainToolbar = new Asc.ButtonToolbar(null, id);
|
||||
buttonMainToolbar.text = name;
|
||||
|
||||
let items = {
|
||||
guid : window.Asc.plugin.guid,
|
||||
tabs : []
|
||||
};
|
||||
|
||||
buttonMainToolbar.childs = buttons;
|
||||
for (let i = 0, len = buttons.length; i < len; i++)
|
||||
buttons[i].parent = buttonMainToolbar;
|
||||
|
||||
buttonMainToolbar.toToolbar(items);
|
||||
|
||||
if (items.tabs.length > 0)
|
||||
window.Asc.plugin.executeMethod("UpdateToolbarMenuItem", [items]);
|
||||
};
|
||||
|
||||
var ToolbarButtonType = {
|
||||
Button : "button",
|
||||
BigButton : "big-button"
|
||||
@ -110,6 +130,7 @@
|
||||
this.lockInViewMode = true;
|
||||
this.enableToggle = false;
|
||||
this.disabled = false;
|
||||
this.removed = false;
|
||||
|
||||
this.parent = parent ? parent : null;
|
||||
this.childs = null;
|
||||
@ -147,6 +168,9 @@
|
||||
if (this.disabled)
|
||||
item.disabled = true;
|
||||
|
||||
if (this.removed)
|
||||
item.removed = true;
|
||||
|
||||
if (this.icons)
|
||||
item.icons = this.icons;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user