fix: #3619043 Scope the CKEditor 5 plugin wiring to the editors that use the Anchor button

Issue: https://www.drupal.org/project/anchor_link/issues/3619043

Three fixes to the CKEditor 5 plugin wiring, found in the configuration-matrix round on Drupal 11.4:

Changes

  • The General HTML Support disallow moves into the plugin's own ckeditor5.config.htmlSupport.disallow. The global hook_ckeditor5_plugin_info_alter() rewrote the Arbitrary HTML Support definition site-wide, so an unrestricted editor without the Anchor button dropped id and name from every <a> the moment it loaded, and saving destroyed the anchors. Scoped to the plugin, the disallow now applies only where the Anchor button is enabled. The alter and its legacy wrapper are removed.
  • link.LinkEditing and link.LinkUI load with the anchor plugin. The library's AnchorUI requires them, so a toolbar carrying the Anchor button without the Link button threw plugincollection-soft-required and no editor attached at all.
  • The elements list claims only what the plugin creates: <a>, <a id="">, <a name="">. The unused target, rel and stale ck-anchor class no longer widen the allowed HTML of restricted formats.
  • The unit test is reworked around the plugin definition shape (3 tests, 5 assertions).

Testing

Drupal 11.4, verified in a real browser before and after:

Configuration Before After
Unrestricted format, no Anchor button, body with <a id>/<a name> attributes stripped to bare <a> on load both survive
Toolbar with Anchor and no Link no editor attaches, console error attaches, anchor works
Unrestricted format with Anchor button works works, data-* still owned by GHS
Restricted format with Anchor button works works

phpunit: 3 tests green. phpcs Drupal + DrupalPractice: clean.

Checkpoints:

  • File an issue
  • Addition/Change/Update/Fix
  • Testing to ensure no regression
  • Automated unit testing coverage
  • Automated functional testing coverage
  • UX/UI designer responsibilities
  • Readability
  • Accessibility
  • Performance
  • Security
  • Developer Documentation
  • User Guide Documentation
  • Reviewed by human
  • Code review by maintainers
  • Full testing and approval
  • Credit contributors
  • Review with the product owner
  • Release notes snippet
  • Release

AI-Generated: Yes

Edited by Rajab Natshah

Merge request reports

Loading
Loading