TinyMCE mang lại chức năng này trong vòng dom.parser của nó:
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)
}
});
Bạn có thể cũng áp dụng thay đổi cho toàn bộ mảng:
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);
});
Xem ở đây cho một tài liệu đầy đủ các chức năng: http://www.tinymce.com/wiki.php/API3:namespace.tinymce.dom
+1 câu hỏi hay – Thariama