BitPhinix / slate-yjs

Yjs binding for Slate
https://docs.slate-yjs.dev
MIT License
514 stars 73 forks source link

Undo after replacing selected text with mark is bringing back mark incorrectly and throws exceptions afterwards #379

Open oskar-szwajkowski opened 1 year ago

oskar-szwajkowski commented 1 year ago

I am having setup with plate editor + yjs + yjshistory and cursor, basically all plugins that can be put there are working together

It is working for some time already without problems, but I have run into case when it breaks when selected text contains marks, and then we Undo (ctrl + z)

Suddenly more text than before contains this mark, and when we click on it, it throws Path doesn't match yText, yTarget spans multiple nodes

Similar error has thrown when I tried to create plugin which wraps around slate's insertText and was doing removeMark + insertText, because I have some functionality that works as marks, but I do not want it to be transfered to newly typed text as rest of marks are doing, everything is fine until I do Undo, which is then adding this mark to some additional text and it breaks

It can also be reproduced on slate-yjs demo page Slate-yjs Playground page

Video of this issue:

https://user-images.githubusercontent.com/26646354/204486421-c3a7c873-cdd6-49e4-baa3-d417380091a5.mp4

arekczarny commented 1 year ago

This is what we also see in our project. Would be great to have this one resolved.

hakanshehu commented 1 year ago

@oskar-szwajkowski were you able to find a workaround for this one?

oskar-szwajkowski commented 1 year ago

@oskar-szwajkowski were you able to find a workaround for this one?

Not really, I am not working with slate anymore, so honestly I forgot about this issue