tags:

views:

442

answers:

2

Does anyone know if there is a way I can dynamically load and unload a TinyMCE plugin after TinyMCE has already been loaded? Specifically, I'm thinking about asking the user whether or not they wish to load the fullpage plugin using perhaps a radio button or something above TinyMCE:

<input type="radio" name="fullpage" value="enabled"  /> Enable Fullpage Plugin<br />
<input type="radio" name="fullpage" value="disabled" /> Disable Fullpage Plugin<br />
<textarea name="tinymce" id="tinymce">...</textarea>

I suppose I could destroy the original instance and load a new config (one for enabled / one for disabled), but it seems as though there should be a more elegant way of loading and unloading plugins.

A: 

I've used TinyMCE in the past a bit, and don't recall any way of doing this.

Checking the API docs at http://tinymce.moxiecode.com/js/tinymce/docs/api/index.html#class_tinymce.Editor.html, it seems like there is only a property for the plugins, no method() to add more.

It would seem that destroying the original instance and loading a new config is your only option. (Unless you want to modify TinyMCE code)

Jonathan Fingland
A: 

You can use the AddOnManager load() function to dynamically load a plugin (http://tinymce.ephox.com/documentation/api/index.html#class_tinymce.AddOnManager.html-load). You may need to create an instance of the plugin class, in this case tinymce.plugins.FullPagePlugin once it's loaded.

However, since most plugins are designed to be loaded during the initialization of the editor, it's unlikely that the plugin will work consistently. The full page plugin in particular expects to be able to filter the content on the way into the editor so it's likely to have problems.

REgards,

Adrian Sutton.
http://tinymce.ephox.com

ajsutton