Range.on("postionchanged", function(){...})?

I understand there is only a removed event for ranges. What’s the recommended way for monitoring whether the from/to Pos values have changed? Should one just listen for pm.on(“change”) and then compare whether all paths and offsets are still the same as they were before the change, and if not trigger the signal?

What do you want to use the event handler for? Even if the from/to contain the same numbers, the marker might now be in a different context (if a parent node was changed or replaced)

What do you want to use the event handler for?

If one doesn’t have Nodejs running on the server, and one needs to store the positions on the server, the client needs to send updates about changes of these to the server.

Even if the from/to contain the same numbers, the marker might now be in a different context (if a parent node was changed or replaced)

Right, that would be fine though.

I was trying to build on your comment system, but noticing that you do really need to run nodejs on the server, I have now come up with an alternative plan: maintain a list of objects (pretty much like you did it in the example), but only give them an id and no selection-info. Additionally, create a CommentMark that only has an ID. The changes to the commentmark will be sent around to collaborators automatically, just like updates to other nodes are propagating through the system. There then only needs to be a piece of JavaScript that links the commentMark with the comment.

Though I still don’t see why you need the positions on the server if the server can’t see through the document, it might be preferable to parse the JSON on the server and search for the nodes you are interested in by looking at the JSON data, rather than building a system where the client is sending redundant information to the server because the server doesn’t understand the main data.

I solved it by created a new comment mark and just have that be part of the document and the commentstore be something maintained by the server apart from that.

So the server is now looking through the JSON, but only the part related to the comment.

I had initially set it up the way you did, with a list of comments maintained by the server, including their from and to positions. But then I realized that the server doesn’t really have a way of finding out whether any positions have changed between any two diffs. The only thing to do there would be that every time the client saves the entire document, it also sends in the current positions of all comments. But then it gets more complicated if a certain comment action has been “approved” by the server (for example the creation of a comment), but there has not yet been a save of the entire document, etc. .