在ckeditor中删除特殊标签
Deled special tgas inckeditor
我在 ckeditor 的长文本字段中加入了这行代码:
<div style="width:100%"> <canvas id="canvas3"></canvas></div>
但是当我保存然后删除并替换为:
<div style="width:100%"> </div>
所以全部删除:我用来显示图形。有什么办法解决吗?
谢谢
您需要在 config.js
中添加 config.extraAllowedContent = 'canvas[*]{*}(*)';
。基本上 none 的现有插件已向高级内容过滤器 (ACF) 报告了 canvas
元素,因此它们被删除了。此过滤器可让您决定在编辑器中可以使用哪些标签、属性、样式和 类。
添加后,请切换到源代码模式。如果 canvas
在那里,则意味着 CKEditor 已修复并且不再删除该标签。如果标签尽管在编辑器中,但仍未保存在您的数据库中,请检查您的服务器端代码是否存在潜在的 HTML 过滤器。
如果您想了解更多关于 ACF 的信息,请参阅:
- https://docs.ckeditor.com/ckeditor4/latest/guide/dev_acf.html
- https://docs.ckeditor.com/ckeditor4/latest/guide/dev_advanced_content_filter.html
- https://ckeditor.com/docs/ckeditor4/latest/guide/dev_disallowed_content.html
- https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-allowedContent
- https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-extraAllowedContent
- https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-disallowedContent
- https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_filter.html#method-addTransformations
我在 ckeditor 的长文本字段中加入了这行代码:
<div style="width:100%"> <canvas id="canvas3"></canvas></div>
但是当我保存然后删除并替换为:
<div style="width:100%"> </div>
所以全部删除:我用来显示图形。有什么办法解决吗? 谢谢
您需要在 config.js
中添加 config.extraAllowedContent = 'canvas[*]{*}(*)';
。基本上 none 的现有插件已向高级内容过滤器 (ACF) 报告了 canvas
元素,因此它们被删除了。此过滤器可让您决定在编辑器中可以使用哪些标签、属性、样式和 类。
添加后,请切换到源代码模式。如果 canvas
在那里,则意味着 CKEditor 已修复并且不再删除该标签。如果标签尽管在编辑器中,但仍未保存在您的数据库中,请检查您的服务器端代码是否存在潜在的 HTML 过滤器。
如果您想了解更多关于 ACF 的信息,请参阅:
- https://docs.ckeditor.com/ckeditor4/latest/guide/dev_acf.html
- https://docs.ckeditor.com/ckeditor4/latest/guide/dev_advanced_content_filter.html
- https://ckeditor.com/docs/ckeditor4/latest/guide/dev_disallowed_content.html
- https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-allowedContent
- https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-extraAllowedContent
- https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-disallowedContent
- https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_filter.html#method-addTransformations