Problem/Motivation
When using ckeditor5_plugin_pack together with ckeditor5_plugin_pack_link_attributes and ckeditor5_plugin_pack_bookmark, the Link Attributes dialog can stop working after switching into Bookmark options and then backing out without selecting a bookmark. In that flow, opening Link Attributes afterward fails to apply attributes such as target. The browser console shows a CKEditor 5 error: document-selection-wrong-position, which indicates the editor selection has become invalid.
Steps to reproduce
- Link attribute "Open in new window" is configured and enabled ckeditor5 text_format
- Bookmarks are enabled in ckeditor5 text_format
- Create a link in CKEditor.
- Open the Bookmark options.
- Click back in the Bookmark options without selecting anything.
- Close the link dialog.
- Open the Link Attributes options and try to set target.
- Result: it is not possible to add link attributes.
Expected result:
Link Attributes should remain usable after leaving Bookmark options, even if no bookmark was selected.
Additional note:
"Internally" the plugin seems to work as it should, since the checkbox is enabled after closing and reopening the link attributes dialogue.
How to avoid the issue - but not a real fix
The issue can be avoided if, after step 3, you click Update in the link dialog before closing it.
Proposed resolution
Ensure the editor selection is properly restored or normalized when leaving Bookmark options without making a selection. The dialog flow should not leave CKEditor in a state where the selection points to an invalid model position. Link Attributes should be able to open and apply its values after the Bookmark subdialog is exited, regardless of whether a bookmark was chosen.
Remaining tasks
- Fix the dialog close/back flow so it preserves or restores a valid selection.
- Verify that Link Attributes works after the fix when switching between Bookmark and Link Attributes options.
User interface changes
No intended UI changes. This is a behavior fix for existing dialogs.
API changes
No API changes are expected.
Data model changes
No data model changes are expected. The fix should only affect selection handling and dialog behavior in the editor.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | Screen Recording 2026-05-29 at 19.25.20.mov | 1.96 MB | steffenr |
| #3 | link-attributes-reproduce-attempt.mov | 2.48 MB | salmonek |
| Screenshot 2026-04-24 at 07.37.14.jpg | 374.36 KB | steffenr |
Comments
Comment #2
steffenrComment #3
salmonek commentedHi Steffen
We have tried to reproduce the issue, however without success. I'm attaching a screencast, please take a look and tell if we're doing something differently.
Comment #4
steffenrThat's interesting. In my case i clicking the "Open in new window" toggle does not do anything.
See attached screen recording.
Comment #5
salmonek commentedUnfortunately I still wasn't able to reproduce this. I have configured text format with same plugins and followed actions you made on the screencast and it worked.
Could you share your Drupal core version (CKEditor version depends on core version) and if possible your editor configuration (if you have exported config it will be
editor.editor.{TEXT_FORMAT_ID}.ymlfile) ?Comment #6
dmrupp commentedFYI - I am able to reproduce this exact same error, but not with ckeditor5_plugin_pack. Instead we are using editor_advanced_link - but the error originates for us from enabling the "Entity links" option that was added to core. With that option disabled, the "open in new window" toggle closes the pop up, and functions fine. With Entity links enabled - the toggle is throwing the same CKEditor 5 error: document-selection-wrong-position.
So either this is an issue with core's Entity link function, or with how ckeditor5_plugin_pack AND editor_advanced_link are implementing their options.
I've verified it is the same between plugin_pack and editor_advanced_link.
Steps to reproduce:
- Vanilla D11 install
- Install & enable ckeditor5_plugin_pack and CKEditor 5 Link Attributes
- Add "open in new window" + "target|_blank " to Link Attributes for text format
- Verify the "open in new window" toggle is working
- Enable "Entity links" for the text format
- "open in new window" toggle throws the CKEditor 5 error: document-selection-wrong-position.
Comment #7
dmrupp commentedFYI for anyone looking at this - it looks like the similar issue for editor_advanced_link is fixed with the patch for this issue: https://www.drupal.org/project/editor_advanced_link/issues/3614661