Skip to content

Commit

Permalink
First test converting the plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano committed Apr 25, 2023
1 parent 3683b2d commit c8fe0b5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};
});

0 comments on commit c8fe0b5

Please sign in to comment.