Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ckeditor removing empty span automatically

Tags:

i am using ckeditor and i have vary strange issue.

it remove automatically empty <span> for example

 <span class="new-class"></span>

removed automatically.

i am searching for solution for last 2 days but no success. i try to put following code in

config.js

CKEDITOR.config.allowedContent = true;

but no success.

i also add following code in html where i use ckeditor but no success.

   <script>     
var editor = CKEDITOR.replace( 'editor1', {
allowedContent: true,
    } );
   </script>    

thanks

like image 711
air Avatar asked Aug 15 '13 20:08

air


2 Answers

I am using Django CMS 3, CKEditor 4.3 and I got the same problem using twitter bootstrap glyphicon. Looking at : http://ckeditor.com/forums/Support/Prevent-removal-of-empty-span-tags#forum-topic-top.

To allow empty span tag, I have added at the end of ckeditor/config.js

CKEDITOR.dtd.$removeEmpty.span = 0;
like image 111
Patrick Avatar answered Sep 26 '22 13:09

Patrick


I came across this thread with the same problem and thought I'd post my solution. I didn't want CKEditor to remove any blank elements. Add the following to the bottom of your config.js file:

    $.each(CKEDITOR.dtd.$removeEmpty, function (i, value) {
        CKEDITOR.dtd.$removeEmpty[i] = false;
    });
like image 42
Jonathan Carter Avatar answered Sep 24 '22 13:09

Jonathan Carter