仅供参考,tinymce在粘贴插件中将其作为默认选项实现,从而改进了这一点。
更多信息:
http://www.tinymce.com/wiki.php/Plugin:paste
然而,它仍然不是完美的。
因此,这里有一个脚本,它也会触发所有的html:
// Paste
paste_auto_cleanup_on_paste : true,
paste_remove_spans: true,
paste_remove_styles: true,
paste_retain_style_properties: false,
paste_preprocess : function(pl, o)
{ // Replace
o.content = o.content.replace(/
");
o.content = o.content.replace(//gi, "
");o.content = o.content.replace(/
o.content = o.content.replace(/
o.content = o.content.replace(/
// Replace empty styles
o.content = o.content.replace(/
o.wordContent = true;
},
paste_postprocess : function(pl, o)
{ //console.log(o.node.innerHTML);
var ed = pl.editor, dom = ed.dom;
// Remove all tags which are not
or
tinymce.each(dom.select('*', o.node), function(el)
{ if (el.tagName.toLowerCase() != "p" && el.tagName.toLowerCase() != "br")
{ dom.remove(el, 1); // 1 = KeepChildren
console.log(el.tagName);
}
dom.setAttrib(el, 'style', '');
});
},