paste_preprocess tinymce 问题 [英] paste_preprocess tinymce issue
本文介绍了paste_preprocess tinymce 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 tinymce 编辑器中粘贴时,我想去除所有 html 标签.以下是不起作用的代码......以下是tinymce设置...... paste_preprocess回调没有触发......我错过了一些选项......?
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...
推荐答案
以下是解决问题的代码.
Following is the code which solved the problem.
paste_preprocess : function(pl, o) {
// Content string containing the HTML from the clipboard
var str = o.content;
var ta = document.createElement("textarea");
ta.innerHTML = str.replace(/</g,"<").replace(/>/g,">");
o.content = CleanWordHTML(ta.value);
},
paste_postprocess : function(pl, o) {
},
CleanWordHTML(ta.value); 是用户定义的函数,其中提取 html 字符串正则表达式.
CleanWordHTML(ta.value); is user defined function where the html strings are extracted regular expressions.
这篇关于paste_preprocess tinymce 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文