Skip to content

Commit e8e0ad4

Browse files
committed
selection_fix
1 parent 127985b commit e8e0ad4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

packages/lexical-table/src/LexicalTableCellNode.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ export class TableCellNode extends ElementNode {
320320
prevNode.__rowSpan !== this.__rowSpan ||
321321
prevNode.__backgroundColor !== this.__backgroundColor ||
322322
prevNode.__writingMode !== this.__writingMode ||
323-
prevNode.__format !== this.__format ||
324-
this.getFormatType() !== this.getChildFormatType()
323+
prevNode.__format !== this.__format
325324
);
326325
}
327326

packages/lexical-table/src/LexicalTableSelectionHelpers.ts

+15
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,21 @@ export function applyTableHandlers(
443443
FORMAT_ELEMENT_COMMAND,
444444
(formatType) => {
445445
const selection = $getSelection();
446+
if (
447+
$isSelectionInTable(selection, tableNode) &&
448+
selection!.getNodes().length === 1 &&
449+
$isTextNode(selection!.getNodes()[0])
450+
) {
451+
const tableCellNode = $findMatchingParent(
452+
selection!.getNodes()[0],
453+
$isTableCellNode,
454+
);
455+
if (tableCellNode) {
456+
tableCellNode.setFormat(formatType);
457+
}
458+
return false;
459+
}
460+
446461
if (
447462
!$isTableSelection(selection) ||
448463
!$isSelectionInTable(selection, tableNode)

0 commit comments

Comments
 (0)