我一直在搜索没有任何结果,这里有没有人知道如何在
例如:
<table cellpadding="0" cellspacing="0" class="tdTable" style="margin: 0 20px 0 0;">
我想将上面的代码替换为:
<table cellpadding="0" cellspacing="5">
答案 0 :(得分:3)
tinyMCE在其dom.parser中提供此功能:
tinyMCE.activeEditor.dom.Serializer.addAttributeFilter('class,style', function(nodes, name) {
for (var i = 0; i < nodes.length; i++) {
console.log(nodes[i].name);
tinyMCE.dom.setAttrib(nodes[i], 'class', null);
tinyMCE.dom.setAttrib(nodes[i], 'style', null);
// Process the nodes here (e.g. set attribute to null or delete Attribute)
}
});
您还可以对整个阵列应用更改:
tinyMCE.activeEditor.dom.Serializer.addAttributeFilter('class', function(nodes, name) {
tinyMCE.dom.setAttrib(nodes, 'class', null);
});
tinyMCE.activeEditor.dom.Serializer.addAttributeFilter('style', function(nodes, name) {
tinyMCE.dom.setAttrib(nodes, 'style', null);
});
请在此处查看功能的完整文档: http://www.tinymce.com/wiki.php/API3:namespace.tinymce.dom
答案 1 :(得分:1)
初始化编辑器时使用invalid_elements设置 例如,我使用:
invalid_elements: '@[onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],script,input,select,option,button,textarea,form',
删除输出文本中提到的所有元素/属性