Ignore / replace element attributes in TinyMCE

I was looking for results without any results, does anyone know how to ignore and / or replace element attributes in TinyMCE?

For instance:

<table cellpadding="0" cellspacing="0" class="tdTable" style="margin: 0 20px 0 0;">

I would like to replace the above code with:

<table cellpadding="0" cellspacing="5">
+5
source share
2 answers

tinyMCE supports this functionality inside its 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)
        }
    });

You can also apply the change to the entire array:

    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);
    });

See here for full feature documentation: http://www.tinymce.com/wiki.php/API3:namespace.tinymce.dom

+3
source

invalid_elements , :

invalid_elements: '@[onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],script,input,select,option,button,textarea,form',

/

+1

All Articles