Skip to content
Snippets Groups Projects
Unverified Commit 88a8d35c authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3248177 by Wim Leers, marcvangend, lauriii, Lendude: Language toolbar...

Issue #3248177 by Wim Leers, marcvangend, lauriii, Lendude: Language toolbar item cannot be removed from the toolbar
parent 65c863be
No related branches found
No related tags found
No related merge requests found
......@@ -671,10 +671,18 @@ protected function getEventualEditorWithPrimedFilterFormat(SubformStateInterface
$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.
......
......@@ -170,4 +170,32 @@ public function testMessagesDoNotAccumulate(): void {
$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"]');
}
}
......@@ -183,27 +183,6 @@ public function testSwitchToVersion5() {
$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.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment