TinyMCE stacks classes

妖精的绣舞 提交于 2020-03-03 07:44:09

问题


I'm using TinyMCE 4 as my default editor. In the config I specified style formats. This works excuistly except for one thing: it stacks classes.

My style format:

style_formats: [
        { title: 'Heading 2', block: 'h2', classes: 'heading-02' },
        { title: 'Heading 3', block: 'h3', classes: 'heading-03' },
        { title: 'Heading 4', block: 'h4', classes: 'heading-04' },
        { title: 'Heading 5', block: 'h5', classes: 'heading-05' },
        { title: 'Text', block: 'p', classes: 'copy-02' },
    ],

After selecting text and switching between format, the end result looks like this:

<h4 class="heading-02 heading-03 heading-04">example</h4>

Obviously there should be no other classes than heading-04 alone. But non the less it adds them anyways.

My question therefore is, how can I make sure there is only 1 class after a format switch.


回答1:


Add style_formats_merge: true

style_formats_merge

This option allows you to set whether TinyMCE should append the styles in the style_formats setting to the default style formats or completely replace them.

Source



来源:https://stackoverflow.com/questions/39640053/tinymce-stacks-classes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!