Cannot disable colorPicker for the FontColor plugin

Created on 26 September 2024, about 2 months ago

Problem/Motivation

When trying to use the hook_ckeditor5_plugin_info_alter hook to alter CKEditor5 configs of the fontColor plugin, we can't disable the colorPicker because the getDynamicPluginConfig function in the font color plugin is always overriding the static plugin config with the following code:
$static_plugin_config['fontColor']['colorPicker']['format'] = 'hex';

Steps to reproduce

Using the following code, the color picker of the font background color plugin will be disabled successfully but not with the font color plugin.

/**
 * Implements hook_ckeditor5_plugin_info_alter().
 */
function custom_module_ckeditor5_plugin_info_alter(array &$plugin_definitions) {
  assert($plugin_definitions['ckeditor5_plugin_pack_font__font_color'] instanceof CKEditor5PluginDefinition);
  $color_plugin_definition = $plugin_definitions['ckeditor5_plugin_pack_font__font_color']->toArray();
  $color_plugin_definition['ckeditor5']['config']['fontColor']['colorPicker'] = FALSE;
  $color_plugin_definition['ckeditor5']['config']['fontBackgroundColor']['colorPicker'] = FALSE;
  $plugin_definitions['ckeditor5_plugin_pack_font__font_color'] = new CKEditor5PluginDefinition($color_plugin_definition);
}

Proposed resolution

In the getDynamicPluginConfig function of the font color plugin, we should first check if the colorPicker property has been set to FALSE, if that's the case, we shouldn't set a format for the colorPicker config object

🐛 Bug report
Status

Active

Version

1.2

Component

Code

Created by

🇦🇺Australia peterwcm

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024