ckeditor removes <br/> when br is in allowed content

安稳与你 提交于 2020-01-02 06:51:44

问题


When I add br to ckeditor allowed content and adding <br> tag it is being changed into <br /> But when I add <br/> it is being removed.

Why is it being removed when br is in allowed content? Any suggestions?


回答1:


There are some bits missing from your post, not sure why, or what you were trying to say.

If what you were saying is that you wanted to add, say, clear="all" to your <br /> tags, you can use this to update your allowed content:

config.AllowedContent = "br[clear]";

Separate individual elements with ;.

Here is the reference to the AllowedContent rules in the documentation:

http://docs.ckeditor.com/#!/guide/dev_allowed_content_rules

I keep this bit in comments above my AllowedContent declaration as a reminder:

elements [attributes]{styles}(classes)

If that's not what you were asking, forgive me, again, there are some parts missing from your post. If you can update it and let me know I'll revisit this answer.

== EDIT ==

Ok, I just looked at the edit of the post, and it seems you had "naked" <br /> tags in your question, which turned into actual line breaks.

What you're seeing is that the editor is forcing valid HTML. BR tags should always be formatted as such: <br /> (notice the space)



来源:https://stackoverflow.com/questions/25163537/ckeditor-removes-br-when-br-is-in-allowed-content

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