admin管理员组

文章数量:1335107

In CKEditor there are allowedContent and extraAllowedContent options in the config. I understand how allowedContent allows you to say what tags and attributes will be left by the ACF but why is there allowedContent and extraAllowedContent? Don't they do the same thing?

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.

Why? What is the difference?

In CKEditor there are allowedContent and extraAllowedContent options in the config. I understand how allowedContent allows you to say what tags and attributes will be left by the ACF but why is there allowedContent and extraAllowedContent? Don't they do the same thing?

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.

Why? What is the difference?

Share Improve this question asked Oct 26, 2017 at 7:35 texelatetexelate 2,5083 gold badges26 silver badges32 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Setting allowedContent manually instructs the editor to ignore pletely the allowed markup specified by enabled plugins (e.g. the list plugin "registers" <ul> and <li> tags). It may result in removing features from CKEditor. For example if you use the Standard preset and you allow just iframe[*], then most of the buttons will "disappear" (like Bold, List, Table) fro the toolbar, because you no longer allow elements like <strong>, <ul>, <li> and so on.

extraAllowedContent, as the name suggests, lets you extend the list of allowed tags/attributes that CKEditor will allow by default. What CKEditor supports by default directly depends on what features you did enable.

The following link explains it really well: https://docs.ckeditor./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.

It looks like you made a mistake in the code because I just checked that case and it works as expected (the iframe element is left in the content, all other markup is removed, most of the toolbar buttons disappeared).

Last but not least, instead of just enabling the iframe element with extraAllowedContent, consider adding another plugin to CKEditor that correctly handles editing iframes (https://ckeditor./cke4/addon/iframe). If you add it to your build, it will automatically allow <iframe> elements.

本文标签: javascriptWhat is the difference between allowedContent and extraAllowedContent in CKEditorStack Overflow