开发者

Tinymce initizlising textarea with <> tags

开发者 https://www.devze.com 2023-04-07 05:13 出处:网络
Tinymce editor is 开发者_C百科not rendering editor properly when the content is something like <textarea><p>&lt;sample data&gt;</p></textarea>

Tinymce editor is 开发者_C百科not rendering editor properly when the content is something like

<textarea><p>&lt;sample data&gt;</p></textarea>

i.e. <sample data>.

When I initialize a TinyMCE editor here, I dont see anything as it looks like it assumes <sample data> is an HTML tag.

Please assume I have tinymce.js loaded and I initilize using tinymce.init.

Is there a fix for this? Please let me know if it is a server side fix, or is there a tinymce.init option I could give to fix this problem.

PS: It does look like this is an HTML Entity encoding related issue but I am hardly an expert in this area.


Have a look at the tinymce config parameter entity_encoding.

If this does not work you may use this workaround

// save content
var saved_content = document.getElementById('id_of_my_textarea').innerHTML;

// init the editor
tinyMCE.execCommand('mceAddControl', false, 'id_of_my_textarea');

// after tinymce is fully initialized do
// you should use the tinymce configuration parameter "setup" rather than this code here
tinymce.get('id_of_my_textarea').setContent(saved_content);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号