Horen
Horen

Reputation: 11382

List items in CKEDITOR.ENTER_BR mode

I am using an instance of CKEditor 4.5.7 that should not allow any <p /> tags.
The config looks like this:

config.enterMode = CKEDITOR.ENTER_BR;
config.forceEnterMode = true;
config.shiftEnterMode = CKEDITOR.ENTER_BR;

Now, when I insert an ordered <ol /> or unordered <ul /> list, I cannot add a second list item because pressing Enter only adds a <br /> inside the <li /> instead of adding a new <li />.

I would like the Enter to insert a new <li />, and Shift+Enter to add a <br /> inside the <li />.

Only when I change the enterMode to CKEDITOR.ENTER_P, I can add new <li /> items, but then the user can add <p /> tags everywhere.

Any help greatly appreciated!

Upvotes: 0

Views: 1008

Answers (1)

Anna Tomanek
Anna Tomanek

Reputation: 2239

In general, using CKEDITOR.ENTER_BR is not recommended and may cause some editor features not to work as expected. If you do it to control paragraph spacing, you should use stylesheets instead.

In your particular case, however, check whether you really need to set config.forceEnterMode to true as this seems to be causing your issue.

Take a look at the Enter Key Configuration sample - with both config.enterMode and config.shiftEnterMode set to CKEDITOR.ENTER_BR it works just as you want it, with Enter creating new list items and Shift+Enter creating a <br /> inside the list item.

Upvotes: 1

Related Questions