Problem/motivation

CKEditor version 45 overhauled the Link editor. See https://ckeditor.com/docs/ckeditor5/latest/updating/guides/update-to-45.... . Drupal 10.5 and Drupal 11.2 update to CKEditor version 45.

During our testing for the upgrade to Drupal 10.5.x, we identified a bug that occurs when attempting to update the "Displayed text" of an existing link.

  1. Go to any node with CKEditor
  2. Add link by clicking on Link button from CKEditor
  3. In the Link URL field, set to 'www.youtube.com'
  4. The Displayed text field must be empty
  5. Click on insert
  6. Click on the link and edit it
  7. The Displayed text field should have the same value as the Link URL field
  8. Change the Displayed text field
  9. Click on update

This will generate the following errors on console:

Uncaught CKEditorError: Cannot read properties of undefined (reading 'attributes')
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-Cannot read properties of undefined (reading 'attributes')
    at mi.getChanges (ckeditor5-dll.js?v=45.2.0:5:428639)
    at html-support.js?v=45.2.0:5:29843
    at vi._callPostFixers (ckeditor5-dll.js?v=45.2.0:5:442557)
    at vi._handleChangeBlock (ckeditor5-dll.js?v=45.2.0:5:441779)
    at qi._runPendingChanges (ckeditor5-dll.js?v=45.2.0:5:476270)
    at qi.change (ckeditor5-dll.js?v=45.2.0:5:473265)
    at _.<anonymous> (editorAdvancedLink.js?v=10.5.1:1:2664)
    at _.fire (ckeditor5-dll.js?v=45.2.0:5:639290)
    at <computed> [as execute] (ckeditor5-dll.js?v=45.2.0:5:642831)
    at f.execute (ckeditor5-dll.js?v=45.2.0:5:163419)
ckeditor5-dll.js?v=45.2.0:5 Uncaught CKEditorError: document-selection-wrong-position {"range":{"start":{"root":"main","path":[0,9],"stickiness":"toNone"},"end":{"root":"main","path":[0,9],"stickiness":"toNone"}}}
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-document-selection-wrong-position
    at Co._validateSelectionRanges (ckeditor5-dll.js?v=45.2.0:5:329930)
    at Co._replaceAllRanges (ckeditor5-dll.js?v=45.2.0:5:329670)
    at Co._setRanges (ckeditor5-dll.js?v=45.2.0:5:320078)
    at Co.setTo (ckeditor5-dll.js?v=45.2.0:5:319218)
    at Co.setTo (ckeditor5-dll.js?v=45.2.0:5:328804)
    at Ao._setTo (ckeditor5-dll.js?v=45.2.0:5:326266)
    at Pi.setSelection (ckeditor5-dll.js?v=45.2.0:5:455870)
    at Object.callback (ckeditor5-dll.js?v=45.2.0:5:356853)
    at qi._runPendingChanges (ckeditor5-dll.js?v=45.2.0:5:476216)
    at qi.change (ckeditor5-dll.js?v=45.2.0:5:473265)

Steps to reproduce

While I haven’t been able to reproduce the issue consistently, I can trigger the error approximately 90% of the time. Given this frequency, I believe it's worth creating an issue for further discussion and investigation.

Steps to reproduce

1. Click the "Link" icon.
2. Enter a "Displayed text" value.
3. Enter the first character of an existing node and use Linkit's autocomplete to choose a result from the dropdown. Confirm that the internal path to the node is populated in the "Link URL" field.
4. Quickly(!) Remove the contents from the "Displayed text" input and quickly enter new text and press "Insert."
5. Link text will not be updated and the console will show the Uncaught CKEditorError: Cannot read properties of undefined (reading 'attributes') error.

CommentFileSizeAuthor
#34 ckeditor5.png194.77 KBjannakha
#10 2025-07-16_09-33-16.png88 KBnicholass

Issue fork linkit-3535098

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

peterwcm created an issue. See original summary.

mark_fullmer’s picture

Title: Cannot replace 'Displayed text' of existing links » [CKEditor v45] Cannot replace 'Displayed text' of existing links
Priority: Normal » Major

Thanks for reporting this. I am able to reproduce. Specifically, using a generic installation of the Standard profile, adding Linkit to the Basic HTML text format:

1. Click the "Link" icon.
2. Enter a "Displayed text" value.
3. Enter the first character of an existing node and use Linkit's autocomplete to choose a result from the dropdown. Confirm that the internal path to the node is populated in the "Link URL" field.
4. Quickly(!) Remove the contents from the "Displayed text" input and quickly enter new text and press "Insert."
5. Link text will not be updated and the console will show the Uncaught CKEditorError: Cannot read properties of undefined (reading 'attributes') error.

Additionally, this is something else that doesn't work correctly.
1. Click the "Link" icon.
2. Enter a "Displayed text" value.
3. Enter the first character of an existing node and use Linkit's autocomplete to choose a result from the dropdown. Confirm that the internal path to the node is populated in the "Link URL" field.
4. Now click "Link URL" field again and enter the first character of another node and use Linkit's autocomplete to choose a different result.
5. The link field will NOT correctly populate the internal path to the node but will simply populate the character you entered.

mark_fullmer’s picture

Title: [CKEditor v45] Cannot replace 'Displayed text' of existing links » [CKEditor v45] Cannot replace 'Displayed text' or "Link URL' of existing links
mark_fullmer’s picture

Issue summary: View changes

mark_fullmer’s picture

Issue summary: View changes
mark_fullmer’s picture

mark_fullmer’s picture

Issue summary: View changes
mark_fullmer’s picture

Title: [CKEditor v45] Cannot replace 'Displayed text' or "Link URL' of existing links » [CKEditor v45] Cannot replace 'Displayed text' of existing links
Status: Active » Needs work

I've merged a number of changes related to CKEditor v45 compatibility to reduce the surface area here. The originally reported problem still remains, so this is "Needs work."

nicholass’s picture

StatusFileSize
new88 KB

Also had to disable the "Linkit profile" for Ckeditors after updating core 10.5 due to the error "Cannot convert undefined or null to object" in CKEditor 5 caused by a bug in the Linkit module version 6.1.6. Specifically, in the JavaScript file index.js at line 122, the code attempts to call Object.assign(args[2], values) where args[2] can be undefined or null. This occurs when the CKEditor 5 link command is executed with fewer than 3 arguments, but the code assumes the third argument (index 2) will always be an object.

When title is empty and clicking insert
Click insert, fails to create link

UPDATE/UNRELATED
Ok so update on my issue, I guess its not related looks like I am on core 10.5.1 with 6.1.6 and the only compatible version is the 7.x, so I have to question why composer did that when I ran composer update. This may catch others.

jannakha’s picture

@nicholass
when you're updating dependencies, especially when Drupal is updated, run command to check for any major versions of contrib modules:
composer outdated -M -D

composer update usually just updates minor version by default (eg 6.1 to 6.2) if dependency has carrot (^) "drupal/linkit": "^6.0", but not to 7.0

mrshowerman’s picture

@mark_fullmer, see my comment in #3534699-14: [CKEditor5 v45+] Attributes can overwrite other attributes and editing displayed text from collapsed selection generates multiple links for another bug that is related to CKEditor 45. Not sure if this is the right place to report, but as @jannakha points out in their reply, it likely has to be fixed in Linkit.

Of course, I can also open a separate issue if that is preferred.

mark_fullmer’s picture

see my comment in #3534699-14: Refactor plugin for CKEditor5 v45+ for another bug that is related to CKEditor 45...Of course, I can also open a separate issue if that is preferred.

It appears that another community member created a separate issue for that today: #3540235: [CKEditor v45] Editing Displayed text from collapsed selection generates multiple links . I think it makes sense to initially keep that issue and this one tracked separately; if the fix ends up fixing both, fine :)

Thanks!

mark_fullmer’s picture

Version: 7.x-dev » 7.1.x-dev

I've created a new target development branch, 7.1.x, for this work, since it will require introducing backwards-compatibility-breaking changes. See https://www.drupal.org/project/linkit/releases/7.1.x-dev

mark_fullmer’s picture

Priority: Major » Critical
giancarlorosa’s picture

Doing more tests, I found some specific behaviors related to this issue. First, I was using Linkit version 7.0.7, and this issue was happening through internal and external links. Now, I updated to version 7.0.8, and it seems that internal links are working just fine, but for external links, the issue still happens.

I've noticed that this issue tends to happen when, instead of selecting a text and adding a link, I add the link by directly clicking on the Link button from CKEditor. It's like if the created link does not have a reference to the element and can not update the Displyed text value.

Here are the steps to reproduce the issue:

  1. Go to any node with CKEditor
  2. Add link by clicking on Link button from CKEditor
  3. In the Link URL field, set to 'www.youtube.com'
  4. The Displayed text field must be empty
  5. Click on insert
  6. Click on the link and edit it
  7. The Displayed text field should have the same value as the Link URL field
  8. Change the Displayed text field
  9. Click on update

This will generate the following errors on console:

ckeditor5-dll.js?v=45.2.0:5 Uncaught CKEditorError: Cannot read properties of undefined (reading 'attributes')
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-Cannot read properties of undefined (reading 'attributes')
    at mi.getChanges (ckeditor5-dll.js?v=45.2.0:5:428639)
    at html-support.js?v=45.2.0:5:29843
    at vi._callPostFixers (ckeditor5-dll.js?v=45.2.0:5:442557)
    at vi._handleChangeBlock (ckeditor5-dll.js?v=45.2.0:5:441779)
    at qi._runPendingChanges (ckeditor5-dll.js?v=45.2.0:5:476270)
    at qi.change (ckeditor5-dll.js?v=45.2.0:5:473265)
    at Object.<anonymous> (ckeditor5-dll.js?v=45.2.0:5:356839)
    at Object.fire (ckeditor5-dll.js?v=45.2.0:5:639290)
    at fe (ckeditor5-dll.js?v=45.2.0:5:219549)
    at ke.fire (ckeditor5-dll.js?v=45.2.0:5:218940)
Uncaught CKEditorError: document-selection-wrong-position {"range":{"start":{"root":"main","path":[1,18],"stickiness":"toNone"},"end":{"root":"main","path":[1,18],"stickiness":"toNone"}}}
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-document-selection-wrong-position
    at Co._validateSelectionRanges (ckeditor5-dll.js?v=45.2.0:5:329930)
    at Co._replaceAllRanges (ckeditor5-dll.js?v=45.2.0:5:329670)
    at Co._setRanges (ckeditor5-dll.js?v=45.2.0:5:320078)
    at Co.setTo (ckeditor5-dll.js?v=45.2.0:5:319218)
    at Co.setTo (ckeditor5-dll.js?v=45.2.0:5:328804)
    at Ao._setTo (ckeditor5-dll.js?v=45.2.0:5:326266)
    at Pi.setSelection (ckeditor5-dll.js?v=45.2.0:5:455870)
    at Object.callback (ckeditor5-dll.js?v=45.2.0:5:356853)
    at qi._runPendingChanges (ckeditor5-dll.js?v=45.2.0:5:476216)
    at qi.change (ckeditor5-dll.js?v=45.2.0:5:473265)

If I execute the same process, but instead of adding a link by first clicking on the Link button, I first select a text inside CKEditor, the Linkit works fine.

jannakha’s picture

use 7.0.7 and MR122 from https://www.drupal.org/project/linkit/issues/3535479 (hidden branch)

mark_fullmer changed the visibility of the branch 3535098-ckeditor-v45-cannot to hidden.

mark_fullmer changed the visibility of the branch 3535098-ckeditor-insert-fix to hidden.

mark_fullmer’s picture

Status: Needs work » Needs review

I've confirmed that changes staged in the merge request for #3540235: [CKEditor v45] Editing Displayed text from collapsed selection generates multiple links do resolve this issue's problem, and would love confirmation of that from someone else that the "Steps to Reproduce" from #16 above result in successfully being able to change link text.

The problem of duplicated links is still present in the merge request for #3540235: [CKEditor v45] Editing Displayed text from collapsed selection generates multiple links, so I'm continuing to work on that...

mark_fullmer’s picture

Issue summary: View changes
agnesliu’s picture

Edited 9/10/2025: If it's an internal link, I'm able to change the "Displayed text". If it's an external link, I'm unable to update the "Displayed text" no matter the link url will be changed or not.
--------
I have similar issue with Linkit 7.0.8 (Drupal Core 10.5.2).
When I try to update an existing link, I cannot replace the "Displayed text" and the "link url" together. It does not seem to change anything after I click "Update" and I cannot make any edits anywhere anymore (editor freezing).

mark_fullmer’s picture

and I cannot make any edits anywhere anymore (editor freezing).

Thanks for reporting this, @agnesliu, and sorry to hear about the problematic editing. Given that you describe the editor "freezing," can you check whether the browser console reports any JavaScript errors when this happens? If so, can you post the error message here? Also, are you using any other modules or plugins related to CKEditor on the problem site, or is it just plain Drupal core 10.5.2 and Linkit 7.0.8?

agnesliu’s picture

are you using any other modules or plugins related to CKEditor on the problem site, or is it just plain Drupal core 10.5.2 and Linkit 7.0.8

CKEditor Accordion is the only other module that is related to CKEditor. The site is also using External Links, which just be used to differentiate between internal and external links.

In the console-

Uncaught CKEditorError: can't access property "attributes", s[a] is undefined
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#erro...'t access property "attributes", s[a] is undefined

mark_fullmer’s picture

Version: 7.1.x-dev » 7.x-dev

mark_fullmer changed the visibility of the branch 3535098-unable-update-link to hidden.

mark_fullmer’s picture

Status: Needs review » Fixed

This should be fixed, per the code changes added to the 7.0.9 release of Linkit. Note, however, that the other issue related to CKEditor v45 (i.e., Drupal 10.5+ and Drupal 11.2+), #3540235: [CKEditor v45] Editing Displayed text from collapsed selection generates multiple links, remains.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

cdupree’s picture

Is anyone having issues with Displayed Text when applying a link to existing text in Drupal 11? It seems to be specifically when an entire line is selected, i.e. when triple-clicking to select. By contrast, clicking and dragging to select a substring of text and then applying a link works as expected.

Currently using:

  • Drupal core 11.2.8 (11/12/25)
  • Linkit 7.0.11

Steps to reproduce:

  1. Go to any node with CKEditor
  2. Type a string of text, hit enter (to close the paragraph tag)
  3. Triple-click the line of text to select
  4. Add link by clicking the Link button in CKEditor
  5. The Displayed text field is disabled / greyed out
  6. Select or enter a URL
  7. Click Insert

This will generate the following errors in the console, similar to #16 above, and afterwards the user is unable to click elsewhere in the editor / the editor freezes, similar to #23, after the error is thrown:

ckeditor5-dll.js?v=45.2.2:5 Uncaught CKEditorError: Cannot read properties of undefined (reading 'attributes')
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-Cannot read properties of undefined (reading 'attributes')
    at li.getChanges (ckeditor5-dll.js?v=45.2.2:5:426292)
    at js_eSj03_QezNeDw_7PCho9Mo5MeyL4yFBuG3FX3eShEGY.js?scope=footer&delta=3&language=en&theme=claro&include=eJyNVFtu4zAMvJBif_UALdB-FdgjGLTEWNroVYpKN3v60q-4iYsiP5I4M6RIihCY4GLHKfkeqF32hgmxsemM5CJjZAXfZV1BIG3beWtOeOkTkOmKTcS6stInNI4TPbWjO0XwjaGaZbsyj2gaDNlCceUhseXgX-PgIj4kdwGGx5RBDqC0B0rtQkY4Hxh6SSyJ2z-u4FdqQw5Lu0RE2G7xwLshhrGr90TldEwUYMf0PunTR02M94xOBl9G9p6Qt3D_JRfw71NLblkXzQ8JeBd3cbwrO12GwvhGKfw5Hp3eBScMMjpvP1ZSUiWNr2K5OOxIvvhdNOnzCi4tBs3ujIct22vrvYdcbsWFgbHcQFNEQzDsUcKSUywSfuauU_H3oyJdmvF51JzZ6jdbjcyIT8PCdWDOEDWabkxyK0YdnZeAq-tsqVHj-Jtqmjhx7Qno0n46MyALGGtX3eq7mCrKAFzHUs4qg1RGkG1Z4Q2ZWif1_S5aLszAdmPZTsA4o2tGZLvp9nE5TJ3hdMLYTqu6_1OwaMj4PH4kX_4Ltfs:10:29832
    at _i._callPostFixers (ckeditor5-dll.js?v=45.2.2:5:440188)
    at _i._handleChangeBlock (ckeditor5-dll.js?v=45.2.2:5:439410)
    at qi._runPendingChanges (ckeditor5-dll.js?v=45.2.2:5:475715)
    at qi.change (ckeditor5-dll.js?v=45.2.2:5:472714)
    at linkCommand.on.priority (editoradvancedlinkediting.js:129:15)
    at V.fire (ckeditor5-dll.js?v=45.2.2:5:638431)
    at <computed> [as execute] (ckeditor5-dll.js?v=45.2.2:5:641978)
    at f.execute (ckeditor5-dll.js?v=45.2.2:5:163358)
mark_fullmer’s picture

Thanks, @cdupree, for reporting this. It had not yet been reported, and I can confirm that I can reproduce the issue with the Steps to Reproduce. I've created a new issue for resolving this problem: https://www.drupal.org/project/linkit/issues/3557993

jannakha’s picture

StatusFileSize
new194.77 KB

Empty Display Text this is not an issue of linkit.

Empty Display Text is CKEditor5 itself (see screenshot) when you triple-click, CKEditor selects a whole paragraph and it doesn't put whole paragraph text into Displayed Text field.

cdupree’s picture

Update: posted this before reviewing the thread in the new issue in #33, I closed the issue with CKEditor.

--

Thank you for narrowing that down @jannakha. I opened a ticket in the CKEditor project: https://github.com/ckeditor/ckeditor5/issues/19373