防止 CKEditor 删除样式属性中的无效样式声明
有什么方法可以阻止 CKEditor 删除元素中损坏/无效的样式声明。
我们有一些用户对 margin
、widths
等使用了无效值。基本上他们忽略了值的测量单位,如下例所示:
<p style="margin-left: 5; margin-top: 2; margin-bottom: 2">...</p>
CKEditor
删除了从源视图切换到设计视图时的错误声明。有什么办法可以阻止这种情况吗?
我理解为什么它被删除,我同意为什么它被删除,但它已成为允许这样做的要求。基本上,我们希望 CKEditor 尽可能多地保留用户输入的内容,即使它是错误的
Is there any way to prevent CKEditor
from removing broken/invalid style declarations from elements.
We have some users that have used invalid values for things like margins
, widths
, etc. Basically they leave out the unit of measurement of the value like the following example:
<p style="margin-left: 5; margin-top: 2; margin-bottom: 2">...</p>
CKEditor
removes the incorrect declaration when switching from source view to design view. Is there any way to stop this?
I understand why it is removed, I agree with why it is removed however it has become a requirement to allow this. Basically we want CKEditor
to leave as much of what a user enters untouched even if it is wrong
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 CKEditor 描述的
“它是一个所见即所得的编辑器,这意味着在其上编辑的文本看起来与用户发布时的结果尽可能相似”。
我认为您只需向需要设置样式和样式的元素添加一个
class
会更容易在你的外在css
文件。如果你有不同的内容和不同的风格,你可以这样做
As CKEditor describes
"It's a WYSIWYG editor, which means that the text being edited on it looks as similar as possible to the results users have when publishing it".
I think it will be easier for you to just add a
class
to the element that you need to style and style it in your externalcss
file.If you got different contents with dirrefent styles you can do something like this