@windoc/core 0.3.21 → 0.3.22

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.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var version = "0.3.21";
2
+ var version = "0.3.22";
3
3
 
4
4
  // src/dataset/enum/Common.ts
5
5
  var MaxHeightRatio = /* @__PURE__ */ ((MaxHeightRatio2) => {
@@ -424,7 +424,7 @@ var ElementType = /* @__PURE__ */ ((ElementType2) => {
424
424
  // src/utils/ua.ts
425
425
  var isApple = typeof navigator !== "undefined" && /Mac OS X/.test(navigator.userAgent);
426
426
  var isIOS = typeof navigator !== "undefined" && /iPad|iPhone/.test(navigator.userAgent);
427
- var isMobile = /Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
427
+ var isMobile = typeof navigator !== "undefined" && /Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
428
428
  navigator.userAgent
429
429
  );
430
430
  var isFirefox = typeof navigator !== "undefined" && /Firefox/.test(navigator.userAgent);
@@ -519,6 +519,8 @@ var TABLE_TD_ZIP_ATTR = [
519
519
  "externalId",
520
520
  "verticalAlign",
521
521
  "backgroundColor",
522
+ "borderColor",
523
+ "padding",
522
524
  "borderTypes",
523
525
  "slashTypes",
524
526
  "disabled",
@@ -4937,6 +4939,37 @@ function pickElementAttr(payload, option = {}) {
4937
4939
  });
4938
4940
  return element;
4939
4941
  }
4942
+ function mergeSplitTableRowsForZip(trList) {
4943
+ for (let t = trList.length - 1; t >= 0; t--) {
4944
+ const splitTr = trList[t];
4945
+ if (!splitTr.splitParentId) continue;
4946
+ const parentTrIdx = trList.findIndex(
4947
+ (tr) => tr.id === splitTr.splitParentId
4948
+ );
4949
+ if (!~parentTrIdx) continue;
4950
+ const parentTr = trList[parentTrIdx];
4951
+ parentTr.height += splitTr.height;
4952
+ for (let d = 0; d < parentTr.tdList.length; d++) {
4953
+ const parentTd = parentTr.tdList[d];
4954
+ const splitTd = splitTr.tdList[d];
4955
+ if (!parentTd || !splitTd) continue;
4956
+ const hasSyntheticLeadingZero = !!splitTd.splitSyntheticLeadingZero && splitTd.value[0]?.value === ZERO;
4957
+ parentTd.value.push(
4958
+ ...hasSyntheticLeadingZero ? splitTd.value.slice(1) : splitTd.value
4959
+ );
4960
+ }
4961
+ trList.splice(t, 1);
4962
+ }
4963
+ for (let t = 0; t < trList.length; t++) {
4964
+ const tr = trList[t];
4965
+ delete tr.id;
4966
+ delete tr.splitParentId;
4967
+ delete tr.splitRootId;
4968
+ delete tr.splitLevel;
4969
+ delete tr.splitBoundaryTop;
4970
+ delete tr.splitBoundaryBottom;
4971
+ }
4972
+ }
4940
4973
  function zipElementList(payload, options = {}) {
4941
4974
  const { extraPickAttrs, isClassifyArea = false, isClone = true } = options;
4942
4975
  const elementList = isClone ? deepClone(payload) : payload;
@@ -5036,8 +5069,11 @@ function zipElementList(payload, options = {}) {
5036
5069
  while (tableIndex < elementList.length) {
5037
5070
  const nextElement = elementList[tableIndex];
5038
5071
  if (nextElement.pagingId === element.pagingId) {
5072
+ const nextTrList = nextElement.trList.filter(
5073
+ (tr) => !tr.pagingRepeat
5074
+ );
5039
5075
  element.height += nextElement.height;
5040
- element.trList.push(...nextElement.trList);
5076
+ element.trList.push(...nextTrList);
5041
5077
  tableIndex++;
5042
5078
  combineCount++;
5043
5079
  } else {
@@ -5047,9 +5083,9 @@ function zipElementList(payload, options = {}) {
5047
5083
  e += combineCount;
5048
5084
  }
5049
5085
  if (element.trList) {
5086
+ mergeSplitTableRowsForZip(element.trList);
5050
5087
  for (let t = 0; t < element.trList.length; t++) {
5051
5088
  const tr = element.trList[t];
5052
- delete tr.id;
5053
5089
  for (let d = 0; d < tr.tdList.length; d++) {
5054
5090
  const td = tr.tdList[d];
5055
5091
  const zipTd = {
@@ -6749,6 +6785,57 @@ var RadioControl = class extends CheckboxControl {
6749
6785
  }
6750
6786
  };
6751
6787
 
6788
+ // src/core/event/handlers/splitCell.ts
6789
+ function isSameSplitCellSelection(first, second) {
6790
+ if (!first || !second) return false;
6791
+ return first.pagingId === second.pagingId && first.rootTrId === second.rootTrId && first.colIndex === second.colIndex;
6792
+ }
6793
+ function getSplitCellPointer(draw, position) {
6794
+ if (!position.isTable || position.index === void 0 || position.tdIndex === void 0 || position.tdValueIndex === void 0 || !position.trId) {
6795
+ return null;
6796
+ }
6797
+ const originalElementList = draw.getOriginalElementList();
6798
+ const tableElement = originalElementList[position.index];
6799
+ if (tableElement?.type !== "table" /* TABLE */ || !tableElement.pagingId || !tableElement.trList?.length) {
6800
+ return null;
6801
+ }
6802
+ const tr = tableElement.trList.find((row) => row.id === position.trId);
6803
+ const td = tr?.tdList[position.tdIndex];
6804
+ if (!tr || !td || td.colIndex === void 0 || !tr.id) {
6805
+ return null;
6806
+ }
6807
+ const splitCellSelection = {
6808
+ pagingId: tableElement.pagingId,
6809
+ rootTrId: tr.splitRootId || tr.id,
6810
+ colIndex: td.colIndex
6811
+ };
6812
+ const splitCellContext = draw.getSplitCellSelectionContext(
6813
+ originalElementList,
6814
+ splitCellSelection
6815
+ );
6816
+ if (!splitCellContext) {
6817
+ return null;
6818
+ }
6819
+ let globalIndex = 0;
6820
+ for (let c = 0; c < splitCellContext.cellContextList.length; c++) {
6821
+ const cellContext = splitCellContext.cellContextList[c];
6822
+ const currentTd = cellContext.td;
6823
+ const skipLeadingZero = !!currentTd.splitSyntheticLeadingZero && currentTd.value[0]?.value === ZERO ? 1 : 0;
6824
+ if (cellContext.tr.id === tr.id && currentTd.id === td.id) {
6825
+ globalIndex += Math.max(position.tdValueIndex - skipLeadingZero, 0);
6826
+ return {
6827
+ splitCellSelection,
6828
+ globalIndex
6829
+ };
6830
+ }
6831
+ globalIndex += Math.max(currentTd.value.length - skipLeadingZero, 0);
6832
+ }
6833
+ return null;
6834
+ }
6835
+ function isSameSplitCellPointer(first, second) {
6836
+ return isSameSplitCellSelection(first, second);
6837
+ }
6838
+
6752
6839
  // src/core/event/handlers/mousedown.ts
6753
6840
  function setRangeCache(host) {
6754
6841
  const draw = host.getDraw();
@@ -6836,9 +6923,11 @@ function mousedown(evt, host) {
6836
6923
  tdValueIndex,
6837
6924
  hitLineStartIndex
6838
6925
  } = positionResult;
6926
+ const splitCellPointer = getSplitCellPointer(draw, positionResult);
6839
6927
  host.mouseDownStartPosition = {
6840
6928
  ...positionResult,
6841
- index: isTable ? tdValueIndex : index,
6929
+ index: splitCellPointer ? splitCellPointer.globalIndex : isTable ? tdValueIndex : index,
6930
+ splitCellSelection: splitCellPointer?.splitCellSelection,
6842
6931
  x: evt.offsetX,
6843
6932
  y: evt.offsetY
6844
6933
  };
@@ -7278,10 +7367,33 @@ function mousemove(evt, host) {
7278
7367
  isTable: startIsTable,
7279
7368
  tdIndex: startTdIndex,
7280
7369
  trIndex: startTrIndex,
7281
- tableId: startTableId
7370
+ tableId: startTableId,
7371
+ splitCellSelection: startSplitCellSelection
7282
7372
  } = host.mouseDownStartPosition;
7283
7373
  const endIndex = isTable ? tdValueIndex : index;
7284
7374
  const rangeManager = draw.getRange();
7375
+ if (startSplitCellSelection) {
7376
+ const currentSplitCellPointer = getSplitCellPointer(draw, positionResult);
7377
+ if (currentSplitCellPointer && isSameSplitCellPointer(
7378
+ startSplitCellSelection,
7379
+ currentSplitCellPointer.splitCellSelection
7380
+ )) {
7381
+ let start = startIndex;
7382
+ let end = currentSplitCellPointer.globalIndex;
7383
+ if (start > end) {
7384
+ [start, end] = [end, start];
7385
+ }
7386
+ if (start === end) return;
7387
+ rangeManager.setRange(start, end);
7388
+ rangeManager.setSplitCellSelection(startSplitCellSelection);
7389
+ draw.render({
7390
+ isSubmitHistory: false,
7391
+ isSetCursor: false,
7392
+ isCompute: false
7393
+ });
7394
+ return;
7395
+ }
7396
+ }
7285
7397
  if (isTable && startIsTable && (tdIndex !== startTdIndex || trIndex !== startTrIndex)) {
7286
7398
  rangeManager.setRange(
7287
7399
  endIndex,
@@ -7448,7 +7560,9 @@ function backspace(evt, host) {
7448
7560
  const control = draw.getControl();
7449
7561
  const { startIndex, endIndex, isCrossRowCol } = rangeManager.getRange();
7450
7562
  let curIndex;
7451
- if (isCrossRowCol) {
7563
+ if (rangeManager.getSplitCellSelection() && startIndex !== endIndex) {
7564
+ curIndex = draw.replaceSplitCellSelection([]);
7565
+ } else if (isCrossRowCol) {
7452
7566
  const rowCol = draw.getTableParticle().getRangeRowCol();
7453
7567
  if (!rowCol) return;
7454
7568
  let isDeleted = false;
@@ -7606,7 +7720,9 @@ function del(evt, host) {
7606
7720
  deleteHideElement(host);
7607
7721
  }
7608
7722
  let curIndex;
7609
- if (isCrossRowCol) {
7723
+ if (rangeManager.getSplitCellSelection() && startIndex !== endIndex) {
7724
+ curIndex = draw.replaceSplitCellSelection([]);
7725
+ } else if (isCrossRowCol) {
7610
7726
  const rowCol = draw.getTableParticle().getRangeRowCol();
7611
7727
  if (!rowCol) return;
7612
7728
  let isDeleted = false;
@@ -8518,6 +8634,8 @@ function input(data2, host) {
8518
8634
  if (!isComposing) {
8519
8635
  control.emitControlContentChange();
8520
8636
  }
8637
+ } else if (rangeManager.getSplitCellSelection()) {
8638
+ curIndex = draw.replaceSplitCellSelection(inputData);
8521
8639
  } else {
8522
8640
  const start = startIndex + 1;
8523
8641
  if (startIndex !== endIndex) {
@@ -9017,7 +9135,7 @@ var CanvasEvent = class {
9017
9135
  }
9018
9136
  selectAll() {
9019
9137
  if (this.position.getPositionContext().isTable) {
9020
- this.draw.getTableOperate().tableSelectAll();
9138
+ this.draw.getTableOperate().tableTdSelectAll();
9021
9139
  } else {
9022
9140
  const positionList = this.position.getPositionList();
9023
9141
  this.range.setRange(0, positionList.length - 1);
@@ -9294,6 +9412,10 @@ var Position = class {
9294
9412
  return this.floatPositionList;
9295
9413
  }
9296
9414
  getTablePositionList(sourceElementList) {
9415
+ const splitCellSelectionContext = this.draw.getSplitCellSelectionContext(sourceElementList);
9416
+ if (splitCellSelectionContext) {
9417
+ return splitCellSelectionContext.positionList;
9418
+ }
9297
9419
  return this.draw.resolveTableCellContext(sourceElementList, this.positionContext)?.td.positionList || [];
9298
9420
  }
9299
9421
  getPositionList() {
@@ -10084,6 +10206,18 @@ var RangeManager = class {
10084
10206
  clearRange() {
10085
10207
  this.setRange(-1, -1);
10086
10208
  }
10209
+ getSplitCellSelection() {
10210
+ return this.range.splitCellSelection;
10211
+ }
10212
+ setSplitCellSelection(payload) {
10213
+ this.range.splitCellSelection = payload || void 0;
10214
+ }
10215
+ getTableCellSelection() {
10216
+ return this.range.tableCellSelection;
10217
+ }
10218
+ setTableCellSelection(payload) {
10219
+ this.range.tableCellSelection = payload || void 0;
10220
+ }
10087
10221
  setDefaultStyle(style) {
10088
10222
  if (!style) {
10089
10223
  this.defaultStyle = null;
@@ -10374,6 +10508,8 @@ var RangeManager = class {
10374
10508
  this.range.isCrossRowCol = !!(startTdIndex || endTdIndex || startTrIndex || endTrIndex);
10375
10509
  this.setDefaultStyle(null);
10376
10510
  }
10511
+ this.range.splitCellSelection = void 0;
10512
+ this.range.tableCellSelection = void 0;
10377
10513
  this.range.zone = this.draw.getZone().getZone();
10378
10514
  const control = this.draw.getControl();
10379
10515
  if (~startIndex && ~endIndex) {
@@ -12096,6 +12232,44 @@ var TableParticle = class {
12096
12232
  }
12097
12233
  ctx.restore();
12098
12234
  }
12235
+ _isSelectedCell(element, tr, td, selection) {
12236
+ if (selection.pagingId && selection.rootTrId && selection.colIndex !== void 0) {
12237
+ return element.pagingId === selection.pagingId && (tr.id === selection.rootTrId || tr.splitRootId === selection.rootTrId) && td.colIndex === selection.colIndex;
12238
+ }
12239
+ if (selection.tableId && element.id !== selection.tableId) {
12240
+ return false;
12241
+ }
12242
+ if (selection.trId && tr.id !== selection.trId) {
12243
+ return false;
12244
+ }
12245
+ if (selection.tdId) {
12246
+ return td.id === selection.tdId;
12247
+ }
12248
+ return false;
12249
+ }
12250
+ drawCellRange(ctx, element, startX, startY, selection) {
12251
+ const { scale, rangeAlpha, rangeColor } = this.options;
12252
+ const { type, trList } = element;
12253
+ if (!trList || type !== "table" /* TABLE */) return;
12254
+ ctx.save();
12255
+ ctx.globalAlpha = rangeAlpha;
12256
+ ctx.fillStyle = rangeColor;
12257
+ for (let t = 0; t < trList.length; t++) {
12258
+ const tr = trList[t];
12259
+ for (let d = 0; d < tr.tdList.length; d++) {
12260
+ const td = tr.tdList[d];
12261
+ if (!this._isSelectedCell(element, tr, td, selection)) {
12262
+ continue;
12263
+ }
12264
+ const x = td.x * scale;
12265
+ const y = td.y * scale;
12266
+ const width = td.width * scale;
12267
+ const height = td.height * scale;
12268
+ ctx.fillRect(x + startX, y + startY, width, height);
12269
+ }
12270
+ }
12271
+ ctx.restore();
12272
+ }
12099
12273
  render(ctx, element, startX, startY) {
12100
12274
  this._drawBackgroundColor(ctx, element, startX, startY);
12101
12275
  this._drawBorder(ctx, element, startX, startY);
@@ -16600,17 +16774,14 @@ function computeValue(data2, options) {
16600
16774
  const { extraPickAttrs = [] } = options || {};
16601
16775
  return {
16602
16776
  header: zipElementList(data2.header, {
16603
- extraPickAttrs,
16604
- isClone: false
16777
+ extraPickAttrs
16605
16778
  }),
16606
16779
  main: zipElementList(data2.main, {
16607
16780
  extraPickAttrs,
16608
- isClassifyArea: true,
16609
- isClone: false
16781
+ isClassifyArea: true
16610
16782
  }),
16611
16783
  footer: zipElementList(data2.footer, {
16612
- extraPickAttrs,
16613
- isClone: false
16784
+ extraPickAttrs
16614
16785
  })
16615
16786
  };
16616
16787
  }
@@ -18649,6 +18820,38 @@ var ListParticle = class {
18649
18820
  const level = element.listLevel ?? 0;
18650
18821
  return level * INDENT_PER_LEVEL * scale;
18651
18822
  }
18823
+ _getListMarkerStyleElement(elementList, startIndex = 0) {
18824
+ const startElement = elementList[startIndex];
18825
+ for (let i = startIndex + 1; i < elementList.length; i++) {
18826
+ const element = elementList[i];
18827
+ if (element.value === ZERO && !element.listWrap) {
18828
+ break;
18829
+ }
18830
+ if (element.type === "tab" /* TAB */) {
18831
+ continue;
18832
+ }
18833
+ if (element.value !== ZERO || element.type) {
18834
+ return element;
18835
+ }
18836
+ }
18837
+ return startElement;
18838
+ }
18839
+ _getListMarkerText(element, listIndex) {
18840
+ if (element.listStyle === "checkbox" /* CHECKBOX */) {
18841
+ return "";
18842
+ }
18843
+ if (element.listType === "ul" /* UL */) {
18844
+ if (element.listPreset) {
18845
+ return this._getUlBulletForLevel(element);
18846
+ }
18847
+ return ulStyleMapping[element.listStyle] || ulStyleMapping["disc" /* DISC */];
18848
+ }
18849
+ if (element.listPreset) {
18850
+ const olStyle = this._getOlStyleForLevel(element);
18851
+ return formatOlNumber(listIndex, olStyle);
18852
+ }
18853
+ return `${listIndex + 1}${"." /* PERIOD */}`;
18854
+ }
18652
18855
  computeListStyle(ctx, elementList) {
18653
18856
  const listStyleMap = /* @__PURE__ */ new Map();
18654
18857
  let start = 0;
@@ -18679,23 +18882,40 @@ var ListParticle = class {
18679
18882
  }
18680
18883
  getListStyleWidth(ctx, listElementList) {
18681
18884
  const { scale, checkbox } = this.options;
18682
- const startElement = listElementList[0];
18683
- if (startElement.listStyle && startElement.listStyle !== "decimal" /* DECIMAL */) {
18684
- if (startElement.listStyle === "checkbox" /* CHECKBOX */) {
18685
- return (checkbox.width + this.LIST_GAP) * scale;
18885
+ let maxWidth = 0;
18886
+ let listIndex = 0;
18887
+ for (let i = 0; i < listElementList.length; i++) {
18888
+ const element = listElementList[i];
18889
+ if (element.value !== ZERO || element.listWrap) continue;
18890
+ if (element.listStyle === "checkbox" /* CHECKBOX */) {
18891
+ maxWidth = Math.max(maxWidth, checkbox.width + this.LIST_GAP);
18892
+ listIndex++;
18893
+ continue;
18686
18894
  }
18687
- return this.UN_COUNT_STYLE_WIDTH * scale;
18688
- }
18689
- const count = listElementList.reduce((pre, cur) => {
18690
- if (cur.value === ZERO) {
18691
- pre += 1;
18895
+ const markerStyleElement = this._getListMarkerStyleElement(
18896
+ listElementList,
18897
+ i
18898
+ );
18899
+ const text = this._getListMarkerText(element, listIndex);
18900
+ if (!text) {
18901
+ listIndex++;
18902
+ continue;
18692
18903
  }
18693
- return pre;
18694
- }, 0);
18695
- if (!count) return 0;
18696
- const text = `${this.MEASURE_BASE_TEXT.repeat(String(count).length)}${"." /* PERIOD */}`;
18697
- const textMetrics = ctx.measureText(text);
18698
- return Math.ceil((textMetrics.width + this.LIST_GAP) * scale);
18904
+ ctx.save();
18905
+ ctx.font = this.draw.getElementFont(markerStyleElement);
18906
+ const textMetrics = ctx.measureText(text);
18907
+ ctx.restore();
18908
+ maxWidth = Math.max(maxWidth, textMetrics.width + this.LIST_GAP);
18909
+ listIndex++;
18910
+ }
18911
+ if (maxWidth > 0) {
18912
+ return Math.ceil(maxWidth * scale);
18913
+ }
18914
+ const startElement = listElementList[0];
18915
+ if (startElement?.listStyle === "checkbox" /* CHECKBOX */) {
18916
+ return (checkbox.width + this.LIST_GAP) * scale;
18917
+ }
18918
+ return this.UN_COUNT_STYLE_WIDTH * scale;
18699
18919
  }
18700
18920
  _getOlStyleForLevel(element) {
18701
18921
  const preset = element.listPreset || "olDefault" /* DEFAULT */;
@@ -18716,7 +18936,7 @@ var ListParticle = class {
18716
18936
  const startElement = elementList[0];
18717
18937
  if (startElement.value !== ZERO || startElement.listWrap) return;
18718
18938
  let tabWidth = 0;
18719
- const { defaultTabWidth, scale, defaultFont, defaultSize } = this.options;
18939
+ const { defaultTabWidth, scale } = this.options;
18720
18940
  for (let i = 1; i < elementList.length; i++) {
18721
18941
  const element = elementList[i];
18722
18942
  if (element?.type !== "tab" /* TAB */) break;
@@ -18754,24 +18974,11 @@ var ListParticle = class {
18754
18974
  }
18755
18975
  });
18756
18976
  } else {
18757
- let text = "";
18758
- if (startElement.listType === "ul" /* UL */) {
18759
- if (startElement.listPreset) {
18760
- text = this._getUlBulletForLevel(startElement);
18761
- } else {
18762
- text = ulStyleMapping[startElement.listStyle] || ulStyleMapping["disc" /* DISC */];
18763
- }
18764
- } else {
18765
- if (startElement.listPreset) {
18766
- const olStyle = this._getOlStyleForLevel(startElement);
18767
- text = formatOlNumber(listIndex, olStyle);
18768
- } else {
18769
- text = `${listIndex + 1}${"." /* PERIOD */}`;
18770
- }
18771
- }
18977
+ const text = this._getListMarkerText(startElement, listIndex);
18772
18978
  if (!text) return;
18979
+ const markerStyleElement = this._getListMarkerStyleElement(elementList);
18773
18980
  ctx.save();
18774
- ctx.font = `${defaultSize * (96 / 72) * scale}px ${defaultFont}`;
18981
+ ctx.font = this.draw.getElementFont(markerStyleElement, scale);
18775
18982
  ctx.fillText(text, x, y);
18776
18983
  ctx.restore();
18777
18984
  }
@@ -19221,6 +19428,39 @@ var TableOperate = class {
19221
19428
  this.tableParticle = draw.getTableParticle();
19222
19429
  this.options = draw.getOptions();
19223
19430
  }
19431
+ getActiveTableElements() {
19432
+ const positionContext = this.position.getPositionContext();
19433
+ if (!positionContext.isTable) return [];
19434
+ const originalElementList = this.draw.getOriginalElementList();
19435
+ const element = originalElementList[positionContext.index];
19436
+ if (!element || element.type !== "table" /* TABLE */) return [];
19437
+ if (!element.pagingId) return [element];
19438
+ return originalElementList.filter(
19439
+ (item) => item.type === "table" /* TABLE */ && item.pagingId === element.pagingId
19440
+ );
19441
+ }
19442
+ getSplitCellStyleSelection() {
19443
+ const tableCellSelection = this.range.getTableCellSelection();
19444
+ if (tableCellSelection?.pagingId && tableCellSelection.rootTrId && tableCellSelection.colIndex !== void 0) {
19445
+ return tableCellSelection;
19446
+ }
19447
+ return this.range.getSplitCellSelection();
19448
+ }
19449
+ getStyleTargetRowCol() {
19450
+ const splitCellSelection = this.getSplitCellStyleSelection();
19451
+ if (splitCellSelection) {
19452
+ const splitCellContext = this.draw.getSplitCellSelectionContext(
19453
+ this.draw.getOriginalElementList(),
19454
+ splitCellSelection
19455
+ );
19456
+ if (splitCellContext) {
19457
+ return splitCellContext.cellContextList.map((cellContext) => [
19458
+ cellContext.td
19459
+ ]);
19460
+ }
19461
+ }
19462
+ return this.tableParticle.getRangeRowCol();
19463
+ }
19224
19464
  insertTable(row, col) {
19225
19465
  const { startIndex, endIndex } = this.range.getRange();
19226
19466
  if (!~startIndex && !~endIndex) return;
@@ -19901,7 +20141,7 @@ var TableOperate = class {
19901
20141
  this.tableTool.render();
19902
20142
  }
19903
20143
  tableTdVerticalAlign(payload) {
19904
- const rowCol = this.tableParticle.getRangeRowCol();
20144
+ const rowCol = this.getStyleTargetRowCol();
19905
20145
  if (!rowCol) return;
19906
20146
  for (let r = 0; r < rowCol.length; r++) {
19907
20147
  const row = rowCol[r];
@@ -19921,13 +20161,17 @@ var TableOperate = class {
19921
20161
  tableBorderType(payload) {
19922
20162
  const positionContext = this.position.getPositionContext();
19923
20163
  if (!positionContext.isTable) return;
19924
- const { index } = positionContext;
19925
- const originalElementList = this.draw.getOriginalElementList();
19926
- const element = originalElementList[index];
19927
- if (!element.borderType && payload === "all" /* ALL */ || element.borderType === payload) {
20164
+ const tableElements = this.getActiveTableElements();
20165
+ if (!tableElements.length) return;
20166
+ const isAllSame = tableElements.every(
20167
+ (element) => !element.borderType && payload === "all" /* ALL */ || element.borderType === payload
20168
+ );
20169
+ if (isAllSame) {
19928
20170
  return;
19929
20171
  }
19930
- element.borderType = payload;
20172
+ tableElements.forEach((element) => {
20173
+ element.borderType = payload;
20174
+ });
19931
20175
  const { endIndex } = this.range.getRange();
19932
20176
  this.draw.render({
19933
20177
  curIndex: endIndex
@@ -19936,13 +20180,17 @@ var TableOperate = class {
19936
20180
  tableBorderColor(payload) {
19937
20181
  const positionContext = this.position.getPositionContext();
19938
20182
  if (!positionContext.isTable) return;
19939
- const { index } = positionContext;
19940
- const originalElementList = this.draw.getOriginalElementList();
19941
- const element = originalElementList[index];
19942
- if (!element.borderColor && payload === this.options.table.defaultBorderColor || element.borderColor === payload) {
20183
+ const tableElements = this.getActiveTableElements();
20184
+ if (!tableElements.length) return;
20185
+ const isAllSame = tableElements.every(
20186
+ (element) => !element.borderColor && payload === this.options.table.defaultBorderColor || element.borderColor === payload
20187
+ );
20188
+ if (isAllSame) {
19943
20189
  return;
19944
20190
  }
19945
- element.borderColor = payload;
20191
+ tableElements.forEach((element) => {
20192
+ element.borderColor = payload;
20193
+ });
19946
20194
  const { endIndex } = this.range.getRange();
19947
20195
  this.draw.render({
19948
20196
  curIndex: endIndex,
@@ -19950,7 +20198,7 @@ var TableOperate = class {
19950
20198
  });
19951
20199
  }
19952
20200
  tableTdBorderType(payload) {
19953
- const rowCol = this.tableParticle.getRangeRowCol();
20201
+ const rowCol = this.getStyleTargetRowCol();
19954
20202
  if (!rowCol) return;
19955
20203
  const tdList = rowCol.flat();
19956
20204
  const isSetBorderType = tdList.some(
@@ -19982,7 +20230,7 @@ var TableOperate = class {
19982
20230
  });
19983
20231
  }
19984
20232
  tableTdSlashType(payload) {
19985
- const rowCol = this.tableParticle.getRangeRowCol();
20233
+ const rowCol = this.getStyleTargetRowCol();
19986
20234
  if (!rowCol) return;
19987
20235
  const tdList = rowCol.flat();
19988
20236
  const isSetTdSlashType = tdList.some(
@@ -20012,7 +20260,7 @@ var TableOperate = class {
20012
20260
  });
20013
20261
  }
20014
20262
  tableTdBackgroundColor(payload) {
20015
- const rowCol = this.tableParticle.getRangeRowCol();
20263
+ const rowCol = this.getStyleTargetRowCol();
20016
20264
  if (!rowCol) return;
20017
20265
  for (let r = 0; r < rowCol.length; r++) {
20018
20266
  const row = rowCol[r];
@@ -20033,14 +20281,14 @@ var TableOperate = class {
20033
20281
  const { index } = positionContext;
20034
20282
  const originalElementList = this.draw.getOriginalElementList();
20035
20283
  const element = originalElementList[index];
20036
- const rowCol = this.tableParticle.getRangeRowCol();
20284
+ const rowCol = this.getStyleTargetRowCol();
20037
20285
  if (!rowCol) return;
20038
20286
  const tdList = rowCol.flat();
20039
20287
  const totalCells = element.trList.reduce(
20040
20288
  (sum, tr) => sum + tr.tdList.length,
20041
20289
  0
20042
20290
  );
20043
- const allSelected = tdList.length >= totalCells;
20291
+ const allSelected = !element.pagingId && !this.getSplitCellStyleSelection() && tdList.length >= totalCells;
20044
20292
  if (allSelected) {
20045
20293
  element.borderColor = payload || void 0;
20046
20294
  element.trList.forEach(
@@ -20060,7 +20308,7 @@ var TableOperate = class {
20060
20308
  });
20061
20309
  }
20062
20310
  tableTdPadding(payload) {
20063
- const rowCol = this.tableParticle.getRangeRowCol();
20311
+ const rowCol = this.getStyleTargetRowCol();
20064
20312
  if (!rowCol) return;
20065
20313
  const tdList = rowCol.flat();
20066
20314
  tdList.forEach((td) => {
@@ -20095,6 +20343,46 @@ var TableOperate = class {
20095
20343
  isSubmitHistory: false
20096
20344
  });
20097
20345
  }
20346
+ tableTdSelectAll() {
20347
+ const originalElementList = this.draw.getOriginalElementList();
20348
+ const resolved = this.draw.resolveTableCellContext(originalElementList);
20349
+ if (!resolved) return;
20350
+ const currentTr = resolved.element.trList?.[resolved.trIndex];
20351
+ if (!currentTr) return;
20352
+ const currentTd = resolved.td;
20353
+ const currentElement = resolved.element;
20354
+ const splitCellSelection = currentElement.pagingId && currentTr.id && currentTd.colIndex !== void 0 ? {
20355
+ pagingId: currentElement.pagingId,
20356
+ rootTrId: currentTr.splitRootId || currentTr.id,
20357
+ colIndex: currentTd.colIndex
20358
+ } : void 0;
20359
+ const splitCellSelectionContext = this.draw.getSplitCellSelectionContext(
20360
+ originalElementList,
20361
+ splitCellSelection
20362
+ );
20363
+ if (splitCellSelectionContext) {
20364
+ const endIndex = Math.max(
20365
+ splitCellSelectionContext.positionList.length - 1,
20366
+ 0
20367
+ );
20368
+ this.range.setRange(0, endIndex);
20369
+ this.range.setSplitCellSelection(splitCellSelection);
20370
+ this.range.setTableCellSelection(splitCellSelection);
20371
+ } else {
20372
+ const endIndex = Math.max(currentTd.value.length - 1, 0);
20373
+ this.range.setRange(0, endIndex);
20374
+ this.range.setTableCellSelection({
20375
+ tableId: currentElement.id,
20376
+ trId: currentTr.id,
20377
+ tdId: currentTd.id
20378
+ });
20379
+ }
20380
+ this.draw.render({
20381
+ isSetCursor: false,
20382
+ isCompute: false,
20383
+ isSubmitHistory: false
20384
+ });
20385
+ }
20098
20386
  };
20099
20387
 
20100
20388
  // src/dataset/enum/Area.ts
@@ -20952,8 +21240,156 @@ var Draw = class {
20952
21240
  return this.header.getElementList();
20953
21241
  }
20954
21242
  getTableElementList(sourceElementList) {
21243
+ const splitCellSelectionContext = this.getSplitCellSelectionContext(
21244
+ sourceElementList
21245
+ );
21246
+ if (splitCellSelectionContext) {
21247
+ return splitCellSelectionContext.value;
21248
+ }
20955
21249
  return this.resolveTableCellContext(sourceElementList)?.td.value || [];
20956
21250
  }
21251
+ getSplitCellSelectionContext(sourceElementList = this.getOriginalElementList(), splitCellSelection = this.range.getSplitCellSelection()) {
21252
+ if (!splitCellSelection) return null;
21253
+ const { pagingId, rootTrId, colIndex } = splitCellSelection;
21254
+ const cellContextList = [];
21255
+ for (let i = 0; i < sourceElementList.length; i++) {
21256
+ const element = sourceElementList[i];
21257
+ if (element.type !== "table" /* TABLE */ || element.pagingId !== pagingId) {
21258
+ continue;
21259
+ }
21260
+ const trList = element.trList;
21261
+ if (!trList?.length) continue;
21262
+ for (let t = 0; t < trList.length; t++) {
21263
+ const tr = trList[t];
21264
+ if (tr.id !== rootTrId && tr.splitRootId !== rootTrId) continue;
21265
+ const tdIndex = tr.tdList.findIndex((td2) => td2.colIndex === colIndex);
21266
+ if (tdIndex < 0) continue;
21267
+ const td = tr.tdList[tdIndex];
21268
+ cellContextList.push({
21269
+ tableIndex: i,
21270
+ trIndex: t,
21271
+ tdIndex,
21272
+ element,
21273
+ tr,
21274
+ td
21275
+ });
21276
+ }
21277
+ }
21278
+ if (cellContextList.length < 2) return null;
21279
+ const value = [];
21280
+ const positionList = [];
21281
+ for (let c = 0; c < cellContextList.length; c++) {
21282
+ const { td } = cellContextList[c];
21283
+ const skipLeadingZero = !!td.splitSyntheticLeadingZero && td.value[0]?.value === ZERO ? 1 : 0;
21284
+ value.push(...td.value.slice(skipLeadingZero));
21285
+ if (td.positionList?.length) {
21286
+ positionList.push(...td.positionList.slice(skipLeadingZero));
21287
+ }
21288
+ }
21289
+ return {
21290
+ value,
21291
+ positionList,
21292
+ cellContextList
21293
+ };
21294
+ }
21295
+ syncTableElementContext(elementList, context) {
21296
+ const { tableId, trId, tdId } = context;
21297
+ for (let i = 0; i < elementList.length; i++) {
21298
+ const element = elementList[i];
21299
+ element.tableId = tableId;
21300
+ element.trId = trId;
21301
+ element.tdId = tdId;
21302
+ }
21303
+ }
21304
+ getCollapsedSplitTableCursorContext(element) {
21305
+ const positionContext = this.position.getPositionContext();
21306
+ const { startIndex, endIndex } = this.range.getRange();
21307
+ if (!element.pagingId || !positionContext.isTable || startIndex !== endIndex || positionContext.tableId !== element.id || !positionContext.trId) {
21308
+ return null;
21309
+ }
21310
+ const trList = element.trList;
21311
+ if (!trList?.length) return null;
21312
+ const currentTr = trList.find((tr) => tr.id === positionContext.trId);
21313
+ const currentTd = currentTr && (positionContext.tdId ? currentTr.tdList.find((td) => td.id === positionContext.tdId) : currentTr.tdList[positionContext.tdIndex]);
21314
+ if (!currentTr?.id || !currentTd || currentTd.colIndex === void 0) {
21315
+ return null;
21316
+ }
21317
+ const rootTrId = currentTr.splitRootId || currentTr.id;
21318
+ let mergedIndex = 0;
21319
+ for (let t = 0; t < trList.length; t++) {
21320
+ const tr = trList[t];
21321
+ if (tr.id !== rootTrId && tr.splitRootId !== rootTrId) {
21322
+ continue;
21323
+ }
21324
+ const td = tr.tdList.find((cell) => cell.colIndex === currentTd.colIndex);
21325
+ if (!td) continue;
21326
+ const skipLeadingZero = !!td.splitSyntheticLeadingZero && td.value[0]?.value === ZERO ? 1 : 0;
21327
+ if (tr.id === currentTr.id && td.id === currentTd.id) {
21328
+ mergedIndex += Math.max(startIndex - skipLeadingZero, 0);
21329
+ return {
21330
+ rootTrId,
21331
+ colIndex: currentTd.colIndex,
21332
+ mergedIndex
21333
+ };
21334
+ }
21335
+ mergedIndex += Math.max(td.value.length - skipLeadingZero, 0);
21336
+ }
21337
+ return null;
21338
+ }
21339
+ applyCollapsedSplitTableCursor(payload) {
21340
+ const {
21341
+ tableIndex,
21342
+ tableId,
21343
+ overflowTr,
21344
+ overflowTrIdx,
21345
+ continuationTr,
21346
+ continuationTdList,
21347
+ logicalCursor,
21348
+ splits
21349
+ } = payload;
21350
+ const tdIndex = overflowTr.tdList.findIndex(
21351
+ (td) => td.colIndex === logicalCursor.colIndex
21352
+ );
21353
+ if (tdIndex < 0) return false;
21354
+ const splitIdx = splits[tdIndex]?.elemIdx;
21355
+ if (splitIdx === void 0) return false;
21356
+ const positionContext = this.position.getPositionContext();
21357
+ if (logicalCursor.mergedIndex >= splitIdx) {
21358
+ const continuationTd = continuationTdList[tdIndex];
21359
+ if (!continuationTd) return false;
21360
+ const hasPrependedZero = !!continuationTd.splitSyntheticLeadingZero && continuationTd.value[0]?.value === ZERO;
21361
+ const continuationCursorIndex = logicalCursor.mergedIndex - splitIdx + (hasPrependedZero ? 1 : 0);
21362
+ positionContext.index = tableIndex;
21363
+ positionContext.trIndex = overflowTrIdx + 1;
21364
+ positionContext.tdIndex = tdIndex;
21365
+ positionContext.tdId = continuationTd.id;
21366
+ positionContext.trId = continuationTr.id;
21367
+ positionContext.tableId = tableId;
21368
+ this.position.setPositionContext(positionContext);
21369
+ this.range.setRange(
21370
+ continuationCursorIndex,
21371
+ continuationCursorIndex
21372
+ );
21373
+ this.pendingTableCursorIndex = continuationCursorIndex;
21374
+ return true;
21375
+ }
21376
+ const rootTd = overflowTr.tdList[tdIndex];
21377
+ if (!rootTd) return false;
21378
+ const rootCursorIndex = Math.min(
21379
+ logicalCursor.mergedIndex,
21380
+ Math.max(rootTd.value.length - 1, 0)
21381
+ );
21382
+ positionContext.index = tableIndex;
21383
+ positionContext.trIndex = overflowTrIdx;
21384
+ positionContext.tdIndex = tdIndex;
21385
+ positionContext.tdId = rootTd.id;
21386
+ positionContext.trId = overflowTr.id;
21387
+ positionContext.tableId = tableId;
21388
+ this.position.setPositionContext(positionContext);
21389
+ this.range.setRange(rootCursorIndex, rootCursorIndex);
21390
+ this.pendingTableCursorIndex = rootCursorIndex;
21391
+ return true;
21392
+ }
20957
21393
  getElementList() {
20958
21394
  const positionContext = this.position.getPositionContext();
20959
21395
  const elementList = this.getOriginalElementList();
@@ -20991,6 +21427,18 @@ var Draw = class {
20991
21427
  isHandleFirstElement: false,
20992
21428
  editorOptions: this.options
20993
21429
  });
21430
+ const splitCellSelection = this.range.getSplitCellSelection();
21431
+ if (splitCellSelection) {
21432
+ const curIndex2 = this.replaceSplitCellSelection(payload, splitCellSelection);
21433
+ if (~curIndex2) {
21434
+ this.range.setRange(curIndex2, curIndex2);
21435
+ this.render({
21436
+ curIndex: curIndex2,
21437
+ isSubmitHistory
21438
+ });
21439
+ }
21440
+ return;
21441
+ }
20994
21442
  let curIndex = -1;
20995
21443
  let activeControl = this.control.getActiveControl();
20996
21444
  if (!activeControl && this.control.getIsRangeWithinControl()) {
@@ -21086,6 +21534,80 @@ var Draw = class {
21086
21534
  }
21087
21535
  }
21088
21536
  }
21537
+ replaceSplitCellSelection(payload, splitCellSelection = this.range.getSplitCellSelection()) {
21538
+ const splitCellSelectionContext = this.getSplitCellSelectionContext(
21539
+ this.getOriginalElementList(),
21540
+ splitCellSelection
21541
+ );
21542
+ if (!splitCellSelectionContext) return -1;
21543
+ const [rootCellContext, ...continuationCellContextList] = splitCellSelectionContext.cellContextList;
21544
+ const rootTd = rootCellContext.td;
21545
+ const rootStartIndex = rootTd.value[0]?.value === ZERO ? 1 : 0;
21546
+ if (!rootStartIndex) {
21547
+ rootTd.value.unshift({
21548
+ value: ZERO,
21549
+ type: "text" /* TEXT */
21550
+ });
21551
+ this.syncTableElementContext([rootTd.value[0]], {
21552
+ tableId: rootCellContext.element.id,
21553
+ trId: rootCellContext.tr.id,
21554
+ tdId: rootTd.id
21555
+ });
21556
+ }
21557
+ this.syncTableElementContext(payload, {
21558
+ tableId: rootCellContext.element.id,
21559
+ trId: rootCellContext.tr.id,
21560
+ tdId: rootTd.id
21561
+ });
21562
+ this.spliceElementList(
21563
+ rootTd.value,
21564
+ 1,
21565
+ rootTd.value.length - 1,
21566
+ payload
21567
+ );
21568
+ rootTd.rowList = void 0;
21569
+ rootTd.positionList = void 0;
21570
+ rootTd.mainHeight = void 0;
21571
+ rootTd.realHeight = void 0;
21572
+ rootTd.realMinHeight = void 0;
21573
+ for (let c = 0; c < continuationCellContextList.length; c++) {
21574
+ const continuationTd = continuationCellContextList[c].td;
21575
+ const startIndex = continuationTd.value[0]?.value === ZERO ? 1 : 0;
21576
+ if (!startIndex) {
21577
+ continuationTd.value.unshift({
21578
+ value: ZERO,
21579
+ type: "text" /* TEXT */
21580
+ });
21581
+ this.syncTableElementContext([continuationTd.value[0]], {
21582
+ tableId: continuationCellContextList[c].element.id,
21583
+ trId: continuationCellContextList[c].tr.id,
21584
+ tdId: continuationTd.id
21585
+ });
21586
+ }
21587
+ if (continuationTd.value.length > 1) {
21588
+ this.spliceElementList(
21589
+ continuationTd.value,
21590
+ 1,
21591
+ continuationTd.value.length - 1
21592
+ );
21593
+ }
21594
+ continuationTd.rowList = void 0;
21595
+ continuationTd.positionList = void 0;
21596
+ continuationTd.mainHeight = void 0;
21597
+ continuationTd.realHeight = void 0;
21598
+ continuationTd.realMinHeight = void 0;
21599
+ }
21600
+ this.position.setPositionContext({
21601
+ isTable: true,
21602
+ index: rootCellContext.tableIndex,
21603
+ trIndex: rootCellContext.trIndex,
21604
+ tdIndex: rootCellContext.tdIndex,
21605
+ tdId: rootTd.id,
21606
+ trId: rootCellContext.tr.id,
21607
+ tableId: rootCellContext.element.id
21608
+ });
21609
+ return Math.max(rootTd.value.length - 1, 0);
21610
+ }
21089
21611
  getCanvasEvent() {
21090
21612
  return this.canvasEvent;
21091
21613
  }
@@ -21648,6 +22170,9 @@ var Draw = class {
21648
22170
  } else if (element.type === "table" /* TABLE */) {
21649
22171
  let activeSplitRange;
21650
22172
  let mergedSplitFallback;
22173
+ const logicalSplitCursor = this.getCollapsedSplitTableCursorContext(
22174
+ element
22175
+ );
21651
22176
  if (element.pagingId) {
21652
22177
  let tableIndex = i + 1;
21653
22178
  let combineCount = 0;
@@ -21706,6 +22231,11 @@ var Draw = class {
21706
22231
  if (!splitTd) continue;
21707
22232
  const hasSyntheticLeadingZero = !!splitTd.splitSyntheticLeadingZero && splitTd.value[0]?.value === ZERO;
21708
22233
  const splitValue = hasSyntheticLeadingZero ? splitTd.value.slice(1) : splitTd.value;
22234
+ this.syncTableElementContext(splitValue, {
22235
+ tableId: element.id,
22236
+ trId: parentTr.id,
22237
+ tdId: parentTd.id
22238
+ });
21709
22239
  parentTd.value.push(...splitValue);
21710
22240
  parentTd.rowList = void 0;
21711
22241
  parentTd.positionList = void 0;
@@ -21987,13 +22517,12 @@ var Draw = class {
21987
22517
  const continuationTdList = overflowTr.tdList.map(
21988
22518
  (td, d) => {
21989
22519
  const splitIdx = splits[d].elemIdx;
22520
+ const newTdId = getUUID();
21990
22521
  const initialListState2 = this.getListStateBeforeIndex(
21991
22522
  td.value,
21992
22523
  splitIdx
21993
22524
  );
21994
- const overflowElements = deepClone(
21995
- td.value.slice(splitIdx)
21996
- );
22525
+ const overflowElements = td.value.slice(splitIdx);
21997
22526
  const overflowStartElement = overflowElements[0];
21998
22527
  let splitSyntheticLeadingZero = false;
21999
22528
  if (!overflowElements.length || overflowElements[0]?.value !== ZERO) {
@@ -22009,7 +22538,13 @@ var Draw = class {
22009
22538
  });
22010
22539
  splitSyntheticLeadingZero = true;
22011
22540
  }
22541
+ this.syncTableElementContext(overflowElements, {
22542
+ tableId: element.id,
22543
+ trId: newTrId,
22544
+ tdId: newTdId
22545
+ });
22012
22546
  const {
22547
+ id: _tdId,
22013
22548
  value: _v,
22014
22549
  rowList: _rl,
22015
22550
  positionList: _pl,
@@ -22019,6 +22554,7 @@ var Draw = class {
22019
22554
  } = td;
22020
22555
  return {
22021
22556
  ...deepClone(tdMeta),
22557
+ id: newTdId,
22022
22558
  value: overflowElements,
22023
22559
  splitSyntheticLeadingZero,
22024
22560
  splitListState: initialListState2,
@@ -22040,8 +22576,21 @@ var Draw = class {
22040
22576
  splitRootId,
22041
22577
  splitLevel
22042
22578
  };
22579
+ let isLogicalSplitCursorHandled = false;
22580
+ if (logicalSplitCursor && logicalSplitCursor.rootTrId === splitRootId) {
22581
+ isLogicalSplitCursorHandled = this.applyCollapsedSplitTableCursor({
22582
+ tableIndex: i,
22583
+ tableId: element.id,
22584
+ overflowTr,
22585
+ overflowTrIdx,
22586
+ continuationTr,
22587
+ continuationTdList,
22588
+ logicalCursor: logicalSplitCursor,
22589
+ splits
22590
+ });
22591
+ }
22043
22592
  const positionContext = this.position.getPositionContext();
22044
- if (activeSplitRange && positionContext.isTable && positionContext.trId === activeSplitRange.trId) {
22593
+ if (!isLogicalSplitCursorHandled && activeSplitRange && positionContext.isTable && positionContext.trId === activeSplitRange.trId) {
22045
22594
  const splitIdx = splits[activeSplitRange.tdIndex]?.elemIdx;
22046
22595
  const continuationTd = continuationTdList[activeSplitRange.tdIndex];
22047
22596
  if (splitIdx !== void 0 && continuationTd && activeSplitRange.mergedIndex >= splitIdx) {
@@ -22098,16 +22647,26 @@ var Draw = class {
22098
22647
  element.height -= cloneTrHeight;
22099
22648
  metrics.height -= cloneTrRealHeight;
22100
22649
  metrics.boundingBoxDescent -= cloneTrRealHeight;
22101
- const cloneElement = deepClone(element);
22102
- cloneElement.pagingId = pagingId;
22103
- cloneElement.pagingIndex = element.pagingIndex + 1;
22650
+ const {
22651
+ trList: _currentTrList,
22652
+ id: _currentId,
22653
+ height: _currentHeight,
22654
+ pagingIndex: _currentPagingIndex,
22655
+ ...cloneElementMeta
22656
+ } = element;
22657
+ const cloneElement = {
22658
+ ...deepClone(cloneElementMeta),
22659
+ trList: cloneTrList,
22660
+ height: cloneTrHeight,
22661
+ pagingId,
22662
+ pagingIndex: element.pagingIndex + 1
22663
+ };
22104
22664
  const repeatTrList = trList2.filter((tr) => tr.pagingRepeat);
22105
22665
  if (repeatTrList.length) {
22106
22666
  const cloneRepeatTrList = deepClone(repeatTrList);
22107
22667
  cloneRepeatTrList.forEach((tr) => tr.id = getUUID());
22108
22668
  cloneTrList.unshift(...cloneRepeatTrList);
22109
22669
  }
22110
- cloneElement.trList = cloneTrList;
22111
22670
  cloneElement.id = getUUID();
22112
22671
  this.spliceElementList(elementList, i + 1, 0, [cloneElement]);
22113
22672
  }
@@ -22555,6 +23114,27 @@ var Draw = class {
22555
23114
  const isPrintMode = this.isPrintMode();
22556
23115
  const isGraffitiMode = this.isGraffitiMode();
22557
23116
  const { isCrossRowCol, tableId } = this.range.getRange();
23117
+ const splitCellSelection = this.range.getSplitCellSelection();
23118
+ const tableCellSelection = this.range.getTableCellSelection();
23119
+ const splitCellRenderOffsetMap = splitCellSelection ? (() => {
23120
+ const splitCellContext = this.getSplitCellSelectionContext(
23121
+ this.getOriginalElementList(),
23122
+ splitCellSelection
23123
+ );
23124
+ if (!splitCellContext) return null;
23125
+ const offsetMap = /* @__PURE__ */ new Map();
23126
+ let offset = 0;
23127
+ for (let c = 0; c < splitCellContext.cellContextList.length; c++) {
23128
+ const { td } = splitCellContext.cellContextList[c];
23129
+ const skipLeadingZero = !!td.splitSyntheticLeadingZero && td.value[0]?.value === ZERO ? 1 : 0;
23130
+ offsetMap.set(td.id, {
23131
+ offset,
23132
+ skipLeadingZero
23133
+ });
23134
+ offset += Math.max(td.value.length - skipLeadingZero, 0);
23135
+ }
23136
+ return offsetMap;
23137
+ })() : null;
22558
23138
  let index = startIndex;
22559
23139
  for (let i = 0; i < rowList.length; i++) {
22560
23140
  const curRow = rowList[i];
@@ -22586,6 +23166,9 @@ var Draw = class {
22586
23166
  this.textParticle.complete();
22587
23167
  this.laTexParticle.render(ctx, element, x, y + offsetY);
22588
23168
  } else if (element.type === "table" /* TABLE */) {
23169
+ if (tableCellSelection) {
23170
+ tableRangeElement = element;
23171
+ }
22589
23172
  if (isCrossRowCol) {
22590
23173
  rangeRecord.x = x;
22591
23174
  rangeRecord.y = y;
@@ -22733,11 +23316,14 @@ var Draw = class {
22733
23316
  startIndex: startIndex2,
22734
23317
  endIndex
22735
23318
  } = this.range.getRange();
22736
- if (currentZone === zone && startIndex2 !== endIndex && startIndex2 <= index && index <= endIndex) {
23319
+ const splitCellOffset = element.tdId ? splitCellRenderOffsetMap?.get(element.tdId) : void 0;
23320
+ const splitCellIndex = splitCellOffset ? index - splitCellOffset.skipLeadingZero + splitCellOffset.offset : index;
23321
+ const isSplitCellElement = !!splitCellOffset && index >= splitCellOffset.skipLeadingZero;
23322
+ if (currentZone === zone && startIndex2 !== endIndex && startIndex2 <= splitCellIndex && splitCellIndex <= endIndex) {
22737
23323
  const positionContext = this.position.getPositionContext();
22738
- if (!positionContext.isTable && !element.tdId || positionContext.tdId === element.tdId) {
22739
- if (startIndex2 === index) {
22740
- const nextElement = elementList[startIndex2 + 1];
23324
+ if (splitCellRenderOffsetMap && isSplitCellElement || !splitCellRenderOffsetMap && (!positionContext.isTable && !element.tdId || positionContext.tdId === element.tdId)) {
23325
+ if (startIndex2 === splitCellIndex) {
23326
+ const nextElement = splitCellRenderOffsetMap && isSplitCellElement ? this.getElementList()[startIndex2 + 1] : elementList[startIndex2 + 1];
22741
23327
  if (nextElement && nextElement.value === ZERO) {
22742
23328
  rangeRecord.x = x + metrics.width;
22743
23329
  rangeRecord.y = y - (curRow.spaceAbove || 0);
@@ -22802,7 +23388,7 @@ var Draw = class {
22802
23388
  this.strikeout.render(ctx);
22803
23389
  this.group.render(ctx);
22804
23390
  if (!isPrintMode && !isGraffitiMode) {
22805
- if (rangeRecord.width && rangeRecord.height) {
23391
+ if (!tableCellSelection && rangeRecord.width && rangeRecord.height) {
22806
23392
  const { x, y, width, height } = rangeRecord;
22807
23393
  this.range.render(ctx, x, y, width, height);
22808
23394
  }
@@ -22814,6 +23400,20 @@ var Draw = class {
22814
23400
  } = positionList[curRow.startIndex];
22815
23401
  this.tableParticle.drawRange(ctx, tableRangeElement, x, y);
22816
23402
  }
23403
+ if (tableCellSelection && tableRangeElement) {
23404
+ const {
23405
+ coordinate: {
23406
+ leftTop: [x, y]
23407
+ }
23408
+ } = positionList[curRow.startIndex];
23409
+ this.tableParticle.drawCellRange(
23410
+ ctx,
23411
+ tableRangeElement,
23412
+ x,
23413
+ y,
23414
+ tableCellSelection
23415
+ );
23416
+ }
22817
23417
  }
22818
23418
  }
22819
23419
  }
@@ -23440,6 +24040,34 @@ var CommandAdapt = class {
23440
24040
  this.zone = draw.getZone();
23441
24041
  this.tableOperate = draw.getTableOperate();
23442
24042
  }
24043
+ getStyleSelectionElementList(options = {}) {
24044
+ const selection = this.range.getSelectionElementList();
24045
+ if (!selection?.length) return null;
24046
+ const { textLikeOnly = false } = options;
24047
+ const result = [];
24048
+ const collect = (elementList) => {
24049
+ for (let i = 0; i < elementList.length; i++) {
24050
+ const element = elementList[i];
24051
+ if (element.type === "table" /* TABLE */ && element.trList?.length) {
24052
+ for (let t = 0; t < element.trList.length; t++) {
24053
+ const tr = element.trList[t];
24054
+ for (let d = 0; d < tr.tdList.length; d++) {
24055
+ collect(tr.tdList[d].value);
24056
+ }
24057
+ }
24058
+ continue;
24059
+ }
24060
+ result.push(element);
24061
+ }
24062
+ };
24063
+ collect(selection);
24064
+ if (!textLikeOnly) {
24065
+ return result;
24066
+ }
24067
+ return result.filter(
24068
+ (element) => isTextLikeElement(element) || element.type === "label" /* LABEL */
24069
+ );
24070
+ }
23443
24071
  mode(payload) {
23444
24072
  this.draw.setMode(payload);
23445
24073
  }
@@ -23585,7 +24213,7 @@ var CommandAdapt = class {
23585
24213
  const { isIgnoreDisabledRule = false } = options || {};
23586
24214
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23587
24215
  if (isDisabled) return;
23588
- const selection = this.range.getSelectionElementList();
24216
+ const selection = this.getStyleSelectionElementList();
23589
24217
  let renderOption = {};
23590
24218
  let changeElementList = [];
23591
24219
  if (selection?.length) {
@@ -23612,7 +24240,7 @@ var CommandAdapt = class {
23612
24240
  const { isIgnoreDisabledRule = false } = options || {};
23613
24241
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23614
24242
  if (isDisabled) return;
23615
- const selection = this.range.getSelectionElementList();
24243
+ const selection = this.getStyleSelectionElementList();
23616
24244
  if (selection?.length) {
23617
24245
  selection.forEach((el) => {
23618
24246
  el.font = payload;
@@ -23646,7 +24274,9 @@ var CommandAdapt = class {
23646
24274
  if (payload < minSize || payload > maxSize) return;
23647
24275
  let renderOption = {};
23648
24276
  let changeElementList = [];
23649
- const selection = this.range.getTextLikeSelectionElementList();
24277
+ const selection = this.getStyleSelectionElementList({
24278
+ textLikeOnly: true
24279
+ });
23650
24280
  if (selection?.length) {
23651
24281
  changeElementList = selection;
23652
24282
  renderOption = { isSetCursor: false };
@@ -23686,7 +24316,9 @@ var CommandAdapt = class {
23686
24316
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23687
24317
  if (isDisabled) return;
23688
24318
  const { defaultSize, maxSize } = this.options;
23689
- const selection = this.range.getTextLikeSelectionElementList();
24319
+ const selection = this.getStyleSelectionElementList({
24320
+ textLikeOnly: true
24321
+ });
23690
24322
  let renderOption = {};
23691
24323
  let changeElementList = [];
23692
24324
  if (selection?.length) {
@@ -23735,7 +24367,9 @@ var CommandAdapt = class {
23735
24367
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23736
24368
  if (isDisabled) return;
23737
24369
  const { defaultSize, minSize } = this.options;
23738
- const selection = this.range.getTextLikeSelectionElementList();
24370
+ const selection = this.getStyleSelectionElementList({
24371
+ textLikeOnly: true
24372
+ });
23739
24373
  let renderOption = {};
23740
24374
  let changeElementList = [];
23741
24375
  if (selection?.length) {
@@ -23783,7 +24417,7 @@ var CommandAdapt = class {
23783
24417
  const { isIgnoreDisabledRule = false } = options || {};
23784
24418
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23785
24419
  if (isDisabled) return;
23786
- const selection = this.range.getSelectionElementList();
24420
+ const selection = this.getStyleSelectionElementList();
23787
24421
  if (selection?.length) {
23788
24422
  const noBoldIndex = selection.findIndex((s) => !s.bold);
23789
24423
  selection.forEach((el) => {
@@ -23815,7 +24449,7 @@ var CommandAdapt = class {
23815
24449
  const { isIgnoreDisabledRule = false } = options || {};
23816
24450
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23817
24451
  if (isDisabled) return;
23818
- const selection = this.range.getSelectionElementList();
24452
+ const selection = this.getStyleSelectionElementList();
23819
24453
  if (selection?.length) {
23820
24454
  const noItalicIndex = selection.findIndex((s) => !s.italic);
23821
24455
  selection.forEach((el) => {
@@ -23847,7 +24481,7 @@ var CommandAdapt = class {
23847
24481
  const { isIgnoreDisabledRule = false } = options || {};
23848
24482
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23849
24483
  if (isDisabled) return;
23850
- const selection = this.range.getSelectionElementList();
24484
+ const selection = this.getStyleSelectionElementList();
23851
24485
  if (selection?.length) {
23852
24486
  const isSetUnderline = selection.some(
23853
24487
  (s) => !s.underline || !textDecoration && s.textDecoration || textDecoration && !s.textDecoration || textDecoration && s.textDecoration && !isObjectEqual(s.textDecoration, textDecoration)
@@ -23889,7 +24523,7 @@ var CommandAdapt = class {
23889
24523
  const { isIgnoreDisabledRule = false } = options || {};
23890
24524
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23891
24525
  if (isDisabled) return;
23892
- const selection = this.range.getSelectionElementList();
24526
+ const selection = this.getStyleSelectionElementList();
23893
24527
  if (selection?.length) {
23894
24528
  const noStrikeoutIndex = selection.findIndex((s) => !s.strikeout);
23895
24529
  selection.forEach((el) => {
@@ -23924,7 +24558,7 @@ var CommandAdapt = class {
23924
24558
  const { isIgnoreDisabledRule = false } = options || {};
23925
24559
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23926
24560
  if (isDisabled) return;
23927
- const selection = this.range.getSelectionElementList();
24561
+ const selection = this.getStyleSelectionElementList();
23928
24562
  if (!selection) return;
23929
24563
  const superscriptIndex = selection.findIndex(
23930
24564
  (s) => s.type === "superscript" /* SUPERSCRIPT */
@@ -23947,7 +24581,7 @@ var CommandAdapt = class {
23947
24581
  const { isIgnoreDisabledRule = false } = options || {};
23948
24582
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23949
24583
  if (isDisabled) return;
23950
- const selection = this.range.getSelectionElementList();
24584
+ const selection = this.getStyleSelectionElementList();
23951
24585
  if (!selection) return;
23952
24586
  const subscriptIndex = selection.findIndex(
23953
24587
  (s) => s.type === "subscript" /* SUBSCRIPT */
@@ -23970,7 +24604,7 @@ var CommandAdapt = class {
23970
24604
  const { isIgnoreDisabledRule = false } = options || {};
23971
24605
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23972
24606
  if (isDisabled) return;
23973
- const selection = this.range.getSelectionElementList();
24607
+ const selection = this.getStyleSelectionElementList();
23974
24608
  if (selection?.length) {
23975
24609
  selection.forEach((el) => {
23976
24610
  if (payload) {
@@ -24011,7 +24645,7 @@ var CommandAdapt = class {
24011
24645
  const { isIgnoreDisabledRule = false } = options || {};
24012
24646
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
24013
24647
  if (isDisabled) return;
24014
- const selection = this.range.getSelectionElementList();
24648
+ const selection = this.getStyleSelectionElementList();
24015
24649
  if (selection?.length) {
24016
24650
  selection.forEach((el) => {
24017
24651
  if (payload) {
@@ -24642,25 +25276,39 @@ var CommandAdapt = class {
24642
25276
  const endElement = pickElementAttr(elementList[endIndex], {
24643
25277
  extraPickAttrs: ["id", "controlComponent"]
24644
25278
  });
24645
- const rowList = this.draw.getRowList();
24646
25279
  const positionList = this.position.getPositionList();
24647
25280
  const startPosition = positionList[startIndex];
24648
25281
  const endPosition = positionList[endIndex];
25282
+ if (!startPosition || !endPosition) return null;
24649
25283
  const startPageNo = startPosition.pageNo;
24650
25284
  const endPageNo = endPosition.pageNo;
24651
25285
  const startRowNo = startPosition.rowIndex;
24652
25286
  const endRowNo = endPosition.rowIndex;
24653
- const startRow = rowList[startRowNo];
24654
- const endRow = rowList[endRowNo];
25287
+ const getRowStartPositionIndex = (targetIndex) => {
25288
+ let rowStartIndex = targetIndex;
25289
+ const targetPosition = positionList[targetIndex];
25290
+ while (rowStartIndex > 0) {
25291
+ const prePosition = positionList[rowStartIndex - 1];
25292
+ if (!prePosition || prePosition.pageNo !== targetPosition.pageNo || prePosition.rowNo !== targetPosition.rowNo || prePosition.columnNo !== targetPosition.columnNo) {
25293
+ break;
25294
+ }
25295
+ rowStartIndex--;
25296
+ }
25297
+ return rowStartIndex;
25298
+ };
25299
+ const startRowStartIndex = getRowStartPositionIndex(startIndex);
25300
+ const endRowStartIndex = getRowStartPositionIndex(endIndex);
25301
+ const startRowStartsWithZero = elementList[startRowStartIndex]?.value === ZERO;
25302
+ const endRowStartsWithZero = elementList[endRowStartIndex]?.value === ZERO;
24655
25303
  let startColNo = 0;
24656
25304
  let endColNo = 0;
24657
25305
  if (!this.draw.getCursor().getHitLineStartIndex()) {
24658
- startColNo = startRow.elementList[0]?.value === ZERO ? startPosition.index - startRow.startIndex : startPosition.index - startRow.startIndex + 1;
25306
+ startColNo = startRowStartsWithZero ? startIndex - startRowStartIndex : startIndex - startRowStartIndex + 1;
24659
25307
  }
24660
25308
  if (startPosition === endPosition) {
24661
25309
  endColNo = startColNo;
24662
25310
  } else {
24663
- endColNo = endRow.elementList[0]?.value === ZERO ? endPosition.index - endRow.startIndex : endPosition.index - endRow.startIndex + 1;
25311
+ endColNo = endRowStartsWithZero ? endIndex - endRowStartIndex : endIndex - endRowStartIndex + 1;
24664
25312
  }
24665
25313
  const rangeRects = [];
24666
25314
  const height = this.draw.getOriginalHeight();
@@ -24668,6 +25316,7 @@ var CommandAdapt = class {
24668
25316
  const selectionPositionList = this.position.getSelectionPositionList();
24669
25317
  if (selectionPositionList) {
24670
25318
  let currentRowNo = null;
25319
+ let currentPageNo = null;
24671
25320
  let currentX = 0;
24672
25321
  let rangeRect = null;
24673
25322
  for (let p = 0; p < selectionPositionList.length; p++) {
@@ -24677,7 +25326,7 @@ var CommandAdapt = class {
24677
25326
  coordinate: { leftTop, rightTop },
24678
25327
  lineHeight
24679
25328
  } = selectionPositionList[p];
24680
- if (currentRowNo === null || currentRowNo !== rowNo) {
25329
+ if (currentRowNo === null || currentPageNo === null || currentRowNo !== rowNo || currentPageNo !== pageNo) {
24681
25330
  if (rangeRect) {
24682
25331
  rangeRects.push(rangeRect);
24683
25332
  }
@@ -24688,6 +25337,7 @@ var CommandAdapt = class {
24688
25337
  height: lineHeight
24689
25338
  };
24690
25339
  currentRowNo = rowNo;
25340
+ currentPageNo = pageNo;
24691
25341
  currentX = leftTop[0];
24692
25342
  } else {
24693
25343
  rangeRect.width = rightTop[0] - currentX;