Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CKEditor remove spaces/tabs from between headings

CKEditor does this whenever I add a heading tag:

<h2>
    Mai 2010</h2>

How can I remove the new line and spaces after the h2 starting tag, please?

like image 975
Francisc Avatar asked Sep 04 '10 20:09

Francisc


2 Answers

The way to do this without modifying CKEditor's source is to do the following:

CKEDITOR.on( 'instanceReady', function( ev )
   {
      ev.editor.dataProcessor.writer.setRules( 'p',
         {
            indent : false,
            breakBeforeOpen : true,
            breakAfterOpen : false,
            breakBeforeClose : false,
            breakAfterClose : true
         });
   }); 

For more information see:

http://cksource.com/forums/viewtopic.php?f=6&t=14493 http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Output_Formatting

like image 111
Johnny Avatar answered Nov 08 '22 15:11

Johnny


This is the default CKEDITOR behavior for a lot of tag. To avoid it, open the ckeditor.js file and search for this: n.setRules('title',{indent:false,breakAfterOpen:false}); and add this rule: n.setRules('h2',{indent:false,breakAfterOpen:false}); You can add this rule for each tag you want

like image 28
Paolo Avatar answered Nov 08 '22 14:11

Paolo