BitPhinix / slate-yjs

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

「Bug」relativePosition and aboslutePosition transform problem #299

Open pubuzhixing8 opened 3 years ago

pubuzhixing8 commented 3 years ago

Bug description

The cursor of user Adrain Frami was incorrectly converted, and it should be positioned at the last position of the second paragraph。

Cause

We analyzed the reason for this problem. Due to the operation of slate to yjs, the original yjs structure data was deleted (the data structure corresponding to the user's Adrain Frami focus), so an exception occurred when the absolutePositions was converted through relativePosition, and the original corresponding relationship be broken.

Resolve

First of all, I don’t have a solution to this problem. I understand that it may be related to split_node operation.

https://github.com/BitPhinix/slate-yjs/blob/64775edc70eded3f67574c19c825befe4eae177d/src/applyToYjs/node/splitNode.ts#L13

I am not sure if the next branch or v4 is trying to solve this problem

BitPhinix commented 3 years ago

Hi @pubuzhixing8,

Thanks for reporting this issue!

You are correct that this is related to the translation of the split-node operations. It's currently out of the scope for the initial v4 release but this is definitely something that should be fixed in the future.