I use tinyMCE to edit content, and it has cleanup rules set for cleanup before sending data back. but in other areas of my application I need to display the same content ... and I do not want to rely on the fact that it was properly cleaned before it was placed in the database (perhaps this was edited by another application).
so for consistency (and not for duplication of effort) is there any way to use the tinyMCE cleaner / scrubber directly in javascript so that I can clear other content before putting it in the view-only DOM? sort of:
var data = getDataViaAjax(); var content = tinymce.scrubber.cleanup(data); $("someElement").append(content);
UPDATE - an example of how to do this
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)); }