6

I've using CKEditor for updating CMS content on my website. I also using FontAwesome, which includes set of fancy icons, that can be displayed like this

<i class="icon-envelope"></i>

The problem is that CKEditor escapes this i tag on client side, and I can't see it in source mode.

How can I allow this tag? I have tried with CONFIG.removeFormatTags = '', but unfortunately it does not do the job.

dzona
  • 3,323
  • 3
  • 31
  • 47
  • i came across the same problem , read here for a solution http://stackoverflow.com/a/18254082/1316372 – HenryW Aug 15 '13 at 15:15

3 Answers3

9

It is removed because it is empty. Put some non-breaking space &nbsp; or zero-width space &#8203; within it to preserve your tag.

You can also remove i from CKEDITOR.dtd.$removeEmpty object. This may, however, break other empty <i> tags without class="icon-envelope". To fix this you would need to play with a data processor to filter empty <i>'s without class="icon-envelope". Pretty easy I guess.

oleq
  • 15,697
  • 1
  • 38
  • 65
  • 1
    Shouldn't this be handled already via config.fillEmptyBlocks which is set to true by default? How does one edit the CKEDITOR.dtd.$removeEmpty object to remove the i element? I can't find it listed as being removed anywhere in js files. I'd like to edit the fillEmptyBlocks function to use ​ instead of the non-breaking space. The spacing of icons in font-awesome is only correct when the element remains empty or uses ​ – secondman Apr 09 '13 at 19:26
0

below worked for me.. thanks to Vince Kronlein pointing out config.fillEmptyBlocks

CKEDITOR.editorConfig = function( config ) {
       config.fillEmptyBlocks="&#8203;";  
}
CKEDITOR.dtd.$removeEmpty['span'] = false;
CKEDITOR.dtd.$removeEmpty['i'] = false;
0

You can use unicode of &zwnj; in situation of html code showing in CKEditor for making Zero-width non-joiner (mini-space) in languages like persian.

می‌خواهم می‌توانم

keivan kashani
  • 1,263
  • 14
  • 15