Search code examples
djangockeditordjango-ckeditor

django-ckeditor: how to make carrige return insert a <br> instead of a new <p>?


In my CKEditor instances, I need ENTER to insert a <br> instead of a new <p> element, mainly because of the line separation. I found this question in the CKEditor forums and gave it a try (although they talk about fckconfig.js and not config.js), but it didn't work. Also found this question here, but I don't know how to apply the solution.

How can I change this?


Solution

  • Well you can change ckeditor configs. There are two options for changing this config:

    a- 1 for adding <p> tags for enter mode

    b- 2 for adding <br> tags for enter mode

    So you can use this configs in your project's settings.py:

    CKEDITOR_CONFIGS = {
        'default': {
            'enterMode': 2, # 1 for add p tags and 2 for add br tags
        },
    }
    

    Therefore I think you should use 2 as your enter mode option.