Suggestions - matching multiple words with spaces from dynamic list

Hi, I would appreciate if anyone could tell me if what I am trying to do is possible and maybe some pointers to right way?

My usecase: When you type @, suggestions popup shows and you can type, list is fetched from server. Sounds easy, but since there may be spaces between words, I am not sure when to stop suggesting.

For this reason, I was thinking it would be useful to somehow change context when I am in suggestion mode. Maybe when I type @, inputbox or editable span appears inline in editor and I type in it until I press enter. On enter, I leave inputbox/span and either insert the text to editor (when no match) or insert new node (if any match).

Notion uses something similar, which is good because you know exactly what you are trying to parse: image

I am playing with the suggestions extension but it works well when you have the suggestion list. In my case I don’t have list but rather send search query to server so there is no way for me to say when to stop sending. I think using inputbox or editable span would give me exact boundaries to know what words I am trying to match and based on that I could tell if I can match it or not.

Thanks for any suggestions

It should be possible to track the extent of the current completion in custom plugin state, without creating a different element in the actual DOM (assuming that you only want to start completion when typing an @).

The source code of tiptap’s suggestion is a good starting point: https://github.com/ueberdosis/tiptap/blob/main/packages/tiptap-extensions/src/plugins/Suggestions.js.