Implement draggable ranges/object through mouse curser.

Ok so a bit of a difficult issue, but most likely possible to implement. What I am trying to is to implement a text cursor which on drag of the mouse cursor, can show where the position of the text cursor/object/range expected position when the drag ends.

Best way to understand this might just be to see a demo(A clean demo of close to what I am trying to reproduce, expect I would use the object, in this case the image as the cursor which is being dragged):

Another demo, it is not as clean, but in the case the image is used rather than the curser in the first case:
https://youtube.com/shorts/-HX65SAgL6k?feature=share

A very simple implementation can easily be made using a ViewPlugin, and replace/widget decoration where I can implement some sort of drag eventHandler, and use posAtCoords to change the position of the widget where drag ends, simple and easy.

But I would like to see the text curser/widget position if the drag ended without the drag ending, just exactly like the first video, I don’t really know how would I go about this.

My best guess on how I may go about it would be to make a virtual/duplicate widget, and actually moving it depending on where the curser is, but then also telling the editor that it is not something to record in the history, I have no ideas how would I go about this. Some guidance, would be very helpful.

Sincerely,
Dex Devlon.

Is this dropCursor?

Yes, this is very close to what I am trying to get, though I need a modified instance of it.

Also I didn’t fully understand the logic so maybe you could help here, and I didn’t want to create another issue as I think so its a bit specific.

Here you create a StateEffect and set the map property to map the position though a ChangeDesc, but I couldn’t ever get it to run, I assumed that it would run every time a change takes place, but it doesn’t. Is it a function that has to called? If so then why does it exists, as it never called anywhere in the code, nor exported? Or is there something that I am missing here? The code I am referring to:

Thanks,
Dex Devlon.

That defines how the effect should be mapped when you, for example, create it from changeByRange and it needs to be transformed for some other change. It’s not common for this to happen, but when it does you need a mapping function for things to be correct.

Ah, that makes a lot of sense. Are there other occurrences of this sort of mapping, as it seems like this is the only one.

Also I feel like this should be in the reference documentation, so maybe you could consider changing it.

Thanks a lot,
Dex Devlon.

And wouldn’t CodeMirror Decoration Underline Example also need to be mapped accordingly, why is the case its not mapped like this there? Is it because of simplicity’s sake?

Thanks,
Dex Devlon.