Skip to content
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: 12 additions & 0 deletions packages/core-data/src/utils/crdt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ export function applyPostChangesToCRDTDoc(

switch ( key ) {
case 'blocks': {
// Account for the case where the content has some invalid blocks, and as a result
// the blocks are undefined but the content is not.
if ( changes.content && ! changes.blocks ) {
try {
// Pull in the parsed blocks from the content, and use that as the new value.
newValue = parse( getRawValue( changes.content ) );
} catch ( e ) {
// No-op as one of the blocks is expected to be invalid.
// This ensures that neither the blocks, nor the content are overwritten.
}
}

let currentBlocks = ymap.get( 'blocks' ) as Y.Array< YBlock >;

// Initialize.
Expand Down
Loading