Open GermanJablo opened 1 year ago
UPDATE: merged the two messages above, improved the problem explanation and got the repro to work (can't be codesandbox for collab server to work)
UPDATE 2: I have done the repro on a fork branch of lexical: https://github.com/EgonBolton/lexical/tree/collab-final
This makes it easier to debug CollabPlugin. The steps are the same: npm run dev
and npm run collab-server
.
I've also been able to track where the two updates that fire the listeners are and I've put console.logs in those places:
onAwarenessUpdate > syncCursorPositions
onYjsTreeChanges > syncYjsChangesToLexical > syncEvent(binding, event)
When the CollaborationPlugin handles changing documents by receiving a different id, the listeners fire. Of course, listeners should not fire on document initialization/change. I've noticed that this doesn't happen with the OnChangePlugin, because it checks that the previous editorState is not null, apparently to avoid this situation:
Ideally, this should be the default behavior. But the problem is that even if you wanted to, you couldn't imitate this trick with the other listeners, since updateListener is the only one that receives
prevEditorState
as callback.Lexical version: 0.9.1
Steps To Reproduce
npm run dev
npm run collab-server
content changed
appears in the console.Link to code example: https://github.com/EgonBolton/collab
The current behavior
The listeners are fired, as seen in the console.
The expected behavior
I think the listeners should not fire in this case.