Search code examples
javascriptphphtmltinymce

TinyMCE Removing HTML Elements


I'm writing contents that has example HTML tags in it.

I've already tried all these attributes:

tinyMCE.init({
    // ...
       cleanup: false,
       cleanup_on_startup: false,
       verify_html: false,
       extended_valid_elements : '*[*]',
});

After saving, everything is OK: After Saving

But when I reopen it, TinyMCE deletes all the HTML tags in my text: reopen


Solution

  • How is the content being stored in your database?

    If you want to use a code example that includes HTML, you must use HTML entities for your < and >. If you don't do this, it will be interpreted as actual HTML.

    &lt;title&gt;Example Title&lt;/title&gt;
    

    Also, have you looked into TinyMCE's Code Sample plugin to show code examples? https://www.tiny.cloud/docs/plugins/opensource/codesample/