7

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?

Francisc
  • 77,430
  • 63
  • 180
  • 276

2 Answers2

20

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

Johnny
  • 201
  • 2
  • 3
1

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

Paolo
  • 100
  • 5
  • Thank you! Is there a way to do this from the PHP config `side` rather than editing the CORE files? – Francisc Oct 19 '10 at 15:07
  • I'd also like to know how to do this via PHP config – designosis Sep 26 '11 at 11:36
  • 3
    Changing the source of plugins/libraries is not appropriate. Because when someone else upgrades a library in your application, someone else will have to figure out why an existing functionality broke. – cherouvim Dec 01 '11 at 16:13