fix: recover paragraph editor index errors

This commit is contained in:
lucaronin
2026-06-07 02:49:04 +02:00
parent 3d28e21a5a
commit 48eac1e40d
4 changed files with 54 additions and 10 deletions

View File

@@ -95,6 +95,12 @@ describe('isRecoverableEditorTransformError', () => {
expect(isRecoverableEditorTransformError(new Error(
'Index 1 out of range for <tableRow(tableCell(tableParagraph("A")))>',
))).toBe(true)
expect(isRecoverableEditorTransformError(new RangeError(
'Index 1 out of range for <paragraph("/")>',
))).toBe(true)
expect(isRecoverableEditorTransformError(new Error(
'Index 1 out of range for <paragraph("/")>',
))).toBe(true)
expect(isRecoverableEditorTransformError(new Error(
'Block with ID 6c1c3bb4-e218-4f00-aaf5-40606852d286 not found',
))).toBe(true)
@@ -106,9 +112,6 @@ describe('isRecoverableEditorTransformError', () => {
expect(isRecoverableEditorTransformError(new TypeError(
"Cannot read properties of null (reading 'append')",
))).toBe(false)
expect(isRecoverableEditorTransformError(new RangeError(
'Index 1 out of range for <paragraph("A")>',
))).toBe(false)
expect(isRecoverableEditorTransformError(new Error('unrelated'))).toBe(false)
})
})
@@ -218,6 +221,13 @@ describe('installRichEditorTransformErrorRecovery', () => {
)
})
it('recovers production paragraph index transactions from stale slash input', () => {
expectDocumentRepairRecovery(
new RangeError('Index 1 out of range for <paragraph("/")>'),
'paragraph_position_out_of_range',
)
})
it('recovers invalid insertion-depth transactions after note switching and saves', () => {
expectDocumentRepairRecovery(
new RangeError('Inserted content deeper than insertion position'),