CKEditor 中的 allowedContent 和 extraAllowedContent 有什么区别?

What is the difference between allowedContent and extraAllowedContent in CKEditor?

在 CKEditor 中,配置中有 allowedContentextraAllowedContent 选项。我理解 allowedContent 如何允许您说出 ACF 将留下哪些标签和属性,但为什么会有 allowedContentextraAllowedContent?他们不也是这样吗?

我发现的一件事是,当想要允许 iframe 时,它​​似乎只有在将 iframe[*] 放入 extraAllowedContent 时才有效;如果你把它放在 allowedContent.

中,它不起作用

为什么?有什么区别?

手动设置 allowedContent 指示编辑器完全忽略启用插件指定的允许标记(例如列表插件 "registers" <ul><li> 标签)。它可能会导致从 CKEditor 中删除功能。例如,如果您使用标准预设并且只允许 iframe[*],那么工具栏中的大多数按钮将 "disappear"(如粗体、列表、Table),因为您不再允许<strong><ul><li> 等元素。

顾名思义,

extraAllowedContent 允许您扩展 CKEditor 默认允许的 tags/attributes 列表。 CKEditor 默认支持什么直接取决于你启用了哪些功能。

下面的link解释得很好:https://docs.ckeditor.com/ckeditor4/docs/#!/guide/dev_acf

One thing I have found is when wanting to allow iframes it only seems to work if you put iframe[*] in extraAllowedContent; it does not work if you put it in allowedContent.

看起来你在代码中犯了一个错误,因为我刚刚检查了那个案例并且它按预期工作(iframe 元素留在内容中,所有其他标记被删除,大部分工具栏按钮消失)。

最后但同样重要的是,考虑向 CKEditor 添加另一个插件以正确处理编辑 iframe (https://ckeditor.com/cke4/addon/iframe),而不是仅启用带有 extraAllowedContent 的 iframe 元素。如果将它添加到构建中,它将自动允许 <iframe> 个元素。