[Drupal] Change CKEditor behaviour for line breaks (br or p)

Here is a little code snippet to be added in a .module file.

Additional Information

  • Instructions made on Drupal 8.5.x.
  • Will break text align buttons in the CKEditor toolbar: Issue on Drupal.org
  • The default behaviour of CKEditor is the following:
    • Enter: inserts a paragraph directly in the WYSIWYG,
    • Shift + Enter: inserts a line break.
  • The new behaviour of CKEditor with the hook will be:
    • Enter: inserts a single line break (br),
    • 2 × Enter: inserts two line breaks which will be converted into a paragraph when rendered.

Published by Dakwamine

Dakwamine, alias Quang-Minh Dang, né en 1987 en région parisienne. Un type sympa, pas bavard et pragmatique.