How do you dynamically add a button / plugin to TinyMCE?

I have a TinyMCE editor on my page. I would like to add / remove buttons / plugins from the toolbar based on things that happen differently where on the page. I'm looking for a solution that avoids breaking and recreating the editor. Is there a tinyMCE team to do this? Something like

tinyMCE.execCommand("mceInsertPlugin", pluginName);



source to share

1 answer

You cannot load plugins without reinitializing the editor. But with buttons you can:

Create a button on the fly:

  ed.addButton('example', {
     title : 'example.desc',
     image : '../jscripts/tiny_mce/plugins/example/img/example.gif',
     onclick : function() {
        ed.windowManager.alert('Hello world!! Selection: ' + ed.selection.getContent({format : 'text'}));


Removal: $('.mce_example').parent('td').remove();



All Articles