Editing link targets

The current implementation of hyperlinks in the example-setup is adding/removing (and not updating) links. I want to make it possible to edit the properties of the link. I have been looking at the way image nodes are implemented.

But, link properties are part of a mark. So, I was thinking of using something like state.doc.rangeHasMark() (e.g. rangeGetMark()) to find the actual mark that contains the link properties, and use these properties to pre-fill the fields in openPrompt(). Is this a sensible approach, or am I missing some convenient API call?

Yes, that sounds like a reasonable approach. The example setup does something like that for images—if you have an image node selected and do ‘insert image’, it’ll pre-fill the prompt with the image’s attributes.

I think the question here is more like “how to find the Mark in the given range” than “How to fill the prompt”. And since images are nodes and not marks, I don’t see how this gives an answer to the question.

This post however is related to getting a mark in the current selection: Expanding the selection to the active mark?