diff --git a/core/modules/ckeditor5/ckeditor5.ckeditor5.yml b/core/modules/ckeditor5/ckeditor5.ckeditor5.yml index 09d5f8ec59..3a457be0a1 100644 --- a/core/modules/ckeditor5/ckeditor5.ckeditor5.yml +++ b/core/modules/ckeditor5/ckeditor5.ckeditor5.yml @@ -391,7 +391,7 @@ ckeditor5_horizontalLine: -
ckeditor5_alignment: - ckeditor5: &alignment_ckeditor5_section + ckeditor5: plugins: [alignment.Alignment] config: # @see core/modules/system/css/components/align.module.css @@ -405,60 +405,17 @@ ckeditor5_alignment: className: text-align-right - name: justify className: text-align-justify - drupal: &alignment_drupal_section + drupal: label: Alignment library: core/ckeditor5.alignment admin_library: ckeditor5/admin.alignment + class: Drupal\ckeditor5\Plugin\CKEditor5Plugin\Alignment toolbar_items: alignment: label: Text alignment elements: - <$text-container class="text-align-left text-align-center text-align-right text-align-justify"> -ckeditor5_alignment.left: - ckeditor5: *alignment_ckeditor5_section - drupal: - label: Align left - toolbar_items: - "alignment:left": - label: Align left - elements: - - <$text-container class="text-align-left"> - <<: *alignment_drupal_section - -ckeditor5_alignment.center: - ckeditor5: *alignment_ckeditor5_section - drupal: - label: Align center - toolbar_items: - "alignment:center": - label: Align center - elements: - - <$text-container class="text-align-center"> - <<: *alignment_drupal_section - -ckeditor5_alignment.right: - ckeditor5: *alignment_ckeditor5_section - drupal: - label: Align right - toolbar_items: - "alignment:right": - label: Align right - elements: - - <$text-container class="text-align-right"> - <<: *alignment_drupal_section - -ckeditor5_alignment.justify: - ckeditor5: *alignment_ckeditor5_section - drupal: - label: Justify - toolbar_items: - "alignment:justify": - label: Justify - elements: - - <$text-container class="text-align-justify"> - <<: *alignment_drupal_section - ckeditor5_removeFormat: ckeditor5: plugins: [removeFormat.RemoveFormat] diff --git a/core/modules/ckeditor5/ckeditor5.post_update.php b/core/modules/ckeditor5/ckeditor5.post_update.php new file mode 100644 index 0000000000..bb82debc76 --- /dev/null +++ b/core/modules/ckeditor5/ckeditor5.post_update.php @@ -0,0 +1,53 @@ +getEditor() !== 'ckeditor5') { + return FALSE; + } + + $needs_update = FALSE; + // Only update if the editor is using the non-dropdown buttons. + $settings = $editor->getSettings(); + $old_alignment_buttons_to_types = [ + 'alignment:left' => 'left', + 'alignment:right' => 'right', + 'alignment:center' => 'center', + 'alignment:justify' => 'justify', + ]; + if (is_array($settings['toolbar']['items'])) { + foreach ($old_alignment_buttons_to_types as $button => $type) { + if (in_array($button, $settings['toolbar']['items'], TRUE)) { + $settings['toolbar']['items'] = array_values(array_diff($settings['toolbar']['items'], [$button])); + $settings['plugins']['ckeditor5_alignment']['enabled_alignments'][] = $type; + if (!in_array('alignment', $settings['toolbar']['items'], TRUE)) { + $settings['toolbar']['items'][] = 'alignment'; + } + // Flag this display as needing to be updated. + $needs_update = TRUE; + } + } + } + if ($needs_update) { + $editor->setSettings($settings); + } + return $needs_update; + }; + + $config_entity_updater->update($sandbox, 'editor', $callback); +} diff --git a/core/modules/ckeditor5/config/schema/ckeditor5.schema.yml b/core/modules/ckeditor5/config/schema/ckeditor5.schema.yml index 3a154b310f..b7c670a683 100644 --- a/core/modules/ckeditor5/config/schema/ckeditor5.schema.yml +++ b/core/modules/ckeditor5/config/schema/ckeditor5.schema.yml @@ -87,6 +87,27 @@ ckeditor5.plugin.ckeditor5_sourceEditing: SourceEditingRedundantTags: [] SourceEditingPreventSelfXssConstraint: [] +# Plugin \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Alignment +ckeditor5.plugin.ckeditor5_alignment: + type: mapping + label: Alignments + mapping: + enabled_alignments: + type: sequence + label: 'Enabled Alignments' + constraints: + NotBlank: + message: "Enable at least one alignment, otherwise disable the Alignment button." + sequence: + type: string + label: 'Alignment type' + constraints: + Choice: + - left + - center + - right + - justify + # Plugin \Drupal\ckeditor5\Plugin\CKEditor5Plugin\ListPlugin ckeditor5.plugin.ckeditor5_list: type: mapping diff --git a/core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Core.php b/core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Core.php index 39b2097e4e..25e132222a 100644 --- a/core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Core.php +++ b/core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Core.php @@ -59,6 +59,7 @@ * }, * cke5_plugin_elements_subset_configuration = { * "ckeditor5_heading", + * "ckeditor5_alignment", * "ckeditor5_list", * "media_media", * } @@ -73,6 +74,7 @@ class Core extends PluginBase implements CKEditor4To5UpgradePluginInterface { * {@inheritdoc} */ public function mapCKEditor4ToolbarButtonToCKEditor5ToolbarItem(string $cke4_button, HTMLRestrictions $text_format_html_restrictions): ?array { + static $alignment_mapped; switch ($cke4_button) { // @see \Drupal\ckeditor\Plugin\CKEditorPlugin\DrupalImage case 'DrupalImage': @@ -103,16 +105,14 @@ public function mapCKEditor4ToolbarButtonToCKEditor5ToolbarItem(string $cke4_but return ['blockQuote']; case 'JustifyLeft': - return ["alignment:left"]; - case 'JustifyCenter': - return ["alignment:center"]; - case 'JustifyRight': - return ["alignment:right"]; - case 'JustifyBlock': - return ["alignment:justify"]; + if (!isset($alignment_mapped)) { + $alignment_mapped = TRUE; + return ['alignment']; + } + return NULL; case 'HorizontalRule': return ['horizontalLine']; @@ -228,6 +228,37 @@ public function computeCKEditor5PluginSubsetConfiguration(string $cke5_plugin_id } return $configuration; + case 'ckeditor5_alignment': + $alignment_classes_to_types = [ + 'text-align-left' => 'left', + 'text-align-right' => 'right', + 'text-align-center' => 'center', + 'text-align-justify' => 'justify', + ]; + $restrictions = $text_format->getHtmlRestrictions(); + if ($restrictions === FALSE) { + // The default is to allow all alignments. This makes sense when there + // are no restrictions. + // @see \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Alignment::DEFAULT_CONFIGURATION + return NULL; + } + // Otherwise, enable alignment types based on the provided restrictions. + // I.e. if a tag is found with a text-align-{alignment type} class, + // activate that alignment type. + $configuration = []; + foreach ($restrictions['allowed'] as $tag) { + $classes = isset($tag['class']) && is_array($tag['class']) ? $tag['class'] : []; + foreach (array_keys($classes) as $class) { + if (isset($alignment_classes_to_types[$class])) { + $configuration['enabled_alignments'][] = $alignment_classes_to_types[$class]; + } + } + } + if (isset($configuration['enabled_alignments'])) { + $configuration['enabled_alignments'] = array_unique($configuration['enabled_alignments']); + } + return $configuration; + case 'ckeditor5_list': $restrictions = $text_format->getHtmlRestrictions(); if ($restrictions === FALSE) { diff --git a/core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Alignment.php b/core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Alignment.php new file mode 100644 index 0000000000..7a3a8af494 --- /dev/null +++ b/core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Alignment.php @@ -0,0 +1,125 @@ + [ + 'left', + 'center', + 'right', + 'justify', + ], + ]; + + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + return static::DEFAULT_CONFIGURATION; + } + + /** + * {@inheritdoc} + * + * Form for choosing which alignment types are available. + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $form['enabled_alignments'] = [ + '#type' => 'fieldset', + '#title' => $this->t('Enabled Alignments'), + '#description' => $this->t('These are the alignment types that will appear in the alignment dropdown.'), + ]; + + foreach ($this->getPluginDefinition()->getCKEditor5Config()['alignment']['options'] as $alignment_option) { + $name = $alignment_option['name']; + $form['enabled_alignments'][$name] = [ + '#type' => 'checkbox', + '#title' => $this->t($name), + '#return_value' => $name, + '#default_value' => in_array($name, $this->configuration['enabled_alignments'], TRUE) ? $name : NULL, + ]; + } + + return $form; + } + + /** + * {@inheritdoc} + */ + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { + // Match the config schema structure at ckeditor5.plugin.ckeditor5_alignment. + $form_value = $form_state->getValue('enabled_alignments'); + $config_value = array_values(array_filter($form_value)); + $form_state->setValue('enabled_alignments', $config_value); + } + + /** + * {@inheritdoc} + */ + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { + $this->configuration['enabled_alignments'] = $form_state->getValue('enabled_alignments'); + } + + /** + * {@inheritdoc} + * + * Filters the alignment options to those chosen in editor config. + */ + public function getDynamicPluginConfig(array $static_plugin_config, EditorInterface $editor): array { + $enabled_alignments = $this->configuration['enabled_alignments']; + $all_alignment_options = $static_plugin_config['alignment']['options']; + + $configured_alignment_options = array_filter($all_alignment_options, function ($option) use ($enabled_alignments) { + return in_array($option['name'], $enabled_alignments, TRUE); + }); + + return [ + 'alignment' => [ + 'options' => array_values($configured_alignment_options), + ], + ]; + } + + /** + * {@inheritdoc} + */ + public function getElementsSubset(): array { + $enabled_alignments = $this->configuration['enabled_alignments']; + $plugin_definition = $this->getPluginDefinition(); + $all_elements = $plugin_definition->getElements(); + $subset = HTMLRestrictions::fromString(implode($all_elements)); + foreach ($plugin_definition->getCKEditor5Config()['alignment']['options'] as $configured_alignment) { + if (!in_array($configured_alignment['name'], $enabled_alignments, TRUE)) { + $element_string = '<$text-container class=' . '"' . $configured_alignment["className"] . '"' . '>'; + $subset = $subset->diff(HTMLRestrictions::fromString($element_string)); + } + } + return $subset->toCKEditor5ElementsArray(); + } + +} diff --git a/core/modules/ckeditor5/tests/fixtures/update/ckeditor5-3259593.php b/core/modules/ckeditor5/tests/fixtures/update/ckeditor5-3259593.php new file mode 100644 index 0000000000..5c485aba07 --- /dev/null +++ b/core/modules/ckeditor5/tests/fixtures/update/ckeditor5-3259593.php @@ -0,0 +1,54 @@ +select('config') + ->fields('config', ['data']) + ->condition('collection', '') + ->condition('name', 'core.extension') + ->execute() + ->fetchField(); +$extensions = unserialize($extensions); +$extensions['module']['ckeditor5'] = 0; +$connection->update('config') + ->fields(['data' => serialize($extensions)]) + ->condition('collection', '') + ->condition('name', 'core.extension') + ->execute(); + +$test_format_format = Yaml::decode(file_get_contents(__DIR__ . '/filter.format.test_format.yml')); +$connection->insert('config') + ->fields([ + 'collection', + 'name', + 'data', + ]) + ->values([ + 'collection' => '', + 'name' => 'filter.format.test_format', + 'data' => serialize($test_format_format), + ]) + ->execute(); + +$test_format_editor = Yaml::decode(file_get_contents(__DIR__ . '/editor.editor.test_format.yml')); +$connection->insert('config') + ->fields([ + 'collection', + 'name', + 'data', + ]) + ->values([ + 'collection' => '', + 'name' => 'editor.editor.test_format', + 'data' => serialize($test_format_editor), + ]) + ->execute(); diff --git a/core/modules/ckeditor5/tests/fixtures/update/editor.editor.test_format.yml b/core/modules/ckeditor5/tests/fixtures/update/editor.editor.test_format.yml new file mode 100644 index 0000000000..341c532c88 --- /dev/null +++ b/core/modules/ckeditor5/tests/fixtures/update/editor.editor.test_format.yml @@ -0,0 +1,22 @@ +uuid: f962b8c7-4c74-4100-b6de-08e6a65ff43d +langcode: en +status: true +dependencies: + config: + - filter.format.test_format + module: + - ckeditor5 +format: test_format +editor: ckeditor5 +settings: + toolbar: + items: + - link + - bold + - italic + - 'alignment:center' + - sourceEditing + plugins: + ckeditor5_sourceEditing: + allowed_tags: { } +image_upload: { } diff --git a/core/modules/ckeditor5/tests/fixtures/update/filter.format.test_format.yml b/core/modules/ckeditor5/tests/fixtures/update/filter.format.test_format.yml new file mode 100644 index 0000000000..e47cd4d3c5 --- /dev/null +++ b/core/modules/ckeditor5/tests/fixtures/update/filter.format.test_format.yml @@ -0,0 +1,17 @@ +uuid: 343a36d6-5852-45f5-b4de-437551cb9caf +langcode: en +status: true +dependencies: { } +name: 'Test format' +format: test_format +weight: 0 +filters: + filter_html: + id: filter_html + provider: filter + status: true + weight: -10 + settings: + allowed_html: '

' + filter_html_help: true + filter_html_nofollow: false diff --git a/core/modules/ckeditor5/tests/src/Functional/Update/CKEditor5UpdateAlignmentTest.php b/core/modules/ckeditor5/tests/src/Functional/Update/CKEditor5UpdateAlignmentTest.php new file mode 100644 index 0000000000..eef8096080 --- /dev/null +++ b/core/modules/ckeditor5/tests/src/Functional/Update/CKEditor5UpdateAlignmentTest.php @@ -0,0 +1,62 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../../system/tests/fixtures/update/drupal-9.3.0.filled.standard.php.gz', + __DIR__ . '/../../fixtures/update/ckeditor5-3259593.php', + ]; + } + + /** + * Tests that CKEditor 5 alignment configurations that are individual buttons + * are updated to be in dropdown form in the toolbar. + */ + public function testUpdateAlignmentButtons() { + $editor = Editor::load('test_format'); + $settings = $editor->getSettings(); + $this->assertContains('alignment:center', $settings['toolbar']['items']); + + $this->runUpdates(); + + $expected_toolbar_items = [ + 'link', + 'bold', + 'italic', + 'sourceEditing', + 'alignment', + ]; + $expected_alignment_plugin = [ + 'enabled_alignments' => [ + 'center', + ], + ]; + $editor = Editor::load('test_format'); + $settings = $editor->getSettings(); + $this->assertEquals($expected_toolbar_items, $settings['toolbar']['items']); + $this->assertEquals($expected_alignment_plugin, $settings['plugins']['ckeditor5_alignment']); + } + +} diff --git a/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php b/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php index 747633aee7..2363bde9af 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php @@ -1119,11 +1119,11 @@ public function testEnabledPlugins() { // Case 7: GHS is enabled for other text editors if they are using a // CKEditor 5 plugin that uses wildcard tags. - $settings['toolbar']['items'][] = 'alignment:center'; + $settings['toolbar']['items'][] = 'alignment'; $editor->setSettings($settings); $plugin_ids = array_keys($this->manager->getEnabledDefinitions($editor)); $expected_plugins = array_merge($expected_plugins, [ - 'ckeditor5_alignment.center', + 'ckeditor5_alignment', 'ckeditor5_wildcardHtmlSupport', ]); sort($expected_plugins); diff --git a/core/modules/ckeditor5/tests/src/Kernel/ConfigurablePluginTest.php b/core/modules/ckeditor5/tests/src/Kernel/ConfigurablePluginTest.php index f35ad49dd1..73af339187 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/ConfigurablePluginTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/ConfigurablePluginTest.php @@ -71,6 +71,14 @@ public function testDefaults() { 'reversed' => TRUE, 'startIndex' => TRUE, ], + 'ckeditor5_alignment' => [ + 'enabled_alignments' => [ + 0 => 'left', + 1 => 'center', + 2 => 'right', + 3 => 'justify', + ], + ], 'ckeditor5_imageResize' => [ 'allow_resize' => TRUE, ], diff --git a/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php b/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php index 7ff22ce7a8..bd085b940d 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php @@ -752,14 +752,19 @@ public function provider() { 'toolbar' => [ 'items' => array_merge( array_slice($basic_html_test_case['expected_ckeditor5_settings']['toolbar']['items'], 0, -1), - [ - 'alignment:center', - 'alignment:justify', - ], + ['alignment'], array_slice($basic_html_test_case['expected_ckeditor5_settings']['toolbar']['items'], -1) ), ], - 'plugins' => $basic_html_test_case['expected_ckeditor5_settings']['plugins'], + 'plugins' => array_merge( + array_slice($basic_html_test_case['expected_ckeditor5_settings']['plugins'], 0, 1), + [ + 'ckeditor5_alignment' => [ + 'enabled_alignments' => ['center', 'justify'], + ], + ], + array_slice($basic_html_test_case['expected_ckeditor5_settings']['plugins'], 1), + ), ], 'expected_superset' => implode(' ', [ // Note that aligning left and right is being added, on top of what the @@ -779,7 +784,7 @@ public function provider() { 'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'], 'expected_messages' => array_merge_recursive($basic_html_test_case['expected_messages'], [ 'status' => [ - 'The following plugins were enabled to support specific attributes that are allowed by this text format: Align center ( for tag: <p> to support: class with value(s): text-align-center), Justify ( for tag: <p> to support: class with value(s): text-align-justify).', + 'The following plugins were enabled to support specific attributes that are allowed by this text format: Alignment ( for tag: <p> to support: class with value(s): text-align-center, text-align-justify).', 'This format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported by this text format, the following were added to the Source Editing plugin\'s Manually editable HTML tags: <a hreflang> <blockquote cite> <ul type> <ol type> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>.', ], ]), diff --git a/core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php b/core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php index 0545022456..af09958ad5 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php @@ -745,7 +745,7 @@ public function providerPair(): array { 'settings.plugins.ckeditor5_sourceEditing.allowed_tags.1' => 'The following tag(s) are already supported by available plugins and should not be added to the Source Editing "Manually editable HTML tags" field. Instead, enable the following plugins to support these tags: Table (<table>).', 'settings.plugins.ckeditor5_sourceEditing.allowed_tags.3' => 'The following attribute(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Language (<span lang>).', 'settings.plugins.ckeditor5_sourceEditing.allowed_tags.5' => 'The following tag(s) are already supported by available plugins and should not be added to the Source Editing "Manually editable HTML tags" field. Instead, enable the following plugins to support these tags: Code Block (<code class="language-*">).', - 'settings.plugins.ckeditor5_sourceEditing.allowed_tags.6' => 'The following attribute(s) are already supported by available plugins and should not be added to the Source Editing "Manually editable HTML tags" field. Instead, enable the following plugins to support these attributes: Alignment (<h2 class="text-align-center">), Align center (<h2 class="text-align-center">).', + 'settings.plugins.ckeditor5_sourceEditing.allowed_tags.6' => 'The following attribute(s) are already supported by available plugins and should not be added to the Source Editing "Manually editable HTML tags" field. Instead, enable the following plugins to support these attributes: Alignment (<h2 class="text-align-center">).', ], ]; $data['INVALID some invalid Source Editable tags provided by plugin and another available in a not enabled plugin'] = [ diff --git a/core/modules/ckeditor5/tests/src/Kernel/WildcardHtmlSupportTest.php b/core/modules/ckeditor5/tests/src/Kernel/WildcardHtmlSupportTest.php index 85623982b4..1e9b93f8be 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/WildcardHtmlSupportTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/WildcardHtmlSupportTest.php @@ -57,7 +57,7 @@ public function testGhsConfiguration(string $filter_html_allowed, array $source_ ], ], ])->save(); - $editor = Editor::create([ + $editor_config = [ 'editor' => 'ckeditor5', 'format' => 'test_format', 'settings' => [ @@ -73,7 +73,14 @@ public function testGhsConfiguration(string $filter_html_allowed, array $source_ 'image_upload' => [ 'status' => FALSE, ], - ]); + ]; + if (in_array('alignment', $additional_toolbar_items, TRUE)) { + $editor_config['settings']['plugins']['ckeditor5_alignment'] = [ + 'enabled_alignments' => ['left', 'center', 'right', 'justify'], + ]; + } + + $editor = Editor::create($editor_config); $editor->save(); $this->assertSame([], array_map( function (ConstraintViolation $v) { diff --git a/core/modules/ckeditor5/tests/src/Unit/AlignmentPluginTest.php b/core/modules/ckeditor5/tests/src/Unit/AlignmentPluginTest.php new file mode 100644 index 0000000000..6e3ef192a3 --- /dev/null +++ b/core/modules/ckeditor5/tests/src/Unit/AlignmentPluginTest.php @@ -0,0 +1,117 @@ + [ + Alignment::DEFAULT_CONFIGURATION, + [ + 'alignment' => [ + 'options' => [ + [ + 'name' => 'left', + 'className' => 'text-align-left', + ], + [ + 'name' => 'center', + 'className' => 'text-align-center', + ], + [ + 'name' => 'right', + 'className' => 'text-align-right', + ], + [ + 'name' => 'justify', + 'className' => 'text-align-justify', + ], + ], + ], + ], + ], + 'No alignments allowed' => [ + [ + 'enabled_alignments' => [], + ], + [ + 'alignment' => [ + 'options' => [], + ], + ], + ], + 'Left only' => [ + [ + 'enabled_alignments' => [ + 'left', + ], + ], + [ + 'alignment' => [ + 'options' => [ + [ + 'name' => 'left', + 'className' => 'text-align-left', + ], + ], + ], + ], + ], + 'Left and justify only' => [ + [ + 'enabled_alignments' => [ + 'left', + 'justify', + ], + ], + [ + 'alignment' => [ + 'options' => [ + [ + 'name' => 'left', + 'className' => 'text-align-left', + ], + [ + 'name' => 'justify', + 'className' => 'text-align-justify', + ], + ], + ], + ], + ], + ]; + } + + /** + * @covers ::getDynamicPluginConfig + * @dataProvider providerGetDynamicPluginConfig + */ + public function testGetDynamicPluginConfig(array $configuration, array $expected_dynamic_config): void { + // Read the CKEditor 5 plugin's static configuration from YAML. + $ckeditor5_plugin_definitions = Yaml::parseFile(__DIR__ . '/../../../ckeditor5.ckeditor5.yml'); + $static_plugin_config = $ckeditor5_plugin_definitions['ckeditor5_alignment']['ckeditor5']['config']; + + $plugin = new Alignment($configuration, 'ckeditor5_alignment', NULL); + $dynamic_plugin_config = $plugin->getDynamicPluginConfig($static_plugin_config, $this->prophesize(EditorInterface::class) + ->reveal()); + + $this->assertSame($expected_dynamic_config, $dynamic_plugin_config); + } + +}