I'm using the TinyMCE component for a project to let users submit rich text to the database. TinyMCE allows users to paste from other a wordprocessor (copying all styles), which gives the user access to more styles then I would allow in the normal editor.
A way to circumvent this is to add to paste plug-in and a paste_preprocess event handler, which strips the pasted text from it's style before the text is inserted in the dom tree.
In plain html it's a matter of adding a few lines to the init method of TinyMCE (see below). But when I add custom settings to TinyMCESettings, they will be displayed in the init method if I view the generated source but never executed.
Any ideas how I could accomplish that the preprocessor is executed, on paste?
The output I want to accomplish within the TinyMCE Component (this code works when using html).
I'm aware that the component doesn't add plugins in simple mode, I also tried doing it in advanced mode .
tinyMCE.init({
mode : "exact",
elements : "elm1",
language : "en",
theme : "simple",
plugins : "paste",
paste_preprocess : function(pl, o) {
o.content = o.content.replace(/<br[^<>]*>/ig,"[br]");
o.content = o.content.replace(/(<p[^<>]*>)/ig,"[p]");
o.content = o.content.replace(/(<\/p[^<>]*>)/ig,"[/p]");
o.content = o.content.replace(/(<\S([^<>]*)>)/ig,"");
o.content = o.content.replace(/(\[br\])/ig,"<br />");
o.content = o.content.replace(/(\[p\])/ig,"<p>");
o.content = o.content.replace(/(\[\/p\])/ig,"</p>");
}
});