i want to strip all the html tags when pasting in tinymce editor. following is the code which is not functional... following is the tinymce settings... the paste_preprocess callback is not trigering... am i missing some option..?
tinyMCESettings = [ {
mode : "none,textareas",
height:heightEditor,
width:'100%',
plugins: "paste",
theme : "advanced", //skin : "wp_theme",
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter",
relative_urls : "true",
paste_use_dialog : false,
paste_auto_cleanup_on_paste : false,
content_css: styleSheetToLoadForTinyMCE + "?" + new Date().getTime(),
force_p_newlines: false,
setup: function (ed) {
ed.onInit.add(
function (ed, evt) {
//resizeFrame1();
var a = tinyMCE.get(ed.id).getContent();
if(a.indexOf("hcRestrictedMode", 0) > 0){
ed.getDoc().designMode = "off";
setTimeout(function(){
tinyMCE.activeEditor.dom.setAttrib(tinyMCE.activeEditor.dom.select(".hcEditable"), 'contenteditable', 'true');
}, 1000);
}
});
},
paste_preprocess : function(pl, o) {
// Content string containing the HTML from the clipboard
alert(o.content);
o.content = o.content.replace(/<.+?>/,"");
},
paste_postprocess : function(pl, o) {
// Content DOM node containing the DOM structure of the clipboard
alert(o.content)
o.content = o.content.replace(/<.+?>/,"");
}
}];
help here... thnx in advance...
Here is the config code:
Here is the function used (taken from here)
EDIT: set
paste_auto_cleanup_on_paste
to true and it will work (checked your config in my system)Following is the code which solved the problem.
CleanWordHTML(ta.value); is user defined function where the html strings are extracted regular expressions.