I am using TinyMCE editor. I want to remove or destroy tinymce editors (Page contain more then one editor). Also remove classes and IDs added by tinyMCE.
Bu
Just in case anybody arrived here who is using the jQuery version of TinyMce use the following instead to remove an instance:
$("#textarea_id").tinymce().remove();
Bear in mind that if given textarea
has an id, tinyMCE will use it for some strange reason, even if selector
parameter has been used to apply editor to given element. This id is then used in internal array - tinyMCE.editors
which isn't cleared (isn't cleared if you'll use tinymce.execCommand('mceRemoveControl', true, [id])
, remove
actually removes editors
and prevents tinyMCE to be applied ever again). As such if you have a dynamic content with tinyMCE applied, it will work once, but never again. To resolve this you need to clean this array manually per delete tinyMCE.editors[$(node).getAttribute('id')]
we were getting error on callingelementReference.destroy()
// destroy is a dojo function
we replaced that code withelementReference.domNode.remove()
we were also using tinymce.min.js, and it was giving us NS_ERROR_UNEXPECTED
I had the same problem. In v4 all suggestions above did not work for me, but this did:
tinymce.remove("div.editable");
... regenerated HTML dynamicaly ...
tinymce.init(...);
I use inline editor:
tinymce.init({
selector: "div.editable",
inline: true,
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"
],
menubar: false,
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"});
Hope this helped
You need an editor id (which usually equals your editor html root elements id (in most cases a textarea)).
Example:
tinymce.execCommand('mceRemoveControl', true, 'my_original_textarea_id');
TinyMCE will check if its already loaded in window.scripts
. If you remove the according entry TinyMCE will behave like it is a untouched document.
function cleanTinyMCE() {
for (var i=0; i < window.scripts.length; i++) {
if (window.scripts[i].match('.*tinymce.*js.*')){
delete window.scripts[i];
return;
}
}
}