[CKEditor] CK Editor Automatically Adding break <br> tag
Forge component by Matthias Preuter
Published on 25 Aug 2020

Hi everyone, I'm wondering if anyone has experienced this in CKEditor. Everytime I save lines of text from CKEditor field, some of the parts were added <br> tag automatically which mess up the view of my text. I would like to prevent the CKEditor to add the <br> tags automatically. How can I solve this?
Thanks in advance.



Rank: #1346

Hi ,

You can use this code , i hope it was helpful to you.

CKEDITOR.editorConfig = function (config) {
    // Define changes to default configuration here. For example:
    // config.language = 'fr';
    // config.uiColor = '#AADC6E';
    CKEDITOR.on('instanceReady', function (ev) {
        var writer = ev.editor.dataProcessor.writer;
        // The character sequence to use for every indentation step.
        writer.indentationChars = '  ';

        var dtd = CKEDITOR.dtd;
        // Elements taken as an example are: block-level elements (div or p), list items (li, dd), and table elements (td, tbody).
        for (var e in CKEDITOR.tools.extend({}, dtd.$block, dtd.$listItem, dtd.$tableContent)) {
            ev.editor.dataProcessor.writer.setRules(e, {
                // Indicates that an element creates indentation on line breaks that it contains.
                indent: false,
                // Inserts a line break before a tag.
                breakBeforeOpen: false,
                // Inserts a line break after a tag.
                breakAfterOpen: false,
                // Inserts a line break before the closing tag.
                breakBeforeClose: false,
                // Inserts a line break after the closing tag.
                breakAfterClose: false

        for (var e in CKEDITOR.tools.extend({}, dtd.$list, dtd.$listItem, dtd.$tableContent)) {
            ev.editor.dataProcessor.writer.setRules(e, {
                indent: true,