Open excelwebzone opened 2 months ago
Based on https://lexical.dev/docs/collaboration/react it's critical for collaboration plugin to set editor state to null:
const initialConfig = {
namespace: 'Streamer',
nodes: [...EditorNodes],
onError: (error: Error) => {
throw error;
},
theme: EditorTheme,
editorState: !collaborationId ? initialEditorState : null,
editable: !readOnly,
};
This seems to solve the sync issue, so I see both users making changes at the same time. But now, the editor is empty even though I pass the initialEditorState to the plugin:
<CollaborationPlugin
id={collaborationId}
username={currentUser?.name}
cursorColor={currentUser?.color || undefined}
cursorsContainerRef={containerRef}
providerFactory={createMercureProvider}
initialEditorState={initialEditorState}
shouldBootstrap={!skipCollaborationInit}
/>
Note: Still don't see the cursor of the users..
Quick update: I kinda solve the initialEditorState
empty issue. Had to make sure the editor key and collaboration doesn't change on the component.
As for the cursor, it seems to be working, but when I open for a second user (new browser) it only start showing the cursor after I press enter, even though I see the change the second user name via the send/received message.
Any thought, anyone?
When using the Lexical editor’s CollaborationPlugin with the MercureProvider (based on y-websocket code), real-time collaboration features such as user cursor visibility and document updates are not working. Messages are being sent and received, but changes are not reflected across different users’ views.
Lexical version:
Steps To Reproduce
The current behavior
Although no errors are thrown, the collaboration does not seem to be working between multiple users. Messages are sent and received, but user cursors and updated content are not visible across different users.
The expected behavior
User cursors and document updates should be visible to all connected users in real-time.
Impact of fix
This bug affects all users attempting to use the collaboration feature, causing a lack of real-time collaboration functionality. Fixing this issue would benefit any team or group relying on real-time editing, improving the overall usability of the Lexical editor.