BookStackApp/BookStack · error · Error

Expected table cell to be inside of table.

Error message

Expected table cell to be inside of table.

What it means

Internal invariant in $getTableNodeFromLexicalNodeOrThrow: no ancestor TableNode is found for the given node, meaning the starting node does not belong to any table. Input at fault: a LexicalNode outside of a TableNode.

Source

Thrown at resources/js/wysiwyg/lexical/table/LexicalTableUtils.ts:115

  const node = $findMatchingParent(startingNode, (n) => $isTableRowNode(n));

  if ($isTableRowNode(node)) {
    return node;
  }

  throw new Error('Expected table cell to be inside of table row.');
}

export function $getTableNodeFromLexicalNodeOrThrow(
  startingNode: LexicalNode,
): TableNode {
  const node = $findMatchingParent(startingNode, (n) => $isTableNode(n));

  if ($isTableNode(node)) {
    return node;
  }

  throw new Error('Expected table cell to be inside of table.');
}

export function $getTableRowIndexFromTableCellNode(
  tableCellNode: TableCellNode,
): number {
  const tableRowNode = $getTableRowNodeFromTableCellNodeOrThrow(tableCellNode);
  const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableRowNode);
  return tableNode.getChildren().findIndex((n) => n.is(tableRowNode));
}

export function $getTableColumnIndexFromTableCellNode(
  tableCellNode: TableCellNode,
): number {
  const tableRowNode = $getTableRowNodeFromTableCellNodeOrThrow(tableCellNode);
  return tableRowNode.getChildren().findIndex((n) => n.is(tableCellNode));
}

export type TableCellSiblings = {

View on GitHub (pinned to 18f8469a1c)

Solutions

  1. Ensure the node passed is inside a table before requesting its TableNode
  2. Check $isTableNode on ancestors first and skip table operations otherwise
  3. Verify selection is not on a node that was just removed from the table
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at resources/js/wysiwyg/lexical/table/LexicalTableUtils.ts:115 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BookStackApp/BookStack@18f8469a1c (2026-09-02). Data as JSON: /api/errors/193a212133642631. Report an issue: GitHub.