我一直在尋找的元素屬性沒有任何結果,有誰知道這裏如何忽略和/或替換TinyMCE的元素屬性?忽略/替換TinyMCE的
例如:
<table cellpadding="0" cellspacing="0" class="tdTable" style="margin: 0 20px 0 0;">
我想換成上面的代碼:
<table cellpadding="0" cellspacing="5">
我一直在尋找的元素屬性沒有任何結果,有誰知道這裏如何忽略和/或替換TinyMCE的元素屬性?忽略/替換TinyMCE的
例如:
<table cellpadding="0" cellspacing="0" class="tdTable" style="margin: 0 20px 0 0;">
我想換成上面的代碼:
<table cellpadding="0" cellspacing="5">
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
使用invalid_elements初始化編輯 例如當設定,我使用:
invalid_elements: '@[onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],script,input,select,option,button,textarea,form',
擺脫所有提到的在輸出文本中的元素/屬性
+1好問題 – Thariama