),
);
- tableObserver.listenersToRemove.add(
- editor.registerCommand<ElementFormatType>(
- FORMAT_ELEMENT_COMMAND,
- (formatType) => {
- const selection = $getSelection();
- if (
- !$isTableSelection(selection) ||
- !$isSelectionInTable(selection, tableNode)
- ) {
- return false;
- }
-
- const anchorNode = selection.anchor.getNode();
- const focusNode = selection.focus.getNode();
- if (!$isTableCellNode(anchorNode) || !$isTableCellNode(focusNode)) {
- return false;
- }
-
- const [tableMap, anchorCell, focusCell] = $computeTableMap(
- tableNode,
- anchorNode,
- focusNode,
- );
- const maxRow = Math.max(anchorCell.startRow, focusCell.startRow);
- const maxColumn = Math.max(
- anchorCell.startColumn,
- focusCell.startColumn,
- );
- const minRow = Math.min(anchorCell.startRow, focusCell.startRow);
- const minColumn = Math.min(
- anchorCell.startColumn,
- focusCell.startColumn,
- );
- for (let i = minRow; i <= maxRow; i++) {
- for (let j = minColumn; j <= maxColumn; j++) {
- const cell = tableMap[i][j].cell;
- cell.setFormat(formatType);
-
- const cellChildren = cell.getChildren();
- for (let k = 0; k < cellChildren.length; k++) {
- const child = cellChildren[k];
- if ($isElementNode(child) && !child.isInline()) {
- child.setFormat(formatType);
- }
- }
- }
- }
- return true;
- },
- COMMAND_PRIORITY_CRITICAL,
- ),
- );
-
tableObserver.listenersToRemove.add(
editor.registerCommand(
CONTROLLED_TEXT_INSERTION_COMMAND,