msDead
msDead

Reputation: 45

CKEDITOR.config.allowedContent true don't working

I'm using ckeditor. I want to allow the user to use all inline style that they want.

But when i use CKEDITOR.config.allowedContent = true;, nothing changes and ckeditor change style name with [removed].

Here's what I've tried to do:

config.js

CKEDITOR.editorConfig = function( config ) { };
CKEDITOR.config.allowedContent = true;

I also tried:

CKEDITOR.editorConfig = function( config ) {    
    CKEDITOR.config.allowedContent = true;
};

I cleared the cache after each change, but no luck. When I enter

<p style="text-align: center;"><span style="color:#ff0000">this is for test</span></p>

the result becomes:

<p [removed]="color:#ff0000">this is for test</span></p>

I read many articles, but still no luck. Any suggestions?

Upvotes: 1

Views: 2819

Answers (2)

Wizard
Wizard

Reputation: 3151

Use CKEditor configuration file config.js with allowedContent property set to true (therefore disabling data filtering completely):

CKEDITOR.editorConfig = function( config ) {    
    config.allowedContent = true;
};

Upvotes: 0

Jay Kareliya
Jay Kareliya

Reputation: 770

A simple sample on how to enabled additional markup in CKEditor

CKEDITOR.replace( 'editor1', {
    extraAllowedContent: 'style;*[id,rel](*){*}'
 } );

extraAllowedContent here enables the element, allows two additional attributes (in square brackets) for all (* is a wildcard) already allowed elements, allows usage of any class names (*) for them and allows usage of any inline styles { * }

To allow style tag (style type="text/css">...</style>):

config.extraAllowedContent = 'style';

To allows any class and any inline style.

config.extraAllowedContent = '*(*);*{*}';

I hope it will work for you!!

Upvotes: 1

Related Questions