How to allow some custom tag in tinymce editor

2019-08-15 02:09发布

问题:

when i pest a html code inside tinymce editor my < figure> tag remove by this editor.

how to allow this tag in tinymce editor.

<ul>
<li>
    <div class="list-top">
        <figure>1</figure>
        <div class="list-top-right">
            <h3>It's Competitive Out There</h3>
        </div>
    </div>      
</li>
</ul>

it convert into

<ul>
<li>
    <div class="list-top">
        1
        <div class="list-top-right">
            <h3>It's Competitive Out There</h3>
        </div>
    </div>      
</li>
</ul>

Just remove this <figure>1</figure> tag

回答1:

Use .html() in jquery

$("ul li").html(function(i,h){ 
         return h.replace(/<figure>/g,'').replace(/<\/figure>/g,'');
}); 

FIDDLE



回答2:

You need to tell TinyMCE to treat figure as valid element.

Use this option: http://www.tinymce.com/wiki.php/Configuration:extended_valid_elements