diff --git a/src/components/richEditorTransformErrorRecoveryExtension.test.ts b/src/components/richEditorTransformErrorRecoveryExtension.test.ts index 4a70be05..64ad9ced 100644 --- a/src/components/richEditorTransformErrorRecoveryExtension.test.ts +++ b/src/components/richEditorTransformErrorRecoveryExtension.test.ts @@ -61,6 +61,9 @@ describe('isRecoverableEditorTransformError', () => { expect(isRecoverableEditorTransformError(new RangeError( 'Invalid content for node blockContainer: ', ))).toBe(true) + expect(isRecoverableEditorTransformError(transformError( + 'Cannot join blockGroup onto blockContainer', + ))).toBe(true) expect(isRecoverableEditorTransformError(new RangeError( 'Inserted content deeper than insertion position', ))).toBe(true) @@ -111,6 +114,13 @@ describe('installRichEditorTransformErrorRecovery', () => { ) }) + it('repairs invalid block joins after pull refreshes editor state', () => { + expectDocumentRepairRecovery( + transformError('Cannot join blockGroup onto blockContainer'), + 'invalid_block_join', + ) + }) + it('recovers table selection transactions whose target row changed underneath BlockNote', () => { expectDocumentRepairRecovery( new RangeError('Index 1 out of range for '), diff --git a/src/components/richEditorTransformErrorRecoveryExtension.ts b/src/components/richEditorTransformErrorRecoveryExtension.ts index f0266bda..2ac264fb 100644 --- a/src/components/richEditorTransformErrorRecoveryExtension.ts +++ b/src/components/richEditorTransformErrorRecoveryExtension.ts @@ -36,6 +36,7 @@ interface RepairableBlockNoteEditor { } type RecoveryReason = + | 'invalid_block_join' | 'invalid_insertion_depth' | 'mismatched_transaction' | 'stale_block_reference' @@ -81,11 +82,15 @@ function isTablePositionOutOfRangeError(error: unknown): boolean { return error instanceof RangeError && /^Index \d+ out of range for { console.warn('[editor] Recovered rich-editor transform error:', error) trackEvent('rich_editor_transform_error_recovered', { reason }) }