Set default headers for CKEditor

Created on 2 June 2025, 6 days ago

Problem/Motivation

CKEditor inserts tables without headers by default.

Then Editoria11y immediately alerts on the header.

But it turns out it may be possible to provide config to CK5 to tell it to automatically have a header row or column β†’ .

Steps to reproduce

Proposed resolution

Try the code linked above:

use Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition;

/**
 * Implements hook_ckeditor5_plugin_info_alter().
 */
function my_module_ckeditor5_plugin_info_alter(array &$plugin_definitions) {
  if (isset($plugin_definitions['ckeditor5_table'])) {
    $table_plugin_definition = $plugin_definitions['ckeditor5_table']->toArray();
    $table_plugin_definition['ckeditor5']['config']['table']['defaultHeadings'] = [
      'rows' => 1,
      'columns' => 1,
    ];
    $plugin_definitions['ckeditor5_table'] = new CKEditor5PluginDefinition($table_plugin_definition);
  }
}

But check that this use statement does not crash sites that do not have CK5 installed. This may need to be reserved for the next version of Editoria11y, as there are still people on CK4.

Remaining tasks

Test snippet, create schema and config, test what happens if CK5 isn't installed and see if there is a way to make a hook / use statement optional or if this would need to be a sidecar module.

User interface changes

New config...

✨ Feature request
Status

Active

Version

2.2

Component

Feature and test requests

Created by

πŸ‡ΊπŸ‡ΈUnited States itmaybejj

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024