diff --git a/CHANGELOG.md b/CHANGELOG.md index b9eabc7e..a8a8edc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - It’s now possible to set the “Config Options” setting to a JS or JSON file within `config/ckeditor/`. ([#540](https://github.com/craftcms/ckeditor/pull/540)) - It’s now possible to set the “Custom Styles” setting to a CSS file within `config/ckeditor/`. ([#540](https://github.com/craftcms/ckeditor/pull/540)) - The v5 migration now automatically creates JS/JSON/CSS files within `config/ckeditor/` for any Config Options/Custom Styles from CKEditor Configs that were used by two or more fields. ([#540](https://github.com/craftcms/ckeditor/pull/540)) +- Fixed an error that could occur when registering a custom CKEditor plugin. ([#531](https://github.com/craftcms/ckeditor/issues/531)) ## 5.2.1 - 2026-03-18 diff --git a/src/helpers/CkeditorConfig.php b/src/helpers/CkeditorConfig.php index 55ee8ac1..6e7c9335 100644 --- a/src/helpers/CkeditorConfig.php +++ b/src/helpers/CkeditorConfig.php @@ -215,7 +215,12 @@ public static function registerPackage(string $name, array $config): void $plugins = $config['plugins'] ?? []; $toolbarItems = $config['toolbarItems'] ?? []; - self::$pluginsByPackage[$name] = $plugins; + if (!isset(self::$pluginsByPackage[$name])) { + self::$pluginsByPackage[$name] = $plugins; + } else { + self::$pluginsByPackage[$name] = array_unique(array_merge(self::$pluginsByPackage[$name], $plugins)); + } + self::$toolbarItems[] = $toolbarItems; self::$pluginButtonMap[] = [ 'plugins' => $plugins,