diff --git a/packages/lexical-table/src/LexicalTableSelectionHelpers.ts b/packages/lexical-table/src/LexicalTableSelectionHelpers.ts index bb03a8b2525..90914855c9e 100644 --- a/packages/lexical-table/src/LexicalTableSelectionHelpers.ts +++ b/packages/lexical-table/src/LexicalTableSelectionHelpers.ts @@ -38,6 +38,7 @@ import { $getSelection, $isDecoratorNode, $isElementNode, + $isNodeSelection, $isRangeSelection, $isRootOrShadowRoot, $isTextNode, @@ -460,6 +461,19 @@ export function applyTableHandlers( FORMAT_ELEMENT_COMMAND, (formatType) => { const selection = $getSelection(); + if ( + $isSelectionInTable(selection, tableNode) || + $isNodeSelection(selection) + ) { + selection!.getNodes().forEach((node) => { + const tableCellNode = $findMatchingParent(node, $isTableCellNode); + if (tableCellNode) { + tableCellNode.setFormat(formatType); + } + }); + return false; + } + if ( !$isTableSelection(selection) || !$isSelectionInTable(selection, tableNode)