CKEditor - 如何删除特定属性?
CKEditor - How to remove a specific attribute?
关于如何使用 CKEditor 删除/禁止特定属性的任何想法?
所以在我的例子中,我试图从所有 HTML 元素中删除/禁用所有 "style" 属性(内联 css)。
我正在阅读,虽然没有任何反应,但建议这样做:
config.disallowedContent = 'style';
这是网上找到的另一种方法,同样无效:
config.disallowedContent = 'div[style*]; p[style]; h1[style]; h2[style]'; // etc etc
另一个建议,没有用!
config.disallowedContent = '{style}';
更多"suggestions"欢迎!来吧,我们来算一下这个:)
编辑:为了测试目的,我已经安装了 "Full Package" 的全新安装!
首先你必须允许内容使用对象格式。因为根本就只是声明 config.allowedContent to be equal true will turn off Content Filter 。允许所有带有对象格式的标签的官方 CK 编辑器示例:
config.allowedContent = {
: {
elements: CKEDITOR.dtd,
attributes: true,
styles: true,
classes: true
}
};
第二件事是你不能过滤样式属性,好吧,作为一个属性。 CKEditor 使用模式元素[属性]{样式}(类)。样式元素特别适用于花括号中的模式。
*[*]{height}
将匹配所有元素,例如 style="height:10px"
。要在任何地方完全拒绝样式属性,您可以使用此模式:
*[style]{*}
关于如何使用 CKEditor 删除/禁止特定属性的任何想法?
所以在我的例子中,我试图从所有 HTML 元素中删除/禁用所有 "style" 属性(内联 css)。
我正在阅读,虽然没有任何反应,但建议这样做:
config.disallowedContent = 'style';
这是网上找到的另一种方法,同样无效:
config.disallowedContent = 'div[style*]; p[style]; h1[style]; h2[style]'; // etc etc
另一个建议,没有用!
config.disallowedContent = '{style}';
更多"suggestions"欢迎!来吧,我们来算一下这个:)
编辑:为了测试目的,我已经安装了 "Full Package" 的全新安装!
首先你必须允许内容使用对象格式。因为根本就只是声明 config.allowedContent to be equal true will turn off Content Filter 。允许所有带有对象格式的标签的官方 CK 编辑器示例:
config.allowedContent = {
: {
elements: CKEDITOR.dtd,
attributes: true,
styles: true,
classes: true
}
};
第二件事是你不能过滤样式属性,好吧,作为一个属性。 CKEditor 使用模式元素[属性]{样式}(类)。样式元素特别适用于花括号中的模式。
*[*]{height}
将匹配所有元素,例如 style="height:10px"
。要在任何地方完全拒绝样式属性,您可以使用此模式:
*[style]{*}