Open Isini-Dananjana opened 1 year ago
I resolved this by making sure that the editor is not mounted until the yjs SyncStep2 has completed which means any existing clients have synced up their changes. If you mount too early, the data isn't yet synced, so the children is empty and the new line will be added.
Not sure about Plate but I got it to work for the example in this repo the same way @rcbevans did. After configuring the HocusPocus provider, you can use the listener - provider.on('synced', ...callback) to set a flag to true that will then render your slate editor component. You need to move editor initialization code to a subcomponent which is only rendered after the flag is set tot true. This will make sure that the editor will already have the synced data state and not the empty data state when it is mounted and calls Normalize Node for the .
This is just the example implementation (which adds an empty paragraph automatically). If you remove that you'll be fine
@rcbevans can u share the core part code, or give a example
Discussed in https://github.com/BitPhinix/slate-yjs/discussions/384