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?

Using state.doc.rangeHasMark() I am not able to find the mark.

Is there any other way of finding the mark that contains the link properties

I realize this is an old post however my code may be of help to someone with this issue. Note that I am very new to Prosemirror, so there may well be better ways to accomplish this.

See my post: How to get the determined attributes from a mark