Mentions: How do I use a user id to span? #1235
Replies: 3 comments
-
Found that I can just change mention.ts to my requirements. Thanks |
Beta Was this translation helpful? Give feedback.
-
Another way to do it would be to extend the mention object. For example, lets say that you wanted to also include the attribute First extend the Mention by adding the user attribute const CustomMention = Mention.extend({
addAttributes() {
return {
...this.parent(),
user: {
default: '',
}
}
}
}); And then add the custom extension to the editor object instead of the original. And then make sure you pass the user value. In the example below selectItem(index) {
const item = this.items[index]
if (item) {
this.command({ id: item.label, user: item.id })
}
} |
Beta Was this translation helpful? Give feedback.
-
https://tiptap.dev/docs/editor/extensions/nodes/mention#renderhtml can be useful also
|
Beta Was this translation helpful? Give feedback.
-
Hi!
Using your example at:
https://www.tiptap.dev/examples/suggestions
I have changed it so I am passing the full objects to the MentionList.vue and rendering them in the pop-up. I am wondering if I am able to use an id for the "data-mention" property, or add another property with the user's ID as opposed to the user's name. Example below.
At the moment, I have...
But ideally, I'd like (for example user-id = 342)
OR...
I presumed in selectItem in MentionList.vue, I would be able to pass stuff in there, but I couldn't find the correct document
Any help is appreciated! thank you
Beta Was this translation helpful? Give feedback.
All reactions