diff --git a/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php b/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php index b93b78ef006..ed6cc6512ee 100644 --- a/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php +++ b/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php @@ -671,10 +671,18 @@ class CKEditor5 extends EditorBase implements ContainerFactoryPluginInterface { $pair = static::createEphemeralPairedEditor($submitted_editor, $submitted_filter_format); + // When CKEditor 5 plugins are disabled in the form-based admin UI, the + // associated settings (if any) should be omitted too. + $original_settings = $pair->getSettings(); + $enabled_plugins = $this->ckeditor5PluginManager->getEnabledDefinitions($pair); + $updated_settings = [ + 'plugins' => array_intersect_key($original_settings['plugins'], $enabled_plugins), + ] + $original_settings; + $pair->setSettings($updated_settings); + if ($pair->getFilterFormat()->filters('filter_html')->status) { // Compute elements provided by the current CKEditor 5 settings. - $enabled_plugins = array_keys($this->ckeditor5PluginManager->getEnabledDefinitions($pair)); - $elements = $this->ckeditor5PluginManager->getProvidedElements($enabled_plugins, $pair); + $elements = $this->ckeditor5PluginManager->getProvidedElements(array_keys($enabled_plugins), $pair); // Compute eventual filter_html setting. Eventual as in: this is the list // of eventually allowed HTML tags. diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/AdminUiTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/AdminUiTest.php index d2c01635e6b..9f655886cde 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/AdminUiTest.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/AdminUiTest.php @@ -170,4 +170,32 @@ class AdminUiTest extends CKEditor5TestBase { $this->assertCount(1, $find_validation_error_messages()); } + /** + * Tests the language config form. + */ + public function testLanguageConfigForm() { + $page = $this->getSession()->getPage(); + $assert_session = $this->assertSession(); + + $this->createNewTextFormat($page, $assert_session); + $assert_session->assertWaitOnAjaxRequest(); + + // The language plugin config form should not be present. + $assert_session->elementNotExists('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-language"]'); + + $this->assertNotEmpty($assert_session->waitForElement('css', '.ckeditor5-toolbar-item-textPartLanguage')); + $this->triggerKeyUp('.ckeditor5-toolbar-item-textPartLanguage', 'ArrowDown'); + $assert_session->assertWaitOnAjaxRequest(); + + // The language plugin config form should now be present. + $assert_session->elementExists('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-language"]'); + + // It must also be possible to remove the language plugin again. + $this->triggerKeyUp('.ckeditor5-toolbar-item-textPartLanguage', 'ArrowUp'); + $assert_session->assertWaitOnAjaxRequest(); + + // The language plugin config form should not be present anymore. + $assert_session->elementNotExists('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-language"]'); + } + } diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php index 5c06e07a853..875c755c62c 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php @@ -183,27 +183,6 @@ class CKEditor5AllowedTagsTest extends CKEditor5TestBase { $assert_session->pageTextContains('The text format ckeditor has been updated'); } - /** - * Tests the language config form. - */ - public function testLanguageConfigForm() { - $page = $this->getSession()->getPage(); - $assert_session = $this->assertSession(); - - $this->createNewTextFormat($page, $assert_session); - $assert_session->assertWaitOnAjaxRequest(); - - // The language plugin config form should not be present. - $assert_session->elementNotExists('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-language"]'); - - $this->assertNotEmpty($assert_session->waitForElement('css', '.ckeditor5-toolbar-item-textPartLanguage')); - $this->triggerKeyUp('.ckeditor5-toolbar-item-textPartLanguage', 'ArrowDown'); - $assert_session->assertWaitOnAjaxRequest(); - - // The language plugin config form should now be present. - $assert_session->elementExists('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-language"]'); - } - /** * Tests that the img tag is added after enabling image uploads. */