6

I am using CKEditor and what it does is add by default a <p> at the beginning of the content.

Even if I set enterMode to be <br/>, it will only affect what the Enter key does, and keep the starting <p>.

The problem I have with that is that if a text starts with an <img> tag, it will wrap the <p> around that and the float:left on the image has no effect anymore.

How can I stop the default <p> from showing please?

Francisc
  • 77,430
  • 63
  • 180
  • 276

4 Answers4

9

Was looking for the answer to this question also and found this link helped: http://cksource.com/forums/viewtopic.php?f=11&t=15467&hilit=prevent+%3Cp%3E

So adding this to your config.js file works:

CKEDITOR.editorConfig = function( config )
{
    config.enterMode = CKEDITOR.ENTER_BR;
};
SMSidat
  • 1,163
  • 1
  • 15
  • 34
  • Thank you. Is there anyway of doing this from the PHP side of the config? – Francisc Mar 14 '11 at 09:57
  • That the enclosing p is removed with this is only a side effect. It's actually for changing the behaviour when the user presses return. – Leif May 09 '12 at 08:57
  • I've tried this way, but the first p tag is still exists.. so, what should I do to change that to div or br? – Bobby Stenly Mar 20 '13 at 03:37
4

MAKE THIS YOUR config.js file code

CKEDITOR.editorConfig = function( config ) {

   //   config.enterMode = 2; //disabled <p> completely
        config.enterMode = CKEDITOR.ENTER_BR // pressing the ENTER KEY input <br/>
        config.shiftEnterMode = CKEDITOR.ENTER_P; //pressing the SHIFT + ENTER KEYS input <p>
        config.autoParagraph = false; // stops automatic insertion of <p> on focus
    };
Timothy Nwanwene
  • 995
  • 11
  • 18
2

This solution worked for me, put it in config.js:

config.enterMode = 2;
Martin
  • 3,018
  • 1
  • 26
  • 45
prabhatjn
  • 21
  • 1
0
        CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;
Mirko MyRent
  • 111
  • 1
  • 4