Refactor custom JS for CKEditor5 v45+

Created on 8 July 2025, about 2 months ago

Problem/Motivation

Editor Advanced Link has been created long time ago and hasn't been cleaned up for CKEditor5 45+
This is a task to clean up JS code.

Remaining tasks

- Known issue: CKEditor5 45+ has a new field for Link "Displayed text", new API removes old range and adds a new range so new link loses advanced attributes
- update tests

User interface changes

none

API changes

none

Data model changes

none

πŸ“Œ Task
Status

Active

Version

2.3

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia jannakha Brisbane!

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @jannakha
  • πŸ‡¦πŸ‡ΊAustralia jannakha Brisbane!

    jannakha β†’ changed the visibility of the branch 3534699-refactor-custom-js to hidden.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 203s
    #542010
  • Pipeline finished with Failed
    about 2 months ago
    Total: 207s
    #542020
  • πŸ‡¦πŸ‡ΊAustralia jannakha Brisbane!

    this also fixes:
    https://www.drupal.org/project/editor_advanced_link/issues/3519379 πŸ› Fix keyboard accessibility of advanced attribute fields Active
    https://www.drupal.org/project/editor_advanced_link/issues/3534044 πŸ› Adding "Open in new window" removes all other attributes Active
    https://www.drupal.org/project/editor_advanced_link/issues/3391226 πŸ› matcher-pattern-deprecated-attributes-class-key ckeditor warnings Active

  • πŸ‡¦πŸ‡ΊAustralia jannakha Brisbane!

    @DuaelFr
    Hello from Australia! I'm working with @vladimiraus and I did a refactoring of JS files to be more inline with CKEditor5 45+ - would you like to collaborate on it? I'm on slack or here.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 197s
    #542063
  • Pipeline finished with Failed
    about 2 months ago
    Total: 240s
    #542614
  • Pipeline finished with Failed
    about 1 month ago
    Total: 250s
    #544732
  • Pipeline finished with Failed
    about 1 month ago
    Total: 199s
    #544741
  • Pipeline finished with Failed
    about 1 month ago
    #545126
  • πŸ‡¦πŸ‡ΊAustralia jannakha Brisbane!
  • πŸ‡©πŸ‡ͺGermany styx1983

    The MR seems to fix all problems we are currently experiencing with the latest release 2.3.1 on Drupal 11.

    Especially the "Uncaught CKEditorError: can't access property "_items", t._manualDecoratorSwitches is undefined" that prevented linkit from working properly seems to be fixed within this one.

  • πŸ‡¦πŸ‡ΊAustralia marc.groth

    Just to clarify... Issue #3534044 is still an issue. It's a bit confusing because the problem is listed as a known issue under 'Remaining tasks'... But then comment #4 says that the patch fixes it. The former is true. It is still an issue. I also added a comment to the aforementioned ticket

  • πŸ‡ΊπŸ‡ΈUnited States tommasorandazzo

    Confirming that this fixes my issue with 2.3.1. It also seemed to fix the issue in #3534044 for me. Drupal core 11.2.2

  • πŸ‡ΊπŸ‡ΈUnited States jcandan

    Confirmed text link attributes all persist as expected with MR !37 on 2.3.x with Drupal 11.2.2.

    However, MR !37 breaks image link attributes which, according to #3349389-47: Fix image/media link attributes being lost β†’ , all but target="_blank" have been shown working in 2.3.1.

  • πŸ‡ΊπŸ‡ΈUnited States jcandan

    Given πŸ› Link attributes don't save Needs review bug affects both 2.2.x and 2.3.x,

    And given the effort here to fix 2.3.x specifically for CKEditor 45+

    Can we officially adopt the image/media link attributes bug within the scope of this issue?

    This would allow us to laser focus on the issues as they exist differently in each minor version.

    The question is, are we willing to change the scope of each, given the amount of work already attempted?

    Give it a day or so, if no comments to the contrary, I may go in and update and clarify scopes for each.

  • πŸ‡¦πŸ‡ΊAustralia jannakha Brisbane!

    @jcandan I'll see if have some time next week to check how to handle link attrs on media (it's something to do with their upgrade in v44 and https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-lin...)

  • πŸ‡©πŸ‡ͺGermany mrshowerman Munich

    Using the patch from MR37 together with Linkit 7.0.8, which added a similar change, I am experiencing some strange behavior.

    I have a link like this:

    <a href="/node/30" data-entity-type="node" data-entity-uuid="85f7822b-f889-4515-9e20-1addb7ef8e57" data-entity-substitution="canonical">FOOBAR</a>
    

    When I click on it and edit an attribute (e.g. "Open in new window"), the link is temporarily split up into 3 links: one for the part to the left of the cursor, one invisible filler link (containing only 7 &NoBreak; characters), and one for the part to the right of the cursor.

    <a class="ck-link_selected" href="/node/30" data-entity-type="node" data-entity-uuid="85f7822b-f889-4515-9e20-1addb7ef8e57" data-entity-substitution="canonical" target="_blank">FOO</a>
    <a class="ck-link_selected" href="/node/30" target="_blank">⁠⁠⁠⁠⁠⁠⁠</a>
    <a class="ck-link_selected" href="/node/30" data-entity-type="node" data-entity-uuid="85f7822b-f889-4515-9e20-1addb7ef8e57" data-entity-substitution="canonical" target="_blank">BAR</a>
    

    When the link dialog is closed, the 3 links are replaced with one link again.

    <a href="/node/30" data-entity-type="node" data-entity-uuid="85f7822b-f889-4515-9e20-1addb7ef8e57" data-entity-substitution="canonical" target="_blank">FOOBAR</a>
    

    @jannakha, do you have any idea why this happens?

    While it normally shouldn't be a problem for most users, it messes up the display for us, because we add an icon to the text through CSS to links that open a new window.
    Thus, the text temporarily looks like this:

    FOO β†— β†—BAR β†—
    (should be FOOBAR β†—, of course)

  • πŸ‡¦πŸ‡ΊAustralia jannakha Brisbane!

    I can confirm I can reproduce it (see screenshot β†’ ).

    @mrshowerman yeah, that's an issue of not going proper version for CKEditor 45+.

    Reason for it: CKEditor 44 refactored links api (Drupal is using 45+) which is not compatible with current versions of editor_advanced_link, linkit and other modules as they are now.

    linkit 7.0.8 is a bare min refactor to keep attributes of the link, it's not a proper refactor for CKEditor 45+

    Fix (not really a fix, but an example of proper refactoring for CKEditor 45+):
    - install linkit 7.0.7 and patch https://git.drupalcode.org/project/linkit/-/merge_requests/122.diff (hidden fork on https://www.drupal.org/project/linkit/issues/3535479 πŸ“Œ Refactor Linkit plugin for CKEditor5 v45+ Active ) - that works (see screenshot β†’ ).

    Please re-open (or open a new bug) https://www.drupal.org/project/linkit/issues/3535479 πŸ“Œ Refactor Linkit plugin for CKEditor5 v45+ Active and indicate to the maintainer that proper CKEditor 45+ refactoring is required.

  • πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson

    Please re-open (or open a new bug) https://www.drupal.org/project/linkit/issues/3535479 πŸ“Œ Refactor Linkit plugin for CKEditor5 v45+ Active and indicate to the maintainer that proper CKEditor 45+ refactoring is required.

    An issue for this has been created in the Linkit issue queue at πŸ› Editing Displayed text generates multiple links Active

Production build 0.71.5 2024