Jump to content

CKEditor and extra allowed content


AAD Web Team
 Share

Recommended Posts

I have the following code in my config.js file. All of it works except the 'extraAllowedContent' line. I realise there is an 'Extra allowed content' option within the settings for individual fields (and if I add p(tip) to that it works perfectly), but I was hoping I might be able to set up some global allowed classes.

Any ideas why my config.extraAllowedContent = 'p(tip)'; line might not work?

CKEDITOR.editorConfig = function( config ) {
	// Define changes to default configuration here. For example:
	// config.uiColor = '#AADC6E';
	config.coreStyles_italic = { element: 'i' };
	config.disallowedContent = '*{*}'; // All inline styles disallowed
	config.extraAllowedContent = 'p(tip)';
	config.language_list = [ 'la:Latin' ];
};

I can of course use config.allowedContent instead, but then I have to specify each and every allowed element. I was hoping to use the default allowed content and then just add some classes. According to the CKEditor documentation this should be possible, so I'm wondering if ProcessWire is overriding this setting somehow. Or perhaps I haven't done it correctly?

Given you helped me with my previous CKEditor question, @Robin S, I'm wondering if you might know the answer?

Thanks!

Margaret

Link to comment
Share on other sites

21 minutes ago, AAD Web Team said:

Any ideas why my config.extraAllowedContent = 'p(tip)'; line might not work?

I think you may need a semicolon inside the quotes.

config.extraAllowedContent = 'p(tip);';

The CKEditor docs are not 100% clear about when semicolons are needed but you can see them included in some sample code here: https://docs.ckeditor.com/ckeditor4/latest/guide/dev_advanced_content_filter.html#custom-mode

  • Like 1
Link to comment
Share on other sites

Great tip, thanks, but unfortunately it hasn't made any difference...

2 minutes ago, Robin S said:

I think you may need a semicolon inside the quotes.


config.extraAllowedContent = 'p(tip);';

The CKEditor docs are not 100% clear about when semicolons are needed but you can see them included in some sample code here: https://docs.ckeditor.com/ckeditor4/latest/guide/dev_advanced_content_filter.html#custom-mode

 

Link to comment
Share on other sites

I've just worked out a possible workaround, and that is to add classes to the styles drop-down in the toolbar. Once they're on there, they're allowed.

However, I'm still curious if there's a solution to my query here, because it seems like it should work.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...