This is my D7 module (module name is ckeditor_show_blocks):


 * Implements hook_ckeditor_editor_settings_alter().
function ckeditor_show_blocks_ckeditor_settings_alter(&$settings) {
    $settings['startupOutlineBlocks'] = TRUE;

All it does, it toggles Show Blocks by default on page load in the CKEditor when editing the page/node:

enter image description here

I'm trying to achieve same on D8. I did read some on hooks documentation, and it looked like same, so I didn't change anything, but the module won't apply when in editing mode, what I'm missing? Is hook format different? Does it have something to do with the fact that CKEditor is built-in feature in D8?

There is normal documentation on D7 on how to implement a simple hook module, but not so much about D8.

  • It might be hook_editor_js_settings_alter() in D8: api.drupal.org/api/drupal/… – Jaypan Jun 1 '17 at 12:47
  • Hey @Jaypan thanks for reply, but no effect. – user3108268 Jun 1 '17 at 12:52
  • Did you clear your cache after changing the hook? If so, then yeah, it's probably not the same hook. It will have changed in D8 though, as it's no longer the ckeditor module, but part of core. – Jaypan Jun 1 '17 at 12:53
  • Yes, I did. Also there are two modules editor and ckeditor in core/modules, and the $settings I apply is from ckeditor, are you sure it's the editor_js in the hook to be used? – user3108268 Jun 1 '17 at 12:58
  • No, I'm not sure at all. That's why I put it as a comment, rather than an answer. – Jaypan Jun 1 '17 at 13:08

Considering that the Editor module in Drupal core is the equivalent of the Wysiwyg module for Drupal 7, and the core CkEditor module is the equivalent of the Drupal 7 module with the same name, I would say that the hook you are looking for is hook_editor_js_settings_alter() that, for a module whose machine name is ckeditor_show_blocks, it is implemented from the ckeditor_show_blocks_editor_js_settings_alter() function.

If you need to know the ID of the editor plugin used for a input format, you can get that from $settings['editor']['formats'][$format_id]['editor']; that is the case, for example, when you need to change settings if the used editor is the one implemented by the CkEditor module.

To make it clearer, the Editor module is the module that associate editors to the input formats used from a Drupal 8 site, while the CkEditor module in core contains an implementation of editor.

| improve this answer | |
  • startupOutlineBlocks is called in CKEditor module not in Editor module so I thought hook should be CKEditor's module. I tried your example and many other variations by now and nothing seems to work. – user3108268 Jun 4 '17 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.