Advanced Mention Name Reminder

Hover an advanced mention in Summernote to show its target entity’s name in a tooltip.

As of 2022-05-16. See the latest version.

Author
Salvatos
Ratings
0 0 0
Version
1.0
Created
2022-05-16
Updated
2022-05-16
Size
2.6 KB
License
MIT
Applies to

This Kanka script adds a tooltip to all advanced mentions in Summernote’s visual editor that shows the linked entity’s name on hover. This way, you don’t have to go back and view the entity to figure out what each mention points to. This script runs only once when the editor is loaded, so changes will not be reflected and new mentions won’t get a tooltip immediately. If there is demand, I may add a toolbar button to regenerate the tooltips during an editing session.

Note that this feature does not "work" in the code view as that editor contains only plain text and a tooltip cannot be attached to an arbitrary part of the text, however you will see a dfn tag around your mentions, like so:

<dfn entity-id="494047" title="Ragnar Lokra">[character:494047]</dfn>

You can therefore refer to the title attribute to find the target entity’s name. (Since <dfn> is not whitelisted on Kanka, those tags will not be saved when the form is submitted and you don’t have to worry about it affecting your entities.)

If you wish to style the mentions differently (this script underlines them with a dotted line by default), you can use the following CSS selector:

.note-editable dfn {}


If my scripts are making your life easier, feel free to tip me via Ko-fi (no account needed):

Support me on Ko-fi.com