Verified Commit 31998326 authored by Dave Long's avatar Dave Long
Browse files

fix: #3040302 "Edit summary" button for the text with summary widget has unthemable markup

By: rodrigoaguilera
By: sulfikar_s
By: ankithashetty
By: smustgrave
By: mdranove
(cherry picked from commit 6f2da240)
parent f237db4b
Loading
Loading
Loading
Loading
Loading
+6 −3
Changes for core/modules/text/js/text.js: 6 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -41,9 +41,7 @@

        // Set up the edit/hide summary link.
        const $link = $(
          `<span class="field-edit-link"> (<button type="button" class="link link-edit-summary">${Drupal.t(
            'Hide summary',
          )}</button>)</span>`,
          Drupal.theme('textEditSummaryButton', Drupal.t('Hide summary')),
        );
        const $button = $link.find('button');
        let toggleClick = true;
@@ -70,4 +68,9 @@
      });
    },
  };
  $.extend(Drupal.theme, {
    textEditSummaryButton(title) {
      return `<span class="field-edit-link"> (<button type="button" class="link link-edit-summary">${title}</button>)</span>`;
    },
  });
})(jQuery, Drupal);
+12 −0
Changes for core/modules/text/tests/modules/text_summary_test/js/text-summary-override.js: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
(function (Drupal) {
  Drupal.theme.textEditSummaryButton = function (title) {
    // Add an extra class for testing.
    return `
      <span class="field-edit-link text-test-edit-link">
        (<button type="button" class="link link-edit-summary">
          <span class="visually-hidden">Custom override: </span>${title}
        </button>)
      </span>
    `;
  };
})(Drupal);
+25 −0
Changes for core/modules/text/tests/modules/text_summary_test/src/Hook/TextSummaryTestHooks.php: 25 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace Drupal\text_summary_test\Hook;

use Drupal\Core\Hook\Attribute\Hook;
use Drupal\Core\State\StateInterface;

/**
 * Hook implementations for text_summary_test.
 */
class TextSummaryTestHooks {

  public function __construct(protected readonly StateInterface $state) {}

  /**
 * Implements hook_page_attachments_alter().
 */
  #[Hook('page_attachments_alter')]
  public function pageAttachmentsAlter(array &$attachments) : void {
    $attachments['#attached']['library'][] = 'text_summary_test/text-summary-override';
  }

}
+7 −0
Changes for core/modules/text/tests/modules/text_summary_test/text_summary_test.info.yml: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
name: 'Text summary test'
type: module
description: 'Provides test hook implementations for text summary tests'
package: Testing
version: VERSION
dependencies:
  - drupal:text
+7 −0
Changes for core/modules/text/tests/modules/text_summary_test/text_summary_test.libraries.yml: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
text-summary-override:
  js:
    js/text-summary-override.js: {}
  dependencies:
    - core/drupal
    - core/jquery
    - core/drupal.text
Loading