diff --git a/packages/sync/src/manager.ts b/packages/sync/src/manager.ts index dcca0c5d9970e6..7444f1c4b9b318 100644 --- a/packages/sync/src/manager.ts +++ b/packages/sync/src/manager.ts @@ -286,15 +286,19 @@ export function createSyncManager( debug = false ): SyncManager { } ) ); - // Attach observers. - recordMap.observeDeep( onRecordUpdate ); - stateMap.observe( onStateMapUpdate ); - // Initialize the Yjs document with the necessary CRDT state. initializeYjsDoc( ydoc ); // Get and apply the persisted CRDT document, if it exists. + // Observers are attached after hydration so the applyUpdateV2 inside + // _applyPersistedCrdtDoc does not trigger _updateEntityRecord with the + // just-loaded state, which would dispatch a redundant editRecord whose + // blocks already match the editor's parsed content. internal.applyPersistedCrdtDoc( objectType, objectId, record ); + + // Attach observers. + recordMap.observeDeep( onRecordUpdate ); + stateMap.observe( onStateMapUpdate ); } /**