Subject: CKEditor removing empty tags automatically

Posted on: 07/12/17 01:51am
By: alb3rt

I insert html content contain the <i> elements. I do this with the CKEditor. Everything works when I add "&nbsp;" and the content shows up on the webpage. But when i want to edit the previously inserted content, the <i> elements are missing.

For example:

PHP Formatted Code
<i class="fa fa-map-marker fa-2x"> </i>


I tried add this lines to the config.js (/public_html/editors/ckeditor/ckeditor.js) but not works

PHP Formatted Code
CKEDITOR.dtd.$removeEmpty['i'] = false;


PHP Formatted Code
config.protectedSource.push(/<i[^>]*><\/i>/g);


PHP Formatted Code
CKEDITOR.dtd.$removeEmpty['b'] = false;

Re: CKEditor removing empty tags automatically

Posted on: 07/12/17 06:58am
By: Laugh

Do the solutions on any of these pages work?

https://stackoverflow.com/questions/18261198/ckeditor-removing-empty-span-automatically

https://drupal.stackexchange.com/questions/198783/ckeditor-strips-i-tags

Re: CKEditor removing empty tags automatically

Posted on: 09/12/17 02:52am
By: alb3rt

I solved it. It is necessary to add the following lines to the file (~/editors/ckeditor/config.js) between ... CKEDITOR.editorConfig = function( config ) { ... }
PHP Formatted Code

config.protectedSource.push(/<i[^>]*><\/i>/g);  // <i></i>
config.protectedSource.push(/<span[^>]*><\/span>/g);  //<span></span>
 


And clean the browser cache (Important).

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=96661