Here is a little code snippet to be added in a .module file.
/**
* Implements hook_editor_js_settings_alter().
*
* {@inheritdoc}
*/
function MODULE_editor_js_settings_alter(array &$settings) {
foreach ($settings['editor']['formats'] as $name => $value) {
// Use
instead of on enter.
// See: https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR.html#property-ENTER_BR.
// CKEditor natively converts double
into
on rendering.
$settings['editor']['formats'][$name]['editorSettings']['enterMode'] = '2';
}
}
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.