fix: recover table-cell transform errors
This commit is contained in:
@@ -139,6 +139,13 @@ describe('installRichEditorTransformErrorRecovery', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('repairs invalid table-cell joins while editing table contents', () => {
|
||||
expectDocumentRepairRecovery(
|
||||
transformError('Cannot join tableCell onto blockContainer'),
|
||||
'invalid_block_join',
|
||||
)
|
||||
})
|
||||
|
||||
it('recovers invalid block joins thrown during keydown handling before dispatch', () => {
|
||||
const { view, keyDownPlugin } = createViewWithSomeProp(() => {
|
||||
throw transformError('Cannot join blockGroup onto blockContainer')
|
||||
@@ -155,6 +162,22 @@ describe('installRichEditorTransformErrorRecovery', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('recovers invalid table-cell joins thrown during keydown handling', () => {
|
||||
const { view, keyDownPlugin } = createViewWithSomeProp(() => {
|
||||
throw transformError('Cannot join tableCell onto blockContainer')
|
||||
})
|
||||
const recoverDocument = vi.fn()
|
||||
|
||||
installRichEditorTransformErrorRecovery(view, { recoverDocument })
|
||||
|
||||
expect(view.someProp('handleKeyDown', (handler) => handler())).toBe(true)
|
||||
expect(keyDownPlugin).toHaveBeenCalledTimes(1)
|
||||
expect(recoverDocument).toHaveBeenCalledTimes(1)
|
||||
expect(trackEvent).toHaveBeenCalledWith('rich_editor_transform_error_recovered', {
|
||||
reason: 'invalid_block_join',
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps unrelated keydown handler failures visible', () => {
|
||||
const { view } = createViewWithSomeProp(() => {
|
||||
throw new Error('keyboard plugin failed')
|
||||
|
||||
@@ -92,7 +92,7 @@ function isTablePositionOutOfRangeError(error: unknown): boolean {
|
||||
}
|
||||
|
||||
function isInvalidBlockJoinError(error: unknown): boolean {
|
||||
return isTransformError(error) && error.message === 'Cannot join blockGroup onto blockContainer'
|
||||
return isTransformError(error) && /^Cannot join (blockGroup|tableCell) onto blockContainer$/.test(error.message)
|
||||
}
|
||||
|
||||
export function isStaleBlockReferenceError(error: unknown): boolean {
|
||||
|
||||
Reference in New Issue
Block a user