TinyMCE: when I save the content, my HTML code changes. How can I save my HTML?

I use format parameter to initialize tinymce to use b-, i- and u-tags instead of spans and styles

formats: {
    bold : {inline : 'b' },  
    italic : {inline : 'i' },
    underline: { inline: 'u' }
},

When I save the contents, the u-tags are replaced with spaces (i- and b-tags are not affected):

<span style="text-decoration: underline;">underlined text</span>

What can I do to save u tags in html?

+3
source share
1 answer

After some “attempts and errors”, I found a solution that works. But I'm sure there is a more elegant way. Feel free to point me in the right direction. My solution is to replace the new span back with a u-tag in the onSave event:

ed.onSaveContent.add(function(ed, o) {
    o.content = o.content.replace(/<span style="text-decoration: ?underline;">(.*?)<\/span>/gi, "<u>$1</u>");   
});

legacyoutput. , , legacyplugin , , .

+2

Source: https://habr.com/ru/post/1785174/


All Articles