Update plugins.js script

This commit is contained in:
Oleg Korshul
2025-06-10 18:46:22 +03:00
parent 83850417c5
commit 6f941b41b2
3 changed files with 47 additions and 380 deletions

View File

@ -383,6 +383,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]);
};
Asc.Buttons.registerContentControl = function()
{
window.Asc.plugin.attachEditorEvent("onShowContentControlTrack", function(contentControls) {
@ -462,6 +482,7 @@
this.lockInViewMode = true;
this.enableToggle = false;
this.disabled = false;
this.removed = false;
this.parent = parent ? parent : null;
this.childs = null;
@ -498,6 +519,11 @@
if (this.disabled)
item.disabled = true;
else
item.disabled = false;
if (this.removed)
item.removed = true;
if (this.icons)
item.icons = this.icons;
@ -752,4 +778,3 @@
Asc.ButtonToolbar = ButtonToolbar;
Asc.ButtonContentControl = ButtonContentControl;
})(window);

View File

@ -16,23 +16,24 @@
*
*/
(function(b,t){function v(a){b.Asc.plugin.ie_channel?b.Asc.plugin.ie_channel.postMessage(a):b.parent.postMessage(a,"*")}function q(a,c){if(!a||"object"!=typeof a&&"array"!=typeof a)return a;c=c===t?{}:c;for(var f in a)a.hasOwnProperty(f)&&(c[f]=a[f]&&"object"===typeof a[f]?q(a[f]):a[f]);return c}function m(a){var c=b.location.search,f=a+"=";a=c.indexOf(f);return 0<=a?(a+=f.length,f=c.indexOf("&",a),0>f&&(f=c.length),c.substring(a,f)):t}function l(){var a=m("windowID");a&&(b.Asc.plugin.windowID=a,
b.Asc.plugin.guid||(b.Asc.plugin.guid=decodeURIComponent(m("guid"))));return t!==a?!0:!1}function n(a){if(b.Asc&&b.Asc.plugin)if(b.plugin_onMessage)b.Asc.supportOrigins[a.origin]&&b.plugin_onMessage(a);else if(b.Asc.plugin._initInternal&&"string"==typeof a.data){var c={};try{c=JSON.parse(a.data)}catch(f){c={}}"plugin_init"==c.type&&(b.Asc.supportOrigins[a.origin]=!0,b.Asc.plugin.ie_channel_check(a),eval(c.data))}}b.Asc=b.Asc||{};b.Asc.plugin={};b.Asc.plugin.ie_channel=null;b.Asc.plugin.ie_channel_check=
function(a){var c=navigator.userAgent.toLowerCase();(-1<c.indexOf("msie")||-1<c.indexOf("trident"))&&a.ports&&a.ports[0]&&(this.ie_channel=a.ports[0])};b.Asc.plugin.tr_init=!1;b.Asc.plugin.tr=function(a){return a};b.Asc.scope={};b.Asc.scope.prototype={clear:function(){for(var a in b.Asc.scope)delete b.Asc.scope[a]}};b.onload=function(){if(b.Asc&&b.Asc.plugin){var a=new XMLHttpRequest;a.open("get","./config.json",!0);a.responseType="json";a.onload=function(){if(b.Asc&&b.Asc.plugin){if(404===a.status)return a.onerror();
if(200==a.status||0==a.status&&4==a.readyState){var c=a.response;"string"==typeof c&&(c=JSON.parse(c));q(c,b.Asc.plugin);c={type:"initialize",guid:b.Asc.plugin.guid};l()&&(c.windowID=b.Asc.plugin.windowID);var f=document.body;f&&!0!==b.Asc.plugin.enableDrops&&(f.ondrop=function(h){h&&h.preventDefault&&h.preventDefault();return!1},f.ondragenter=function(h){h&&h.preventDefault&&h.preventDefault();return!1},f.ondragover=function(h){h&&h.preventDefault&&h.preventDefault();h&&h.dataTransfer&&(h.dataTransfer.dropEffect=
"none");return!1});b.Asc.plugin._initInternal=!0;b.parent.postMessage(JSON.stringify(c),"*")}}};a.onerror=function(){if(b.Asc&&b.Asc.plugin&&l()){var c={type:"initialize",guid:b.Asc.plugin.guid};c.windowID=b.Asc.plugin.windowID;b.Asc.plugin._initInternal=!0;b.parent.postMessage(JSON.stringify(c),"*")}};a.send()}};b.Asc.supportOrigins={};b.Asc.supportOrigins[b.origin]=!0;b.addEventListener?b.addEventListener("message",n,!1):b.attachEvent("onmessage",n);b.Asc.plugin._attachCustomMenuClickEvent=function(a,
c,f){this[a]||(this[a]={});this[a][c]=f};b.Asc.plugin._onCustomMenuClick=function(a,c){var f=t,h=c.indexOf("_oo_sep_");-1!==h&&(f=c.substring(h+8),c=c.substring(0,h));this[a]&&this[a][c]&&this[a][c].call(this,f)};b.Asc.plugin.attachContextMenuClickEvent=function(a,c){this._attachCustomMenuClickEvent("contextMenuEvents",a,c)};b.Asc.plugin.event_onContextMenuClick=function(a){this._onCustomMenuClick("contextMenuEvents",a)};b.Asc.plugin.attachToolbarMenuClickEvent=function(a,c){this._attachCustomMenuClickEvent("toolbarMenuEvents",
a,c)};b.Asc.plugin.event_onToolbarMenuClick=function(a){this._onCustomMenuClick("toolbarMenuEvents",a)};b.Asc.plugin.event_onContentControlButtonClick=function(a){let c=a&&a.buttonId?a.buttonId:null;a=a&&a.contentControlId?a.contentControlId:null;c&&a&&this.ContentControlButtonEvents&&this.ContentControlButtonEvents[c]&&this.ContentControlButtonEvents[c].call(this,a)};b.Asc.plugin._attachContentControlButtonClickEvent=function(a,c){this.ContentControlButtonEvents||(this.ContentControlButtonEvents=
{});this.ContentControlButtonEvents[a]=c};b.Asc.plugin.attachEvent=function(a,c){var f=b.Asc.plugin;f._events||(f._events={});f._events[a]=c};b.Asc.plugin.detachEvent=function(a){var c=b.Asc.plugin;c._events&&c._events[a]&&delete c._events[a]};b.Asc.plugin.onEvent=function(a,c){var f=b.Asc.plugin;f._events&&f._events[a]&&f._events[a].call(f,c)};b.Asc.plugin.attachEditorEvent=function(a,c){b.Asc.plugin["event_"+a]=c.bind(b.Asc.plugin);v(JSON.stringify({guid:b.Asc.plugin.guid,type:"attachEvent",name:a}))};
b.Asc.plugin.detachEditorEvent=function(a){b.Asc.plugin["event_"+a]&&delete b.Asc.plugin["event_"+a];v(JSON.stringify({guid:b.Asc.plugin.guid,type:"detachEvent",name:a}))};b.onunload=function(){b.addEventListener?b.removeEventListener("message",n,!1):b.detachEvent("onmessage",n)}})(window,void 0);
(function(b,t){function v(){function d(){return(65536+e[k++]).toString(16).substring(1)}if(!b.crypto||!b.crypto.getRandomValues){function g(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return g()+g()+"-"+g()+"-"+g()+"-"+g()+"-"+g()+g()+g()}var e=new Uint16Array(8);b.crypto.getRandomValues(e);var k=0;return d()+d()+"-"+d()+"-"+d()+"-"+d()+"-"+d()+d()+d()}function q(d){return b.Asc.plugin.tr(d)}function m(d,e){this.itemType=h.None;this.editors=["word","cell","slide"];this.id=
e===t?v():e;this.icons=null;this.text="";this.hint=null;this.data="";this.separator=!1;this.lockInViewMode=!0;this.disabled=this.enableToggle=!1;this.parent=d?d:null;this.childs=null;this.parent&&(this.parent.childs||(this.parent.childs=[]),this.parent.childs.push(this))}function l(d,e){m.call(this,d,e);this.itemType=h.ContextMenu;this.showOnOptionsType=[];c.Buttons.ButtonsContextMenu.push(this)}function n(d,e){m.call(this,d,e);this.itemType=h.Toolbar;this.type=f.BigButton;this.tab="";c.Buttons.ButtonsToolbar.push(this)}
function a(d,e){m.call(this,d,e);this.itemType=h.ContentControl;this.checker=null;0===c.Buttons.ButtonsContentControl.length&&c.Buttons.registerContentControl();c.Buttons.ButtonsContentControl.push(this)}b.Asc=b.Asc||{};var c=b.Asc;c.Buttons={};c.Buttons.ButtonsContextMenu=[];c.Buttons.ButtonsToolbar=[];c.Buttons.ButtonsContentControl=[];c.Buttons.registerContextMenu=function(){b.Asc.plugin.attachEvent("onContextMenuShow",function(d){if(d){var e={guid:b.Asc.plugin.guid};for(let k=0,g=c.Buttons.ButtonsContextMenu.length;k<
g;k++){let p=c.Buttons.ButtonsContextMenu[k];if(null===p.parent)p.onContextMenuShow(d,e)}e.items&&b.Asc.plugin.executeMethod("AddContextMenuItem",[e])}})};c.Buttons.registerToolbarMenu=function(){let d={guid:b.Asc.plugin.guid,tabs:[]};for(let e=0,k=c.Buttons.ButtonsToolbar.length;e<k;e++){let g=c.Buttons.ButtonsToolbar[e];null===g.parent&&g.toToolbar(d);if(g.menu)for(item of g.menu)item.onclick&&b.Asc.plugin.attachToolbarMenuClickEvent(item.id,item.onclick)}0<d.tabs.length&&b.Asc.plugin.executeMethod("AddToolbarMenuItem",
[d])};c.Buttons.registerContentControl=function(){b.Asc.plugin.attachEvent("onShowContentControlTrack",function(d){let e={guid:b.Asc.plugin.guid,items:{}},k=[];for(let g=0,p=c.Buttons.ButtonsContentControl.length;g<p;++g)k.push(c.Buttons.ButtonsContentControl[g].onShowTrack(d,e.items));Promise.all(k).then(function(){for(let g in e.items){b.Asc.plugin.executeMethod("AddContentControlButtons",[e]);break}})})};var f={Button:"button",BigButton:"big-button"},h={None:0,ContextMenu:1,Toolbar:2,ContentControl:3};
m.prototype.toItem=function(){let d={id:this.id,text:q(this.text)};null!==this.hint&&(d.hint=q(""===this.hint?this.hint:this.text));this.separator&&(d.separator=!0);this.data&&(d.data=this.data);this.lockInViewMode&&(d.lockInViewMode=!0);this.enableToggle&&(d.enableToggle=!0);this.disabled&&(d.disabled=!0);this.icons&&(d.icons=this.icons);this.itemType===h.Toolbar&&(d.type=this.type);this.menu&&(d.items=this.menu.map(function(e){e.text=q(e.text);return e}));this.split&&(d.split=!0);return d};m.prototype.attachOnClick=
function(d){};m.prototype.onClick=function(){console.log("BUTTON: "+this.text)};l.prototype=Object.create(m.prototype);l.prototype.constructor=l;l.prototype.copy=function(){let d=new l(this.parent,this.id);d.editors=this.editors;d.separator=this.separator;d.lockInViewMode=this.lockInViewMode;d.enableToggle=this.enableToggle;d.disabled=this.disabled;d.showOnOptionsType=this.showOnOptionsType.slice();return d};l.prototype.addCheckers=function(){let d=arguments.length;this.showOnOptionsType=Array(d);
for(let e=0;e<d;e++)this.showOnOptionsType[e]=arguments[e]};l.prototype.attachOnClick=function(d){b.Asc.plugin.attachContextMenuClickEvent(this.id,d)};l.prototype.onContextMenuShowAnalyze=function(d,e){return!1};l.prototype.onContextMenuShowExtendItem=function(d,e){};l.prototype.onContextMenuShow=function(d,e){if(!this.onContextMenuShowAnalyze(d,e)){var k=!1;for(let g=0,p=this.editors.length;g<p;g++)if(c.plugin.info.editorType===this.editors[g]){k=!0;break}if(k)for(let g=0,p=this.showOnOptionsType.length;g<
p;g++)if(d.type===this.showOnOptionsType[g]||"All"===this.showOnOptionsType[g]){e.items||(e.items=[]);k=this.toItem();this.onContextMenuShowExtendItem(d,k);if(this.childs)for(let r=0,x=this.childs.length;r<x;r++)this.childs[r].onContextMenuShow(d,k);e.items.push(k);break}}};n.prototype=Object.create(m.prototype);n.prototype.constructor=n;n.prototype.attachOnClick=function(d){b.Asc.plugin.attachToolbarMenuClickEvent(this.id,d)};n.prototype.toItem=function(d){d=m.prototype.toItem.call(this);d.type=
this.type;return d};n.prototype.toToolbar=function(d){if(null===this.parent){var e={id:this.id,text:q(this.text),items:[]};null!==this.hint&&(e.hint=q(""===this.hint?this.hint:this.text));d.tabs.push(e)}else e=this.toItem(),d.items||(d.items=[]),d.items.push(e);if(this.childs)for(let k=0,g=this.childs.length;k<g;k++)this.childs[k].toToolbar(e)};a.prototype=Object.create(m.prototype);a.prototype.constructor=a;a.prototype.attachOnClick=function(d){b.Asc.plugin._attachContentControlButtonClickEvent(this.id,
d)};a.prototype.addChecker=function(d){d&&"function"===typeof d&&(this.checker=d)};a.prototype.onShowTrack=function(d,e){let k=this.checker,g=[],p=this.toItem();for(let r=0,x=d.length;r<x;++r){let w=d[r];g.push((new Promise(function(u){if(k){let y=k(w);y instanceof Promise?y.then(function(z){u(z)}):u(!!y)}else u(!0)})).then(function(u){u&&(e[w]||(e[w]=[]),e[w].push(p))}))}return Promise.all(g)};c.ToolbarButtonType=f;c.ButtonContextMenu=l;c.ButtonToolbar=n;c.ButtonContentControl=a})(window);
(function(a,t){function v(c){a.Asc.plugin.ie_channel?a.Asc.plugin.ie_channel.postMessage(c):a.parent.postMessage(c,"*")}function r(c,d){if(!c||"object"!=typeof c&&"array"!=typeof c)return c;d=d===t?{}:d;for(var f in c)c.hasOwnProperty(f)&&(d[f]=c[f]&&"object"===typeof c[f]?r(c[f]):c[f]);return d}function n(c){var d=a.location.search,f=c+"=";c=d.indexOf(f);return 0<=c?(c+=f.length,f=d.indexOf("&",c),0>f&&(f=d.length),d.substring(c,f)):t}function m(){var c=n("windowID");c&&(a.Asc.plugin.windowID=c,
a.Asc.plugin.guid||(a.Asc.plugin.guid=decodeURIComponent(n("guid"))));return t!==c?!0:!1}function p(c){if(a.Asc&&a.Asc.plugin)if(a.plugin_onMessage)a.Asc.supportOrigins[c.origin]&&a.plugin_onMessage(c);else if(a.Asc.plugin._initInternal&&"string"==typeof c.data){var d={};try{d=JSON.parse(c.data)}catch(f){d={}}"plugin_init"==d.type&&(a.Asc.supportOrigins[c.origin]=!0,a.Asc.plugin.ie_channel_check(c),eval(d.data))}}a.Asc=a.Asc||{};a.Asc.plugin={};a.Asc.plugin.ie_channel=null;a.Asc.plugin.ie_channel_check=
function(c){var d=navigator.userAgent.toLowerCase();(-1<d.indexOf("msie")||-1<d.indexOf("trident"))&&c.ports&&c.ports[0]&&(this.ie_channel=c.ports[0])};a.Asc.plugin.tr_init=!1;a.Asc.plugin.tr=function(c){return c};a.Asc.scope={};a.Asc.scope.prototype={clear:function(){for(var c in a.Asc.scope)delete a.Asc.scope[c]}};a.onload=function(){if(a.Asc&&a.Asc.plugin){var c=new XMLHttpRequest;c.open("get","./config.json",!0);c.responseType="json";c.onload=function(){if(a.Asc&&a.Asc.plugin){if(404===c.status)return c.onerror();
if(200==c.status||0==c.status&&4==c.readyState){var d=c.response;"string"==typeof d&&(d=JSON.parse(d));r(d,a.Asc.plugin);d={type:"initialize",guid:a.Asc.plugin.guid};m()&&(d.windowID=a.Asc.plugin.windowID);var f=document.body;f&&!0!==a.Asc.plugin.enableDrops&&(f.ondrop=function(k){k&&k.preventDefault&&k.preventDefault();return!1},f.ondragenter=function(k){k&&k.preventDefault&&k.preventDefault();return!1},f.ondragover=function(k){k&&k.preventDefault&&k.preventDefault();k&&k.dataTransfer&&(k.dataTransfer.dropEffect=
"none");return!1});a.Asc.plugin._initInternal=!0;a.parent.postMessage(JSON.stringify(d),"*")}}};c.onerror=function(){if(a.Asc&&a.Asc.plugin&&m()){var d={type:"initialize",guid:a.Asc.plugin.guid};d.windowID=a.Asc.plugin.windowID;a.Asc.plugin._initInternal=!0;a.parent.postMessage(JSON.stringify(d),"*")}};c.send()}};a.Asc.supportOrigins={};a.Asc.supportOrigins[a.origin]=!0;a.addEventListener?a.addEventListener("message",p,!1):a.attachEvent("onmessage",p);a.Asc.plugin._attachCustomMenuClickEvent=function(c,
d,f){this[c]||(this[c]={});this[c][d]=f};a.Asc.plugin._onCustomMenuClick=function(c,d){var f=t,k=d.indexOf("_oo_sep_");-1!==k&&(f=d.substring(k+8),d=d.substring(0,k));this[c]&&this[c][d]&&this[c][d].call(this,f)};a.Asc.plugin.attachContextMenuClickEvent=function(c,d){this._attachCustomMenuClickEvent("contextMenuEvents",c,d)};a.Asc.plugin.event_onContextMenuClick=function(c){this._onCustomMenuClick("contextMenuEvents",c)};a.Asc.plugin.attachToolbarMenuClickEvent=function(c,d){this._attachCustomMenuClickEvent("toolbarMenuEvents",
c,d)};a.Asc.plugin.event_onToolbarMenuClick=function(c){this._onCustomMenuClick("toolbarMenuEvents",c)};a.Asc.plugin.attachEvent=function(c,d){var f=a.Asc.plugin;f._events||(f._events={});f._events[c]=d};a.Asc.plugin.detachEvent=function(c){var d=a.Asc.plugin;d._events&&d._events[c]&&delete d._events[c]};a.Asc.plugin.onEvent=function(c,d){var f=a.Asc.plugin;f._events&&f._events[c]&&f._events[c].call(f,d)};a.Asc.plugin.attachEditorEvent=function(c,d){a.Asc.plugin["event_"+c]=d.bind(a.Asc.plugin);v(JSON.stringify({guid:a.Asc.plugin.guid,
type:"attachEvent",name:c}))};a.Asc.plugin.detachEditorEvent=function(c){a.Asc.plugin["event_"+c]&&delete a.Asc.plugin["event_"+c];v(JSON.stringify({guid:a.Asc.plugin.guid,type:"detachEvent",name:c}))};a.onunload=function(){a.addEventListener?a.removeEventListener("message",p,!1):a.detachEvent("onmessage",p)}})(window,void 0);
(function(a,t){function v(){function b(){return(65536+e[h++]).toString(16).substring(1)}if(!a.crypto||!a.crypto.getRandomValues){function g(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return g()+g()+"-"+g()+"-"+g()+"-"+g()+"-"+g()+g()+g()}var e=new Uint16Array(8);a.crypto.getRandomValues(e);var h=0;return b()+b()+"-"+b()+"-"+b()+"-"+b()+"-"+b()+b()+b()}function r(b){return a.Asc.plugin.tr(b)}function n(b,e){this.itemType=k.None;this.editors=["word","cell","slide"];this.id=
e===t?v():e;this.icons=null;this.text="";this.hint=null;this.data="";this.separator=!1;this.lockInViewMode=!0;this.removed=this.disabled=this.enableToggle=!1;this.parent=b?b:null;this.childs=null;this.parent&&(this.parent.childs||(this.parent.childs=[]),this.parent.childs.push(this))}function m(b,e){n.call(this,b,e);this.itemType=k.ContextMenu;this.showOnOptionsType=[];d.Buttons.ButtonsContextMenu.push(this)}function p(b,e){n.call(this,b,e);this.itemType=k.Toolbar;this.type=f.BigButton;this.tab="";
d.Buttons.ButtonsToolbar.push(this)}function c(b,e){n.call(this,b,e);this.itemType=k.ContentControl;this.checker=null;0===d.Buttons.ButtonsContentControl.length&&d.Buttons.registerContentControl();d.Buttons.ButtonsContentControl.push(this)}a.Asc=a.Asc||{};var d=a.Asc;d.Buttons={};d.Buttons.ButtonsContextMenu=[];d.Buttons.ButtonsToolbar=[];d.Buttons.ButtonsContentControl=[];d.Buttons.registerContextMenu=function(){a.Asc.plugin.attachEvent("onContextMenuShow",function(b){if(b){var e={guid:a.Asc.plugin.guid};
for(let h=0,g=d.Buttons.ButtonsContextMenu.length;h<g;h++){let l=d.Buttons.ButtonsContextMenu[h];if(null===l.parent)l.onContextMenuShow(b,e)}e.items&&a.Asc.plugin.executeMethod("AddContextMenuItem",[e])}})};d.Buttons.registerToolbarMenu=function(){let b={guid:a.Asc.plugin.guid,tabs:[]};for(let e=0,h=d.Buttons.ButtonsToolbar.length;e<h;e++){let g=d.Buttons.ButtonsToolbar[e];null===g.parent&&g.toToolbar(b);if(g.menu)for(item of g.menu)item.onclick&&a.Asc.plugin.attachToolbarMenuClickEvent(item.id,item.onclick)}0<
b.tabs.length&&a.Asc.plugin.executeMethod("AddToolbarMenuItem",[b])};d.Buttons.updateToolbarMenu=function(b,e,h){b=new d.ButtonToolbar(null,b);b.text=e;e={guid:a.Asc.plugin.guid,tabs:[]};b.childs=h;for(let g=0,l=h.length;g<l;g++)h[g].parent=b;b.toToolbar(e);0<e.tabs.length&&a.Asc.plugin.executeMethod("UpdateToolbarMenuItem",[e])};d.Buttons.registerContentControl=function(){a.Asc.plugin.attachEditorEvent("onShowContentControlTrack",function(e){let h={guid:a.Asc.plugin.guid,items:{}},g=[];for(let l=
0,q=d.Buttons.ButtonsContentControl.length;l<q;++l)g.push(d.Buttons.ButtonsContentControl[l].onShowTrack(e,h.items));Promise.all(g).then(function(){for(let l in h.items){a.Asc.plugin.executeMethod("AddContentControlButtons",[h]);break}})});a.Asc.plugin._attachContentControlButtonClickEvent=function(e,h){this.ContentControlButtonEvents||(this.ContentControlButtonEvents={});this.ContentControlButtonEvents[e]=h};let b=a.Asc.plugin;a.Asc.plugin.attachEditorEvent("onContentControlButtonClick",function(e){let h=
e&&e.buttonId?e.buttonId:null;e=e&&e.contentControlId?e.contentControlId:null;h&&e&&b.ContentControlButtonEvents&&b.ContentControlButtonEvents[h]&&b.ContentControlButtonEvents[h].call(b,e)})};var f={Button:"button",BigButton:"big-button"},k={None:0,ContextMenu:1,Toolbar:2,ContentControl:3};n.prototype.toItem=function(){let b={id:this.id,text:r(this.text)};null!==this.hint&&(b.hint=r(""===this.hint?this.hint:this.text));this.separator&&(b.separator=!0);this.data&&(b.data=this.data);this.lockInViewMode&&
(b.lockInViewMode=!0);this.enableToggle&&(b.enableToggle=!0);b.disabled=this.disabled?!0:!1;this.removed&&(b.removed=!0);this.icons&&(b.icons=this.icons);this.itemType===k.Toolbar&&(b.type=this.type);this.menu&&(b.items=this.menu.map(function(e){e.text=r(e.text);return e}));this.split&&(b.split=!0);return b};n.prototype.attachOnClick=function(b){};n.prototype.onClick=function(){console.log("BUTTON: "+this.text)};m.prototype=Object.create(n.prototype);m.prototype.constructor=m;m.prototype.copy=function(){let b=
new m(this.parent,this.id);b.editors=this.editors;b.separator=this.separator;b.lockInViewMode=this.lockInViewMode;b.enableToggle=this.enableToggle;b.disabled=this.disabled;b.showOnOptionsType=this.showOnOptionsType.slice();return b};m.prototype.addCheckers=function(){let b=arguments.length;this.showOnOptionsType=Array(b);for(let e=0;e<b;e++)this.showOnOptionsType[e]=arguments[e]};m.prototype.attachOnClick=function(b){a.Asc.plugin.attachContextMenuClickEvent(this.id,b)};m.prototype.onContextMenuShowAnalyze=
function(b,e){return!1};m.prototype.onContextMenuShowExtendItem=function(b,e){};m.prototype.onContextMenuShow=function(b,e){if(!this.onContextMenuShowAnalyze(b,e)){var h=!1;for(let g=0,l=this.editors.length;g<l;g++)if(d.plugin.info.editorType===this.editors[g]){h=!0;break}if(h)for(let g=0,l=this.showOnOptionsType.length;g<l;g++)if(b.type===this.showOnOptionsType[g]||"All"===this.showOnOptionsType[g]){e.items||(e.items=[]);h=this.toItem();this.onContextMenuShowExtendItem(b,h);if(this.childs)for(let q=
0,x=this.childs.length;q<x;q++)this.childs[q].onContextMenuShow(b,h);e.items.push(h);break}}};p.prototype=Object.create(n.prototype);p.prototype.constructor=p;p.prototype.attachOnClick=function(b){a.Asc.plugin.attachToolbarMenuClickEvent(this.id,b)};p.prototype.toItem=function(b){b=n.prototype.toItem.call(this);b.type=this.type;return b};p.prototype.toToolbar=function(b){if(null===this.parent){var e={id:this.id,text:r(this.text),items:[]};null!==this.hint&&(e.hint=r(""===this.hint?this.hint:this.text));
b.tabs.push(e)}else e=this.toItem(),b.items||(b.items=[]),b.items.push(e);if(this.childs)for(let h=0,g=this.childs.length;h<g;h++)this.childs[h].toToolbar(e)};c.prototype=Object.create(n.prototype);c.prototype.constructor=c;c.prototype.attachOnClick=function(b){a.Asc.plugin._attachContentControlButtonClickEvent(this.id,b)};c.prototype.addChecker=function(b){b&&"function"===typeof b&&(this.checker=b)};c.prototype.onShowTrack=function(b,e){let h=this.checker,g=[],l=this.toItem();for(let q=0,x=b.length;q<
x;++q){let w=b[q];g.push((new Promise(function(u){if(h){let y=h(w);y instanceof Promise?y.then(function(z){u(z)}):u(!!y)}else u(!0)})).then(function(u){u&&(e[w]||(e[w]=[]),e[w].push(l))}))}return Promise.all(g)};d.ToolbarButtonType=f;d.ButtonContextMenu=m;d.ButtonToolbar=p;d.ButtonContentControl=c})(window);