Search code examples
angularckeditor

In Angular, how to insert <div> instead of <p> when enter is pressed in CKeditor?


I have tried using

config = {
    height: 250,
    enterMode: 'CKEDITOR.ENTER_DIV',
  };
}

But this doesn't work. It still puts a paragraph tag instead of the div tag in the source.

What am I missing here -

https://stackblitz.com/edit/ckeditor-3efz3n?file=app%2Fapp.component.ts


Solution

  • You sholw not use it as a string there is no meaning to CKEDITOR.ENTER_DIV. You should import the value from the source code or use the number 3

    If you would like to import:

    config = {
        height: 250,
        enterMode: CKEDITOR.ENTER_DIV, // It's a variable not a string like in the question
      };
    }
    

    Or without import you can do it will fix your issue:

    config = {
        height: 250,
        enterMode: 3
      };
    }
    

    I have found the number 3 in The ckEditor source code.