In collab setup with selections, cursor jumps to a different position without selection being changed


#1

I have set up a collab editor like in collab example on the website but with websockets. Its working fine.

I have now added the functionality where in all the users can see each others selections like in Google docs.

Steps:

  1. Lets say two users are editing the same doc, user0 and user1.
  2. user0’s cursor is somewhere at the start of a line. And user1’s cursor is at the end of that line.
  3. Now, when user0 types a character, user0’s cursor jumps to the position of user1’s cursor. And then the characters are written at this new position.

You can see the sample here -> https://youtu.be/jF-jtEtnnjw

The strange thing is when I try to look into “selection” in EditorState of the editor in chrome DevTools, the selection there shows the position at end of the line (where it should have been). Which means somehow DOM position changed but prosemirror’s position remained correct.

Please let me know, if it seems like a bug or something I am doing wrong. The code I have is all integrated with my application code. So it is hard to separate it out. But let me know, and I will try to figure out something.

Thanks and, BTW awesome editor :slight_smile:


#2

Since this doesn’t happen in the collab demo on the website, it seems to be related to something you’re doing differently. I don’t have enough information to say what, though, and you’ll have to narrow it down before I can say whether it’s a bug in your code or in ProseMirror.


#3

Ok. I will try to narrow it down then.


#4

@abhinavzspace We have had caret sharing for a while in Fidus Writer and this doesn’t happen to us. Must be something about how you implemented it.


#5

@johanneswilm Most likely I am doing something stupid. I just wanted to check. :slight_smile: I am tired trying to debug this issue, so I have kept it aside for a while. I will pick it up in a day or two, and try to isolate it into a separate standalone project, if it still occurs.


#6

FWIW; We have the exact same issue. I’ll report back should I find the cause.


#7

@EtienneLem any luck?


#8

We’re seeing some jumbling issues because of character rewriting with an inline span deco. If you haven’t already, you may want to look through how ViewTreeUpdater is dealing with your document and cursor inside NodeViewDesc.updateChildren.


#9

We were having a similar problem. But, we found out it’s due to a Chrome bug reported here -> https://github.com/ProseMirror/prosemirror/issues/710

It happens when you have a span near your cursor. But works without any problem in Firefox.


#10

Thanks. This worked so easily. Implemented it just now.


#11

What did you implement to fix the issue?


#12

Ah! So thanks to Cursor jumps from the line end to widget decorator I figured my Widget was just missing the key params.