Unverified Commit 7a1c45f3 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3259443 by marcvangend, bnjmnm, Abhijith S: Plugin settings do not...

Issue #3259443 by marcvangend, bnjmnm, Abhijith S: Plugin settings do not appear when a configurable plugin is added AFTER removing all buttons
parent e2b5903f
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -229,10 +229,19 @@ function _add_ajax_listeners_to_plugin_inputs(array &$plugins_config_form): void
  $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.
  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'];
+36 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@

namespace Drupal\Tests\ckeditor5\FunctionalJavascript;

// cspell:ignore sourceediting

/**
 * Tests for CKEditor 5 in the admin UI.
 *
@@ -170,6 +172,40 @@ public function testMessagesDoNotAccumulate(): void {
    $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.
   */