- Issue created by @abramm
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
});
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.
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
Find the correct way to fix the attributes similarity check.
None.
None.
None.
Active
3.0
Code