Problem/Motivation

ckeditor5_mentions currently initializes mention feeds only when it finds select[data-editor-for="edit-body-0-value"]. That works for the default body field, but it fails on other CKEditor 5 instances where the source element id is different, such as comment forms or custom text fields.
In those cases, the mention plugin settings are attached, but the JS integration never runs because the selector is too specific. As a result, typing @ does not show any user suggestions even though the backend endpoint is available.

Steps to reproduce

  1. Enable ckeditor5_mentions
  2. Open a form that uses CKEditor 5, such as a comment form.
  3. Type @ followed by part of a real username.
  4. Observe that no mention dropdown appears.
  5. Inspect the page and see that the active editor uses a different data-editor-for value, not edit-body-0-value.

Proposed resolution

Update the mention integration to use the active CKEditor source element id instead of hardcoding edit-body-0-value.
The integration should:

  1. Read the current editor’s sourceElement.id.
  2. Look up the matching format control using [data-editor-for="${sourceElementId}"].
  3. Initialize mentions when that control exists, regardless of the field name.
  4. Keep the existing mention feed behavior unchanged.

Remaining tasks

User interface changes

None

API changes

None. This only affects mention initialization behavior in CKEditor 5.

Data model changes

None

Comments

drupal_simply_amazing’s picture

drupal_simply_amazing’s picture

drupal_simply_amazing’s picture

StatusFileSize
new5.55 KB

The fix is to use the active editor’s own data-editor-for target instead of assuming a specific field ID. This makes the mention integration work consistently for both:

  • normal node body forms
  • comment forms
drupal_simply_amazing’s picture

StatusFileSize
new5.46 KB
sujan shrestha’s picture

Version: 2.0.0 » 2.0.x-dev
Status: Active » Fixed

Fixed in 2.0.x (commit f3512a1, release 2.0.1), with a different approach from the patch. The JS no longer reads the DOM at all: the feeds enabled for a text format are passed to each editor through its CKEditor 5 configuration (getDynamicPluginConfig()). Mentions now work in any field using the format (node body, comments, custom text fields), with or without a format selector. Thanks @drupal_simply_amazing for the report and patches.

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

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

Maintainers, credit people who helped resolve this issue.