CKeditor rich text editor displaying html tags in browser

若如初见. 提交于 2019-12-02 07:39:44

If you don't want CKEditor to create paragraphs for you, set config.autoParagraph to false. Additionally you may want to change enter key behaviour with config.enterMode set to CKEDITOR.ENTER_BR.

And regarding disappearing styles...


EDIT: OK, it seems I missed your point.

So your website is displaying HTML markup instead of HTML while rendering out what you typed? Then the problem is your server side rather than CKEditor. You can verify in your console that CKEDITOR.instances.yourInstance.getData() yields the correct, unescaped HTML:

<p>This is text</p> // Right!

If it is so, and I strongly believe it is, CKEditor's just fine and this is your server app that is converting special chars into entities (i.e. like PHP htmlspecialchars) while saving to database. You didn't mention what kind of framework/language you use there, so I can just tell you that it is to secure user input to prevent cross-site scripting, breaking layouts etc. and all popular frameworks allow you to disable that feature for a particular field. Simply refer to documentation.

Modern templating languages tend to autoescape html input. For example, in DTL it would be displayed correctly in the template by simply using {{ object.field_name|safe }} This is a desired action, since user input is considered untrusted and may be considered malicious.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!