Displaying a preview of a link under it

Hi all, I’m feeling a little unsure about the best way to approach my current problem, and I was hoping someone could give me a few pointers, or maybe an example to check out.

I’d like to add a feature to our basic ProseMirror editor which detects links (pasted or typed) and renders a preview of the link (the data for which has already been fetched) directly below where the link occurs.

How would one go about doing that?

Does a “link” type need to be part of the schema, or is there another method entirely for detecting certain patterns in the document and rendering something in addition? I read about decorations, but the concepts aren’t too clear in my head.

Thanks!

https://curvenote.github.io/editor/

Dante/packages/dante3/src/editor at master · michelson/Dante · GitHub (builds on top of dante3)