Is it possible to extend the TinyMce setup/initialisation? I need to make a change to enhance the behaviour of a couple of features, e.g. apply a specific class to elements when Justify-Left or Justify-Right are selected from the formatting toolbar.
tinymce.init({
setup: function(editor) {
editor.on('ExecCommand', function(e) {
var selectedNode = editor.selection.getNode(); // Get the currently selected node
if (e.command === 'JustifyLeft' || e.command === 'JustifyRight') {
// Remove any previously added alignment classes
editor.dom.removeClass(selectedNode, 'custom-justify-left custom-justify-right');
// Check command and add the appropriate class
if (e.command === 'JustifyLeft') {
editor.dom.addClass(selectedNode, 'custom-justify-left');
} else if (e.command === 'JustifyRight') {
editor.dom.addClass(selectedNode, 'custom-justify-right');
}
}
});
}
});
Is this achievable somehow?