Asked 7 years ago
18 Sep 2017
Views 1891
yogi

yogi posted

CKEditor strips span tag , how to avoid it ?

CKEditor Standard Package strips span tag which is empty like this

<span class="tittle-line"></span>

i put allowedContent to true

          $(function () {  
          CKEDITOR.replace('desc',{
      allowedContent: true,
    autoGrow_onStartup: true,
    enterMode: CKEDITOR.ENTER_BR
      });         
        });
    



and than i tried
extraAllowedContent : "span(*)"


        $(function () {  
          CKEDITOR.replace('tPageDesc',{
   
   extraAllowedContent : "span(*)",
   allowedContent: true,
    autoGrow_onStartup: true,
    enterMode: CKEDITOR.ENTER_BR
      });         
        });

still it strips span tag
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

CKEDITOR.dtd.$removeEmpty.span solve your issue to strips <span> tag . it will say CKEDITOR not to remove empty span tag .


  $(function () {  
          CKEDITOR.replace('desc',{
     allowedContent: true,
    autoGrow_onStartup: true,
    enterMode: CKEDITOR.ENTER_BR
      });         
      CKEDITOR.dtd.$removeEmpty.span = 0;
      CKEDITOR.dtd.$removeEmpty.i = 0; 
        });


same for <i> tag ,
CKEDITOR.dtd.$removeEmpty.i = 0;
above code will not strip <i> tag in CKEDITOR
Post Answer