diff --git a/amd/build/commands.min.js b/amd/build/commands.min.js
index 6973829..4d25d2f 100644
--- a/amd/build/commands.min.js
+++ b/amd/build/commands.min.js
@@ -1,3 +1,3 @@
-define("tiny_codepro/commands",["exports","editor_tiny/utils","core/str","./ui","./common","./options"],(function(_exports,_utils,_str,_ui,_common,_options){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.getSetup=void 0;_exports.getSetup=async()=>{const[pluginName,buttonImage]=await Promise.all([(0,_str.get_string)("pluginname",_common.component),(0,_utils.getButtonImage)("icon",_common.component)]);return editor=>{if(!(0,_options.isPluginVisible)(editor))return;editor.ui.registry.addIcon(_common.icon,buttonImage.html);const onSetup=api=>{const cb=()=>api.setEnabled(!0);return editor.on("SetContent",cb),()=>editor.off("SetContent",cb)};editor.ui.registry.addButton(_common.component,{icon:_common.icon,tooltip:pluginName,onAction:()=>(0,_ui.handleAction)(editor),enabled:!1,onSetup:onSetup}),editor.ui.registry.addMenuItem(_common.component,{icon:_common.icon,text:pluginName,onAction:()=>(0,_ui.handleAction)(editor),enabled:!1,onSetup:onSetup})}}}));
+define("tiny_codepro/commands",["exports","editor_tiny/utils","core/str","./ui","./common","./options"],(function(_exports,_utils,_str,_ui,_common,_options){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.getSetup=void 0;_exports.getSetup=async()=>{const[pluginName,buttonImage]=await Promise.all([(0,_str.get_string)("pluginname",_common.component),(0,_utils.getButtonImage)("icon",_common.component)]);return editor=>{(0,_options.isPluginVisible)(editor)&&(editor.ui.registry.addIcon(_common.icon,buttonImage.html),editor.ui.registry.addButton(_common.component,{icon:_common.icon,tooltip:pluginName,onAction:()=>(0,_ui.handleAction)(editor),enabled:!1,onSetup:api=>{const cb=()=>api.setEnabled(!0);return editor.on("SetContent",cb),()=>editor.off("SetContent",cb)}}),editor.ui.registry.addMenuItem(_common.component,{icon:_common.icon,text:pluginName,onAction:()=>(0,_ui.handleAction)(editor)}))}}}));
//# sourceMappingURL=commands.min.js.map
\ No newline at end of file
diff --git a/amd/build/commands.min.js.map b/amd/build/commands.min.js.map
index 757dec5..05a6921 100644
--- a/amd/build/commands.min.js.map
+++ b/amd/build/commands.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"commands.min.js","sources":["../src/commands.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Tiny CodePro plugin.\n *\n * @module tiny_codepro/plugin\n * @copyright 2023 Josep Mulet Pol \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {getButtonImage} from 'editor_tiny/utils';\nimport {get_string as getString} from 'core/str';\nimport {handleAction} from './ui';\nimport {component, icon} from './common';\nimport {isPluginVisible} from './options';\n\nexport const getSetup = async() => {\n const [\n pluginName,\n buttonImage,\n ] = await Promise.all([\n getString('pluginname', component),\n getButtonImage('icon', component),\n ]);\n\n return (editor) => {\n if (!isPluginVisible(editor)) {\n return;\n }\n // Register the Icon.\n editor.ui.registry.addIcon(icon, buttonImage.html);\n\n // Disable button and menu item until the content has been set.\n const onSetup = (api) => {\n const cb = () => api.setEnabled(true);\n editor.on('SetContent', cb);\n return () => editor.off('SetContent', cb);\n };\n\n // Register the Toolbar Button.\n editor.ui.registry.addButton(component, {\n icon,\n tooltip: pluginName,\n onAction: () => handleAction(editor),\n enabled: false,\n onSetup\n });\n\n // Add the Menu Item.\n // This allows it to be added to a standard menu, or a context menu.\n editor.ui.registry.addMenuItem(component, {\n icon,\n text: pluginName,\n onAction: () => handleAction(editor),\n enabled: false,\n onSetup\n });\n };\n};"],"names":["async","pluginName","buttonImage","Promise","all","component","editor","ui","registry","addIcon","icon","html","onSetup","api","cb","setEnabled","on","off","addButton","tooltip","onAction","enabled","addMenuItem","text"],"mappings":"gQA6BwBA,gBAEhBC,WACAC,mBACMC,QAAQC,IAAI,EAClB,mBAAU,aAAcC,oBACxB,yBAAe,OAAQA,4BAGnBC,cACC,4BAAgBA,eAIrBA,OAAOC,GAAGC,SAASC,QAAQC,aAAMR,YAAYS,YAGvCC,QAAWC,YACPC,GAAK,IAAMD,IAAIE,YAAW,UAChCT,OAAOU,GAAG,aAAcF,IACjB,IAAMR,OAAOW,IAAI,aAAcH,KAI1CR,OAAOC,GAAGC,SAASU,UAAUb,kBAAW,CACpCK,KAAAA,aACAS,QAASlB,WACTmB,SAAU,KAAM,oBAAad,QAC7Be,SAAS,EACTT,QAAAA,UAKJN,OAAOC,GAAGC,SAASc,YAAYjB,kBAAW,CACtCK,KAAAA,aACAa,KAAMtB,WACNmB,SAAU,KAAM,oBAAad,QAC7Be,SAAS,EACTT,QAAAA"}
\ No newline at end of file
+{"version":3,"file":"commands.min.js","sources":["../src/commands.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Tiny CodePro plugin.\n *\n * @module tiny_codepro/plugin\n * @copyright 2023 Josep Mulet Pol \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {getButtonImage} from 'editor_tiny/utils';\nimport {get_string as getString} from 'core/str';\nimport {handleAction} from './ui';\nimport {component, icon} from './common';\nimport {isPluginVisible} from './options';\n\nexport const getSetup = async() => {\n const [\n pluginName,\n buttonImage,\n ] = await Promise.all([\n getString('pluginname', component),\n getButtonImage('icon', component),\n ]);\n\n return (editor) => {\n if (!isPluginVisible(editor)) {\n return;\n }\n // Register the Icon.\n editor.ui.registry.addIcon(icon, buttonImage.html);\n\n // Register the Toolbar Button.\n editor.ui.registry.addButton(component, {\n icon,\n tooltip: pluginName,\n onAction: () => handleAction(editor),\n enabled: false,\n onSetup: (api) => {\n const cb = () => api.setEnabled(true);\n editor.on('SetContent', cb);\n return () => editor.off('SetContent', cb);\n }\n });\n\n // Add the Menu Item.\n // This allows it to be added to a standard menu, or a context menu.\n editor.ui.registry.addMenuItem(component, {\n icon,\n text: pluginName,\n onAction: () => handleAction(editor)\n });\n };\n};"],"names":["async","pluginName","buttonImage","Promise","all","component","editor","ui","registry","addIcon","icon","html","addButton","tooltip","onAction","enabled","onSetup","api","cb","setEnabled","on","off","addMenuItem","text"],"mappings":"gQA6BwBA,gBAEhBC,WACAC,mBACMC,QAAQC,IAAI,EAClB,mBAAU,aAAcC,oBACxB,yBAAe,OAAQA,4BAGnBC,UACC,4BAAgBA,UAIrBA,OAAOC,GAAGC,SAASC,QAAQC,aAAMR,YAAYS,MAG7CL,OAAOC,GAAGC,SAASI,UAAUP,kBAAW,CACpCK,KAAAA,aACAG,QAASZ,WACTa,SAAU,KAAM,oBAAaR,QAC7BS,SAAS,EACTC,QAAUC,YACAC,GAAK,IAAMD,IAAIE,YAAW,UAChCb,OAAOc,GAAG,aAAcF,IACjB,IAAMZ,OAAOe,IAAI,aAAcH,OAM9CZ,OAAOC,GAAGC,SAASc,YAAYjB,kBAAW,CACtCK,KAAAA,aACAa,KAAMtB,WACNa,SAAU,KAAM,oBAAaR"}
\ No newline at end of file
diff --git a/amd/src/commands.js b/amd/src/commands.js
index 3d0e1be..b4ff71d 100644
--- a/amd/src/commands.js
+++ b/amd/src/commands.js
@@ -43,20 +43,17 @@ export const getSetup = async() => {
// Register the Icon.
editor.ui.registry.addIcon(icon, buttonImage.html);
- // Disable button and menu item until the content has been set.
- const onSetup = (api) => {
- const cb = () => api.setEnabled(true);
- editor.on('SetContent', cb);
- return () => editor.off('SetContent', cb);
- };
-
// Register the Toolbar Button.
editor.ui.registry.addButton(component, {
icon,
tooltip: pluginName,
onAction: () => handleAction(editor),
enabled: false,
- onSetup
+ onSetup: (api) => {
+ const cb = () => api.setEnabled(true);
+ editor.on('SetContent', cb);
+ return () => editor.off('SetContent', cb);
+ }
});
// Add the Menu Item.
@@ -64,9 +61,7 @@ export const getSetup = async() => {
editor.ui.registry.addMenuItem(component, {
icon,
text: pluginName,
- onAction: () => handleAction(editor),
- enabled: false,
- onSetup
+ onAction: () => handleAction(editor)
});
};
};
\ No newline at end of file