Giving Mentions a subset of all usernames as suggestions, instead of ALL usernames to search from #5718
Replies: 1 comment
-
It sounds like you're looking to dynamically query postgres when a user types "@" to trigger the mention suggestions, and you want to limit the search results to a smaller set of usernames. I encountered a similar challenge recently, especially with the tippy tooltip not updating as the suggestion data changed. What worked for me was passing the dynamic suggestion data into the editor options and handling the query within the suggestion config. This way, the editor automatically updates the mention suggestions as the user types. Update the query state: CustomMention.configure({
suggestion: {
items: ({ query }) => {
debouncedSetMentionQ(query); // debounced setState to handle search queries
}
}
}); And in your editor options: const editorOptions = {
extensions,
content,
onUpdate: (e) => onUpdate && onUpdate(e.editor.getJSON()),
mentionData, // dynamic array of suggestions
mentionDataIsLoading,
slotBefore: <MenuBar />,
slotAfter: <BottomSaveBar onSave={onSave} />,
};
return (
<Box className="tiptap-editor">
<EditorProvider {...editorOptions}>
...
</Box>
); I don't know if this is the "proper" way to do it, but i struggled finding any documentation on this. |
Beta Was this translation helpful? Give feedback.
-
Hello. I love tiptap but i'm facing an issue with Mention feature.
it expects a static set of names to search from, but in my case i have thousands of names so it becomes really slow.
i'd like to use postgres search (insensitive mode) to narrow down to maybe 5-10 usernames and pass 5-10 names to mention. ideally i don't wanna write a custom function (separate from Mention) to look for "@" in text and do a search and then let Mention do its own search within that least.
Curious if this is doable right now or if it's considered a feature request? and if anyone knows how to go about it.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions