CKEditor5 plugin incompatibility with LinkIt module

Created on 9 June 2025, about 2 months ago

Problem/Motivation

Both ckeditor_mentions and linkit modules CKEditor5 plugins provides downcast/upcast handles for a tags having data-entity-type and/or data-entity-id attributes.

Because of that, the mention a tag is parsed (upcast) by both plugins and is later rendered (downcast) as two nested a tags.
Normally, that wouldn't happen as CKEditor5 would merge these tags into a single one (ref isSimilar()), however, both plugins provide different priority values in downcast definitions; also, the ckeditor_mentions plugin explicitly sets id which also prevents tags to be merged:

        }, {
          // Make mention attribute to be wrapped by other attribute elements.
          priority: 20,
          // Prevent merging mentions together.
          id: modelAttributeValue.uid
        });

Steps to reproduce

1. Install both CKEditor mentions and LinkIt modules.
2. Insert a mention in CKEditor, switch to the source, copy and delete the markup, switch to WYSIWYG, then paste the markup back, switch to WYSIWYG, and then to source again.
This is the easiest way to trigger downcast/upcast transformations. The other way could be editing an entity having a mention markup.
3. Observe the HTML markup.

Expected: a single a tag.

Actual: Two nested a tags. The outer one has data-entity-type and data-entity-id attributes from the mention tag, the inner one is a regular Mentions markup.

Proposed resolution

The solution probably lies somewhere in the isSimilar() method of CKEditor's AttributeElement class. However, I couldn't find a way to allow merging LinkIt and Mentions markups, which wouldn't have any side effects.

As a temporary measurement, I've made a patch for the LinkIt module which disables its CKEditor5 plugin if it's not used:
https://www.drupal.org/project/linkit/issues/3529093 πŸ› Missing filter condition in linkit.ckeditor5.yml Active

Remaining tasks

Find the correct way to fix the attributes similarity check.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

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

Comments & Activities

Production build 0.71.5 2024