Jump to content

Extra Allowed Content | CKEditor strips i tag and classes


electricarts
 Share

Recommended Posts

Hi,

what do i have to do, to allow the i tag and the h4 class in the CKEditor? In the Extra Allowed Content box (setup field -> input) i wrote "i(*);h4(*)". But when i type 

<h4 class="uk-panel-title"><i class="uk-icon-credit-card-alt"></i>Unsere Bankverbindung:</h4>

the CKEditor still strips the complete i tag and the h4 class from the source. 

Mario

Link to comment
Share on other sites

You can also add your personal styles in site->modules->InputfieldCKEditor->mystyle.js

Example:

CKEDITOR.stylesSet.add( 'mystyles', [
 { name: 'Credit Card Icon', element: 'i', attributes: {'class': 'uk-icon-credit-card-alt'} },
 { name: 'Panel Title', element: 'h4', attributes: {'class': 'uk-panel-title'} },
]);

You could now select on-demand which <i> and <h4> you want to apply those styles.

  • Like 2
Link to comment
Share on other sites

Hi.

Maybe HTML purifier and ACF (CKEditor Advanced Content Filter) is stripping all unrecognized or not permitted html.

You can test this, unchecking this option's in in the "Input" tab for the specific field.

Be careful with this because those filter's are there for security/standarization reason's; if you uncheck them you give plenty power to the user's to ruin your html Layout.

(This could be overcome with a good CSS+HTML encapsulation of the content)

Hope this help's.

Link to comment
Share on other sites

Hi,

i tried everything i found about this issue (here and with a Google search). Nothing helped. I unchecked ACF and HTML purifier. I added the i tag to the Format Tags section under field->Input->CKEditor Settings. This made the field unusable (the field in the backend was empty after). I used wildcards 

i[*]{*}(*)

in the Extra Allowed Content box. Didn't work.

In the end i made a Hanna Code snippet. This worked and is maybe the better and more secure solution. But it drives me crazy to not know what i'm doing wrong.  :(

Link to comment
Share on other sites

No, i didn't found this. Thanks for the link!

That means, i've to write this

config.allowedContent = true;
config.extraAllowedContent = 'p(*)[*]{*};div(*)[*]{*};li(*)[*]{*};ul(*)[*]{*}';
CKEDITOR.dtd.$removeEmpty.i = 0; 

directly in the config.js and there's no way to use entries in the Input section of the field to achieve this? 

Link to comment
Share on other sites

I don't know if there is a better way to achieve the same result,I had (for a previous project) to insert :

CKEDITOR.editorConfig = function( config ) {
	// Define changes to default configuration here. For example:
	config.protectedSource.push(/<i[^>]*><\/i>/g);
	config.enterMode = CKEDITOR.ENTER_BR; // I added this because I didn't want a new <p> tag on every new line, <br /> instead.
};

CKEDITOR.dtd.$removeEmpty['i'] = false

 inside site\modules\InputfieldCKEditor\config-body.js (you shoud already have that file there).

To be honest I don't know why this is necessary and doesn't work by default, but as far as I know it's not related to processwire, rather by Ckeditor itself.

  • Like 4
Link to comment
Share on other sites

  • 8 months later...
  • 2 years later...

Sorry to dig out this posting but I have a similar issue:

I tried allowing "button(*)[*]{*}" or "button" or "button(*)" or "button[*]" but Processwire still strips out this html:

<button aria-expanded="false" aria-haspopup="true" class="dlbutton dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" type="button"><span class="sr-only">Toggle Dropdown</span></button>

 

The "fun" part: When inserting above in CKEDitor html source code view and pressing OK, it is still there but when I actually save the page, it gets wiped out.

Any help would be very much appreciated.

Link to comment
Share on other sites

5 hours ago, bartelsmedia said:

The "fun" part: When inserting above in CKEDitor html source code view and pressing OK, it is still there but when I actually save the page, it gets wiped out.

 

Maybe HTML Purifier is at work? CKEditor makes changes when closing its source code editor but HTML Purifier makes changes right before saving the data.

  • Like 1
Link to comment
Share on other sites

You were right. I tried the HTMLPurifier Demo and it removes the button html:

http://htmlpurifier.org/demo.php

Quote

Error Line 4, Column 1: Unrecognized <button type="button" class="btn btn-lg dlbutton disabled btn-success dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> tag removed

Strange, that it doesn't like buttons.

  • Like 1
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

×
×
  • Create New...