I'm using tinyMCE to edit content, and it has the cleanup rules set for what to scrub before posting the data back. but in other areas of my app, I need to display that same content... and I dont want to count on the fact that it was correctly scrubbed before it was put INTO the database (it may have been edited by another app).
so for consistency sake (and not having to duplicate effort) is there a way for me to use the tinyMCE cleanup/scrubber directly in javascript so that I can scrub other content before placing it into the DOM just for viewing? something like:
var data = getDataViaAjax();
var content = tinymce.scrubber.cleanup(data);
$("someElement").append(content);
function parse(html) {
var settings = {
invalid_elements : "script,object,embed,link,style,form,input,iframe",
valid_elements:"a[href],img[src],li,ul,ol,span,div,p,br,blockquote,h1,h2,h3,h4,h5,h6,strong/b,em/i,li,ul,ol"
};
var schema = new tinymce.html.Schema(settings);
var parser = new tinymce.html.DomParser({}, schema);
var serializer = new tinymce.html.Serializer({}, schema);
return serializer.serialize(parser.parse(html));
}
There is no predefined way to use this functionality. In order to get the mceCleanup-Action to work without tinymce you will have to write it yourself, but you should be able to use the predefined javascript classes with a few changes. Have a look at the developer tinymce version (uncompressed). There you may start with the function serialize
in the File Serializer.js
which can be found in the classes/dom
directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With