From c8fe0b5968fbc2861814ce9096c86968188fffd2 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Tue, 25 Apr 2023 17:58:26 +0100 Subject: [PATCH] First test converting the plugins --- .../plugins/magentovariable/editor_plugin.js | 55 ++++------- .../plugins/magentowidget/editor_plugin.js | 92 +++++++------------ 2 files changed, 49 insertions(+), 98 deletions(-) diff --git a/js/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentovariable/editor_plugin.js b/js/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentovariable/editor_plugin.js index 346e1abcdab..0b1045e3568 100644 --- a/js/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentovariable/editor_plugin.js +++ b/js/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentovariable/editor_plugin.js @@ -12,45 +12,22 @@ * @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ -tinyMCE.addI18n({en:{ - magentovariable: - { - insert_variable : "Insert Variable" - } -}}); - -(function() { - tinymce.create('tinymce.plugins.MagentovariablePlugin', { - /** - * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. - * @param {string} url Absolute URL to where the plugin is located. - */ - init : function(ed, url) { - ed.addCommand('mceMagentovariable', function() { - var pluginSettings = ed.settings.magentoPluginsOptions.get('magentovariable'); - MagentovariablePlugin.setEditor(ed); - MagentovariablePlugin.loadChooser(pluginSettings.url, null); - }); - - // Register Widget plugin button - ed.addButton('magentovariable', { - title : 'magentovariable.insert_variable', - cmd : 'mceMagentovariable', - image : url + '/img/icon.gif' - }); - }, +tinymce.PluginManager.add('OpenMageVariablePlugin', (ed, url) => { + ed.addCommand('mceMagentovariable', function() { + var pluginSettings = ed.settings.magentoPluginsOptions.get('magentovariable'); + MagentovariablePlugin.setEditor(ed); + MagentovariablePlugin.loadChooser(pluginSettings.url, null); + }); - getInfo : function() { - return { - longname : 'Magento Variable Manager Plugin for TinyMCE 3.x', - author : 'Magento Core Team', - authorurl : 'http://magentocommerce.com', - infourl : 'https://www.openmage.org', - version : "1.0" - }; - } + // Register Widget plugin button + ed.addButton('magentovariable', { + title : 'magentovariable.insert_variable', + cmd : 'mceMagentovariable', + image : url + '/img/icon.gif' }); - // Register plugin - tinymce.PluginManager.add('magentovariable', tinymce.plugins.MagentovariablePlugin); -})(); + return { + name: 'OpenMage Variable Manager Plugin for TinyMCE', + url: 'https://www.openmage.org' + }; +}); \ No newline at end of file diff --git a/js/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js b/js/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js index d601a5df010..38c02d84029 100644 --- a/js/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js +++ b/js/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js @@ -11,69 +11,43 @@ * @copyright Copyright (c) 2022 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ -tinyMCE.addI18n({en:{ - magentowidget: - { - insert_widget : "Insert Widget" - } -}}); -/* - TODO: Apply JStrim to reduce file size -*/ - -(function() { - tinymce.create('tinymce.plugins.MagentowidgetPlugin', { - /** - * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. - * @param {string} url Absolute URL to where the plugin is located. - */ - init : function(ed, url) { - ed.addCommand('mceMagentowidget', function() { - widgetTools.openDialog(ed.settings.magentowidget_url + 'widget_target_id/' + ed.getElement().id + '/'); - }); - - // Register Widget plugin button - ed.addButton('magentowidget', { - title : 'magentowidget.insert_widget', - cmd : 'mceMagentowidget', - image : url + '/img/icon.gif' - }); +tinymce.PluginManager.add('OpenMageWidgetPlugin', (ed, url) => { + ed.addCommand('mceMagentowidget', function() { + widgetTools.openDialog(ed.settings.magentowidget_url + 'widget_target_id/' + ed.getElement().id + '/'); + }); - // Add a node change handler, selects the button in the UI when a image is selected - ed.onNodeChange.add(function(ed, cm, n) { - cm.setActive('magentowidget', false); - if (n.id && n.nodeName == 'IMG') { - var widgetCode = Base64.idDecode(n.id); - if (widgetCode.indexOf('{{widget') != -1) { - cm.setActive('magentowidget', true); - } - } - }); + // Register Widget plugin button + ed.addButton('magentowidget', { + title : 'magentowidget.insert_widget', + cmd : 'mceMagentowidget', + image : url + '/img/icon.gif' + }); - // Add a widget placeholder image double click callback - ed.onDblClick.add(function(ed, e) { - var n = e.target; - if (n.id && n.nodeName == 'IMG') { - var widgetCode = Base64.idDecode(n.id); - if (widgetCode.indexOf('{{widget') != -1) { - ed.execCommand('mceMagentowidget'); - } - } - }); - }, + // Add a node change handler, selects the button in the UI when a image is selected + ed.onNodeChange.add(function(ed, cm, n) { + cm.setActive('magentowidget', false); + if (n.id && n.nodeName == 'IMG') { + var widgetCode = Base64.idDecode(n.id); + if (widgetCode.indexOf('{{widget') != -1) { + cm.setActive('magentowidget', true); + } + } + }); - getInfo : function() { - return { - longname : 'Magento Widget Manager Plugin for TinyMCE 3.x', - author : 'Magento Core Team', - authorurl : 'http://magentocommerce.com', - infourl : 'https://www.openmage.org', - version : "1.0" - }; + // Add a widget placeholder image double click callback + ed.onDblClick.add(function(ed, e) { + var n = e.target; + if (n.id && n.nodeName == 'IMG') { + var widgetCode = Base64.idDecode(n.id); + if (widgetCode.indexOf('{{widget') != -1) { + ed.execCommand('mceMagentowidget'); + } } }); - // Register plugin - tinymce.PluginManager.add('magentowidget', tinymce.plugins.MagentowidgetPlugin); -})(); + return { + name: 'OpenMage Widget Manager Plugin for TinyMCE', + url: 'https://www.openmage.org' + }; +}); \ No newline at end of file