Problem/Motivation
Currently, Drupal\ckeditor\Plugin\Editor\CKEditor::getJSSettings()
uses a +
operator to combine the configuration arrays provided by plugins. In the event there are identical keys, the first instance is honored, not the last. Drupal's Internal plugin sets some config by default:
/**
* {@inheritdoc}
*/
public function getConfig(Editor $editor) {
// Reasonable defaults that provide expected basic behavior.
$config = [
// Don't load CKEditor's config.js file.
'customConfig' => '',
'pasteFromWordPromptCleanup' => TRUE,
'resize_dir' => 'vertical',
'justifyClasses' => ['text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'],
'entities' => FALSE,
'disableNativeSpellChecker' => FALSE,
];
...
return $config;
}
This means that another plugin, such as the one provided by CKEditor custom config, cannot override the 'pasteFromWordPromptCleanup' config option.
I'm filing this as a bug report, because of the following comment in Drupal\ckeditor\Plugin\CKEditorPlugin\Internal::getConfig()
:
// Reasonable defaults that provide expected basic behavior.
The language shows a clear intent to provide defaults, not to hard-code these values.
Proposed resolution
Use array_merge()
to combine the arrays instead.
Remaining tasks
Submit patch.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
In versions of Drupal prior to 8.8.0, it was not possible to override CKEditor default configuration provided by the Internal plugin. In the event multiple plugins provided configuration with the same key, the first instance was honored. Beginning in Drupal 8.8.0, the last instance is now honored.