roosterjs 8.19.0 → 8.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- // Type definitions for roosterjs (Version 8.19.0)
1
+ // Type definitions for roosterjs (Version 8.19.3)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -947,50 +947,54 @@ export const enum TableOperation {
947
947
  * Merge current column with the column on the right
948
948
  */
949
949
  MergeRight = 10,
950
+ /**
951
+ * Merge all selected cells
952
+ */
953
+ MergeCells = 11,
950
954
  /**
951
955
  * Split current table cell horizontally
952
956
  */
953
- SplitHorizontally = 11,
957
+ SplitHorizontally = 12,
954
958
  /**
955
959
  * Split current table cell vertically
956
960
  */
957
- SplitVertically = 12,
961
+ SplitVertically = 13,
958
962
  /**
959
963
  * Align current table at the center
960
964
  */
961
- AlignCenter = 13,
965
+ AlignCenter = 14,
962
966
  /**
963
967
  * Align current table at the left
964
968
  */
965
- AlignLeft = 14,
969
+ AlignLeft = 15,
966
970
  /**
967
971
  * Align current table at the right
968
972
  */
969
- AlignRight = 15,
973
+ AlignRight = 16,
970
974
  /**
971
975
  * Align current content table cell at the left
972
976
  */
973
- AlignCellLeft = 16,
977
+ AlignCellLeft = 17,
974
978
  /**
975
979
  * Align current content table cell at the center
976
980
  */
977
- AlignCellCenter = 17,
981
+ AlignCellCenter = 18,
978
982
  /**
979
983
  * Align current content table cell at the right
980
984
  */
981
- AlignCellRight = 18,
985
+ AlignCellRight = 19,
982
986
  /**
983
987
  * Align current content table cell at the top
984
988
  */
985
- AlignCellTop = 19,
989
+ AlignCellTop = 20,
986
990
  /**
987
991
  * Align current table cell at the middle
988
992
  */
989
- AlignCellMiddle = 20,
993
+ AlignCellMiddle = 21,
990
994
  /**
991
995
  * Align current table cell at the bottom
992
996
  */
993
- AlignCellBottom = 21
997
+ AlignCellBottom = 22
994
998
  }
995
999
 
996
1000
  /**
@@ -5288,6 +5292,7 @@ export class VTable {
5288
5292
  */
5289
5293
  edit(operation: TableOperation): void;
5290
5294
  setAlignmentToSelectedCells(firstRow: number, lastRow: number, firstColumn: number, lastColumn: number, alignmentType: string, isVertical?: boolean): void;
5295
+ private mergeCells;
5291
5296
  /**
5292
5297
  * Loop each cell of current column and invoke a callback function
5293
5298
  * @param callback The callback function to invoke
@@ -5609,7 +5614,7 @@ export class VListItem {
5609
5614
  * @param startNode (Optional) When specified, try get VList which will contain this node.
5610
5615
  * If not specified, get VList from selection of this region
5611
5616
  */
5612
- export function createVListFromRegion(region: Region, includeSiblingLists?: boolean, startNode?: Node): VList;
5617
+ export function createVListFromRegion(region: Region, includeSiblingLists?: boolean, startNode?: Node): VList | null;
5613
5618
 
5614
5619
  /**
5615
5620
  * Represent a chain of list nodes.
@@ -5638,7 +5643,7 @@ export class VListChain {
5638
5643
  * @param container The container node to create list at
5639
5644
  * @param startNumber Start number of the new list
5640
5645
  */
5641
- createVListAtBlock(container: Node, startNumber: number): VList;
5646
+ createVListAtBlock(container: Node, startNumber: number): VList | null;
5642
5647
  /**
5643
5648
  * After change the lists, commit the change to all lists in this chain to update the list number,
5644
5649
  * and clear the temporary dataset values added to list node
@@ -5839,7 +5844,7 @@ export function getPositionRect(position: NodePosition): Rect | null;
5839
5844
  * @param targetNode The node to check
5840
5845
  * @returns True if position is at beginning of the node, otherwise false
5841
5846
  */
5842
- export function isPositionAtBeginningOf(position: NodePosition, targetNode: Node): boolean;
5847
+ export function isPositionAtBeginningOf(position: NodePosition, targetNode: Node | null): boolean;
5843
5848
 
5844
5849
  /**
5845
5850
  * Get path of the given selection range related to the given rootNode
@@ -6141,7 +6146,7 @@ export function adjustInsertPosition(root: HTMLElement, nodeToInsert: Node, posi
6141
6146
  * @param core The EditorCore object.
6142
6147
  * @param range The range to delete
6143
6148
  */
6144
- export function deleteSelectedContent(root: HTMLElement, range: Range): Position;
6149
+ export function deleteSelectedContent(root: HTMLElement, range: Range): null;
6145
6150
 
6146
6151
  /**
6147
6152
  * get block element's text content.
@@ -3279,7 +3279,6 @@ function setIndentation(editor, indentation) {
3279
3279
  i++;
3280
3280
  }
3281
3281
  var isTabKeyTextFeaturesEnabled = editor.isFeatureEnabled("TabKeyTextFeatures" /* TabKeyTextFeatures */);
3282
- vList.rootList.style.listStylePosition = 'inside';
3283
3282
  if (isTabKeyTextFeaturesEnabled &&
3284
3283
  isFirstItem(vList, startNode) &&
3285
3284
  shouldHandleWithBlockquotes(indentation, editor, startNode)) {
@@ -4420,9 +4419,6 @@ function toggleListType(editor, listType, startNumber, includeSiblingLists) {
4420
4419
  : (0, roosterjs_editor_dom_1.createVListFromRegion)(region, includeSiblingLists);
4421
4420
  if (vList) {
4422
4421
  vList.changeListType(start, end, listType);
4423
- if (editor.isFeatureEnabled("TabKeyTextFeatures" /* TabKeyTextFeatures */)) {
4424
- vList.rootList.style.listStylePosition = 'inside';
4425
- }
4426
4422
  vList.writeBack();
4427
4423
  }
4428
4424
  });
@@ -5561,7 +5557,11 @@ var selectTable = function (core, table, coordinates) {
5561
5557
  ensureUniqueId(table, TABLE_ID);
5562
5558
  ensureUniqueId(core.contentDiv, CONTENT_DIV_ID);
5563
5559
  var ranges = select(core, table, coordinates);
5564
- core.api.selectRange(core, (0, roosterjs_editor_dom_1.createRange)(new roosterjs_editor_dom_1.Position(table.rows.item(coordinates.firstCell.y).cells.item(coordinates.firstCell.x), 0 /* Begin */)));
5560
+ if (!isMergedCell(table, coordinates)) {
5561
+ core.api.selectRange(core, (0, roosterjs_editor_dom_1.createRange)(new roosterjs_editor_dom_1.Position(table.rows
5562
+ .item(coordinates.firstCell.y)
5563
+ .cells.item(coordinates.firstCell.x), 0 /* Begin */)));
5564
+ }
5565
5565
  return {
5566
5566
  type: 1 /* TableSelection */,
5567
5567
  ranges: ranges,
@@ -5724,6 +5724,10 @@ function areValidCoordinates(input) {
5724
5724
  function isValidCoordinate(input) {
5725
5725
  return (!!input || input == 0) && input > -1;
5726
5726
  }
5727
+ function isMergedCell(table, coordinates) {
5728
+ var firstCell = coordinates.firstCell;
5729
+ return !(table.rows.item(firstCell.y) && table.rows.item(firstCell.y).cells.item(firstCell.x));
5730
+ }
5727
5731
 
5728
5732
 
5729
5733
  /***/ }),
@@ -6161,7 +6165,7 @@ var CopyPastePlugin = /** @class */ (function () {
6161
6165
  };
6162
6166
  CopyPastePlugin.prototype.cleanUpAndRestoreSelection = function (tempDiv, range, isCopy) {
6163
6167
  var _a, _b;
6164
- if (!!((_a = range) === null || _a === void 0 ? void 0 : _a.type)) {
6168
+ if (!!((_a = range) === null || _a === void 0 ? void 0 : _a.type) || range.type == 0) {
6165
6169
  var selection = range;
6166
6170
  switch (selection.type) {
6167
6171
  case 1 /* TableSelection */:
@@ -9847,13 +9851,14 @@ function adjustInsertPositionForHyperLink(root, nodeToInsert, position, range) {
9847
9851
  * Adjust position for a node don't be nested inside tags like BR, LI, TD.
9848
9852
  */
9849
9853
  function adjustInsertPositionForStructuredNode(root, nodeToInsert, position, range) {
9854
+ var _a, _b, _c;
9850
9855
  var rootNodeToInsert = nodeToInsert;
9851
9856
  if (rootNodeToInsert.nodeType == 11 /* DocumentFragment */) {
9852
9857
  var rootNodes = (0, toArray_1.default)(rootNodeToInsert.childNodes).filter(function (n) { return (0, getTagOfNode_1.default)(n) != 'BR'; });
9853
9858
  rootNodeToInsert = rootNodes.length == 1 ? rootNodes[0] : null;
9854
9859
  }
9855
9860
  var tag = (0, getTagOfNode_1.default)(rootNodeToInsert);
9856
- var hasBrNextToRoot = tag && (0, getTagOfNode_1.default)(rootNodeToInsert.nextSibling) == 'BR';
9861
+ var hasBrNextToRoot = tag && rootNodeToInsert && (0, getTagOfNode_1.default)(rootNodeToInsert.nextSibling) == 'BR';
9857
9862
  var listItem = (0, findClosestElementAncestor_1.default)(position.node, root, 'LI');
9858
9863
  var listNode = listItem && (0, findClosestElementAncestor_1.default)(listItem, root, 'OL,UL');
9859
9864
  var tdNode = (0, findClosestElementAncestor_1.default)(position.node, root, 'TD,TH');
@@ -9862,7 +9867,9 @@ function adjustInsertPositionForStructuredNode(root, nodeToInsert, position, ran
9862
9867
  tag = listNode ? (0, getTagOfNode_1.default)(listNode) : 'UL';
9863
9868
  rootNodeToInsert = (0, wrap_1.default)(rootNodeToInsert, tag);
9864
9869
  }
9865
- if ((tag == 'OL' || tag == 'UL') && (0, getTagOfNode_1.default)(rootNodeToInsert.firstChild) == 'LI') {
9870
+ if ((tag == 'OL' || tag == 'UL') &&
9871
+ rootNodeToInsert &&
9872
+ (0, getTagOfNode_1.default)(rootNodeToInsert.firstChild) == 'LI') {
9866
9873
  var shouldInsertListAsText = !rootNodeToInsert.firstChild.nextSibling && !hasBrNextToRoot;
9867
9874
  if (hasBrNextToRoot && rootNodeToInsert.parentNode) {
9868
9875
  safeRemove(rootNodeToInsert.nextSibling);
@@ -9884,12 +9891,12 @@ function adjustInsertPositionForStructuredNode(root, nodeToInsert, position, ran
9884
9891
  var newTable = new VTable_1.default(rootNodeToInsert);
9885
9892
  var currentTable = new VTable_1.default(tdNode);
9886
9893
  if (currentTable.col == 0 &&
9887
- tdNode == currentTable.getCell(currentTable.row, 0).td &&
9888
- newTable.cells[0] &&
9889
- newTable.cells[0].length == currentTable.cells[0].length &&
9894
+ tdNode == currentTable.getCell(currentTable.row || 0, 0).td &&
9895
+ ((_a = newTable.cells) === null || _a === void 0 ? void 0 : _a[0]) &&
9896
+ newTable.cells[0].length == ((_b = currentTable.cells) === null || _b === void 0 ? void 0 : _b[0].length) &&
9890
9897
  (0, isPositionAtBeginningOf_1.default)(position, tdNode)) {
9891
9898
  if ((0, getTagOfNode_1.default)(rootNodeToInsert.firstChild) == 'TBODY' &&
9892
- !rootNodeToInsert.firstChild.nextSibling) {
9899
+ !((_c = rootNodeToInsert.firstChild) === null || _c === void 0 ? void 0 : _c.nextSibling)) {
9893
9900
  (0, unwrap_1.default)(rootNodeToInsert.firstChild);
9894
9901
  }
9895
9902
  (0, unwrap_1.default)(rootNodeToInsert);
@@ -10018,13 +10025,15 @@ function deleteSelectedContent(root, range) {
10018
10025
  nodesToDelete.forEach(function (node) { var _a; return (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(node); });
10019
10026
  // 4. Merge lines for each region, so that after we don't see extra line breaks
10020
10027
  nodesPairToMerge.forEach(function (nodes) {
10021
- return (0, mergeBlocksInRegion_1.default)(nodes.region, nodes.beforeStart, nodes.afterEnd);
10028
+ if (nodes) {
10029
+ (0, mergeBlocksInRegion_1.default)(nodes.region, nodes.beforeStart, nodes.afterEnd);
10030
+ }
10022
10031
  });
10023
10032
  return nodeBefore && new Position_1.default(nodeBefore, -1 /* End */);
10024
10033
  }
10025
10034
  exports.default = deleteSelectedContent;
10026
10035
  function ensureBeforeAndAfter(node, offset, isStart) {
10027
- var _a;
10036
+ var _a, _b;
10028
10037
  if ((0, safeInstanceOf_1.default)(node, 'Text')) {
10029
10038
  var newNode = (0, splitTextNode_1.default)(node, offset, isStart);
10030
10039
  return isStart ? [newNode, node] : [node, newNode];
@@ -10051,7 +10060,7 @@ function ensureBeforeAndAfter(node, offset, isStart) {
10051
10060
  // need to add empty text node to convert to condition 3
10052
10061
  if ((nodeBefore || nodeAfter) && (!nodeBefore || !nodeAfter)) {
10053
10062
  var emptyNode = node.ownerDocument.createTextNode('');
10054
- (_a = (nodeBefore || nodeAfter).parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(emptyNode, nodeAfter);
10063
+ (_b = (_a = (nodeBefore || nodeAfter)) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(emptyNode, nodeAfter);
10055
10064
  if (nodeBefore) {
10056
10065
  nodeAfter = emptyNode;
10057
10066
  }
@@ -12145,9 +12154,10 @@ var VList = /** @class */ (function () {
12145
12154
  // Use a placeholder to hold the position since the root list may be moved into document fragment later
12146
12155
  this.rootList.parentNode.replaceChild(placeholder, this.rootList);
12147
12156
  this.items.forEach(function (item) {
12148
- if (item.getNewListStart() && item.getNewListStart() != start) {
12157
+ var newListStart = item.getNewListStart();
12158
+ if (newListStart && newListStart != start) {
12149
12159
  listStack.splice(1, listStack.length - 1);
12150
- start = item.getNewListStart();
12160
+ start = newListStart;
12151
12161
  }
12152
12162
  item.writeBack(listStack, _this.rootList);
12153
12163
  var topList = listStack[1];
@@ -12168,9 +12178,6 @@ var VList = /** @class */ (function () {
12168
12178
  });
12169
12179
  // Restore the content to the position of placeholder
12170
12180
  placeholder.parentNode.replaceChild(listStack[0], placeholder);
12171
- // Set rootList to null to avoid this to be called again for the same VList, because
12172
- // after change the rootList may not be available any more (e.g. outdent all items).
12173
- this.rootList = null;
12174
12181
  };
12175
12182
  /**
12176
12183
  * Sets the New List Start Property, that is going to be used to create a new List in the WriteBack function
@@ -12332,7 +12339,7 @@ var VList = /** @class */ (function () {
12332
12339
  if ((0, getListTypeFromNode_1.isListElement)(item)) {
12333
12340
  _this.populateItems(item, newListTypes);
12334
12341
  }
12335
- else if (item.nodeType != 3 /* Text */ || item.nodeValue.trim() != '') {
12342
+ else if (item.nodeType != 3 /* Text */ || (item.nodeValue || '').trim() != '') {
12336
12343
  _this.items.push(new (VListItem_1.default.bind.apply(VListItem_1.default, __spreadArray([void 0, item], newListTypes, false)))());
12337
12344
  }
12338
12345
  });
@@ -12434,7 +12441,7 @@ var VListChain = /** @class */ (function () {
12434
12441
  var chain = chains.filter(function (c) { return c.canAppendToTail(list); })[0] ||
12435
12442
  new VListChain(region, (nameGenerator || createListChainName)());
12436
12443
  var index = chains.indexOf(chain);
12437
- var afterCurrentNode = currentNode && (0, isNodeAfter_1.default)(list, currentNode);
12444
+ var afterCurrentNode = !!currentNode && (0, isNodeAfter_1.default)(list, currentNode);
12438
12445
  if (!afterCurrentNode) {
12439
12446
  // Make sure current one is at the front if current block has not been met, so that
12440
12447
  // the first chain is always the nearest one from current node
@@ -12467,7 +12474,7 @@ var VListChain = /** @class */ (function () {
12467
12474
  * @param startNumber Start number of the new list
12468
12475
  */
12469
12476
  VListChain.prototype.createVListAtBlock = function (container, startNumber) {
12470
- if (container) {
12477
+ if (container && container.parentNode) {
12471
12478
  var list = container.ownerDocument.createElement('ol');
12472
12479
  list.start = startNumber;
12473
12480
  this.applyChainName(list);
@@ -12491,7 +12498,7 @@ var VListChain = /** @class */ (function () {
12491
12498
  var list = lists[i];
12492
12499
  list.start = lastNumber + 1;
12493
12500
  var vlist = new VList_1.default(list);
12494
- lastNumber = vlist.getLastItemNumber();
12501
+ lastNumber = vlist.getLastItemNumber() || 0;
12495
12502
  delete list.dataset[CHAIN_DATASET_NAME];
12496
12503
  delete list.dataset[AFTER_CURSOR_DATASET_NAME];
12497
12504
  vlist.writeBack();
@@ -12511,7 +12518,7 @@ var VListChain = /** @class */ (function () {
12511
12518
  */
12512
12519
  VListChain.prototype.append = function (list, isAfterCurrentNode) {
12513
12520
  this.applyChainName(list);
12514
- this.lastNumber = new VList_1.default(list).getLastItemNumber();
12521
+ this.lastNumber = new VList_1.default(list).getLastItemNumber() || 0;
12515
12522
  if (isAfterCurrentNode) {
12516
12523
  list.dataset[AFTER_CURSOR_DATASET_NAME] = 'true';
12517
12524
  }
@@ -12755,7 +12762,7 @@ var VListItem = /** @class */ (function () {
12755
12762
  }
12756
12763
  // 3. Add current node into deepest list element
12757
12764
  listStack[listStack.length - 1].appendChild(this.node);
12758
- this.node.style.display = this.dummy ? 'block' : null;
12765
+ this.node.style.setProperty('display', this.dummy ? 'block' : null);
12759
12766
  // 4. Inherit styles of the child element to the li, so we are able to apply the styles to the ::marker
12760
12767
  if (this.listTypes.length > 1) {
12761
12768
  if (!(this.node.style.fontSize || this.node.style.color || this.node.style.fontFamily)) {
@@ -12797,7 +12804,7 @@ function createListElement(newRoot, listType, nextLevel, originalRoot) {
12797
12804
  result = doc.createElement(listType == 1 /* Ordered */ ? 'ol' : 'ul');
12798
12805
  }
12799
12806
  if (listType == 1 /* Ordered */ && nextLevel > 1) {
12800
- result.style.listStyleType = orderListStyles[(nextLevel - 1) % orderListStyles.length];
12807
+ result.style.setProperty('list-style-type', orderListStyles[(nextLevel - 1) % orderListStyles.length]);
12801
12808
  }
12802
12809
  return result;
12803
12810
  }
@@ -12894,18 +12901,22 @@ function createVListFromRegion(region, includeSiblingLists, startNode) {
12894
12901
  }
12895
12902
  var vList = null;
12896
12903
  if (nodes.length > 0) {
12897
- var firstNode = nodes.shift();
12904
+ var firstNode = nodes.shift() || null;
12898
12905
  vList = (0, getListTypeFromNode_1.isListElement)(firstNode)
12899
12906
  ? new VList_1.default(firstNode)
12900
- : createVListFromItemNode(firstNode);
12901
- nodes.forEach(function (node) {
12902
- if ((0, getListTypeFromNode_1.isListElement)(node)) {
12903
- vList.mergeVList(new VList_1.default(node));
12904
- }
12905
- else {
12906
- vList.appendItem(node, 0 /* None */);
12907
- }
12908
- });
12907
+ : firstNode
12908
+ ? createVListFromItemNode(firstNode)
12909
+ : null;
12910
+ if (vList) {
12911
+ nodes.forEach(function (node) {
12912
+ if ((0, getListTypeFromNode_1.isListElement)(node)) {
12913
+ vList.mergeVList(new VList_1.default(node));
12914
+ }
12915
+ else {
12916
+ vList.appendItem(node, 0 /* None */);
12917
+ }
12918
+ });
12919
+ }
12909
12920
  }
12910
12921
  return vList;
12911
12922
  }
@@ -13055,11 +13066,11 @@ exports.default = setListItemStyle;
13055
13066
  function getInlineChildElementsStyle(element) {
13056
13067
  var result = [];
13057
13068
  var contentTraverser = ContentTraverser_1.default.createBodyTraverser(element);
13058
- var currentInlineElement;
13069
+ var currentInlineElement = null;
13059
13070
  while (contentTraverser.currentInlineElement != currentInlineElement) {
13060
13071
  currentInlineElement = contentTraverser.currentInlineElement;
13061
- var currentNode = currentInlineElement.getContainerNode();
13062
- currentNode = (0, findClosestElementAncestor_1.default)(currentNode);
13072
+ var currentNode = (currentInlineElement === null || currentInlineElement === void 0 ? void 0 : currentInlineElement.getContainerNode()) || null;
13073
+ currentNode = currentNode ? (0, findClosestElementAncestor_1.default)(currentNode) : null;
13063
13074
  if ((0, safeInstanceOf_1.default)(currentNode, 'HTMLElement')) {
13064
13075
  var childStyle = (0, getStyles_1.default)(currentNode);
13065
13076
  if (childStyle) {
@@ -14706,13 +14717,7 @@ var VTable = /** @class */ (function () {
14706
14717
  if (cell.td && !cell.spanAbove) {
14707
14718
  var aboveCell = rowIndex < this.row ? cell : currentCell;
14708
14719
  var belowCell = rowIndex < this.row ? currentCell : cell;
14709
- if (aboveCell.td &&
14710
- belowCell.td &&
14711
- aboveCell.td.colSpan == belowCell.td.colSpan) {
14712
- (0, moveChildNodes_1.default)(aboveCell.td, belowCell.td, true /*keepExistingChildren*/);
14713
- belowCell.td = null;
14714
- belowCell.spanAbove = true;
14715
- }
14720
+ this.mergeCells(aboveCell, belowCell);
14716
14721
  break;
14717
14722
  }
14718
14723
  }
@@ -14725,21 +14730,29 @@ var VTable = /** @class */ (function () {
14725
14730
  if (cell.td && !cell.spanLeft) {
14726
14731
  var leftCell = colIndex < this.col ? cell : currentCell;
14727
14732
  var rightCell = colIndex < this.col ? currentCell : cell;
14728
- if (leftCell.td &&
14729
- rightCell.td &&
14730
- leftCell.td.rowSpan == rightCell.td.rowSpan) {
14731
- (0, moveChildNodes_1.default)(leftCell.td, rightCell.td, true /*keepExistingChildren*/);
14732
- rightCell.td = null;
14733
- rightCell.spanLeft = true;
14734
- }
14733
+ this.mergeCells(leftCell, rightCell, true /** horizontally */);
14735
14734
  break;
14736
14735
  }
14737
14736
  }
14738
14737
  break;
14738
+ case 11 /* MergeCells */:
14739
+ for (var colIndex = firstColumn; colIndex <= lastColumn; colIndex++) {
14740
+ for (var rowIndex = firstRow + 1; rowIndex <= lastRow; rowIndex++) {
14741
+ var cell = this.getCell(firstRow, colIndex);
14742
+ var nextCellBelow = this.getCell(rowIndex, colIndex);
14743
+ this.mergeCells(cell, nextCellBelow);
14744
+ }
14745
+ }
14746
+ for (var colIndex = firstColumn + 1; colIndex <= lastColumn; colIndex++) {
14747
+ var cell = this.getCell(firstRow, firstColumn);
14748
+ var nextCellRight = this.getCell(firstRow, colIndex);
14749
+ this.mergeCells(cell, nextCellRight, true /** horizontally */);
14750
+ }
14751
+ break;
14739
14752
  case 4 /* DeleteTable */:
14740
14753
  this.cells = null;
14741
14754
  break;
14742
- case 12 /* SplitVertically */:
14755
+ case 13 /* SplitVertically */:
14743
14756
  if (currentCell.td && currentCell.td.rowSpan > 1) {
14744
14757
  this.getCell(this.row + 1, this.col).td = cloneNode(currentCell.td);
14745
14758
  }
@@ -14754,7 +14767,7 @@ var VTable = /** @class */ (function () {
14754
14767
  this.cells.splice(this.row + 1, 0, splitRow);
14755
14768
  }
14756
14769
  break;
14757
- case 11 /* SplitHorizontally */:
14770
+ case 12 /* SplitHorizontally */:
14758
14771
  if (currentCell.td && currentCell.td.colSpan > 1) {
14759
14772
  this.getCell(this.row, this.col + 1).td = cloneNode(currentCell.td);
14760
14773
  }
@@ -14768,34 +14781,34 @@ var VTable = /** @class */ (function () {
14768
14781
  });
14769
14782
  }
14770
14783
  break;
14771
- case 13 /* AlignCenter */:
14784
+ case 14 /* AlignCenter */:
14772
14785
  this.table.style.marginLeft = 'auto';
14773
14786
  this.table.style.marginRight = 'auto';
14774
14787
  break;
14775
- case 14 /* AlignLeft */:
14788
+ case 15 /* AlignLeft */:
14776
14789
  this.table.style.marginLeft = '';
14777
14790
  this.table.style.marginRight = 'auto';
14778
14791
  break;
14779
- case 15 /* AlignRight */:
14792
+ case 16 /* AlignRight */:
14780
14793
  this.table.style.marginLeft = 'auto';
14781
14794
  this.table.style.marginRight = '';
14782
14795
  break;
14783
- case 17 /* AlignCellCenter */:
14796
+ case 18 /* AlignCellCenter */:
14784
14797
  this.setAlignmentToSelectedCells(firstRow, lastRow, firstColumn, lastColumn, 'center');
14785
14798
  break;
14786
- case 16 /* AlignCellLeft */:
14799
+ case 17 /* AlignCellLeft */:
14787
14800
  this.setAlignmentToSelectedCells(firstRow, lastRow, firstColumn, lastColumn, 'left');
14788
14801
  break;
14789
- case 18 /* AlignCellRight */:
14802
+ case 19 /* AlignCellRight */:
14790
14803
  this.setAlignmentToSelectedCells(firstRow, lastRow, firstColumn, lastColumn, 'right');
14791
14804
  break;
14792
- case 19 /* AlignCellTop */:
14805
+ case 20 /* AlignCellTop */:
14793
14806
  this.setAlignmentToSelectedCells(firstRow, lastRow, firstColumn, lastColumn, 'top', true /** isVertical */);
14794
14807
  break;
14795
- case 20 /* AlignCellMiddle */:
14808
+ case 21 /* AlignCellMiddle */:
14796
14809
  this.setAlignmentToSelectedCells(firstRow, lastRow, firstColumn, lastColumn, 'middle', true /** isVertical */);
14797
14810
  break;
14798
- case 21 /* AlignCellBottom */:
14811
+ case 22 /* AlignCellBottom */:
14799
14812
  this.setAlignmentToSelectedCells(firstRow, lastRow, firstColumn, lastColumn, 'bottom', true /** isVertical */);
14800
14813
  break;
14801
14814
  }
@@ -14816,6 +14829,22 @@ var VTable = /** @class */ (function () {
14816
14829
  }
14817
14830
  }
14818
14831
  };
14832
+ VTable.prototype.mergeCells = function (cell, nextCell, horizontally) {
14833
+ var _a, _b, _c, _d;
14834
+ var checkSpans = horizontally
14835
+ ? ((_a = cell.td) === null || _a === void 0 ? void 0 : _a.rowSpan) === ((_b = nextCell.td) === null || _b === void 0 ? void 0 : _b.rowSpan) && !cell.spanLeft
14836
+ : ((_c = cell.td) === null || _c === void 0 ? void 0 : _c.colSpan) === ((_d = nextCell.td) === null || _d === void 0 ? void 0 : _d.colSpan) && !cell.spanAbove;
14837
+ if (cell.td && nextCell.td && checkSpans) {
14838
+ (0, moveChildNodes_1.default)(cell.td, nextCell.td, true /*keepExistingChildren*/);
14839
+ nextCell.td = null;
14840
+ if (horizontally) {
14841
+ nextCell.spanLeft = true;
14842
+ }
14843
+ else {
14844
+ nextCell.spanAbove = true;
14845
+ }
14846
+ }
14847
+ };
14819
14848
  /**
14820
14849
  * Loop each cell of current column and invoke a callback function
14821
14850
  * @param callback The callback function to invoke
@@ -23645,10 +23674,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
23645
23674
  * and the last cell always going to be last selected in the table.
23646
23675
  */
23647
23676
  function normalizeTableSelection(vTable) {
23648
- if (!vTable || !vTable.selection) {
23677
+ var _a = (vTable === null || vTable === void 0 ? void 0 : vTable.selection) || {}, firstCell = _a.firstCell, lastCell = _a.lastCell;
23678
+ if (!vTable || !vTable.selection || !firstCell || !lastCell) {
23649
23679
  return null;
23650
23680
  }
23651
- var _a = vTable.selection, firstCell = _a.firstCell, lastCell = _a.lastCell;
23652
23681
  var rows = vTable.table.rows;
23653
23682
  var newFirst = {
23654
23683
  x: Math.min(firstCell.x, lastCell.x),
@@ -23673,8 +23702,8 @@ function normalizeTableSelection(vTable) {
23673
23702
  coord.x = rowsCells - 1;
23674
23703
  }
23675
23704
  };
23676
- fixCoordinates(firstCell);
23677
- fixCoordinates(lastCell);
23705
+ fixCoordinates(newFirst);
23706
+ fixCoordinates(newLast);
23678
23707
  return { firstCell: newFirst, lastCell: newLast };
23679
23708
  }
23680
23709
  exports.default = normalizeTableSelection;