Search code examples
tinymcetinymce-5

Getting rid of the excess elements that TinyMCE inserts into text


I've noticed that when using TinyMCE 5 inline it inserts a load of extra elements that I really don't want.

<span id="_mce_caret" data-mce-bogus="1" data-mce-type="format-caret">H</span><sup>2</sup>O

what I'd expect is

H<sup>2</sup>O

Is there any way within Tiny to stop doing this? Alternatively I supose I could get it to remove all the excess before submitting the form.


Solution

  • How are you getting the content from TinyMCE? The various data-mce-xxxx attributes are internal markers used during the editing process but they should not be returned when using getContent().

    If I create a simple TinyMCE Fiddle and create content with the two characters as either superscript or subscript I don't get this extra markup when extracting the content:

    https://fiddle.tiny.cloud/57haab