@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.js CHANGED
@@ -78,7 +78,7 @@ __export(index_exports, {
78
78
  module.exports = __toCommonJS(index_exports);
79
79
 
80
80
  // src/version.ts
81
- var version = "0.3.21";
81
+ var version = "0.3.22";
82
82
 
83
83
  // src/dataset/enum/Common.ts
84
84
  var MaxHeightRatio = /* @__PURE__ */ ((MaxHeightRatio2) => {
@@ -503,7 +503,7 @@ var ElementType = /* @__PURE__ */ ((ElementType2) => {
503
503
  // src/utils/ua.ts
504
504
  var isApple = typeof navigator !== "undefined" && /Mac OS X/.test(navigator.userAgent);
505
505
  var isIOS = typeof navigator !== "undefined" && /iPad|iPhone/.test(navigator.userAgent);
506
- var isMobile = /Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
506
+ var isMobile = typeof navigator !== "undefined" && /Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
507
507
  navigator.userAgent
508
508
  );
509
509
  var isFirefox = typeof navigator !== "undefined" && /Firefox/.test(navigator.userAgent);
@@ -598,6 +598,8 @@ var TABLE_TD_ZIP_ATTR = [
598
598
  "externalId",
599
599
  "verticalAlign",
600
600
  "backgroundColor",
601
+ "borderColor",
602
+ "padding",
601
603
  "borderTypes",
602
604
  "slashTypes",
603
605
  "disabled",
@@ -5016,6 +5018,37 @@ function pickElementAttr(payload, option = {}) {
5016
5018
  });
5017
5019
  return element;
5018
5020
  }
5021
+ function mergeSplitTableRowsForZip(trList) {
5022
+ for (let t = trList.length - 1; t >= 0; t--) {
5023
+ const splitTr = trList[t];
5024
+ if (!splitTr.splitParentId) continue;
5025
+ const parentTrIdx = trList.findIndex(
5026
+ (tr) => tr.id === splitTr.splitParentId
5027
+ );
5028
+ if (!~parentTrIdx) continue;
5029
+ const parentTr = trList[parentTrIdx];
5030
+ parentTr.height += splitTr.height;
5031
+ for (let d = 0; d < parentTr.tdList.length; d++) {
5032
+ const parentTd = parentTr.tdList[d];
5033
+ const splitTd = splitTr.tdList[d];
5034
+ if (!parentTd || !splitTd) continue;
5035
+ const hasSyntheticLeadingZero = !!splitTd.splitSyntheticLeadingZero && splitTd.value[0]?.value === ZERO;
5036
+ parentTd.value.push(
5037
+ ...hasSyntheticLeadingZero ? splitTd.value.slice(1) : splitTd.value
5038
+ );
5039
+ }
5040
+ trList.splice(t, 1);
5041
+ }
5042
+ for (let t = 0; t < trList.length; t++) {
5043
+ const tr = trList[t];
5044
+ delete tr.id;
5045
+ delete tr.splitParentId;
5046
+ delete tr.splitRootId;
5047
+ delete tr.splitLevel;
5048
+ delete tr.splitBoundaryTop;
5049
+ delete tr.splitBoundaryBottom;
5050
+ }
5051
+ }
5019
5052
  function zipElementList(payload, options = {}) {
5020
5053
  const { extraPickAttrs, isClassifyArea = false, isClone = true } = options;
5021
5054
  const elementList = isClone ? deepClone(payload) : payload;
@@ -5115,8 +5148,11 @@ function zipElementList(payload, options = {}) {
5115
5148
  while (tableIndex < elementList.length) {
5116
5149
  const nextElement = elementList[tableIndex];
5117
5150
  if (nextElement.pagingId === element.pagingId) {
5151
+ const nextTrList = nextElement.trList.filter(
5152
+ (tr) => !tr.pagingRepeat
5153
+ );
5118
5154
  element.height += nextElement.height;
5119
- element.trList.push(...nextElement.trList);
5155
+ element.trList.push(...nextTrList);
5120
5156
  tableIndex++;
5121
5157
  combineCount++;
5122
5158
  } else {
@@ -5126,9 +5162,9 @@ function zipElementList(payload, options = {}) {
5126
5162
  e += combineCount;
5127
5163
  }
5128
5164
  if (element.trList) {
5165
+ mergeSplitTableRowsForZip(element.trList);
5129
5166
  for (let t = 0; t < element.trList.length; t++) {
5130
5167
  const tr = element.trList[t];
5131
- delete tr.id;
5132
5168
  for (let d = 0; d < tr.tdList.length; d++) {
5133
5169
  const td = tr.tdList[d];
5134
5170
  const zipTd = {
@@ -6828,6 +6864,57 @@ var RadioControl = class extends CheckboxControl {
6828
6864
  }
6829
6865
  };
6830
6866
 
6867
+ // src/core/event/handlers/splitCell.ts
6868
+ function isSameSplitCellSelection(first, second) {
6869
+ if (!first || !second) return false;
6870
+ return first.pagingId === second.pagingId && first.rootTrId === second.rootTrId && first.colIndex === second.colIndex;
6871
+ }
6872
+ function getSplitCellPointer(draw, position) {
6873
+ if (!position.isTable || position.index === void 0 || position.tdIndex === void 0 || position.tdValueIndex === void 0 || !position.trId) {
6874
+ return null;
6875
+ }
6876
+ const originalElementList = draw.getOriginalElementList();
6877
+ const tableElement = originalElementList[position.index];
6878
+ if (tableElement?.type !== "table" /* TABLE */ || !tableElement.pagingId || !tableElement.trList?.length) {
6879
+ return null;
6880
+ }
6881
+ const tr = tableElement.trList.find((row) => row.id === position.trId);
6882
+ const td = tr?.tdList[position.tdIndex];
6883
+ if (!tr || !td || td.colIndex === void 0 || !tr.id) {
6884
+ return null;
6885
+ }
6886
+ const splitCellSelection = {
6887
+ pagingId: tableElement.pagingId,
6888
+ rootTrId: tr.splitRootId || tr.id,
6889
+ colIndex: td.colIndex
6890
+ };
6891
+ const splitCellContext = draw.getSplitCellSelectionContext(
6892
+ originalElementList,
6893
+ splitCellSelection
6894
+ );
6895
+ if (!splitCellContext) {
6896
+ return null;
6897
+ }
6898
+ let globalIndex = 0;
6899
+ for (let c = 0; c < splitCellContext.cellContextList.length; c++) {
6900
+ const cellContext = splitCellContext.cellContextList[c];
6901
+ const currentTd = cellContext.td;
6902
+ const skipLeadingZero = !!currentTd.splitSyntheticLeadingZero && currentTd.value[0]?.value === ZERO ? 1 : 0;
6903
+ if (cellContext.tr.id === tr.id && currentTd.id === td.id) {
6904
+ globalIndex += Math.max(position.tdValueIndex - skipLeadingZero, 0);
6905
+ return {
6906
+ splitCellSelection,
6907
+ globalIndex
6908
+ };
6909
+ }
6910
+ globalIndex += Math.max(currentTd.value.length - skipLeadingZero, 0);
6911
+ }
6912
+ return null;
6913
+ }
6914
+ function isSameSplitCellPointer(first, second) {
6915
+ return isSameSplitCellSelection(first, second);
6916
+ }
6917
+
6831
6918
  // src/core/event/handlers/mousedown.ts
6832
6919
  function setRangeCache(host) {
6833
6920
  const draw = host.getDraw();
@@ -6915,9 +7002,11 @@ function mousedown(evt, host) {
6915
7002
  tdValueIndex,
6916
7003
  hitLineStartIndex
6917
7004
  } = positionResult;
7005
+ const splitCellPointer = getSplitCellPointer(draw, positionResult);
6918
7006
  host.mouseDownStartPosition = {
6919
7007
  ...positionResult,
6920
- index: isTable ? tdValueIndex : index,
7008
+ index: splitCellPointer ? splitCellPointer.globalIndex : isTable ? tdValueIndex : index,
7009
+ splitCellSelection: splitCellPointer?.splitCellSelection,
6921
7010
  x: evt.offsetX,
6922
7011
  y: evt.offsetY
6923
7012
  };
@@ -7357,10 +7446,33 @@ function mousemove(evt, host) {
7357
7446
  isTable: startIsTable,
7358
7447
  tdIndex: startTdIndex,
7359
7448
  trIndex: startTrIndex,
7360
- tableId: startTableId
7449
+ tableId: startTableId,
7450
+ splitCellSelection: startSplitCellSelection
7361
7451
  } = host.mouseDownStartPosition;
7362
7452
  const endIndex = isTable ? tdValueIndex : index;
7363
7453
  const rangeManager = draw.getRange();
7454
+ if (startSplitCellSelection) {
7455
+ const currentSplitCellPointer = getSplitCellPointer(draw, positionResult);
7456
+ if (currentSplitCellPointer && isSameSplitCellPointer(
7457
+ startSplitCellSelection,
7458
+ currentSplitCellPointer.splitCellSelection
7459
+ )) {
7460
+ let start = startIndex;
7461
+ let end = currentSplitCellPointer.globalIndex;
7462
+ if (start > end) {
7463
+ [start, end] = [end, start];
7464
+ }
7465
+ if (start === end) return;
7466
+ rangeManager.setRange(start, end);
7467
+ rangeManager.setSplitCellSelection(startSplitCellSelection);
7468
+ draw.render({
7469
+ isSubmitHistory: false,
7470
+ isSetCursor: false,
7471
+ isCompute: false
7472
+ });
7473
+ return;
7474
+ }
7475
+ }
7364
7476
  if (isTable && startIsTable && (tdIndex !== startTdIndex || trIndex !== startTrIndex)) {
7365
7477
  rangeManager.setRange(
7366
7478
  endIndex,
@@ -7527,7 +7639,9 @@ function backspace(evt, host) {
7527
7639
  const control = draw.getControl();
7528
7640
  const { startIndex, endIndex, isCrossRowCol } = rangeManager.getRange();
7529
7641
  let curIndex;
7530
- if (isCrossRowCol) {
7642
+ if (rangeManager.getSplitCellSelection() && startIndex !== endIndex) {
7643
+ curIndex = draw.replaceSplitCellSelection([]);
7644
+ } else if (isCrossRowCol) {
7531
7645
  const rowCol = draw.getTableParticle().getRangeRowCol();
7532
7646
  if (!rowCol) return;
7533
7647
  let isDeleted = false;
@@ -7685,7 +7799,9 @@ function del(evt, host) {
7685
7799
  deleteHideElement(host);
7686
7800
  }
7687
7801
  let curIndex;
7688
- if (isCrossRowCol) {
7802
+ if (rangeManager.getSplitCellSelection() && startIndex !== endIndex) {
7803
+ curIndex = draw.replaceSplitCellSelection([]);
7804
+ } else if (isCrossRowCol) {
7689
7805
  const rowCol = draw.getTableParticle().getRangeRowCol();
7690
7806
  if (!rowCol) return;
7691
7807
  let isDeleted = false;
@@ -8597,6 +8713,8 @@ function input(data2, host) {
8597
8713
  if (!isComposing) {
8598
8714
  control.emitControlContentChange();
8599
8715
  }
8716
+ } else if (rangeManager.getSplitCellSelection()) {
8717
+ curIndex = draw.replaceSplitCellSelection(inputData);
8600
8718
  } else {
8601
8719
  const start = startIndex + 1;
8602
8720
  if (startIndex !== endIndex) {
@@ -9096,7 +9214,7 @@ var CanvasEvent = class {
9096
9214
  }
9097
9215
  selectAll() {
9098
9216
  if (this.position.getPositionContext().isTable) {
9099
- this.draw.getTableOperate().tableSelectAll();
9217
+ this.draw.getTableOperate().tableTdSelectAll();
9100
9218
  } else {
9101
9219
  const positionList = this.position.getPositionList();
9102
9220
  this.range.setRange(0, positionList.length - 1);
@@ -9373,6 +9491,10 @@ var Position = class {
9373
9491
  return this.floatPositionList;
9374
9492
  }
9375
9493
  getTablePositionList(sourceElementList) {
9494
+ const splitCellSelectionContext = this.draw.getSplitCellSelectionContext(sourceElementList);
9495
+ if (splitCellSelectionContext) {
9496
+ return splitCellSelectionContext.positionList;
9497
+ }
9376
9498
  return this.draw.resolveTableCellContext(sourceElementList, this.positionContext)?.td.positionList || [];
9377
9499
  }
9378
9500
  getPositionList() {
@@ -10163,6 +10285,18 @@ var RangeManager = class {
10163
10285
  clearRange() {
10164
10286
  this.setRange(-1, -1);
10165
10287
  }
10288
+ getSplitCellSelection() {
10289
+ return this.range.splitCellSelection;
10290
+ }
10291
+ setSplitCellSelection(payload) {
10292
+ this.range.splitCellSelection = payload || void 0;
10293
+ }
10294
+ getTableCellSelection() {
10295
+ return this.range.tableCellSelection;
10296
+ }
10297
+ setTableCellSelection(payload) {
10298
+ this.range.tableCellSelection = payload || void 0;
10299
+ }
10166
10300
  setDefaultStyle(style) {
10167
10301
  if (!style) {
10168
10302
  this.defaultStyle = null;
@@ -10453,6 +10587,8 @@ var RangeManager = class {
10453
10587
  this.range.isCrossRowCol = !!(startTdIndex || endTdIndex || startTrIndex || endTrIndex);
10454
10588
  this.setDefaultStyle(null);
10455
10589
  }
10590
+ this.range.splitCellSelection = void 0;
10591
+ this.range.tableCellSelection = void 0;
10456
10592
  this.range.zone = this.draw.getZone().getZone();
10457
10593
  const control = this.draw.getControl();
10458
10594
  if (~startIndex && ~endIndex) {
@@ -12175,6 +12311,44 @@ var TableParticle = class {
12175
12311
  }
12176
12312
  ctx.restore();
12177
12313
  }
12314
+ _isSelectedCell(element, tr, td, selection) {
12315
+ if (selection.pagingId && selection.rootTrId && selection.colIndex !== void 0) {
12316
+ return element.pagingId === selection.pagingId && (tr.id === selection.rootTrId || tr.splitRootId === selection.rootTrId) && td.colIndex === selection.colIndex;
12317
+ }
12318
+ if (selection.tableId && element.id !== selection.tableId) {
12319
+ return false;
12320
+ }
12321
+ if (selection.trId && tr.id !== selection.trId) {
12322
+ return false;
12323
+ }
12324
+ if (selection.tdId) {
12325
+ return td.id === selection.tdId;
12326
+ }
12327
+ return false;
12328
+ }
12329
+ drawCellRange(ctx, element, startX, startY, selection) {
12330
+ const { scale, rangeAlpha, rangeColor } = this.options;
12331
+ const { type, trList } = element;
12332
+ if (!trList || type !== "table" /* TABLE */) return;
12333
+ ctx.save();
12334
+ ctx.globalAlpha = rangeAlpha;
12335
+ ctx.fillStyle = rangeColor;
12336
+ for (let t = 0; t < trList.length; t++) {
12337
+ const tr = trList[t];
12338
+ for (let d = 0; d < tr.tdList.length; d++) {
12339
+ const td = tr.tdList[d];
12340
+ if (!this._isSelectedCell(element, tr, td, selection)) {
12341
+ continue;
12342
+ }
12343
+ const x = td.x * scale;
12344
+ const y = td.y * scale;
12345
+ const width = td.width * scale;
12346
+ const height = td.height * scale;
12347
+ ctx.fillRect(x + startX, y + startY, width, height);
12348
+ }
12349
+ }
12350
+ ctx.restore();
12351
+ }
12178
12352
  render(ctx, element, startX, startY) {
12179
12353
  this._drawBackgroundColor(ctx, element, startX, startY);
12180
12354
  this._drawBorder(ctx, element, startX, startY);
@@ -16679,17 +16853,14 @@ function computeValue(data2, options) {
16679
16853
  const { extraPickAttrs = [] } = options || {};
16680
16854
  return {
16681
16855
  header: zipElementList(data2.header, {
16682
- extraPickAttrs,
16683
- isClone: false
16856
+ extraPickAttrs
16684
16857
  }),
16685
16858
  main: zipElementList(data2.main, {
16686
16859
  extraPickAttrs,
16687
- isClassifyArea: true,
16688
- isClone: false
16860
+ isClassifyArea: true
16689
16861
  }),
16690
16862
  footer: zipElementList(data2.footer, {
16691
- extraPickAttrs,
16692
- isClone: false
16863
+ extraPickAttrs
16693
16864
  })
16694
16865
  };
16695
16866
  }
@@ -18728,6 +18899,38 @@ var ListParticle = class {
18728
18899
  const level = element.listLevel ?? 0;
18729
18900
  return level * INDENT_PER_LEVEL * scale;
18730
18901
  }
18902
+ _getListMarkerStyleElement(elementList, startIndex = 0) {
18903
+ const startElement = elementList[startIndex];
18904
+ for (let i = startIndex + 1; i < elementList.length; i++) {
18905
+ const element = elementList[i];
18906
+ if (element.value === ZERO && !element.listWrap) {
18907
+ break;
18908
+ }
18909
+ if (element.type === "tab" /* TAB */) {
18910
+ continue;
18911
+ }
18912
+ if (element.value !== ZERO || element.type) {
18913
+ return element;
18914
+ }
18915
+ }
18916
+ return startElement;
18917
+ }
18918
+ _getListMarkerText(element, listIndex) {
18919
+ if (element.listStyle === "checkbox" /* CHECKBOX */) {
18920
+ return "";
18921
+ }
18922
+ if (element.listType === "ul" /* UL */) {
18923
+ if (element.listPreset) {
18924
+ return this._getUlBulletForLevel(element);
18925
+ }
18926
+ return ulStyleMapping[element.listStyle] || ulStyleMapping["disc" /* DISC */];
18927
+ }
18928
+ if (element.listPreset) {
18929
+ const olStyle = this._getOlStyleForLevel(element);
18930
+ return formatOlNumber(listIndex, olStyle);
18931
+ }
18932
+ return `${listIndex + 1}${"." /* PERIOD */}`;
18933
+ }
18731
18934
  computeListStyle(ctx, elementList) {
18732
18935
  const listStyleMap = /* @__PURE__ */ new Map();
18733
18936
  let start = 0;
@@ -18758,23 +18961,40 @@ var ListParticle = class {
18758
18961
  }
18759
18962
  getListStyleWidth(ctx, listElementList) {
18760
18963
  const { scale, checkbox } = this.options;
18761
- const startElement = listElementList[0];
18762
- if (startElement.listStyle && startElement.listStyle !== "decimal" /* DECIMAL */) {
18763
- if (startElement.listStyle === "checkbox" /* CHECKBOX */) {
18764
- return (checkbox.width + this.LIST_GAP) * scale;
18964
+ let maxWidth = 0;
18965
+ let listIndex = 0;
18966
+ for (let i = 0; i < listElementList.length; i++) {
18967
+ const element = listElementList[i];
18968
+ if (element.value !== ZERO || element.listWrap) continue;
18969
+ if (element.listStyle === "checkbox" /* CHECKBOX */) {
18970
+ maxWidth = Math.max(maxWidth, checkbox.width + this.LIST_GAP);
18971
+ listIndex++;
18972
+ continue;
18765
18973
  }
18766
- return this.UN_COUNT_STYLE_WIDTH * scale;
18767
- }
18768
- const count = listElementList.reduce((pre, cur) => {
18769
- if (cur.value === ZERO) {
18770
- pre += 1;
18974
+ const markerStyleElement = this._getListMarkerStyleElement(
18975
+ listElementList,
18976
+ i
18977
+ );
18978
+ const text = this._getListMarkerText(element, listIndex);
18979
+ if (!text) {
18980
+ listIndex++;
18981
+ continue;
18771
18982
  }
18772
- return pre;
18773
- }, 0);
18774
- if (!count) return 0;
18775
- const text = `${this.MEASURE_BASE_TEXT.repeat(String(count).length)}${"." /* PERIOD */}`;
18776
- const textMetrics = ctx.measureText(text);
18777
- return Math.ceil((textMetrics.width + this.LIST_GAP) * scale);
18983
+ ctx.save();
18984
+ ctx.font = this.draw.getElementFont(markerStyleElement);
18985
+ const textMetrics = ctx.measureText(text);
18986
+ ctx.restore();
18987
+ maxWidth = Math.max(maxWidth, textMetrics.width + this.LIST_GAP);
18988
+ listIndex++;
18989
+ }
18990
+ if (maxWidth > 0) {
18991
+ return Math.ceil(maxWidth * scale);
18992
+ }
18993
+ const startElement = listElementList[0];
18994
+ if (startElement?.listStyle === "checkbox" /* CHECKBOX */) {
18995
+ return (checkbox.width + this.LIST_GAP) * scale;
18996
+ }
18997
+ return this.UN_COUNT_STYLE_WIDTH * scale;
18778
18998
  }
18779
18999
  _getOlStyleForLevel(element) {
18780
19000
  const preset = element.listPreset || "olDefault" /* DEFAULT */;
@@ -18795,7 +19015,7 @@ var ListParticle = class {
18795
19015
  const startElement = elementList[0];
18796
19016
  if (startElement.value !== ZERO || startElement.listWrap) return;
18797
19017
  let tabWidth = 0;
18798
- const { defaultTabWidth, scale, defaultFont, defaultSize } = this.options;
19018
+ const { defaultTabWidth, scale } = this.options;
18799
19019
  for (let i = 1; i < elementList.length; i++) {
18800
19020
  const element = elementList[i];
18801
19021
  if (element?.type !== "tab" /* TAB */) break;
@@ -18833,24 +19053,11 @@ var ListParticle = class {
18833
19053
  }
18834
19054
  });
18835
19055
  } else {
18836
- let text = "";
18837
- if (startElement.listType === "ul" /* UL */) {
18838
- if (startElement.listPreset) {
18839
- text = this._getUlBulletForLevel(startElement);
18840
- } else {
18841
- text = ulStyleMapping[startElement.listStyle] || ulStyleMapping["disc" /* DISC */];
18842
- }
18843
- } else {
18844
- if (startElement.listPreset) {
18845
- const olStyle = this._getOlStyleForLevel(startElement);
18846
- text = formatOlNumber(listIndex, olStyle);
18847
- } else {
18848
- text = `${listIndex + 1}${"." /* PERIOD */}`;
18849
- }
18850
- }
19056
+ const text = this._getListMarkerText(startElement, listIndex);
18851
19057
  if (!text) return;
19058
+ const markerStyleElement = this._getListMarkerStyleElement(elementList);
18852
19059
  ctx.save();
18853
- ctx.font = `${defaultSize * (96 / 72) * scale}px ${defaultFont}`;
19060
+ ctx.font = this.draw.getElementFont(markerStyleElement, scale);
18854
19061
  ctx.fillText(text, x, y);
18855
19062
  ctx.restore();
18856
19063
  }
@@ -19300,6 +19507,39 @@ var TableOperate = class {
19300
19507
  this.tableParticle = draw.getTableParticle();
19301
19508
  this.options = draw.getOptions();
19302
19509
  }
19510
+ getActiveTableElements() {
19511
+ const positionContext = this.position.getPositionContext();
19512
+ if (!positionContext.isTable) return [];
19513
+ const originalElementList = this.draw.getOriginalElementList();
19514
+ const element = originalElementList[positionContext.index];
19515
+ if (!element || element.type !== "table" /* TABLE */) return [];
19516
+ if (!element.pagingId) return [element];
19517
+ return originalElementList.filter(
19518
+ (item) => item.type === "table" /* TABLE */ && item.pagingId === element.pagingId
19519
+ );
19520
+ }
19521
+ getSplitCellStyleSelection() {
19522
+ const tableCellSelection = this.range.getTableCellSelection();
19523
+ if (tableCellSelection?.pagingId && tableCellSelection.rootTrId && tableCellSelection.colIndex !== void 0) {
19524
+ return tableCellSelection;
19525
+ }
19526
+ return this.range.getSplitCellSelection();
19527
+ }
19528
+ getStyleTargetRowCol() {
19529
+ const splitCellSelection = this.getSplitCellStyleSelection();
19530
+ if (splitCellSelection) {
19531
+ const splitCellContext = this.draw.getSplitCellSelectionContext(
19532
+ this.draw.getOriginalElementList(),
19533
+ splitCellSelection
19534
+ );
19535
+ if (splitCellContext) {
19536
+ return splitCellContext.cellContextList.map((cellContext) => [
19537
+ cellContext.td
19538
+ ]);
19539
+ }
19540
+ }
19541
+ return this.tableParticle.getRangeRowCol();
19542
+ }
19303
19543
  insertTable(row, col) {
19304
19544
  const { startIndex, endIndex } = this.range.getRange();
19305
19545
  if (!~startIndex && !~endIndex) return;
@@ -19980,7 +20220,7 @@ var TableOperate = class {
19980
20220
  this.tableTool.render();
19981
20221
  }
19982
20222
  tableTdVerticalAlign(payload) {
19983
- const rowCol = this.tableParticle.getRangeRowCol();
20223
+ const rowCol = this.getStyleTargetRowCol();
19984
20224
  if (!rowCol) return;
19985
20225
  for (let r = 0; r < rowCol.length; r++) {
19986
20226
  const row = rowCol[r];
@@ -20000,13 +20240,17 @@ var TableOperate = class {
20000
20240
  tableBorderType(payload) {
20001
20241
  const positionContext = this.position.getPositionContext();
20002
20242
  if (!positionContext.isTable) return;
20003
- const { index } = positionContext;
20004
- const originalElementList = this.draw.getOriginalElementList();
20005
- const element = originalElementList[index];
20006
- if (!element.borderType && payload === "all" /* ALL */ || element.borderType === payload) {
20243
+ const tableElements = this.getActiveTableElements();
20244
+ if (!tableElements.length) return;
20245
+ const isAllSame = tableElements.every(
20246
+ (element) => !element.borderType && payload === "all" /* ALL */ || element.borderType === payload
20247
+ );
20248
+ if (isAllSame) {
20007
20249
  return;
20008
20250
  }
20009
- element.borderType = payload;
20251
+ tableElements.forEach((element) => {
20252
+ element.borderType = payload;
20253
+ });
20010
20254
  const { endIndex } = this.range.getRange();
20011
20255
  this.draw.render({
20012
20256
  curIndex: endIndex
@@ -20015,13 +20259,17 @@ var TableOperate = class {
20015
20259
  tableBorderColor(payload) {
20016
20260
  const positionContext = this.position.getPositionContext();
20017
20261
  if (!positionContext.isTable) return;
20018
- const { index } = positionContext;
20019
- const originalElementList = this.draw.getOriginalElementList();
20020
- const element = originalElementList[index];
20021
- if (!element.borderColor && payload === this.options.table.defaultBorderColor || element.borderColor === payload) {
20262
+ const tableElements = this.getActiveTableElements();
20263
+ if (!tableElements.length) return;
20264
+ const isAllSame = tableElements.every(
20265
+ (element) => !element.borderColor && payload === this.options.table.defaultBorderColor || element.borderColor === payload
20266
+ );
20267
+ if (isAllSame) {
20022
20268
  return;
20023
20269
  }
20024
- element.borderColor = payload;
20270
+ tableElements.forEach((element) => {
20271
+ element.borderColor = payload;
20272
+ });
20025
20273
  const { endIndex } = this.range.getRange();
20026
20274
  this.draw.render({
20027
20275
  curIndex: endIndex,
@@ -20029,7 +20277,7 @@ var TableOperate = class {
20029
20277
  });
20030
20278
  }
20031
20279
  tableTdBorderType(payload) {
20032
- const rowCol = this.tableParticle.getRangeRowCol();
20280
+ const rowCol = this.getStyleTargetRowCol();
20033
20281
  if (!rowCol) return;
20034
20282
  const tdList = rowCol.flat();
20035
20283
  const isSetBorderType = tdList.some(
@@ -20061,7 +20309,7 @@ var TableOperate = class {
20061
20309
  });
20062
20310
  }
20063
20311
  tableTdSlashType(payload) {
20064
- const rowCol = this.tableParticle.getRangeRowCol();
20312
+ const rowCol = this.getStyleTargetRowCol();
20065
20313
  if (!rowCol) return;
20066
20314
  const tdList = rowCol.flat();
20067
20315
  const isSetTdSlashType = tdList.some(
@@ -20091,7 +20339,7 @@ var TableOperate = class {
20091
20339
  });
20092
20340
  }
20093
20341
  tableTdBackgroundColor(payload) {
20094
- const rowCol = this.tableParticle.getRangeRowCol();
20342
+ const rowCol = this.getStyleTargetRowCol();
20095
20343
  if (!rowCol) return;
20096
20344
  for (let r = 0; r < rowCol.length; r++) {
20097
20345
  const row = rowCol[r];
@@ -20112,14 +20360,14 @@ var TableOperate = class {
20112
20360
  const { index } = positionContext;
20113
20361
  const originalElementList = this.draw.getOriginalElementList();
20114
20362
  const element = originalElementList[index];
20115
- const rowCol = this.tableParticle.getRangeRowCol();
20363
+ const rowCol = this.getStyleTargetRowCol();
20116
20364
  if (!rowCol) return;
20117
20365
  const tdList = rowCol.flat();
20118
20366
  const totalCells = element.trList.reduce(
20119
20367
  (sum, tr) => sum + tr.tdList.length,
20120
20368
  0
20121
20369
  );
20122
- const allSelected = tdList.length >= totalCells;
20370
+ const allSelected = !element.pagingId && !this.getSplitCellStyleSelection() && tdList.length >= totalCells;
20123
20371
  if (allSelected) {
20124
20372
  element.borderColor = payload || void 0;
20125
20373
  element.trList.forEach(
@@ -20139,7 +20387,7 @@ var TableOperate = class {
20139
20387
  });
20140
20388
  }
20141
20389
  tableTdPadding(payload) {
20142
- const rowCol = this.tableParticle.getRangeRowCol();
20390
+ const rowCol = this.getStyleTargetRowCol();
20143
20391
  if (!rowCol) return;
20144
20392
  const tdList = rowCol.flat();
20145
20393
  tdList.forEach((td) => {
@@ -20174,6 +20422,46 @@ var TableOperate = class {
20174
20422
  isSubmitHistory: false
20175
20423
  });
20176
20424
  }
20425
+ tableTdSelectAll() {
20426
+ const originalElementList = this.draw.getOriginalElementList();
20427
+ const resolved = this.draw.resolveTableCellContext(originalElementList);
20428
+ if (!resolved) return;
20429
+ const currentTr = resolved.element.trList?.[resolved.trIndex];
20430
+ if (!currentTr) return;
20431
+ const currentTd = resolved.td;
20432
+ const currentElement = resolved.element;
20433
+ const splitCellSelection = currentElement.pagingId && currentTr.id && currentTd.colIndex !== void 0 ? {
20434
+ pagingId: currentElement.pagingId,
20435
+ rootTrId: currentTr.splitRootId || currentTr.id,
20436
+ colIndex: currentTd.colIndex
20437
+ } : void 0;
20438
+ const splitCellSelectionContext = this.draw.getSplitCellSelectionContext(
20439
+ originalElementList,
20440
+ splitCellSelection
20441
+ );
20442
+ if (splitCellSelectionContext) {
20443
+ const endIndex = Math.max(
20444
+ splitCellSelectionContext.positionList.length - 1,
20445
+ 0
20446
+ );
20447
+ this.range.setRange(0, endIndex);
20448
+ this.range.setSplitCellSelection(splitCellSelection);
20449
+ this.range.setTableCellSelection(splitCellSelection);
20450
+ } else {
20451
+ const endIndex = Math.max(currentTd.value.length - 1, 0);
20452
+ this.range.setRange(0, endIndex);
20453
+ this.range.setTableCellSelection({
20454
+ tableId: currentElement.id,
20455
+ trId: currentTr.id,
20456
+ tdId: currentTd.id
20457
+ });
20458
+ }
20459
+ this.draw.render({
20460
+ isSetCursor: false,
20461
+ isCompute: false,
20462
+ isSubmitHistory: false
20463
+ });
20464
+ }
20177
20465
  };
20178
20466
 
20179
20467
  // src/dataset/enum/Area.ts
@@ -21031,8 +21319,156 @@ var Draw = class {
21031
21319
  return this.header.getElementList();
21032
21320
  }
21033
21321
  getTableElementList(sourceElementList) {
21322
+ const splitCellSelectionContext = this.getSplitCellSelectionContext(
21323
+ sourceElementList
21324
+ );
21325
+ if (splitCellSelectionContext) {
21326
+ return splitCellSelectionContext.value;
21327
+ }
21034
21328
  return this.resolveTableCellContext(sourceElementList)?.td.value || [];
21035
21329
  }
21330
+ getSplitCellSelectionContext(sourceElementList = this.getOriginalElementList(), splitCellSelection = this.range.getSplitCellSelection()) {
21331
+ if (!splitCellSelection) return null;
21332
+ const { pagingId, rootTrId, colIndex } = splitCellSelection;
21333
+ const cellContextList = [];
21334
+ for (let i = 0; i < sourceElementList.length; i++) {
21335
+ const element = sourceElementList[i];
21336
+ if (element.type !== "table" /* TABLE */ || element.pagingId !== pagingId) {
21337
+ continue;
21338
+ }
21339
+ const trList = element.trList;
21340
+ if (!trList?.length) continue;
21341
+ for (let t = 0; t < trList.length; t++) {
21342
+ const tr = trList[t];
21343
+ if (tr.id !== rootTrId && tr.splitRootId !== rootTrId) continue;
21344
+ const tdIndex = tr.tdList.findIndex((td2) => td2.colIndex === colIndex);
21345
+ if (tdIndex < 0) continue;
21346
+ const td = tr.tdList[tdIndex];
21347
+ cellContextList.push({
21348
+ tableIndex: i,
21349
+ trIndex: t,
21350
+ tdIndex,
21351
+ element,
21352
+ tr,
21353
+ td
21354
+ });
21355
+ }
21356
+ }
21357
+ if (cellContextList.length < 2) return null;
21358
+ const value = [];
21359
+ const positionList = [];
21360
+ for (let c = 0; c < cellContextList.length; c++) {
21361
+ const { td } = cellContextList[c];
21362
+ const skipLeadingZero = !!td.splitSyntheticLeadingZero && td.value[0]?.value === ZERO ? 1 : 0;
21363
+ value.push(...td.value.slice(skipLeadingZero));
21364
+ if (td.positionList?.length) {
21365
+ positionList.push(...td.positionList.slice(skipLeadingZero));
21366
+ }
21367
+ }
21368
+ return {
21369
+ value,
21370
+ positionList,
21371
+ cellContextList
21372
+ };
21373
+ }
21374
+ syncTableElementContext(elementList, context) {
21375
+ const { tableId, trId, tdId } = context;
21376
+ for (let i = 0; i < elementList.length; i++) {
21377
+ const element = elementList[i];
21378
+ element.tableId = tableId;
21379
+ element.trId = trId;
21380
+ element.tdId = tdId;
21381
+ }
21382
+ }
21383
+ getCollapsedSplitTableCursorContext(element) {
21384
+ const positionContext = this.position.getPositionContext();
21385
+ const { startIndex, endIndex } = this.range.getRange();
21386
+ if (!element.pagingId || !positionContext.isTable || startIndex !== endIndex || positionContext.tableId !== element.id || !positionContext.trId) {
21387
+ return null;
21388
+ }
21389
+ const trList = element.trList;
21390
+ if (!trList?.length) return null;
21391
+ const currentTr = trList.find((tr) => tr.id === positionContext.trId);
21392
+ const currentTd = currentTr && (positionContext.tdId ? currentTr.tdList.find((td) => td.id === positionContext.tdId) : currentTr.tdList[positionContext.tdIndex]);
21393
+ if (!currentTr?.id || !currentTd || currentTd.colIndex === void 0) {
21394
+ return null;
21395
+ }
21396
+ const rootTrId = currentTr.splitRootId || currentTr.id;
21397
+ let mergedIndex = 0;
21398
+ for (let t = 0; t < trList.length; t++) {
21399
+ const tr = trList[t];
21400
+ if (tr.id !== rootTrId && tr.splitRootId !== rootTrId) {
21401
+ continue;
21402
+ }
21403
+ const td = tr.tdList.find((cell) => cell.colIndex === currentTd.colIndex);
21404
+ if (!td) continue;
21405
+ const skipLeadingZero = !!td.splitSyntheticLeadingZero && td.value[0]?.value === ZERO ? 1 : 0;
21406
+ if (tr.id === currentTr.id && td.id === currentTd.id) {
21407
+ mergedIndex += Math.max(startIndex - skipLeadingZero, 0);
21408
+ return {
21409
+ rootTrId,
21410
+ colIndex: currentTd.colIndex,
21411
+ mergedIndex
21412
+ };
21413
+ }
21414
+ mergedIndex += Math.max(td.value.length - skipLeadingZero, 0);
21415
+ }
21416
+ return null;
21417
+ }
21418
+ applyCollapsedSplitTableCursor(payload) {
21419
+ const {
21420
+ tableIndex,
21421
+ tableId,
21422
+ overflowTr,
21423
+ overflowTrIdx,
21424
+ continuationTr,
21425
+ continuationTdList,
21426
+ logicalCursor,
21427
+ splits
21428
+ } = payload;
21429
+ const tdIndex = overflowTr.tdList.findIndex(
21430
+ (td) => td.colIndex === logicalCursor.colIndex
21431
+ );
21432
+ if (tdIndex < 0) return false;
21433
+ const splitIdx = splits[tdIndex]?.elemIdx;
21434
+ if (splitIdx === void 0) return false;
21435
+ const positionContext = this.position.getPositionContext();
21436
+ if (logicalCursor.mergedIndex >= splitIdx) {
21437
+ const continuationTd = continuationTdList[tdIndex];
21438
+ if (!continuationTd) return false;
21439
+ const hasPrependedZero = !!continuationTd.splitSyntheticLeadingZero && continuationTd.value[0]?.value === ZERO;
21440
+ const continuationCursorIndex = logicalCursor.mergedIndex - splitIdx + (hasPrependedZero ? 1 : 0);
21441
+ positionContext.index = tableIndex;
21442
+ positionContext.trIndex = overflowTrIdx + 1;
21443
+ positionContext.tdIndex = tdIndex;
21444
+ positionContext.tdId = continuationTd.id;
21445
+ positionContext.trId = continuationTr.id;
21446
+ positionContext.tableId = tableId;
21447
+ this.position.setPositionContext(positionContext);
21448
+ this.range.setRange(
21449
+ continuationCursorIndex,
21450
+ continuationCursorIndex
21451
+ );
21452
+ this.pendingTableCursorIndex = continuationCursorIndex;
21453
+ return true;
21454
+ }
21455
+ const rootTd = overflowTr.tdList[tdIndex];
21456
+ if (!rootTd) return false;
21457
+ const rootCursorIndex = Math.min(
21458
+ logicalCursor.mergedIndex,
21459
+ Math.max(rootTd.value.length - 1, 0)
21460
+ );
21461
+ positionContext.index = tableIndex;
21462
+ positionContext.trIndex = overflowTrIdx;
21463
+ positionContext.tdIndex = tdIndex;
21464
+ positionContext.tdId = rootTd.id;
21465
+ positionContext.trId = overflowTr.id;
21466
+ positionContext.tableId = tableId;
21467
+ this.position.setPositionContext(positionContext);
21468
+ this.range.setRange(rootCursorIndex, rootCursorIndex);
21469
+ this.pendingTableCursorIndex = rootCursorIndex;
21470
+ return true;
21471
+ }
21036
21472
  getElementList() {
21037
21473
  const positionContext = this.position.getPositionContext();
21038
21474
  const elementList = this.getOriginalElementList();
@@ -21070,6 +21506,18 @@ var Draw = class {
21070
21506
  isHandleFirstElement: false,
21071
21507
  editorOptions: this.options
21072
21508
  });
21509
+ const splitCellSelection = this.range.getSplitCellSelection();
21510
+ if (splitCellSelection) {
21511
+ const curIndex2 = this.replaceSplitCellSelection(payload, splitCellSelection);
21512
+ if (~curIndex2) {
21513
+ this.range.setRange(curIndex2, curIndex2);
21514
+ this.render({
21515
+ curIndex: curIndex2,
21516
+ isSubmitHistory
21517
+ });
21518
+ }
21519
+ return;
21520
+ }
21073
21521
  let curIndex = -1;
21074
21522
  let activeControl = this.control.getActiveControl();
21075
21523
  if (!activeControl && this.control.getIsRangeWithinControl()) {
@@ -21165,6 +21613,80 @@ var Draw = class {
21165
21613
  }
21166
21614
  }
21167
21615
  }
21616
+ replaceSplitCellSelection(payload, splitCellSelection = this.range.getSplitCellSelection()) {
21617
+ const splitCellSelectionContext = this.getSplitCellSelectionContext(
21618
+ this.getOriginalElementList(),
21619
+ splitCellSelection
21620
+ );
21621
+ if (!splitCellSelectionContext) return -1;
21622
+ const [rootCellContext, ...continuationCellContextList] = splitCellSelectionContext.cellContextList;
21623
+ const rootTd = rootCellContext.td;
21624
+ const rootStartIndex = rootTd.value[0]?.value === ZERO ? 1 : 0;
21625
+ if (!rootStartIndex) {
21626
+ rootTd.value.unshift({
21627
+ value: ZERO,
21628
+ type: "text" /* TEXT */
21629
+ });
21630
+ this.syncTableElementContext([rootTd.value[0]], {
21631
+ tableId: rootCellContext.element.id,
21632
+ trId: rootCellContext.tr.id,
21633
+ tdId: rootTd.id
21634
+ });
21635
+ }
21636
+ this.syncTableElementContext(payload, {
21637
+ tableId: rootCellContext.element.id,
21638
+ trId: rootCellContext.tr.id,
21639
+ tdId: rootTd.id
21640
+ });
21641
+ this.spliceElementList(
21642
+ rootTd.value,
21643
+ 1,
21644
+ rootTd.value.length - 1,
21645
+ payload
21646
+ );
21647
+ rootTd.rowList = void 0;
21648
+ rootTd.positionList = void 0;
21649
+ rootTd.mainHeight = void 0;
21650
+ rootTd.realHeight = void 0;
21651
+ rootTd.realMinHeight = void 0;
21652
+ for (let c = 0; c < continuationCellContextList.length; c++) {
21653
+ const continuationTd = continuationCellContextList[c].td;
21654
+ const startIndex = continuationTd.value[0]?.value === ZERO ? 1 : 0;
21655
+ if (!startIndex) {
21656
+ continuationTd.value.unshift({
21657
+ value: ZERO,
21658
+ type: "text" /* TEXT */
21659
+ });
21660
+ this.syncTableElementContext([continuationTd.value[0]], {
21661
+ tableId: continuationCellContextList[c].element.id,
21662
+ trId: continuationCellContextList[c].tr.id,
21663
+ tdId: continuationTd.id
21664
+ });
21665
+ }
21666
+ if (continuationTd.value.length > 1) {
21667
+ this.spliceElementList(
21668
+ continuationTd.value,
21669
+ 1,
21670
+ continuationTd.value.length - 1
21671
+ );
21672
+ }
21673
+ continuationTd.rowList = void 0;
21674
+ continuationTd.positionList = void 0;
21675
+ continuationTd.mainHeight = void 0;
21676
+ continuationTd.realHeight = void 0;
21677
+ continuationTd.realMinHeight = void 0;
21678
+ }
21679
+ this.position.setPositionContext({
21680
+ isTable: true,
21681
+ index: rootCellContext.tableIndex,
21682
+ trIndex: rootCellContext.trIndex,
21683
+ tdIndex: rootCellContext.tdIndex,
21684
+ tdId: rootTd.id,
21685
+ trId: rootCellContext.tr.id,
21686
+ tableId: rootCellContext.element.id
21687
+ });
21688
+ return Math.max(rootTd.value.length - 1, 0);
21689
+ }
21168
21690
  getCanvasEvent() {
21169
21691
  return this.canvasEvent;
21170
21692
  }
@@ -21727,6 +22249,9 @@ var Draw = class {
21727
22249
  } else if (element.type === "table" /* TABLE */) {
21728
22250
  let activeSplitRange;
21729
22251
  let mergedSplitFallback;
22252
+ const logicalSplitCursor = this.getCollapsedSplitTableCursorContext(
22253
+ element
22254
+ );
21730
22255
  if (element.pagingId) {
21731
22256
  let tableIndex = i + 1;
21732
22257
  let combineCount = 0;
@@ -21785,6 +22310,11 @@ var Draw = class {
21785
22310
  if (!splitTd) continue;
21786
22311
  const hasSyntheticLeadingZero = !!splitTd.splitSyntheticLeadingZero && splitTd.value[0]?.value === ZERO;
21787
22312
  const splitValue = hasSyntheticLeadingZero ? splitTd.value.slice(1) : splitTd.value;
22313
+ this.syncTableElementContext(splitValue, {
22314
+ tableId: element.id,
22315
+ trId: parentTr.id,
22316
+ tdId: parentTd.id
22317
+ });
21788
22318
  parentTd.value.push(...splitValue);
21789
22319
  parentTd.rowList = void 0;
21790
22320
  parentTd.positionList = void 0;
@@ -22066,13 +22596,12 @@ var Draw = class {
22066
22596
  const continuationTdList = overflowTr.tdList.map(
22067
22597
  (td, d) => {
22068
22598
  const splitIdx = splits[d].elemIdx;
22599
+ const newTdId = getUUID();
22069
22600
  const initialListState2 = this.getListStateBeforeIndex(
22070
22601
  td.value,
22071
22602
  splitIdx
22072
22603
  );
22073
- const overflowElements = deepClone(
22074
- td.value.slice(splitIdx)
22075
- );
22604
+ const overflowElements = td.value.slice(splitIdx);
22076
22605
  const overflowStartElement = overflowElements[0];
22077
22606
  let splitSyntheticLeadingZero = false;
22078
22607
  if (!overflowElements.length || overflowElements[0]?.value !== ZERO) {
@@ -22088,7 +22617,13 @@ var Draw = class {
22088
22617
  });
22089
22618
  splitSyntheticLeadingZero = true;
22090
22619
  }
22620
+ this.syncTableElementContext(overflowElements, {
22621
+ tableId: element.id,
22622
+ trId: newTrId,
22623
+ tdId: newTdId
22624
+ });
22091
22625
  const {
22626
+ id: _tdId,
22092
22627
  value: _v,
22093
22628
  rowList: _rl,
22094
22629
  positionList: _pl,
@@ -22098,6 +22633,7 @@ var Draw = class {
22098
22633
  } = td;
22099
22634
  return {
22100
22635
  ...deepClone(tdMeta),
22636
+ id: newTdId,
22101
22637
  value: overflowElements,
22102
22638
  splitSyntheticLeadingZero,
22103
22639
  splitListState: initialListState2,
@@ -22119,8 +22655,21 @@ var Draw = class {
22119
22655
  splitRootId,
22120
22656
  splitLevel
22121
22657
  };
22658
+ let isLogicalSplitCursorHandled = false;
22659
+ if (logicalSplitCursor && logicalSplitCursor.rootTrId === splitRootId) {
22660
+ isLogicalSplitCursorHandled = this.applyCollapsedSplitTableCursor({
22661
+ tableIndex: i,
22662
+ tableId: element.id,
22663
+ overflowTr,
22664
+ overflowTrIdx,
22665
+ continuationTr,
22666
+ continuationTdList,
22667
+ logicalCursor: logicalSplitCursor,
22668
+ splits
22669
+ });
22670
+ }
22122
22671
  const positionContext = this.position.getPositionContext();
22123
- if (activeSplitRange && positionContext.isTable && positionContext.trId === activeSplitRange.trId) {
22672
+ if (!isLogicalSplitCursorHandled && activeSplitRange && positionContext.isTable && positionContext.trId === activeSplitRange.trId) {
22124
22673
  const splitIdx = splits[activeSplitRange.tdIndex]?.elemIdx;
22125
22674
  const continuationTd = continuationTdList[activeSplitRange.tdIndex];
22126
22675
  if (splitIdx !== void 0 && continuationTd && activeSplitRange.mergedIndex >= splitIdx) {
@@ -22177,16 +22726,26 @@ var Draw = class {
22177
22726
  element.height -= cloneTrHeight;
22178
22727
  metrics.height -= cloneTrRealHeight;
22179
22728
  metrics.boundingBoxDescent -= cloneTrRealHeight;
22180
- const cloneElement = deepClone(element);
22181
- cloneElement.pagingId = pagingId;
22182
- cloneElement.pagingIndex = element.pagingIndex + 1;
22729
+ const {
22730
+ trList: _currentTrList,
22731
+ id: _currentId,
22732
+ height: _currentHeight,
22733
+ pagingIndex: _currentPagingIndex,
22734
+ ...cloneElementMeta
22735
+ } = element;
22736
+ const cloneElement = {
22737
+ ...deepClone(cloneElementMeta),
22738
+ trList: cloneTrList,
22739
+ height: cloneTrHeight,
22740
+ pagingId,
22741
+ pagingIndex: element.pagingIndex + 1
22742
+ };
22183
22743
  const repeatTrList = trList2.filter((tr) => tr.pagingRepeat);
22184
22744
  if (repeatTrList.length) {
22185
22745
  const cloneRepeatTrList = deepClone(repeatTrList);
22186
22746
  cloneRepeatTrList.forEach((tr) => tr.id = getUUID());
22187
22747
  cloneTrList.unshift(...cloneRepeatTrList);
22188
22748
  }
22189
- cloneElement.trList = cloneTrList;
22190
22749
  cloneElement.id = getUUID();
22191
22750
  this.spliceElementList(elementList, i + 1, 0, [cloneElement]);
22192
22751
  }
@@ -22634,6 +23193,27 @@ var Draw = class {
22634
23193
  const isPrintMode = this.isPrintMode();
22635
23194
  const isGraffitiMode = this.isGraffitiMode();
22636
23195
  const { isCrossRowCol, tableId } = this.range.getRange();
23196
+ const splitCellSelection = this.range.getSplitCellSelection();
23197
+ const tableCellSelection = this.range.getTableCellSelection();
23198
+ const splitCellRenderOffsetMap = splitCellSelection ? (() => {
23199
+ const splitCellContext = this.getSplitCellSelectionContext(
23200
+ this.getOriginalElementList(),
23201
+ splitCellSelection
23202
+ );
23203
+ if (!splitCellContext) return null;
23204
+ const offsetMap = /* @__PURE__ */ new Map();
23205
+ let offset = 0;
23206
+ for (let c = 0; c < splitCellContext.cellContextList.length; c++) {
23207
+ const { td } = splitCellContext.cellContextList[c];
23208
+ const skipLeadingZero = !!td.splitSyntheticLeadingZero && td.value[0]?.value === ZERO ? 1 : 0;
23209
+ offsetMap.set(td.id, {
23210
+ offset,
23211
+ skipLeadingZero
23212
+ });
23213
+ offset += Math.max(td.value.length - skipLeadingZero, 0);
23214
+ }
23215
+ return offsetMap;
23216
+ })() : null;
22637
23217
  let index = startIndex;
22638
23218
  for (let i = 0; i < rowList.length; i++) {
22639
23219
  const curRow = rowList[i];
@@ -22665,6 +23245,9 @@ var Draw = class {
22665
23245
  this.textParticle.complete();
22666
23246
  this.laTexParticle.render(ctx, element, x, y + offsetY);
22667
23247
  } else if (element.type === "table" /* TABLE */) {
23248
+ if (tableCellSelection) {
23249
+ tableRangeElement = element;
23250
+ }
22668
23251
  if (isCrossRowCol) {
22669
23252
  rangeRecord.x = x;
22670
23253
  rangeRecord.y = y;
@@ -22812,11 +23395,14 @@ var Draw = class {
22812
23395
  startIndex: startIndex2,
22813
23396
  endIndex
22814
23397
  } = this.range.getRange();
22815
- if (currentZone === zone && startIndex2 !== endIndex && startIndex2 <= index && index <= endIndex) {
23398
+ const splitCellOffset = element.tdId ? splitCellRenderOffsetMap?.get(element.tdId) : void 0;
23399
+ const splitCellIndex = splitCellOffset ? index - splitCellOffset.skipLeadingZero + splitCellOffset.offset : index;
23400
+ const isSplitCellElement = !!splitCellOffset && index >= splitCellOffset.skipLeadingZero;
23401
+ if (currentZone === zone && startIndex2 !== endIndex && startIndex2 <= splitCellIndex && splitCellIndex <= endIndex) {
22816
23402
  const positionContext = this.position.getPositionContext();
22817
- if (!positionContext.isTable && !element.tdId || positionContext.tdId === element.tdId) {
22818
- if (startIndex2 === index) {
22819
- const nextElement = elementList[startIndex2 + 1];
23403
+ if (splitCellRenderOffsetMap && isSplitCellElement || !splitCellRenderOffsetMap && (!positionContext.isTable && !element.tdId || positionContext.tdId === element.tdId)) {
23404
+ if (startIndex2 === splitCellIndex) {
23405
+ const nextElement = splitCellRenderOffsetMap && isSplitCellElement ? this.getElementList()[startIndex2 + 1] : elementList[startIndex2 + 1];
22820
23406
  if (nextElement && nextElement.value === ZERO) {
22821
23407
  rangeRecord.x = x + metrics.width;
22822
23408
  rangeRecord.y = y - (curRow.spaceAbove || 0);
@@ -22881,7 +23467,7 @@ var Draw = class {
22881
23467
  this.strikeout.render(ctx);
22882
23468
  this.group.render(ctx);
22883
23469
  if (!isPrintMode && !isGraffitiMode) {
22884
- if (rangeRecord.width && rangeRecord.height) {
23470
+ if (!tableCellSelection && rangeRecord.width && rangeRecord.height) {
22885
23471
  const { x, y, width, height } = rangeRecord;
22886
23472
  this.range.render(ctx, x, y, width, height);
22887
23473
  }
@@ -22893,6 +23479,20 @@ var Draw = class {
22893
23479
  } = positionList[curRow.startIndex];
22894
23480
  this.tableParticle.drawRange(ctx, tableRangeElement, x, y);
22895
23481
  }
23482
+ if (tableCellSelection && tableRangeElement) {
23483
+ const {
23484
+ coordinate: {
23485
+ leftTop: [x, y]
23486
+ }
23487
+ } = positionList[curRow.startIndex];
23488
+ this.tableParticle.drawCellRange(
23489
+ ctx,
23490
+ tableRangeElement,
23491
+ x,
23492
+ y,
23493
+ tableCellSelection
23494
+ );
23495
+ }
22896
23496
  }
22897
23497
  }
22898
23498
  }
@@ -23519,6 +24119,34 @@ var CommandAdapt = class {
23519
24119
  this.zone = draw.getZone();
23520
24120
  this.tableOperate = draw.getTableOperate();
23521
24121
  }
24122
+ getStyleSelectionElementList(options = {}) {
24123
+ const selection = this.range.getSelectionElementList();
24124
+ if (!selection?.length) return null;
24125
+ const { textLikeOnly = false } = options;
24126
+ const result = [];
24127
+ const collect = (elementList) => {
24128
+ for (let i = 0; i < elementList.length; i++) {
24129
+ const element = elementList[i];
24130
+ if (element.type === "table" /* TABLE */ && element.trList?.length) {
24131
+ for (let t = 0; t < element.trList.length; t++) {
24132
+ const tr = element.trList[t];
24133
+ for (let d = 0; d < tr.tdList.length; d++) {
24134
+ collect(tr.tdList[d].value);
24135
+ }
24136
+ }
24137
+ continue;
24138
+ }
24139
+ result.push(element);
24140
+ }
24141
+ };
24142
+ collect(selection);
24143
+ if (!textLikeOnly) {
24144
+ return result;
24145
+ }
24146
+ return result.filter(
24147
+ (element) => isTextLikeElement(element) || element.type === "label" /* LABEL */
24148
+ );
24149
+ }
23522
24150
  mode(payload) {
23523
24151
  this.draw.setMode(payload);
23524
24152
  }
@@ -23664,7 +24292,7 @@ var CommandAdapt = class {
23664
24292
  const { isIgnoreDisabledRule = false } = options || {};
23665
24293
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23666
24294
  if (isDisabled) return;
23667
- const selection = this.range.getSelectionElementList();
24295
+ const selection = this.getStyleSelectionElementList();
23668
24296
  let renderOption = {};
23669
24297
  let changeElementList = [];
23670
24298
  if (selection?.length) {
@@ -23691,7 +24319,7 @@ var CommandAdapt = class {
23691
24319
  const { isIgnoreDisabledRule = false } = options || {};
23692
24320
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23693
24321
  if (isDisabled) return;
23694
- const selection = this.range.getSelectionElementList();
24322
+ const selection = this.getStyleSelectionElementList();
23695
24323
  if (selection?.length) {
23696
24324
  selection.forEach((el) => {
23697
24325
  el.font = payload;
@@ -23725,7 +24353,9 @@ var CommandAdapt = class {
23725
24353
  if (payload < minSize || payload > maxSize) return;
23726
24354
  let renderOption = {};
23727
24355
  let changeElementList = [];
23728
- const selection = this.range.getTextLikeSelectionElementList();
24356
+ const selection = this.getStyleSelectionElementList({
24357
+ textLikeOnly: true
24358
+ });
23729
24359
  if (selection?.length) {
23730
24360
  changeElementList = selection;
23731
24361
  renderOption = { isSetCursor: false };
@@ -23765,7 +24395,9 @@ var CommandAdapt = class {
23765
24395
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23766
24396
  if (isDisabled) return;
23767
24397
  const { defaultSize, maxSize } = this.options;
23768
- const selection = this.range.getTextLikeSelectionElementList();
24398
+ const selection = this.getStyleSelectionElementList({
24399
+ textLikeOnly: true
24400
+ });
23769
24401
  let renderOption = {};
23770
24402
  let changeElementList = [];
23771
24403
  if (selection?.length) {
@@ -23814,7 +24446,9 @@ var CommandAdapt = class {
23814
24446
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23815
24447
  if (isDisabled) return;
23816
24448
  const { defaultSize, minSize } = this.options;
23817
- const selection = this.range.getTextLikeSelectionElementList();
24449
+ const selection = this.getStyleSelectionElementList({
24450
+ textLikeOnly: true
24451
+ });
23818
24452
  let renderOption = {};
23819
24453
  let changeElementList = [];
23820
24454
  if (selection?.length) {
@@ -23862,7 +24496,7 @@ var CommandAdapt = class {
23862
24496
  const { isIgnoreDisabledRule = false } = options || {};
23863
24497
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23864
24498
  if (isDisabled) return;
23865
- const selection = this.range.getSelectionElementList();
24499
+ const selection = this.getStyleSelectionElementList();
23866
24500
  if (selection?.length) {
23867
24501
  const noBoldIndex = selection.findIndex((s) => !s.bold);
23868
24502
  selection.forEach((el) => {
@@ -23894,7 +24528,7 @@ var CommandAdapt = class {
23894
24528
  const { isIgnoreDisabledRule = false } = options || {};
23895
24529
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23896
24530
  if (isDisabled) return;
23897
- const selection = this.range.getSelectionElementList();
24531
+ const selection = this.getStyleSelectionElementList();
23898
24532
  if (selection?.length) {
23899
24533
  const noItalicIndex = selection.findIndex((s) => !s.italic);
23900
24534
  selection.forEach((el) => {
@@ -23926,7 +24560,7 @@ var CommandAdapt = class {
23926
24560
  const { isIgnoreDisabledRule = false } = options || {};
23927
24561
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23928
24562
  if (isDisabled) return;
23929
- const selection = this.range.getSelectionElementList();
24563
+ const selection = this.getStyleSelectionElementList();
23930
24564
  if (selection?.length) {
23931
24565
  const isSetUnderline = selection.some(
23932
24566
  (s) => !s.underline || !textDecoration && s.textDecoration || textDecoration && !s.textDecoration || textDecoration && s.textDecoration && !isObjectEqual(s.textDecoration, textDecoration)
@@ -23968,7 +24602,7 @@ var CommandAdapt = class {
23968
24602
  const { isIgnoreDisabledRule = false } = options || {};
23969
24603
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
23970
24604
  if (isDisabled) return;
23971
- const selection = this.range.getSelectionElementList();
24605
+ const selection = this.getStyleSelectionElementList();
23972
24606
  if (selection?.length) {
23973
24607
  const noStrikeoutIndex = selection.findIndex((s) => !s.strikeout);
23974
24608
  selection.forEach((el) => {
@@ -24003,7 +24637,7 @@ var CommandAdapt = class {
24003
24637
  const { isIgnoreDisabledRule = false } = options || {};
24004
24638
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
24005
24639
  if (isDisabled) return;
24006
- const selection = this.range.getSelectionElementList();
24640
+ const selection = this.getStyleSelectionElementList();
24007
24641
  if (!selection) return;
24008
24642
  const superscriptIndex = selection.findIndex(
24009
24643
  (s) => s.type === "superscript" /* SUPERSCRIPT */
@@ -24026,7 +24660,7 @@ var CommandAdapt = class {
24026
24660
  const { isIgnoreDisabledRule = false } = options || {};
24027
24661
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
24028
24662
  if (isDisabled) return;
24029
- const selection = this.range.getSelectionElementList();
24663
+ const selection = this.getStyleSelectionElementList();
24030
24664
  if (!selection) return;
24031
24665
  const subscriptIndex = selection.findIndex(
24032
24666
  (s) => s.type === "subscript" /* SUBSCRIPT */
@@ -24049,7 +24683,7 @@ var CommandAdapt = class {
24049
24683
  const { isIgnoreDisabledRule = false } = options || {};
24050
24684
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
24051
24685
  if (isDisabled) return;
24052
- const selection = this.range.getSelectionElementList();
24686
+ const selection = this.getStyleSelectionElementList();
24053
24687
  if (selection?.length) {
24054
24688
  selection.forEach((el) => {
24055
24689
  if (payload) {
@@ -24090,7 +24724,7 @@ var CommandAdapt = class {
24090
24724
  const { isIgnoreDisabledRule = false } = options || {};
24091
24725
  const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
24092
24726
  if (isDisabled) return;
24093
- const selection = this.range.getSelectionElementList();
24727
+ const selection = this.getStyleSelectionElementList();
24094
24728
  if (selection?.length) {
24095
24729
  selection.forEach((el) => {
24096
24730
  if (payload) {
@@ -24721,25 +25355,39 @@ var CommandAdapt = class {
24721
25355
  const endElement = pickElementAttr(elementList[endIndex], {
24722
25356
  extraPickAttrs: ["id", "controlComponent"]
24723
25357
  });
24724
- const rowList = this.draw.getRowList();
24725
25358
  const positionList = this.position.getPositionList();
24726
25359
  const startPosition = positionList[startIndex];
24727
25360
  const endPosition = positionList[endIndex];
25361
+ if (!startPosition || !endPosition) return null;
24728
25362
  const startPageNo = startPosition.pageNo;
24729
25363
  const endPageNo = endPosition.pageNo;
24730
25364
  const startRowNo = startPosition.rowIndex;
24731
25365
  const endRowNo = endPosition.rowIndex;
24732
- const startRow = rowList[startRowNo];
24733
- const endRow = rowList[endRowNo];
25366
+ const getRowStartPositionIndex = (targetIndex) => {
25367
+ let rowStartIndex = targetIndex;
25368
+ const targetPosition = positionList[targetIndex];
25369
+ while (rowStartIndex > 0) {
25370
+ const prePosition = positionList[rowStartIndex - 1];
25371
+ if (!prePosition || prePosition.pageNo !== targetPosition.pageNo || prePosition.rowNo !== targetPosition.rowNo || prePosition.columnNo !== targetPosition.columnNo) {
25372
+ break;
25373
+ }
25374
+ rowStartIndex--;
25375
+ }
25376
+ return rowStartIndex;
25377
+ };
25378
+ const startRowStartIndex = getRowStartPositionIndex(startIndex);
25379
+ const endRowStartIndex = getRowStartPositionIndex(endIndex);
25380
+ const startRowStartsWithZero = elementList[startRowStartIndex]?.value === ZERO;
25381
+ const endRowStartsWithZero = elementList[endRowStartIndex]?.value === ZERO;
24734
25382
  let startColNo = 0;
24735
25383
  let endColNo = 0;
24736
25384
  if (!this.draw.getCursor().getHitLineStartIndex()) {
24737
- startColNo = startRow.elementList[0]?.value === ZERO ? startPosition.index - startRow.startIndex : startPosition.index - startRow.startIndex + 1;
25385
+ startColNo = startRowStartsWithZero ? startIndex - startRowStartIndex : startIndex - startRowStartIndex + 1;
24738
25386
  }
24739
25387
  if (startPosition === endPosition) {
24740
25388
  endColNo = startColNo;
24741
25389
  } else {
24742
- endColNo = endRow.elementList[0]?.value === ZERO ? endPosition.index - endRow.startIndex : endPosition.index - endRow.startIndex + 1;
25390
+ endColNo = endRowStartsWithZero ? endIndex - endRowStartIndex : endIndex - endRowStartIndex + 1;
24743
25391
  }
24744
25392
  const rangeRects = [];
24745
25393
  const height = this.draw.getOriginalHeight();
@@ -24747,6 +25395,7 @@ var CommandAdapt = class {
24747
25395
  const selectionPositionList = this.position.getSelectionPositionList();
24748
25396
  if (selectionPositionList) {
24749
25397
  let currentRowNo = null;
25398
+ let currentPageNo = null;
24750
25399
  let currentX = 0;
24751
25400
  let rangeRect = null;
24752
25401
  for (let p = 0; p < selectionPositionList.length; p++) {
@@ -24756,7 +25405,7 @@ var CommandAdapt = class {
24756
25405
  coordinate: { leftTop, rightTop },
24757
25406
  lineHeight
24758
25407
  } = selectionPositionList[p];
24759
- if (currentRowNo === null || currentRowNo !== rowNo) {
25408
+ if (currentRowNo === null || currentPageNo === null || currentRowNo !== rowNo || currentPageNo !== pageNo) {
24760
25409
  if (rangeRect) {
24761
25410
  rangeRects.push(rangeRect);
24762
25411
  }
@@ -24767,6 +25416,7 @@ var CommandAdapt = class {
24767
25416
  height: lineHeight
24768
25417
  };
24769
25418
  currentRowNo = rowNo;
25419
+ currentPageNo = pageNo;
24770
25420
  currentX = leftTop[0];
24771
25421
  } else {
24772
25422
  rangeRect.width = rightTop[0] - currentX;