1 ckeditor5.api.php hook_ckeditor5_config_alter(array &$config, $format)

Modify the CKEditor settings passed to the editor.

Parameters

array $config: The array of settings that will be passed to CKEditor.

object $format: The filter format object containing this editor's settings.

Related topics

File

core/modules/ckeditor5/ckeditor5.api.php, line 153
Documentation for CKEditor module APIs.

Code

function hook_ckeditor5_config_alter(array &$config, $format) {
  // If the heading.Heading plugin is installed, remove <h6> from the list of
  // the possible headings.
  if (!empty($config['heading']['options']) && is_array($config['heading']['options'])) {
    if (!empty($format->editor_settings['heading_list'])) {
      $heading_list = $format->editor_settings['heading_list'];

      if (is_array($heading_list) && in_array('h6', $heading_list)) {
        foreach ($config['heading']['options'] as $index => $possible_heading) {
          if ($possible_heading['model'] === 'heading6') {
            unset($config['heading']['options'][$index]);
          }
        }
      }
    }
  }
}