Commit 2f565136 authored by Scott Zhu Reeves's avatar Scott Zhu Reeves
Browse files

fix: hide plugin configuration when plugin is not enabled

Fixes: #3374244
parent e877014d
Loading
Loading
Loading
Loading
+3 −1
Changes for src/Plugin/CKEditor5Plugin/PasteFilter.php: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -140,6 +140,7 @@ class PasteFilter extends CKEditor5PluginDefault implements CKEditor5PluginConfi
    $form['help'] = [
      '#type' => 'details',
      '#title' => $this->t('Help'),
      '#access'=> $this->configuration['enabled'],
    ];
    $form['help']['info']['#markup'] = '';
    $form['help']['info']['#markup'] .= '<p>' . $this->t('Content pasted into the editor will be processed through the configured filters.') . '</p>';
@@ -155,7 +156,6 @@ class PasteFilter extends CKEditor5PluginDefault implements CKEditor5PluginConfi
      ],
    ];

    // @todo Consider hiding if enabled checkbox is not checked (via #states).
    $wrapper_id = 'paste-filters-wrapper';
    $form['filters'] = [
      '#type' => 'table',
@@ -178,6 +178,7 @@ class PasteFilter extends CKEditor5PluginDefault implements CKEditor5PluginConfi
      '#prefix' => '<div id="' . $wrapper_id . '">',
      '#suffix' => '</div>',
      '#after_build' => [[static::class, 'sortFilterRows']],
      '#access'=> $this->configuration['enabled'],
    ];

    $filters = $this->configuration['filters'];
@@ -195,6 +196,7 @@ class PasteFilter extends CKEditor5PluginDefault implements CKEditor5PluginConfi

    $form['actions'] = [
      '#type' => 'actions',
      '#access'=> $this->configuration['enabled'],
    ];

    $form['actions']['add-row'] = [
+5
Changes for tests/src/Nightwatch/Tests/ckEditor5PasteFilterConfigTest.js: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -239,6 +239,11 @@ module.exports = {
        )
        .submitForm('[data-drupal-selector="edit-actions-submit"]')
        .waitForElementVisible("[data-drupal-messages]")
        // Ensure the filter table, help, and "Add another" button are not
        // visible when the plugin is disabled.
        .assert.not.elementPresent('[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-paste-filter-pastefilter-filters"]')
        .assert.not.elementPresent('[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-paste-filter-pastefilter-help"]')
        .assert.not.elementPresent('[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-paste-filter-pastefilter-actions"]')
        .drupalRelativeURL("/node/add/test")
        .waitForElementVisible(".ck-editor__editable")
        .click(".ck-editor__editable")
+3
Changes for tests/src/Nightwatch/Tests/ckEditor5PasteFilterWeightsTest.js: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -38,6 +38,9 @@ module.exports = {
          '[data-drupal-selector="edit-editor-settings-plugin-settings"]'
        )
        .click("link text", "Paste filter")
        .click(
          '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-paste-filter-pastefilter-enabled"]'
        )
        .assert.valueEquals(
          {
            selector: