words/engine: guard the mark-walk against undefined block slots

`getActiveMarksForSelection` → `collectBlockText` switched on `block.type`
without a null check. When a table cell (inside a column) momentarily held an
undefined child slot, the walk threw `Cannot read properties of undefined
(reading 'type')`. The throw propagated out of `insertBlockInColumn` →
`applyHistoryCommand` uncaught, aborting the command and leaving the editor
unable to edit anything (and the column "add block" silently failing).

Add an `if (!block) return` guard at the top of `collectBlockText` so a partial
slot is skipped instead of crashing the whole command. Surfaced via the Chrome
console (TypeError in selection-walkers.ts ← insert-block-types.ts:309).

Engine tests 42/42 pass; selection-walkers type-checks clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
active-uix
dev 4 months ago
parent 2f6bdb4831
commit 76b0d1c8de

@ -67,10 +67,15 @@ export function getTextEntries(doc: WordsDocument): readonly WordsTextEntry[] {
} }
function collectBlockText( function collectBlockText(
block: WordsDocument['children'][number], block: WordsDocument['children'][number] | undefined,
path: WordsPath, path: WordsPath,
out: WordsTextEntry[] out: WordsTextEntry[]
): void { ): void {
// Robustness: a cell / column / callout child slot can momentarily be
// undefined during an editing transition. Skip it rather than throwing
// from the mark-walk — an uncaught error here aborts the command and
// leaves the editor unable to edit at all.
if (!block) return;
switch (block.type) { switch (block.type) {
case 'paragraph': case 'paragraph':
case 'heading': case 'heading':

Loading…
Cancel
Save

Powered by TurnKey Linux.