From 2d2c47dd88ab45bf01ee8fd661d2b275893a19bd Mon Sep 17 00:00:00 2001 From: Alexey Aleev Date: Wed, 31 May 2023 22:23:59 +0200 Subject: [PATCH] [DS-724] Add color font and background color buttons to the CKEditor 5 panel --- composer.json | 8 ++++++++ .../config/install/editor.editor.full_html.yml | 2 ++ openy_editor/openy_editor.info.yml | 1 + openy_editor/openy_editor.install | 17 +++++++++++++++++ 4 files changed, 28 insertions(+) diff --git a/composer.json b/composer.json index 50868b19..3113e49d 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,16 @@ "drupal/core": "^9.5 || ^10", "drupal/rabbit_hole": "^1.0@beta || ^1.0", "drupal/ctools": ">=3.13", + "drupal/ckeditor5_font": "^1.1@beta", "drupal/google_analytics": "^4.0.2" }, + "extra": { + "patches": { + "drupal/ckeditor5_font": { + "Issue #3350333: TypeError: array_filter(): Argument #1 ($array) must be of type array.": "https://www.drupal.org/files/issues/2023-04-21/3350333-5.patch" + } + } + }, "license": "GPL-2.0+", "minimum-stability": "dev" } diff --git a/openy_editor/config/install/editor.editor.full_html.yml b/openy_editor/config/install/editor.editor.full_html.yml index f3c0f1b4..50602bad 100644 --- a/openy_editor/config/install/editor.editor.full_html.yml +++ b/openy_editor/config/install/editor.editor.full_html.yml @@ -15,6 +15,8 @@ settings: - underline - strikethrough - alignment + - fontColor + - fontBackgroundColor - outdent - indent - heading diff --git a/openy_editor/openy_editor.info.yml b/openy_editor/openy_editor.info.yml index c843ef23..d08a9921 100644 --- a/openy_editor/openy_editor.info.yml +++ b/openy_editor/openy_editor.info.yml @@ -8,6 +8,7 @@ dependencies: - colorbutton:colorbutton - ckeditor_bootstrap_buttons:ckeditor_bootstrap_buttons - drupal:ckeditor5 + - drupal:ckeditor5_font - drupal:editor - ckeditor_font:ckeditor_font - drupal:filter diff --git a/openy_editor/openy_editor.install b/openy_editor/openy_editor.install index 9b2d838c..37c51b37 100644 --- a/openy_editor/openy_editor.install +++ b/openy_editor/openy_editor.install @@ -66,3 +66,20 @@ function openy_editor_update_8004() { $active_config->set('settings.plugins', $active_config->get('settings.plugins')); $active_config->save(TRUE); } + +/** + * Add the fontColor and the fontBackgroundColor buttons for CKEditor 5. + */ +function openy_editor_update_8005() { + $active_config = \Drupal::configFactory()->getEditable('editor.editor.full_html'); + $settings = $active_config->get('settings'); + if (empty($settings['toolbar']['rows'])) { + return; + } + // Place these buttons in a specific place. + array_splice($settings['toolbar']['items'], 3, 0, 'fontColor'); + array_splice($settings['toolbar']['items'], 4, 0, 'fontBackgroundColor'); + $active_config->set('settings', $settings); + $active_config->set('settings.plugins', $active_config->get('settings.plugins')); + $active_config->save(TRUE); +}