Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ckeditor removes empty tags

There is a problem with CKEditor when the user inserts empty tags:

(in HTML source mode)

<a href="fds" class="doIt"></a>

When he presses on the source and then back again, the tag 'A' is gone. I made a little research, and I found that this happens since there is a very complicated function in ckeditor.js that checks whether there is a value inside the element. If there's none the CKEditor drops the tag.

like image 614
Roy Avatar asked May 05 '26 23:05

Roy


1 Answers

I know this is old, but in CKEDITOR 4.x you can do:

CKEDITOR.dtd.$removeEmpty.ElementHere = 0;

Replace ElementHere with whatever tag you want. Like allowing empty i tags for icons:

CKEDITOR.dtd.$removeEmpty.i = 0;
like image 188
Mauricio Avatar answered May 07 '26 14:05

Mauricio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!