Crasher
Crasher

Reputation: 2514

Tinymce wrongly rewriting HTML

I have a custom button that insert some HTML in the editor

enter image description here

First block of code is the button action and the second one is how the HTML is inserted

Any idea why it is rewriting it that way and how to stop it?

Upvotes: 0

Views: 187

Answers (2)

Crasher
Crasher

Reputation: 2514

I just managed to fix it, in the init function:

valid_children : 'pre[code]'

Upvotes: 1

Michael Fromin
Michael Fromin

Reputation: 13726

TinyMCE includes the ability to insert code samples into the editor via its Code Sample plugin:

https://www.tinymce.com/docs/plugins/codesample/

If you want to try to do this yourself you need to do a few things like using the protect configuration option to tell TinyMCE to allow your PHP tags. See this TinyMCE Fiddle for a basic example:

http://fiddle.tinymce.com/Qdgaab

Upvotes: 0

Related Questions