Skip to content
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

Initialize collab document and undo as early as possible #151

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/components/collaborative-editing/use-yjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { createMutex } from 'lib0/mutex';
import { v4 as uuidv4 } from 'uuid';
import { noop, once, sample } from 'lodash';
import { noop, sample } from 'lodash';

/**
* Internal dependencies
Expand Down Expand Up @@ -67,13 +67,9 @@ async function initYDoc( { settings, registry } ) {
},
} );

doc.onConnectionReady(
once( () => {
debug( 'Connection ready. Setting up ydoc document and undo manager' );
dispatch( 'isolated/editor' ).setYDoc( doc );
setupUndoManager( doc.getPostMap(), identity, registry );
} )
);
debug( 'Collab enabled. Setting up ydoc document and undo manager' );
dispatch( 'isolated/editor' ).setYDoc( doc );
setupUndoManager( doc.getPostMap(), identity, registry );

doc.onYDocTriggeredChange( ( changes ) => {
debug( 'changes triggered by ydoc, applying to editor state', changes );
Expand Down