CKeditor允许内容行为奇怪 [英] CKeditor allowedContent behaving oddly
问题描述
我试图限制CKEditor在源和wysiwyg模式之间切换时的HTML编辑行为。目前,当我从源切换到wysiwyg时,编辑器删除添加到< span>
标签的任何属性。它不会与任何其他标签重复此行为。
我设置了 CKEDITOR.config.allowedContent = true;
,以及在自定义插件中注册的 allowedContent:'span [*]'
。 allowedContent设置阻止了编辑器完全删除标记,但属性仍然被删除。
code>< div class =float_right_caption_dropstyle =width:243px>
< span style =width:233px;>
< img class =float_imgsrc =/ images / fox.jpgwidth =233border =0alt =/>
< br /> Fox Caption< / span>< / div>这是因为style code>和
class
属性不会被高级内容过滤器作为其他属性处理 - 它们在允许的内容规则中具有特定的格式。您可以在允许的内容规则指南中找到ACR的详细说明。但总之,允许所有的属性,样式和类你需要设置:allowedContent:'span [*] {* }(*)'
如果正确设置
allowedContent = true
,那么您的区间将不会被过滤。Im trying to limit the html editing behavior of CKEditor when switching between source and wysiwyg mode. Currently when I switch from source to wysiwyg the editor removes any attributes added to
<span>
tags. It does not repeat this behavior with any other tags.I've set
CKEDITOR.config.allowedContent = true;
, as well as registeredallowedContent: 'span[*]'
, in a custom plugin. The allowedContent setting prevented the editor from removing the tag entirely, but attributes are still stripped away. The entirety of the code I'm trying to perserve is below.Thanks!
<div class="float_right_caption_drop" style="width: 243px"> <span style="width: 233px;"> <img class="float_img" src="/images/fox.jpg" width="233" border="0" alt="" /> <br />Fox Caption</span></div>
解决方案That's because
style
andclass
attributes are not handled by Advanced Content Filter as other attributes - they have their specific format in Allowed Content Rules. You can find a detailed description of ACRs in Allowed Content Rules guide. But in short - to allow all attributes, styles and classes you need to set:allowedContent: 'span[*]{*}(*)'
PS. If you set
allowedContent = true
correctly, then your spans wouldn't be filtered at all.这篇关于CKeditor允许内容行为奇怪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!