Welcome to Geeklog, Anonymous Friday, March 29 2024 @ 08:45 am EDT

Geeklog Forums

CKEditor removing empty tags automatically


Status: offline

alb3rt

Forum User
Regular Poster
Registered: 10/30/06
Posts: 71
Location:Mexico City
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:

Text 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

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


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


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

D Web Studio - www.d-webstudio.net
 Quote

Status: offline

Laugh

Site Admin
Admin
Registered: 09/27/05
Posts: 1468
Location:Canada

Status: offline

alb3rt

Forum User
Regular Poster
Registered: 10/30/06
Posts: 71
Location:Mexico City
I solved it. It is necessary to add the following lines to the file (~/editors/ckeditor/config.js) between ... CKEDITOR.editorConfig = function( config ) { ... }
Text Formatted Code

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


And clean the browser cache (Important).
D Web Studio - www.d-webstudio.net
 Quote

Phil_69

Anonymous
I had the same problem with the <a> tag and resolved it. But in my case, the closing tag was on the next line. So I had to change the filter :
Text Formatted Code
config.protectedSource.push(/<i[^>]*><\/i>/g);

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

For the others tags this hack seems to work :
Text Formatted Code
$j.each(CKEDITOR.dtd.$removeEmpty, function (i, value) {
    CKEDITOR.dtd.$removeEmpty[i] = false;
});

But not for the <a> tag !
 Quote

Status: offline

alb3rt

Forum User
Regular Poster
Registered: 10/30/06
Posts: 71
Location:Mexico City
This work for me:

Text Formatted Code
<a>&nbsp;</a>


And in gl 2.2.0 I use:

Text Formatted Code
config.protectedSource.push(/\[i[\s\S]+?\/i\]/g);
 

D Web Studio - www.d-webstudio.net
 Quote

All times are EDT. The time is now 08:45 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content