Issue #3259443 by marcvangend, bnjmnm, Abhijith S: Plugin settings do not appear when a configurable plugin is added AFTER removing all buttons
(cherry picked from commitmerge-requests/1229/merge7a1c45f38e
) (cherry picked from commit15011eb13c
)
parent
077ba1bc99
commit
6f5a6eaf47
|
@ -229,10 +229,19 @@ function ckeditor5_form_filter_format_form_alter(array &$form, FormStateInterfac
|
|||
$form['filter_settings']['#wrapper_attributes']['id'] = 'filter-settings-wrapper';
|
||||
|
||||
// Add an ID to the editor settings vertical tabs wrapper so it can be easily
|
||||
// targeted by JavaScript.
|
||||
// targeted by JavaScript. If there are no configurable plugins, render an
|
||||
// empty container with the same ID instead.
|
||||
// @todo consider moving this to editor.module when this module is moved to
|
||||
// Drupal core https://www.drupal.org/project/ckeditor5/issues/3231322.
|
||||
$form['editor']['settings']['subform']['plugin_settings']['#wrapper_attributes']['id'] = 'plugin-settings-wrapper';
|
||||
if (!empty($form['editor']['settings']['subform']['plugins'])) {
|
||||
$form['editor']['settings']['subform']['plugin_settings']['#wrapper_attributes']['id'] = 'plugin-settings-wrapper';
|
||||
}
|
||||
else {
|
||||
$form['editor']['settings']['subform']['plugin_settings'] = [
|
||||
'#type' => 'container',
|
||||
'#attributes' => ['id' => 'plugin-settings-wrapper'],
|
||||
];
|
||||
}
|
||||
|
||||
$form['#after_build'][] = [CKEditor5::class, 'assessActiveTextEditorAfterBuild'];
|
||||
$form['#validate'][] = [CKEditor5::class, 'validateSwitchingToCKEditor5'];
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Drupal\Tests\ckeditor5\FunctionalJavascript;
|
||||
|
||||
// cspell:ignore sourceediting
|
||||
|
||||
/**
|
||||
* Tests for CKEditor 5 in the admin UI.
|
||||
*
|
||||
|
@ -170,6 +172,40 @@ class AdminUiTest extends CKEditor5TestBase {
|
|||
$this->assertCount(1, $find_validation_error_messages());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the plugin settings form section.
|
||||
*/
|
||||
public function testPluginSettingsFormSection() {
|
||||
$page = $this->getSession()->getPage();
|
||||
$assert_session = $this->assertSession();
|
||||
|
||||
$this->createNewTextFormat($page, $assert_session);
|
||||
$assert_session->assertWaitOnAjaxRequest();
|
||||
|
||||
// The default toolbar only enables the configurable heading plugin and the
|
||||
// non-configurable bold and italic plugins.
|
||||
$assert_session->fieldValueEquals('editor[settings][toolbar][items]', '["heading","bold","italic"]');
|
||||
// The heading plugin config form should be present.
|
||||
$assert_session->elementExists('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-heading"]');
|
||||
|
||||
// Remove the heading plugin from the toolbar.
|
||||
$this->triggerKeyUp('.ckeditor5-toolbar-item-heading', 'ArrowUp');
|
||||
$assert_session->assertWaitOnAjaxRequest();
|
||||
|
||||
// The heading plugin config form should no longer be present.
|
||||
$assert_session->elementNotExists('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-heading"]');
|
||||
// The plugin settings wrapper should still be present, but empty.
|
||||
$assert_session->elementExists('css', '#plugin-settings-wrapper');
|
||||
$assert_session->elementNotContains('css', '#plugin-settings-wrapper', '<div');
|
||||
|
||||
// Enable the source plugin.
|
||||
$this->triggerKeyUp('.ckeditor5-toolbar-item-sourceEditing', 'ArrowDown');
|
||||
$assert_session->assertWaitOnAjaxRequest();
|
||||
|
||||
// The source plugin config form should be present.
|
||||
$assert_session->elementExists('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-sourceediting"]');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the language config form.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue