Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
I would like to use this module to suggest mentions in comments, however, rather than mentioning users I wish to mention a different entity, a party. I also do not want to install the realname module.
Proposed resolution
I propose a few changes:
- Add variables to make which view and filter is used configurable.
- Remove the dependency on realname and add a CKEditor Mentions realname module for this functionality. Maintain the upgrade path by adding an update function that automatically enables this module for all sites that already have it installed.
Comments
Comment #2
askibinski CreditAttribution: askibinski as a volunteer and at iO commentedYes, great idea!
It would be a great time to implement this in the 8.x-2.x version of this module, which will also make use of the official CKEditor mention plugin (#3009308: Use the official CKEditor mention plugin).
I haven't given this a lot of thought yet, but I think using plugins to support various content would make sense. This way we could provide a couple default ones (core users, realname) and other people would be able to add their own based on their own custom wishes.
Actually, going this route, we would be building quite the same plugin architecture which the linkit module is already using for their autocompletes. Might be worth exploring that for a bit.
Now, in the current state of ckeditor_mentions the plugin settings are coupled with text format settings. We could leave it that way, which would mean people would probably need to use multiple formats and a module like allowed_formats if they would like to have more fine-grained control.
Or we could also built in support for configuration on a field display level, maybe through the use of third party settings.
Comment #3
vdsh CreditAttribution: vdsh commentedHi askibinski, I have just started to play with this module and it's the same, I want to mention nodes not user. So I dirtily replaced the code to query for node that I want (only nodes of a certain type)
Using plugins would work, but I was wondering if using views would be easier (?) In the configuration of either the text format or the field display, we would be able to select a json view. That way, we could provide some example views (eg: with realnames) and let users build their own autocomplete through views instead of having to build the query manually. Any opinion on it?
Comment #4
askibinski CreditAttribution: askibinski as a volunteer and at iO commentedSounds like an option to me. Any ideas how we could detect which views are available?
Ideally, the admin ui would show compatible views where the preferred one (or multiple?) could be selected.
Comment #5
vdsh CreditAttribution: vdsh commentedWhat I had in mind was to be able to select any REST export view with json response (iterating through all views with Views::getEnabledViews())
I think it would be the dev's responsibility to provide the right fields in the view, so that they are consistenant with the itemTemplate and outputTemplate that are introduced in #3009308: Use the official CKEditor mention plugin.
What I am not too sure of is how to connect to the view result:
- either we connect CKEditor directly to the view, but we loose the CKEditorMentionSuggestionEvent (not sure how much it's used), would probably need to be replaced through some views hook where we can find out how we can target our views...)
- or we still keep the CKMentionsController in between, but in that case, how can we know which view was configured for that text editor
Comment #6
askibinski CreditAttribution: askibinski as a volunteer and at iO commentedSee https://www.drupal.org/project/ckeditor_mentions/issues/3009308#comment-... for a merge request with a plugin based system.
Comment #7
dinazaur CreditAttribution: dinazaur as a volunteer and at DevBranch commentedImplemented plugin system in the latest 8.x-2.0 version.
Any feedback would be appreciated.
Comment #9
dinazaur CreditAttribution: dinazaur as a volunteer and at DevBranch commented