TinyMCE从<span>和<i>元素中删除类

时间:2016-08-08 21:24:18

标签: tinymce font-awesome wysiwyg tinymce-4 glyphicons

在TinyMCE的代码(源代码)编辑器中,当我想在类中添加一些 span i 元素时(例如,当我想添加Font Awesome图标时) ) - TinyMCE删除类。例如,如果我想添加:

<span class="fa fa-university"></span>

最后我会:

<span></span>

此外,在源代码编辑器中,我尝试添加<i class="fa fa-university"></i>,但问题是相同的 - TinyMCE(<i></i>)删除了类。

我正在使用TinyMCE v4.4.1,这些是我的设置:

tinymce.init({
    selector: '#body',
    height: 500,
    theme: 'modern',
    plugins: [
        'advlist autolink lists link image charmap preview hr anchor pagebreak',
        'searchreplace wordcount visualblocks visualchars code fullscreen',
        'insertdatetime media nonbreaking save table contextmenu directionality',
        'emoticons template paste textcolor colorpicker textpattern codesample fontawesome noneditable'
    ],
    toolbar1: 'insertfile undo redo | formatselect fontselect fontsizeselect fontawesome',
    toolbar2: 'bold italic underline strikethrough forecolor backcolor removeformat superscript subscript | alignleft aligncenter alignright alignjustify | outdent indent',
    toolbar3: 'code preview | link unlink anchor image media | codesample | bullist numlist table blockquote hr nonbreaking | charmap emoticons | visualchars visualblocks',
    image_advtab: true,
    relative_urls: false,
    extended_valid_elements: 'span',
    content_css: '/css/all.css' // this includes fontwawesome...
});

2 个答案:

答案 0 :(得分:9)

尝试将以下内容添加到您的TinyMCE配置中:

valid_elements: "*[*]"

当我这样做时,我可以毫无问题地添加你引用的<span>

答案 1 :(得分:1)

我知道这是一个老问题,但这对我有用

extended_valid_elements: 'span[*]'