Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behavior offline + online editing #45

Closed
ovionlogis opened this issue Oct 13, 2020 · 7 comments
Closed

Strange behavior offline + online editing #45

ovionlogis opened this issue Oct 13, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@ovionlogis
Copy link

Strange behavior when editing text online and offline at the same time
I ran this demo https://github.com/BitPhinix/slate-yjs-example
Screen Recording 2020-10-13 at 17 09 04

@BitPhinix
Copy link
Owner

Fixed in slate-yjs 0.1.3

@ovionlogis
Copy link
Author

@BitPhinix I tested the demo again, the error repeats exactly the same

@BitPhinix
Copy link
Owner

Hmm weird, I'll recheck this again asap.

@BitPhinix BitPhinix reopened this Oct 14, 2020
@Yshmeel
Copy link

Yshmeel commented Oct 24, 2020

This bug also occurs when you change selected mark at some part of text and refresh page.
And one more bug, i can't select more than 1 mark marks on one line, weird thing...

@BitPhinix
Copy link
Owner

I took a look at this today and the root cause is the way the split_node operation is translated.

Let's say we have 2 clients with the same state (a paragraph with the text hello world):
{type: "paragraph", children: [{ text: "hello world"}]}

Client 1 performs a split_node operation inside the paragraph with offset 5 this results in the following operations:

  • remove text " world" from [0, 0]
  • insert new text node containing " world" at [0, 1]

Client 2 simultaneously performs a split_node operation inside the paragraph with offset 6 this results in the following operations:

  • remove text "world" from [0, 0]
  • insert new text node containing "world" at [0, 1]

If the clients are now synced the remove text operations will be combined and both insert node operations will be applied resulting in both the "word" and " word" text nodes to be inserted. YJs can't know that the new nodes are a result of a split_node operations.

slate-collaborative has the exact same issue cudr/slate-collaborative#29. I'll try to find a solution as soon as I find the time to or just port over the solution of slate-collaborative if they manage to solve it.

@BitPhinix
Copy link
Owner

Closing this issue because this is the intended behavior. For more details refer to: https://discuss.yjs.dev/t/modeling-slate-split-node-behavior-in-yjs/283/2

@big-camel
Copy link

This problem will cause PathRef to fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants