-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
An empty line is added when the user opens or reloads the the document . #385
Comments
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 |
FWIW I found that I couldn't get this to not happen because of the way plate plugins orchestrate things. The yjs stuff is set up inside the plate context, after you've done things like deal with initial value etc. We added a normaliser to remove dupe empty lines at the top of the document. |
Discussed in #384
Originally posted by Isini-Dananjana February 23, 2023
When using YJS with Plate, it adds a new line to the top of a shared document whenever a new user joins the collaboration session. I think this happens due to the following code found in yTextToSlateElement.
When multiple users are in the same document, this empty line that is added also gets synced, resulting in many empty lines.
Any idea how to resolve the issue?
The text was updated successfully, but these errors were encountered: