tinymce code inserting, can't get it to work -


i enabled codesample plugin https://www.tinymce.com/docs/plugins/codesample/ , test entered head tag

first

and displays in editor

second

when save database gets saved this:

<pre class="language-markup"><code>&lt;head&gt;</code></pre> 

when reload page in editor

<pre>&nbsp;</pre> 

database still looks

<pre class="language-markup"><code>&lt;head&gt;</code></pre> 

but there no head tag visible in editor. ideas why?

when placing raw html <textarea> need escape html code placing in <textarea>. not doing browser (and proxy tinymce) "cleaning up" invalid markup best can.

you can either:

  1. properly escape html
  2. use setcontent() api load html tinymce (as opposed injecting html <textarea>)

i suggest second option above eliminates vagaries of injecting html <textarea>.

if want try first solution listed above might if using php

<?php   $content = "this string contains tm symbol: &trade;";   print "<textarea>". htmlentities($content) ."</textarea>"; ?> 

every language have used has equivalent htmlentities().


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -