@windoc/core 0.3.20 → 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.d.mts +71 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +1328 -189
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1328 -189
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var version = "0.3.
|
|
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(...
|
|
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,
|
|
@@ -7324,6 +7436,71 @@ function mousemove(evt, host) {
|
|
|
7324
7436
|
});
|
|
7325
7437
|
}
|
|
7326
7438
|
|
|
7439
|
+
// src/core/event/handlers/keydown/tableSplit.ts
|
|
7440
|
+
function moveEmptySplitTdCursorToParent(host) {
|
|
7441
|
+
const draw = host.getDraw();
|
|
7442
|
+
const position = draw.getPosition();
|
|
7443
|
+
const positionContext = position.getPositionContext();
|
|
7444
|
+
const cursorPosition = position.getCursorPosition();
|
|
7445
|
+
if (!positionContext.isTable || !cursorPosition || cursorPosition.index !== 0) {
|
|
7446
|
+
return null;
|
|
7447
|
+
}
|
|
7448
|
+
const elementList = draw.getOriginalElementList();
|
|
7449
|
+
const resolved = draw.resolveTableCellContext(elementList, positionContext);
|
|
7450
|
+
if (!resolved) return null;
|
|
7451
|
+
const currentTr = resolved.element.trList?.[resolved.trIndex];
|
|
7452
|
+
const currentTd = resolved.td;
|
|
7453
|
+
if (!currentTr?.splitParentId || currentTd.value.length !== 1 || currentTd.value[0]?.value !== ZERO) {
|
|
7454
|
+
return null;
|
|
7455
|
+
}
|
|
7456
|
+
const pagingId = resolved.element.pagingId;
|
|
7457
|
+
if (!pagingId) return null;
|
|
7458
|
+
let parentTarget;
|
|
7459
|
+
for (let i = resolved.index; i >= 0; i--) {
|
|
7460
|
+
const tableElement = elementList[i];
|
|
7461
|
+
if (tableElement.type !== "table" /* TABLE */) continue;
|
|
7462
|
+
if (tableElement.pagingId !== pagingId) {
|
|
7463
|
+
if (i < resolved.index) break;
|
|
7464
|
+
continue;
|
|
7465
|
+
}
|
|
7466
|
+
const parentTrIndex = tableElement.trList?.findIndex((tr) => tr.id === currentTr.splitParentId) ?? -1;
|
|
7467
|
+
if (parentTrIndex < 0) continue;
|
|
7468
|
+
const parentTr2 = tableElement.trList[parentTrIndex];
|
|
7469
|
+
const parentTdIndex = parentTr2.tdList.findIndex(
|
|
7470
|
+
(td) => td.colIndex === currentTd.colIndex
|
|
7471
|
+
);
|
|
7472
|
+
if (parentTdIndex < 0) return null;
|
|
7473
|
+
parentTarget = {
|
|
7474
|
+
tableId: tableElement.id,
|
|
7475
|
+
tableIndex: i,
|
|
7476
|
+
trIndex: parentTrIndex,
|
|
7477
|
+
tdIndex: parentTdIndex
|
|
7478
|
+
};
|
|
7479
|
+
break;
|
|
7480
|
+
}
|
|
7481
|
+
if (!parentTarget) return null;
|
|
7482
|
+
const parentElement = elementList[parentTarget.tableIndex];
|
|
7483
|
+
const parentTr = parentElement.trList[parentTarget.trIndex];
|
|
7484
|
+
const parentTd = parentTr.tdList[parentTarget.tdIndex];
|
|
7485
|
+
if (!currentTd.splitSyntheticLeadingZero) {
|
|
7486
|
+
currentTd.value.splice(0, 1);
|
|
7487
|
+
currentTd.rowList = void 0;
|
|
7488
|
+
currentTd.positionList = void 0;
|
|
7489
|
+
}
|
|
7490
|
+
const curIndex = Math.max(parentTd.value.length - 1, 0);
|
|
7491
|
+
position.setPositionContext({
|
|
7492
|
+
isTable: true,
|
|
7493
|
+
index: parentTarget.tableIndex,
|
|
7494
|
+
trIndex: parentTarget.trIndex,
|
|
7495
|
+
tdIndex: parentTarget.tdIndex,
|
|
7496
|
+
tdId: parentTd.id,
|
|
7497
|
+
trId: parentTr.id,
|
|
7498
|
+
tableId: parentTarget.tableId
|
|
7499
|
+
});
|
|
7500
|
+
draw.getRange().setRange(curIndex, curIndex);
|
|
7501
|
+
return curIndex;
|
|
7502
|
+
}
|
|
7503
|
+
|
|
7327
7504
|
// src/core/event/handlers/keydown/backspace.ts
|
|
7328
7505
|
function backspaceHideElement(host) {
|
|
7329
7506
|
const draw = host.getDraw();
|
|
@@ -7365,13 +7542,27 @@ function backspace(evt, host) {
|
|
|
7365
7542
|
if (draw.isReadonly()) return;
|
|
7366
7543
|
const rangeManager = draw.getRange();
|
|
7367
7544
|
if (!rangeManager.getIsCanInput()) return;
|
|
7545
|
+
if (rangeManager.getIsCollapsed()) {
|
|
7546
|
+
const splitParentIndex = moveEmptySplitTdCursorToParent(host);
|
|
7547
|
+
if (splitParentIndex !== null) {
|
|
7548
|
+
draw.getGlobalEvent().setCanvasEventAbility();
|
|
7549
|
+
draw.render({
|
|
7550
|
+
curIndex: splitParentIndex,
|
|
7551
|
+
isSubmitHistory: false
|
|
7552
|
+
});
|
|
7553
|
+
evt.preventDefault();
|
|
7554
|
+
return;
|
|
7555
|
+
}
|
|
7556
|
+
}
|
|
7368
7557
|
if (rangeManager.getIsCollapsed()) {
|
|
7369
7558
|
backspaceHideElement(host);
|
|
7370
7559
|
}
|
|
7371
7560
|
const control = draw.getControl();
|
|
7372
7561
|
const { startIndex, endIndex, isCrossRowCol } = rangeManager.getRange();
|
|
7373
7562
|
let curIndex;
|
|
7374
|
-
if (
|
|
7563
|
+
if (rangeManager.getSplitCellSelection() && startIndex !== endIndex) {
|
|
7564
|
+
curIndex = draw.replaceSplitCellSelection([]);
|
|
7565
|
+
} else if (isCrossRowCol) {
|
|
7375
7566
|
const rowCol = draw.getTableParticle().getRangeRowCol();
|
|
7376
7567
|
if (!rowCol) return;
|
|
7377
7568
|
let isDeleted = false;
|
|
@@ -7510,6 +7701,18 @@ function del(evt, host) {
|
|
|
7510
7701
|
if (draw.isReadonly()) return;
|
|
7511
7702
|
const rangeManager = draw.getRange();
|
|
7512
7703
|
if (!rangeManager.getIsCanInput()) return;
|
|
7704
|
+
if (rangeManager.getIsCollapsed()) {
|
|
7705
|
+
const splitParentIndex = moveEmptySplitTdCursorToParent(host);
|
|
7706
|
+
if (splitParentIndex !== null) {
|
|
7707
|
+
draw.getGlobalEvent().setCanvasEventAbility();
|
|
7708
|
+
draw.render({
|
|
7709
|
+
curIndex: splitParentIndex,
|
|
7710
|
+
isSubmitHistory: false
|
|
7711
|
+
});
|
|
7712
|
+
evt.preventDefault();
|
|
7713
|
+
return;
|
|
7714
|
+
}
|
|
7715
|
+
}
|
|
7513
7716
|
const { startIndex, endIndex, isCrossRowCol } = rangeManager.getRange();
|
|
7514
7717
|
const elementList = draw.getElementList();
|
|
7515
7718
|
const control = draw.getControl();
|
|
@@ -7517,7 +7720,9 @@ function del(evt, host) {
|
|
|
7517
7720
|
deleteHideElement(host);
|
|
7518
7721
|
}
|
|
7519
7722
|
let curIndex;
|
|
7520
|
-
if (
|
|
7723
|
+
if (rangeManager.getSplitCellSelection() && startIndex !== endIndex) {
|
|
7724
|
+
curIndex = draw.replaceSplitCellSelection([]);
|
|
7725
|
+
} else if (isCrossRowCol) {
|
|
7521
7726
|
const rowCol = draw.getTableParticle().getRangeRowCol();
|
|
7522
7727
|
if (!rowCol) return;
|
|
7523
7728
|
let isDeleted = false;
|
|
@@ -8429,6 +8634,8 @@ function input(data2, host) {
|
|
|
8429
8634
|
if (!isComposing) {
|
|
8430
8635
|
control.emitControlContentChange();
|
|
8431
8636
|
}
|
|
8637
|
+
} else if (rangeManager.getSplitCellSelection()) {
|
|
8638
|
+
curIndex = draw.replaceSplitCellSelection(inputData);
|
|
8432
8639
|
} else {
|
|
8433
8640
|
const start = startIndex + 1;
|
|
8434
8641
|
if (startIndex !== endIndex) {
|
|
@@ -8928,7 +9135,7 @@ var CanvasEvent = class {
|
|
|
8928
9135
|
}
|
|
8929
9136
|
selectAll() {
|
|
8930
9137
|
if (this.position.getPositionContext().isTable) {
|
|
8931
|
-
this.draw.getTableOperate().
|
|
9138
|
+
this.draw.getTableOperate().tableTdSelectAll();
|
|
8932
9139
|
} else {
|
|
8933
9140
|
const positionList = this.position.getPositionList();
|
|
8934
9141
|
this.range.setRange(0, positionList.length - 1);
|
|
@@ -9205,8 +9412,11 @@ var Position = class {
|
|
|
9205
9412
|
return this.floatPositionList;
|
|
9206
9413
|
}
|
|
9207
9414
|
getTablePositionList(sourceElementList) {
|
|
9208
|
-
const
|
|
9209
|
-
|
|
9415
|
+
const splitCellSelectionContext = this.draw.getSplitCellSelectionContext(sourceElementList);
|
|
9416
|
+
if (splitCellSelectionContext) {
|
|
9417
|
+
return splitCellSelectionContext.positionList;
|
|
9418
|
+
}
|
|
9419
|
+
return this.draw.resolveTableCellContext(sourceElementList, this.positionContext)?.td.positionList || [];
|
|
9210
9420
|
}
|
|
9211
9421
|
getPositionList() {
|
|
9212
9422
|
return this.positionContext.isTable ? this.getTablePositionList(this.draw.getOriginalElementList()) : this.getOriginalPositionList();
|
|
@@ -9860,6 +10070,46 @@ var Position = class {
|
|
|
9860
10070
|
positionResult.index = newIndex;
|
|
9861
10071
|
}
|
|
9862
10072
|
}
|
|
10073
|
+
if (positionResult.isTable && positionResult.trId != null) {
|
|
10074
|
+
const elementList = this.draw.getOriginalMainElementList();
|
|
10075
|
+
const tableElement = elementList[positionResult.index];
|
|
10076
|
+
if (tableElement?.trList) {
|
|
10077
|
+
const matchedTr = tableElement.trList.find(
|
|
10078
|
+
(r) => r.id === positionResult.trId
|
|
10079
|
+
);
|
|
10080
|
+
if (matchedTr?.splitRootId) {
|
|
10081
|
+
const matchedTd = matchedTr.tdList[positionResult.tdIndex];
|
|
10082
|
+
if (matchedTd && matchedTd.splitSyntheticLeadingZero && matchedTd.value.length === 1 && matchedTd.value[0].value === ZERO) {
|
|
10083
|
+
const pagingId = tableElement.pagingId;
|
|
10084
|
+
if (pagingId) {
|
|
10085
|
+
for (let i = positionResult.index - 1; i >= 0; i--) {
|
|
10086
|
+
const prevElement = elementList[i];
|
|
10087
|
+
if (prevElement.pagingId !== pagingId) break;
|
|
10088
|
+
const rootTr = prevElement.trList?.find(
|
|
10089
|
+
(r) => r.id === matchedTr.splitRootId
|
|
10090
|
+
);
|
|
10091
|
+
if (rootTr) {
|
|
10092
|
+
const rootTd = rootTr.tdList.find(
|
|
10093
|
+
(t) => t.colIndex === matchedTd.colIndex
|
|
10094
|
+
);
|
|
10095
|
+
const isRootTdEmpty = !!rootTd && rootTd.value.length === 1 && rootTd.value[0].value === ZERO;
|
|
10096
|
+
if (rootTd && isRootTdEmpty) {
|
|
10097
|
+
positionResult.index = i;
|
|
10098
|
+
positionResult.trIndex = prevElement.trList.indexOf(rootTr);
|
|
10099
|
+
positionResult.tdIndex = rootTr.tdList.indexOf(rootTd);
|
|
10100
|
+
positionResult.trId = rootTr.id;
|
|
10101
|
+
positionResult.tdId = rootTd.id;
|
|
10102
|
+
positionResult.tableId = prevElement.id;
|
|
10103
|
+
positionResult.tdValueIndex = 0;
|
|
10104
|
+
}
|
|
10105
|
+
break;
|
|
10106
|
+
}
|
|
10107
|
+
}
|
|
10108
|
+
}
|
|
10109
|
+
}
|
|
10110
|
+
}
|
|
10111
|
+
}
|
|
10112
|
+
}
|
|
9863
10113
|
const {
|
|
9864
10114
|
index,
|
|
9865
10115
|
isCheckbox,
|
|
@@ -9956,6 +10206,18 @@ var RangeManager = class {
|
|
|
9956
10206
|
clearRange() {
|
|
9957
10207
|
this.setRange(-1, -1);
|
|
9958
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
|
+
}
|
|
9959
10221
|
setDefaultStyle(style) {
|
|
9960
10222
|
if (!style) {
|
|
9961
10223
|
this.defaultStyle = null;
|
|
@@ -10246,6 +10508,8 @@ var RangeManager = class {
|
|
|
10246
10508
|
this.range.isCrossRowCol = !!(startTdIndex || endTdIndex || startTrIndex || endTrIndex);
|
|
10247
10509
|
this.setDefaultStyle(null);
|
|
10248
10510
|
}
|
|
10511
|
+
this.range.splitCellSelection = void 0;
|
|
10512
|
+
this.range.tableCellSelection = void 0;
|
|
10249
10513
|
this.range.zone = this.draw.getZone().getZone();
|
|
10250
10514
|
const control = this.draw.getControl();
|
|
10251
10515
|
if (~startIndex && ~endIndex) {
|
|
@@ -11576,13 +11840,18 @@ var TableParticle = class {
|
|
|
11576
11840
|
ctx.beginPath();
|
|
11577
11841
|
const x = Math.round(startX);
|
|
11578
11842
|
const y = Math.round(startY);
|
|
11843
|
+
const rx = Math.round(startX + width);
|
|
11844
|
+
const ry = Math.round(startY + height);
|
|
11579
11845
|
ctx.translate(0.5, 0.5);
|
|
11580
11846
|
if (isDrawFullBorder) {
|
|
11581
|
-
ctx.rect(x, y,
|
|
11847
|
+
ctx.rect(x, y, rx - x, ry - y);
|
|
11848
|
+
} else if (borderExternalWidth) {
|
|
11849
|
+
ctx.moveTo(x, ry);
|
|
11850
|
+
ctx.lineTo(x, y);
|
|
11851
|
+
ctx.lineTo(rx, y);
|
|
11582
11852
|
} else {
|
|
11583
|
-
ctx.moveTo(x,
|
|
11853
|
+
ctx.moveTo(x, ry);
|
|
11584
11854
|
ctx.lineTo(x, y);
|
|
11585
|
-
ctx.lineTo(x + width, y);
|
|
11586
11855
|
}
|
|
11587
11856
|
ctx.stroke();
|
|
11588
11857
|
if (borderExternalWidth) {
|
|
@@ -11590,20 +11859,32 @@ var TableParticle = class {
|
|
|
11590
11859
|
}
|
|
11591
11860
|
ctx.translate(-0.5, -0.5);
|
|
11592
11861
|
}
|
|
11862
|
+
_drawHorizontalBorder(payload) {
|
|
11863
|
+
const { ctx, startX, endX, y } = payload;
|
|
11864
|
+
const x = Math.round(startX);
|
|
11865
|
+
const rx = Math.round(endX);
|
|
11866
|
+
const ty = Math.round(y);
|
|
11867
|
+
ctx.beginPath();
|
|
11868
|
+
ctx.translate(0.5, 0.5);
|
|
11869
|
+
ctx.moveTo(x, ty);
|
|
11870
|
+
ctx.lineTo(rx, ty);
|
|
11871
|
+
ctx.stroke();
|
|
11872
|
+
ctx.translate(-0.5, -0.5);
|
|
11873
|
+
}
|
|
11593
11874
|
_drawSlash(ctx, td, startX, startY) {
|
|
11594
11875
|
const { scale } = this.options;
|
|
11595
11876
|
ctx.save();
|
|
11596
|
-
const
|
|
11597
|
-
const
|
|
11598
|
-
const
|
|
11599
|
-
const
|
|
11877
|
+
const lx = Math.round(td.x * scale + startX);
|
|
11878
|
+
const ty = Math.round(td.y * scale + startY);
|
|
11879
|
+
const rx = Math.round((td.x + td.width) * scale + startX);
|
|
11880
|
+
const by = Math.round((td.y + td.height) * scale + startY);
|
|
11600
11881
|
if (td.slashTypes?.includes("forward" /* FORWARD */)) {
|
|
11601
|
-
ctx.moveTo(
|
|
11602
|
-
ctx.lineTo(
|
|
11882
|
+
ctx.moveTo(rx, ty);
|
|
11883
|
+
ctx.lineTo(lx, by);
|
|
11603
11884
|
}
|
|
11604
11885
|
if (td.slashTypes?.includes("back" /* BACK */)) {
|
|
11605
|
-
ctx.moveTo(
|
|
11606
|
-
ctx.lineTo(
|
|
11886
|
+
ctx.moveTo(lx, ty);
|
|
11887
|
+
ctx.lineTo(rx, by);
|
|
11607
11888
|
}
|
|
11608
11889
|
ctx.stroke();
|
|
11609
11890
|
ctx.restore();
|
|
@@ -11644,6 +11925,8 @@ var TableParticle = class {
|
|
|
11644
11925
|
isDrawFullBorder: isExternalBorderType
|
|
11645
11926
|
});
|
|
11646
11927
|
}
|
|
11928
|
+
const firstTr = trList[0];
|
|
11929
|
+
const lastTr = trList[trList.length - 1];
|
|
11647
11930
|
for (let t = 0; t < trList.length; t++) {
|
|
11648
11931
|
const tr = trList[t];
|
|
11649
11932
|
for (let d = 0; d < tr.tdList.length; d++) {
|
|
@@ -11654,10 +11937,10 @@ var TableParticle = class {
|
|
|
11654
11937
|
if (!td.borderTypes?.length && (isEmptyBorderType || isExternalBorderType)) {
|
|
11655
11938
|
continue;
|
|
11656
11939
|
}
|
|
11657
|
-
const
|
|
11658
|
-
const
|
|
11659
|
-
const
|
|
11660
|
-
const
|
|
11940
|
+
const lx = Math.round(td.x * scale + startX);
|
|
11941
|
+
const ty = Math.round(td.y * scale + startY);
|
|
11942
|
+
const rx = Math.round((td.x + td.width) * scale + startX);
|
|
11943
|
+
const by = Math.round((td.y + td.height) * scale + startY);
|
|
11661
11944
|
if (td.borderColor) {
|
|
11662
11945
|
ctx.save();
|
|
11663
11946
|
ctx.strokeStyle = td.borderColor;
|
|
@@ -11665,29 +11948,33 @@ var TableParticle = class {
|
|
|
11665
11948
|
ctx.translate(0.5, 0.5);
|
|
11666
11949
|
ctx.beginPath();
|
|
11667
11950
|
if (td.borderTypes?.includes("top" /* TOP */)) {
|
|
11668
|
-
ctx.moveTo(
|
|
11669
|
-
ctx.lineTo(
|
|
11951
|
+
ctx.moveTo(lx, ty);
|
|
11952
|
+
ctx.lineTo(rx, ty);
|
|
11670
11953
|
ctx.stroke();
|
|
11671
11954
|
}
|
|
11672
11955
|
if (td.borderTypes?.includes("right" /* RIGHT */)) {
|
|
11673
|
-
ctx.moveTo(
|
|
11674
|
-
ctx.lineTo(
|
|
11956
|
+
ctx.moveTo(rx, ty);
|
|
11957
|
+
ctx.lineTo(rx, by);
|
|
11675
11958
|
ctx.stroke();
|
|
11676
11959
|
}
|
|
11677
11960
|
if (td.borderTypes?.includes("bottom" /* BOTTOM */)) {
|
|
11678
|
-
ctx.moveTo(
|
|
11679
|
-
ctx.lineTo(
|
|
11961
|
+
ctx.moveTo(rx, by);
|
|
11962
|
+
ctx.lineTo(lx, by);
|
|
11680
11963
|
ctx.stroke();
|
|
11681
11964
|
}
|
|
11682
11965
|
if (td.borderTypes?.includes("left" /* LEFT */)) {
|
|
11683
|
-
ctx.moveTo(
|
|
11684
|
-
ctx.lineTo(
|
|
11966
|
+
ctx.moveTo(lx, ty);
|
|
11967
|
+
ctx.lineTo(lx, by);
|
|
11685
11968
|
ctx.stroke();
|
|
11686
11969
|
}
|
|
11687
11970
|
if (!isEmptyBorderType && !isExternalBorderType) {
|
|
11971
|
+
if (td.rowIndex === 0 && !borderExternalWidth) {
|
|
11972
|
+
ctx.moveTo(lx, ty);
|
|
11973
|
+
ctx.lineTo(rx, ty);
|
|
11974
|
+
}
|
|
11688
11975
|
if (!isInternalBorderType || td.colIndex + td.colspan < colgroup.length) {
|
|
11689
|
-
ctx.moveTo(
|
|
11690
|
-
ctx.lineTo(
|
|
11976
|
+
ctx.moveTo(rx, ty);
|
|
11977
|
+
ctx.lineTo(rx, by);
|
|
11691
11978
|
if (borderExternalWidth && borderExternalWidth !== borderWidth && td.colIndex + td.colspan === colgroup.length) {
|
|
11692
11979
|
const lineWidth = ctx.lineWidth;
|
|
11693
11980
|
ctx.lineWidth = borderExternalWidth * scale;
|
|
@@ -11697,13 +11984,14 @@ var TableParticle = class {
|
|
|
11697
11984
|
}
|
|
11698
11985
|
}
|
|
11699
11986
|
if (!isInternalBorderType || td.rowIndex + td.rowspan < trList.length) {
|
|
11700
|
-
const
|
|
11987
|
+
const isBottomEdge = td.rowIndex + td.rowspan === trList.length;
|
|
11988
|
+
const isSetExternalBottomBorder = borderExternalWidth && borderExternalWidth !== borderWidth && isBottomEdge;
|
|
11701
11989
|
if (isSetExternalBottomBorder) {
|
|
11702
11990
|
ctx.stroke();
|
|
11703
11991
|
ctx.beginPath();
|
|
11704
11992
|
}
|
|
11705
|
-
ctx.moveTo(
|
|
11706
|
-
ctx.lineTo(
|
|
11993
|
+
ctx.moveTo(rx, by);
|
|
11994
|
+
ctx.lineTo(lx, by);
|
|
11707
11995
|
if (isSetExternalBottomBorder) {
|
|
11708
11996
|
const lineWidth = ctx.lineWidth;
|
|
11709
11997
|
ctx.lineWidth = borderExternalWidth * scale;
|
|
@@ -11719,12 +12007,12 @@ var TableParticle = class {
|
|
|
11719
12007
|
ctx.translate(0.5, 0.5);
|
|
11720
12008
|
ctx.beginPath();
|
|
11721
12009
|
if (td.rowIndex === 0) {
|
|
11722
|
-
ctx.moveTo(
|
|
11723
|
-
ctx.lineTo(
|
|
12010
|
+
ctx.moveTo(lx, ty);
|
|
12011
|
+
ctx.lineTo(rx, ty);
|
|
11724
12012
|
}
|
|
11725
12013
|
if (td.colIndex === 0) {
|
|
11726
|
-
ctx.moveTo(
|
|
11727
|
-
ctx.lineTo(
|
|
12014
|
+
ctx.moveTo(lx, ty);
|
|
12015
|
+
ctx.lineTo(lx, by);
|
|
11728
12016
|
}
|
|
11729
12017
|
if (td.rowIndex === 0 || td.colIndex === 0) {
|
|
11730
12018
|
ctx.stroke();
|
|
@@ -11736,6 +12024,22 @@ var TableParticle = class {
|
|
|
11736
12024
|
}
|
|
11737
12025
|
}
|
|
11738
12026
|
}
|
|
12027
|
+
if (!isEmptyBorderType && !isExternalBorderType && !borderExternalWidth && firstTr?.splitBoundaryTop) {
|
|
12028
|
+
this._drawHorizontalBorder({
|
|
12029
|
+
ctx,
|
|
12030
|
+
startX,
|
|
12031
|
+
endX: startX + tableWidth,
|
|
12032
|
+
y: startY
|
|
12033
|
+
});
|
|
12034
|
+
}
|
|
12035
|
+
if (!isEmptyBorderType && !isExternalBorderType && !borderExternalWidth && lastTr?.splitBoundaryBottom) {
|
|
12036
|
+
this._drawHorizontalBorder({
|
|
12037
|
+
ctx,
|
|
12038
|
+
startX,
|
|
12039
|
+
endX: startX + tableWidth,
|
|
12040
|
+
y: startY + tableHeight
|
|
12041
|
+
});
|
|
12042
|
+
}
|
|
11739
12043
|
ctx.restore();
|
|
11740
12044
|
}
|
|
11741
12045
|
_drawBackgroundColor(ctx, element, startX, startY) {
|
|
@@ -11748,12 +12052,12 @@ var TableParticle = class {
|
|
|
11748
12052
|
const td = tr.tdList[d];
|
|
11749
12053
|
if (!td.backgroundColor) continue;
|
|
11750
12054
|
ctx.save();
|
|
11751
|
-
const
|
|
11752
|
-
const
|
|
11753
|
-
const
|
|
11754
|
-
const
|
|
12055
|
+
const lx = Math.round(td.x * scale + startX);
|
|
12056
|
+
const ty = Math.round(td.y * scale + startY);
|
|
12057
|
+
const rx = Math.round((td.x + td.width) * scale + startX);
|
|
12058
|
+
const by = Math.round((td.y + td.height) * scale + startY);
|
|
11755
12059
|
ctx.fillStyle = td.backgroundColor;
|
|
11756
|
-
ctx.fillRect(
|
|
12060
|
+
ctx.fillRect(lx, ty, rx - lx, by - ty);
|
|
11757
12061
|
ctx.restore();
|
|
11758
12062
|
}
|
|
11759
12063
|
}
|
|
@@ -11928,6 +12232,44 @@ var TableParticle = class {
|
|
|
11928
12232
|
}
|
|
11929
12233
|
ctx.restore();
|
|
11930
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
|
+
}
|
|
11931
12273
|
render(ctx, element, startX, startY) {
|
|
11932
12274
|
this._drawBackgroundColor(ctx, element, startX, startY);
|
|
11933
12275
|
this._drawBorder(ctx, element, startX, startY);
|
|
@@ -15163,7 +15505,12 @@ var Control = class {
|
|
|
15163
15505
|
let element;
|
|
15164
15506
|
const newIndex = position.isTable ? tdValueIndex : index;
|
|
15165
15507
|
if (position.isTable) {
|
|
15166
|
-
elementList =
|
|
15508
|
+
elementList = this.draw.resolveTableCellContext(elementList, {
|
|
15509
|
+
isTable: true,
|
|
15510
|
+
index,
|
|
15511
|
+
trIndex,
|
|
15512
|
+
tdIndex
|
|
15513
|
+
})?.td.value || [];
|
|
15167
15514
|
element = elementList[tdValueIndex];
|
|
15168
15515
|
} else {
|
|
15169
15516
|
element = elementList[index];
|
|
@@ -16427,17 +16774,14 @@ function computeValue(data2, options) {
|
|
|
16427
16774
|
const { extraPickAttrs = [] } = options || {};
|
|
16428
16775
|
return {
|
|
16429
16776
|
header: zipElementList(data2.header, {
|
|
16430
|
-
extraPickAttrs
|
|
16431
|
-
isClone: false
|
|
16777
|
+
extraPickAttrs
|
|
16432
16778
|
}),
|
|
16433
16779
|
main: zipElementList(data2.main, {
|
|
16434
16780
|
extraPickAttrs,
|
|
16435
|
-
isClassifyArea: true
|
|
16436
|
-
isClone: false
|
|
16781
|
+
isClassifyArea: true
|
|
16437
16782
|
}),
|
|
16438
16783
|
footer: zipElementList(data2.footer, {
|
|
16439
|
-
extraPickAttrs
|
|
16440
|
-
isClone: false
|
|
16784
|
+
extraPickAttrs
|
|
16441
16785
|
})
|
|
16442
16786
|
};
|
|
16443
16787
|
}
|
|
@@ -18476,6 +18820,38 @@ var ListParticle = class {
|
|
|
18476
18820
|
const level = element.listLevel ?? 0;
|
|
18477
18821
|
return level * INDENT_PER_LEVEL * scale;
|
|
18478
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
|
+
}
|
|
18479
18855
|
computeListStyle(ctx, elementList) {
|
|
18480
18856
|
const listStyleMap = /* @__PURE__ */ new Map();
|
|
18481
18857
|
let start = 0;
|
|
@@ -18506,23 +18882,40 @@ var ListParticle = class {
|
|
|
18506
18882
|
}
|
|
18507
18883
|
getListStyleWidth(ctx, listElementList) {
|
|
18508
18884
|
const { scale, checkbox } = this.options;
|
|
18509
|
-
|
|
18510
|
-
|
|
18511
|
-
|
|
18512
|
-
|
|
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;
|
|
18513
18894
|
}
|
|
18514
|
-
|
|
18515
|
-
|
|
18516
|
-
|
|
18517
|
-
|
|
18518
|
-
|
|
18895
|
+
const markerStyleElement = this._getListMarkerStyleElement(
|
|
18896
|
+
listElementList,
|
|
18897
|
+
i
|
|
18898
|
+
);
|
|
18899
|
+
const text = this._getListMarkerText(element, listIndex);
|
|
18900
|
+
if (!text) {
|
|
18901
|
+
listIndex++;
|
|
18902
|
+
continue;
|
|
18519
18903
|
}
|
|
18520
|
-
|
|
18521
|
-
|
|
18522
|
-
|
|
18523
|
-
|
|
18524
|
-
|
|
18525
|
-
|
|
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;
|
|
18526
18919
|
}
|
|
18527
18920
|
_getOlStyleForLevel(element) {
|
|
18528
18921
|
const preset = element.listPreset || "olDefault" /* DEFAULT */;
|
|
@@ -18543,7 +18936,7 @@ var ListParticle = class {
|
|
|
18543
18936
|
const startElement = elementList[0];
|
|
18544
18937
|
if (startElement.value !== ZERO || startElement.listWrap) return;
|
|
18545
18938
|
let tabWidth = 0;
|
|
18546
|
-
const { defaultTabWidth, scale
|
|
18939
|
+
const { defaultTabWidth, scale } = this.options;
|
|
18547
18940
|
for (let i = 1; i < elementList.length; i++) {
|
|
18548
18941
|
const element = elementList[i];
|
|
18549
18942
|
if (element?.type !== "tab" /* TAB */) break;
|
|
@@ -18581,24 +18974,11 @@ var ListParticle = class {
|
|
|
18581
18974
|
}
|
|
18582
18975
|
});
|
|
18583
18976
|
} else {
|
|
18584
|
-
|
|
18585
|
-
if (startElement.listType === "ul" /* UL */) {
|
|
18586
|
-
if (startElement.listPreset) {
|
|
18587
|
-
text = this._getUlBulletForLevel(startElement);
|
|
18588
|
-
} else {
|
|
18589
|
-
text = ulStyleMapping[startElement.listStyle] || ulStyleMapping["disc" /* DISC */];
|
|
18590
|
-
}
|
|
18591
|
-
} else {
|
|
18592
|
-
if (startElement.listPreset) {
|
|
18593
|
-
const olStyle = this._getOlStyleForLevel(startElement);
|
|
18594
|
-
text = formatOlNumber(listIndex, olStyle);
|
|
18595
|
-
} else {
|
|
18596
|
-
text = `${listIndex + 1}${"." /* PERIOD */}`;
|
|
18597
|
-
}
|
|
18598
|
-
}
|
|
18977
|
+
const text = this._getListMarkerText(startElement, listIndex);
|
|
18599
18978
|
if (!text) return;
|
|
18979
|
+
const markerStyleElement = this._getListMarkerStyleElement(elementList);
|
|
18600
18980
|
ctx.save();
|
|
18601
|
-
ctx.font =
|
|
18981
|
+
ctx.font = this.draw.getElementFont(markerStyleElement, scale);
|
|
18602
18982
|
ctx.fillText(text, x, y);
|
|
18603
18983
|
ctx.restore();
|
|
18604
18984
|
}
|
|
@@ -19048,6 +19428,39 @@ var TableOperate = class {
|
|
|
19048
19428
|
this.tableParticle = draw.getTableParticle();
|
|
19049
19429
|
this.options = draw.getOptions();
|
|
19050
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
|
+
}
|
|
19051
19464
|
insertTable(row, col) {
|
|
19052
19465
|
const { startIndex, endIndex } = this.range.getRange();
|
|
19053
19466
|
if (!~startIndex && !~endIndex) return;
|
|
@@ -19728,7 +20141,7 @@ var TableOperate = class {
|
|
|
19728
20141
|
this.tableTool.render();
|
|
19729
20142
|
}
|
|
19730
20143
|
tableTdVerticalAlign(payload) {
|
|
19731
|
-
const rowCol = this.
|
|
20144
|
+
const rowCol = this.getStyleTargetRowCol();
|
|
19732
20145
|
if (!rowCol) return;
|
|
19733
20146
|
for (let r = 0; r < rowCol.length; r++) {
|
|
19734
20147
|
const row = rowCol[r];
|
|
@@ -19748,13 +20161,17 @@ var TableOperate = class {
|
|
|
19748
20161
|
tableBorderType(payload) {
|
|
19749
20162
|
const positionContext = this.position.getPositionContext();
|
|
19750
20163
|
if (!positionContext.isTable) return;
|
|
19751
|
-
const
|
|
19752
|
-
|
|
19753
|
-
const
|
|
19754
|
-
|
|
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) {
|
|
19755
20170
|
return;
|
|
19756
20171
|
}
|
|
19757
|
-
element
|
|
20172
|
+
tableElements.forEach((element) => {
|
|
20173
|
+
element.borderType = payload;
|
|
20174
|
+
});
|
|
19758
20175
|
const { endIndex } = this.range.getRange();
|
|
19759
20176
|
this.draw.render({
|
|
19760
20177
|
curIndex: endIndex
|
|
@@ -19763,13 +20180,17 @@ var TableOperate = class {
|
|
|
19763
20180
|
tableBorderColor(payload) {
|
|
19764
20181
|
const positionContext = this.position.getPositionContext();
|
|
19765
20182
|
if (!positionContext.isTable) return;
|
|
19766
|
-
const
|
|
19767
|
-
|
|
19768
|
-
const
|
|
19769
|
-
|
|
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) {
|
|
19770
20189
|
return;
|
|
19771
20190
|
}
|
|
19772
|
-
element
|
|
20191
|
+
tableElements.forEach((element) => {
|
|
20192
|
+
element.borderColor = payload;
|
|
20193
|
+
});
|
|
19773
20194
|
const { endIndex } = this.range.getRange();
|
|
19774
20195
|
this.draw.render({
|
|
19775
20196
|
curIndex: endIndex,
|
|
@@ -19777,7 +20198,7 @@ var TableOperate = class {
|
|
|
19777
20198
|
});
|
|
19778
20199
|
}
|
|
19779
20200
|
tableTdBorderType(payload) {
|
|
19780
|
-
const rowCol = this.
|
|
20201
|
+
const rowCol = this.getStyleTargetRowCol();
|
|
19781
20202
|
if (!rowCol) return;
|
|
19782
20203
|
const tdList = rowCol.flat();
|
|
19783
20204
|
const isSetBorderType = tdList.some(
|
|
@@ -19809,7 +20230,7 @@ var TableOperate = class {
|
|
|
19809
20230
|
});
|
|
19810
20231
|
}
|
|
19811
20232
|
tableTdSlashType(payload) {
|
|
19812
|
-
const rowCol = this.
|
|
20233
|
+
const rowCol = this.getStyleTargetRowCol();
|
|
19813
20234
|
if (!rowCol) return;
|
|
19814
20235
|
const tdList = rowCol.flat();
|
|
19815
20236
|
const isSetTdSlashType = tdList.some(
|
|
@@ -19839,7 +20260,7 @@ var TableOperate = class {
|
|
|
19839
20260
|
});
|
|
19840
20261
|
}
|
|
19841
20262
|
tableTdBackgroundColor(payload) {
|
|
19842
|
-
const rowCol = this.
|
|
20263
|
+
const rowCol = this.getStyleTargetRowCol();
|
|
19843
20264
|
if (!rowCol) return;
|
|
19844
20265
|
for (let r = 0; r < rowCol.length; r++) {
|
|
19845
20266
|
const row = rowCol[r];
|
|
@@ -19860,14 +20281,14 @@ var TableOperate = class {
|
|
|
19860
20281
|
const { index } = positionContext;
|
|
19861
20282
|
const originalElementList = this.draw.getOriginalElementList();
|
|
19862
20283
|
const element = originalElementList[index];
|
|
19863
|
-
const rowCol = this.
|
|
20284
|
+
const rowCol = this.getStyleTargetRowCol();
|
|
19864
20285
|
if (!rowCol) return;
|
|
19865
20286
|
const tdList = rowCol.flat();
|
|
19866
20287
|
const totalCells = element.trList.reduce(
|
|
19867
20288
|
(sum, tr) => sum + tr.tdList.length,
|
|
19868
20289
|
0
|
|
19869
20290
|
);
|
|
19870
|
-
const allSelected = tdList.length >= totalCells;
|
|
20291
|
+
const allSelected = !element.pagingId && !this.getSplitCellStyleSelection() && tdList.length >= totalCells;
|
|
19871
20292
|
if (allSelected) {
|
|
19872
20293
|
element.borderColor = payload || void 0;
|
|
19873
20294
|
element.trList.forEach(
|
|
@@ -19887,7 +20308,7 @@ var TableOperate = class {
|
|
|
19887
20308
|
});
|
|
19888
20309
|
}
|
|
19889
20310
|
tableTdPadding(payload) {
|
|
19890
|
-
const rowCol = this.
|
|
20311
|
+
const rowCol = this.getStyleTargetRowCol();
|
|
19891
20312
|
if (!rowCol) return;
|
|
19892
20313
|
const tdList = rowCol.flat();
|
|
19893
20314
|
tdList.forEach((td) => {
|
|
@@ -19922,6 +20343,46 @@ var TableOperate = class {
|
|
|
19922
20343
|
isSubmitHistory: false
|
|
19923
20344
|
});
|
|
19924
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
|
+
}
|
|
19925
20386
|
};
|
|
19926
20387
|
|
|
19927
20388
|
// src/dataset/enum/Area.ts
|
|
@@ -20416,6 +20877,7 @@ var Draw = class {
|
|
|
20416
20877
|
this.intersectionPageNo = 0;
|
|
20417
20878
|
this.lazyRenderIntersectionObserver = null;
|
|
20418
20879
|
this.printModeData = null;
|
|
20880
|
+
this.pendingTableCursorIndex = void 0;
|
|
20419
20881
|
if (this.mode === "print" /* PRINT */) {
|
|
20420
20882
|
this.setPrintData();
|
|
20421
20883
|
}
|
|
@@ -20577,9 +21039,8 @@ var Draw = class {
|
|
|
20577
21039
|
getContextInnerWidth() {
|
|
20578
21040
|
const positionContext = this.position.getPositionContext();
|
|
20579
21041
|
if (positionContext.isTable) {
|
|
20580
|
-
const
|
|
20581
|
-
|
|
20582
|
-
const td = elementList[index].trList[trIndex].tdList[tdIndex];
|
|
21042
|
+
const td = this.resolveTableCellContext(this.getOriginalElementList())?.td;
|
|
21043
|
+
if (!td) return this.getColumnWidth() / this.options.scale;
|
|
20583
21044
|
const tdPadding = this.getTdPadding();
|
|
20584
21045
|
return td.width - tdPadding[1] - tdPadding[3];
|
|
20585
21046
|
}
|
|
@@ -20663,6 +21124,56 @@ var Draw = class {
|
|
|
20663
21124
|
getPage(pageNo = -1) {
|
|
20664
21125
|
return this.pageList[~pageNo ? pageNo : this.pageNo];
|
|
20665
21126
|
}
|
|
21127
|
+
resolveTableCellContext(sourceElementList = this.getOriginalElementList(), context = this.position.getPositionContext()) {
|
|
21128
|
+
if (!context.isTable) return null;
|
|
21129
|
+
const candidateIndexes = [];
|
|
21130
|
+
if (context.index !== void 0 && sourceElementList[context.index]?.type === "table" /* TABLE */) {
|
|
21131
|
+
candidateIndexes.push(context.index);
|
|
21132
|
+
}
|
|
21133
|
+
if (context.tableId) {
|
|
21134
|
+
const tableIndex = sourceElementList.findIndex((el) => el.id === context.tableId);
|
|
21135
|
+
if (~tableIndex && !candidateIndexes.includes(tableIndex)) {
|
|
21136
|
+
candidateIndexes.push(tableIndex);
|
|
21137
|
+
}
|
|
21138
|
+
}
|
|
21139
|
+
for (let i = 0; i < sourceElementList.length; i++) {
|
|
21140
|
+
const element = sourceElementList[i];
|
|
21141
|
+
if (element.type !== "table" /* TABLE */ || candidateIndexes.includes(i)) {
|
|
21142
|
+
continue;
|
|
21143
|
+
}
|
|
21144
|
+
candidateIndexes.push(i);
|
|
21145
|
+
}
|
|
21146
|
+
for (const tableIndex of candidateIndexes) {
|
|
21147
|
+
const element = sourceElementList[tableIndex];
|
|
21148
|
+
const trList = element.trList;
|
|
21149
|
+
if (!trList?.length) continue;
|
|
21150
|
+
let resolvedTrIndex = -1;
|
|
21151
|
+
if (context.trId) {
|
|
21152
|
+
resolvedTrIndex = trList.findIndex((tr) => tr.id === context.trId);
|
|
21153
|
+
}
|
|
21154
|
+
if (resolvedTrIndex < 0 && context.trIndex !== void 0 && trList[context.trIndex]) {
|
|
21155
|
+
resolvedTrIndex = context.trIndex;
|
|
21156
|
+
}
|
|
21157
|
+
if (resolvedTrIndex < 0) continue;
|
|
21158
|
+
const tdList = trList[resolvedTrIndex].tdList;
|
|
21159
|
+
let resolvedTdIndex = -1;
|
|
21160
|
+
if (context.tdId) {
|
|
21161
|
+
resolvedTdIndex = tdList.findIndex((td) => td.id === context.tdId);
|
|
21162
|
+
}
|
|
21163
|
+
if (resolvedTdIndex < 0 && context.tdIndex !== void 0 && tdList[context.tdIndex]) {
|
|
21164
|
+
resolvedTdIndex = context.tdIndex;
|
|
21165
|
+
}
|
|
21166
|
+
if (resolvedTdIndex < 0) continue;
|
|
21167
|
+
return {
|
|
21168
|
+
index: tableIndex,
|
|
21169
|
+
trIndex: resolvedTrIndex,
|
|
21170
|
+
tdIndex: resolvedTdIndex,
|
|
21171
|
+
element,
|
|
21172
|
+
td: tdList[resolvedTdIndex]
|
|
21173
|
+
};
|
|
21174
|
+
}
|
|
21175
|
+
return null;
|
|
21176
|
+
}
|
|
20666
21177
|
getPageList() {
|
|
20667
21178
|
return this.pageList;
|
|
20668
21179
|
}
|
|
@@ -20670,9 +21181,7 @@ var Draw = class {
|
|
|
20670
21181
|
return this.pageList.length;
|
|
20671
21182
|
}
|
|
20672
21183
|
getTableRowList(sourceElementList) {
|
|
20673
|
-
|
|
20674
|
-
const { index, trIndex, tdIndex } = positionContext;
|
|
20675
|
-
return sourceElementList[index].trList[trIndex].tdList[tdIndex].rowList;
|
|
21184
|
+
return this.resolveTableCellContext(sourceElementList)?.td.rowList || [];
|
|
20676
21185
|
}
|
|
20677
21186
|
getOriginalRowList() {
|
|
20678
21187
|
const zoneManager = this.getZone();
|
|
@@ -20731,9 +21240,155 @@ var Draw = class {
|
|
|
20731
21240
|
return this.header.getElementList();
|
|
20732
21241
|
}
|
|
20733
21242
|
getTableElementList(sourceElementList) {
|
|
21243
|
+
const splitCellSelectionContext = this.getSplitCellSelectionContext(
|
|
21244
|
+
sourceElementList
|
|
21245
|
+
);
|
|
21246
|
+
if (splitCellSelectionContext) {
|
|
21247
|
+
return splitCellSelectionContext.value;
|
|
21248
|
+
}
|
|
21249
|
+
return this.resolveTableCellContext(sourceElementList)?.td.value || [];
|
|
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) {
|
|
20734
21305
|
const positionContext = this.position.getPositionContext();
|
|
20735
|
-
const {
|
|
20736
|
-
|
|
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;
|
|
20737
21392
|
}
|
|
20738
21393
|
getElementList() {
|
|
20739
21394
|
const positionContext = this.position.getPositionContext();
|
|
@@ -20761,13 +21416,7 @@ var Draw = class {
|
|
|
20761
21416
|
return this.footer.getElementList();
|
|
20762
21417
|
}
|
|
20763
21418
|
getTd() {
|
|
20764
|
-
|
|
20765
|
-
const { index, trIndex, tdIndex, isTable } = positionContext;
|
|
20766
|
-
if (isTable) {
|
|
20767
|
-
const elementList = this.getOriginalElementList();
|
|
20768
|
-
return elementList[index].trList[trIndex].tdList[tdIndex];
|
|
20769
|
-
}
|
|
20770
|
-
return null;
|
|
21419
|
+
return this.resolveTableCellContext(this.getOriginalElementList())?.td || null;
|
|
20771
21420
|
}
|
|
20772
21421
|
insertElementList(payload, options = {}) {
|
|
20773
21422
|
if (!payload.length || !this.range.getIsCanInput()) return;
|
|
@@ -20778,6 +21427,18 @@ var Draw = class {
|
|
|
20778
21427
|
isHandleFirstElement: false,
|
|
20779
21428
|
editorOptions: this.options
|
|
20780
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
|
+
}
|
|
20781
21442
|
let curIndex = -1;
|
|
20782
21443
|
let activeControl = this.control.getActiveControl();
|
|
20783
21444
|
if (!activeControl && this.control.getIsRangeWithinControl()) {
|
|
@@ -20873,6 +21534,80 @@ var Draw = class {
|
|
|
20873
21534
|
}
|
|
20874
21535
|
}
|
|
20875
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
|
+
}
|
|
20876
21611
|
getCanvasEvent() {
|
|
20877
21612
|
return this.canvasEvent;
|
|
20878
21613
|
}
|
|
@@ -21283,6 +22018,72 @@ var Draw = class {
|
|
|
21283
22018
|
}
|
|
21284
22019
|
return defaultBasicRowMarginHeight * ratio * (el.rowMargin ?? defaultRowMargin) * scale;
|
|
21285
22020
|
}
|
|
22021
|
+
createListStateSeed(initialListState) {
|
|
22022
|
+
const listLevelIndex = /* @__PURE__ */ new Map();
|
|
22023
|
+
if (initialListState?.listLevelIndex) {
|
|
22024
|
+
Object.entries(initialListState.listLevelIndex).forEach(
|
|
22025
|
+
([level, index]) => {
|
|
22026
|
+
listLevelIndex.set(Number(level), index);
|
|
22027
|
+
}
|
|
22028
|
+
);
|
|
22029
|
+
}
|
|
22030
|
+
return {
|
|
22031
|
+
listId: initialListState?.listId,
|
|
22032
|
+
listIndex: initialListState?.listIndex ?? 0,
|
|
22033
|
+
prevListLevel: initialListState?.prevListLevel ?? 0,
|
|
22034
|
+
listLevelIndex
|
|
22035
|
+
};
|
|
22036
|
+
}
|
|
22037
|
+
advanceListState(element, listState) {
|
|
22038
|
+
if (element.listId) {
|
|
22039
|
+
const curLevel = element.listLevel ?? 0;
|
|
22040
|
+
if (element.listId !== listState.listId) {
|
|
22041
|
+
listState.listIndex = 0;
|
|
22042
|
+
listState.listLevelIndex = /* @__PURE__ */ new Map();
|
|
22043
|
+
listState.listLevelIndex.set(curLevel, 0);
|
|
22044
|
+
listState.prevListLevel = curLevel;
|
|
22045
|
+
} else if (element.value === ZERO && !element.listWrap) {
|
|
22046
|
+
if (curLevel !== listState.prevListLevel) {
|
|
22047
|
+
if (curLevel > listState.prevListLevel) {
|
|
22048
|
+
listState.listLevelIndex.set(curLevel, 0);
|
|
22049
|
+
} else {
|
|
22050
|
+
for (const [lvl] of listState.listLevelIndex) {
|
|
22051
|
+
if (lvl > curLevel) {
|
|
22052
|
+
listState.listLevelIndex.delete(lvl);
|
|
22053
|
+
}
|
|
22054
|
+
}
|
|
22055
|
+
listState.listLevelIndex.set(
|
|
22056
|
+
curLevel,
|
|
22057
|
+
(listState.listLevelIndex.get(curLevel) ?? -1) + 1
|
|
22058
|
+
);
|
|
22059
|
+
}
|
|
22060
|
+
} else {
|
|
22061
|
+
listState.listLevelIndex.set(
|
|
22062
|
+
curLevel,
|
|
22063
|
+
(listState.listLevelIndex.get(curLevel) ?? -1) + 1
|
|
22064
|
+
);
|
|
22065
|
+
}
|
|
22066
|
+
listState.listIndex = listState.listLevelIndex.get(curLevel) ?? 0;
|
|
22067
|
+
listState.prevListLevel = curLevel;
|
|
22068
|
+
}
|
|
22069
|
+
}
|
|
22070
|
+
listState.listId = element.listId;
|
|
22071
|
+
}
|
|
22072
|
+
getListStateBeforeIndex(elementList, endExclusive) {
|
|
22073
|
+
const limit = Math.min(endExclusive, elementList.length);
|
|
22074
|
+
if (limit <= 0) return;
|
|
22075
|
+
const listState = this.createListStateSeed();
|
|
22076
|
+
for (let i = 0; i < limit; i++) {
|
|
22077
|
+
this.advanceListState(elementList[i], listState);
|
|
22078
|
+
}
|
|
22079
|
+
if (!listState.listId) return;
|
|
22080
|
+
return {
|
|
22081
|
+
listId: listState.listId,
|
|
22082
|
+
listIndex: listState.listIndex,
|
|
22083
|
+
prevListLevel: listState.prevListLevel,
|
|
22084
|
+
listLevelIndex: Object.fromEntries(listState.listLevelIndex)
|
|
22085
|
+
};
|
|
22086
|
+
}
|
|
21286
22087
|
computeRowList(payload) {
|
|
21287
22088
|
const {
|
|
21288
22089
|
innerWidth,
|
|
@@ -21293,7 +22094,8 @@ var Draw = class {
|
|
|
21293
22094
|
startY = 0,
|
|
21294
22095
|
pageHeight = 0,
|
|
21295
22096
|
mainOuterHeight = 0,
|
|
21296
|
-
surroundElementList = []
|
|
22097
|
+
surroundElementList = [],
|
|
22098
|
+
initialListState
|
|
21297
22099
|
} = payload;
|
|
21298
22100
|
const {
|
|
21299
22101
|
defaultSize,
|
|
@@ -21320,10 +22122,7 @@ var Draw = class {
|
|
|
21320
22122
|
let x = startX;
|
|
21321
22123
|
let y = startY;
|
|
21322
22124
|
let pageNo = 0;
|
|
21323
|
-
|
|
21324
|
-
let listIndex = 0;
|
|
21325
|
-
let listLevelIndex = /* @__PURE__ */ new Map();
|
|
21326
|
-
let prevListLevel = 0;
|
|
22125
|
+
const listState = this.createListStateSeed(initialListState);
|
|
21327
22126
|
let controlRealWidth = 0;
|
|
21328
22127
|
for (let i = 0; i < elementList.length; i++) {
|
|
21329
22128
|
const curRow = rowList[rowList.length - 1];
|
|
@@ -21369,6 +22168,11 @@ var Draw = class {
|
|
|
21369
22168
|
}
|
|
21370
22169
|
metrics.boundingBoxAscent = 0;
|
|
21371
22170
|
} else if (element.type === "table" /* TABLE */) {
|
|
22171
|
+
let activeSplitRange;
|
|
22172
|
+
let mergedSplitFallback;
|
|
22173
|
+
const logicalSplitCursor = this.getCollapsedSplitTableCursorContext(
|
|
22174
|
+
element
|
|
22175
|
+
);
|
|
21372
22176
|
if (element.pagingId) {
|
|
21373
22177
|
let tableIndex = i + 1;
|
|
21374
22178
|
let combineCount = 0;
|
|
@@ -21389,11 +22193,66 @@ var Draw = class {
|
|
|
21389
22193
|
if (combineCount) {
|
|
21390
22194
|
elementList.splice(i + 1, combineCount);
|
|
21391
22195
|
}
|
|
22196
|
+
const mergedTrList = element.trList;
|
|
22197
|
+
for (let t = mergedTrList.length - 1; t >= 0; t--) {
|
|
22198
|
+
const splitTr = mergedTrList[t];
|
|
22199
|
+
if (!splitTr.splitParentId) continue;
|
|
22200
|
+
const parentTrIdx = mergedTrList.findIndex(
|
|
22201
|
+
(r) => r.id === splitTr.splitParentId
|
|
22202
|
+
);
|
|
22203
|
+
if (!~parentTrIdx) continue;
|
|
22204
|
+
const parentTr = mergedTrList[parentTrIdx];
|
|
22205
|
+
const posCtx = this.position.getPositionContext();
|
|
22206
|
+
const { startIndex, endIndex } = this.range.getRange();
|
|
22207
|
+
if (posCtx.isTable && posCtx.trId === splitTr.id && startIndex === endIndex && posCtx.tdIndex !== void 0) {
|
|
22208
|
+
const splitTd = splitTr.tdList[posCtx.tdIndex];
|
|
22209
|
+
const parentTd = parentTr.tdList[posCtx.tdIndex];
|
|
22210
|
+
if (splitTd && parentTd) {
|
|
22211
|
+
const hasSyntheticLeadingZero = !!splitTd.splitSyntheticLeadingZero && splitTd.value[0]?.value === ZERO;
|
|
22212
|
+
const mergedIndex = parentTd.value.length + startIndex - (hasSyntheticLeadingZero ? 1 : 0);
|
|
22213
|
+
activeSplitRange = {
|
|
22214
|
+
tdIndex: posCtx.tdIndex,
|
|
22215
|
+
mergedIndex,
|
|
22216
|
+
trId: splitTr.id
|
|
22217
|
+
};
|
|
22218
|
+
mergedSplitFallback = {
|
|
22219
|
+
tdIndex: posCtx.tdIndex,
|
|
22220
|
+
mergedIndex,
|
|
22221
|
+
trId: splitTr.id,
|
|
22222
|
+
parentTrId: parentTr.id,
|
|
22223
|
+
parentTdId: parentTd.id,
|
|
22224
|
+
parentTrIndex: parentTrIdx
|
|
22225
|
+
};
|
|
22226
|
+
}
|
|
22227
|
+
}
|
|
22228
|
+
for (let d = 0; d < parentTr.tdList.length; d++) {
|
|
22229
|
+
const parentTd = parentTr.tdList[d];
|
|
22230
|
+
const splitTd = splitTr.tdList[d];
|
|
22231
|
+
if (!splitTd) continue;
|
|
22232
|
+
const hasSyntheticLeadingZero = !!splitTd.splitSyntheticLeadingZero && splitTd.value[0]?.value === ZERO;
|
|
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
|
+
});
|
|
22239
|
+
parentTd.value.push(...splitValue);
|
|
22240
|
+
parentTd.rowList = void 0;
|
|
22241
|
+
parentTd.positionList = void 0;
|
|
22242
|
+
}
|
|
22243
|
+
if (posCtx.isTable && posCtx.trId === splitTr.id) {
|
|
22244
|
+
posCtx.index = i;
|
|
22245
|
+
this.position.setPositionContext(posCtx);
|
|
22246
|
+
}
|
|
22247
|
+
mergedTrList.splice(t, 1);
|
|
22248
|
+
}
|
|
21392
22249
|
}
|
|
21393
22250
|
element.pagingIndex = element.pagingIndex ?? 0;
|
|
21394
22251
|
const trList = element.trList;
|
|
21395
22252
|
for (let t = 0; t < trList.length; t++) {
|
|
21396
22253
|
const tr = trList[t];
|
|
22254
|
+
delete tr.splitBoundaryTop;
|
|
22255
|
+
delete tr.splitBoundaryBottom;
|
|
21397
22256
|
tr.height = tr.minHeight || defaultTrMinHeight;
|
|
21398
22257
|
tr.minHeight = tr.height;
|
|
21399
22258
|
}
|
|
@@ -21408,6 +22267,7 @@ var Draw = class {
|
|
|
21408
22267
|
const rowList2 = this.computeRowList({
|
|
21409
22268
|
innerWidth: (td.width - cellPaddingWidth) * scale,
|
|
21410
22269
|
elementList: td.value,
|
|
22270
|
+
initialListState: td.splitListState,
|
|
21411
22271
|
isFromTable: true,
|
|
21412
22272
|
isPagingMode
|
|
21413
22273
|
});
|
|
@@ -21490,6 +22350,7 @@ var Draw = class {
|
|
|
21490
22350
|
const tdRowList = this.computeRowList({
|
|
21491
22351
|
innerWidth: (td.width - cellPaddingWidth) * scale,
|
|
21492
22352
|
elementList: td.value,
|
|
22353
|
+
initialListState: td.splitListState,
|
|
21493
22354
|
isFromTable: true,
|
|
21494
22355
|
isPagingMode
|
|
21495
22356
|
});
|
|
@@ -21583,6 +22444,197 @@ var Draw = class {
|
|
|
21583
22444
|
}
|
|
21584
22445
|
}
|
|
21585
22446
|
}
|
|
22447
|
+
if (deleteCount === 0) {
|
|
22448
|
+
let overflowTrIdx = -1;
|
|
22449
|
+
let preHeightScaled = 0;
|
|
22450
|
+
for (let r = 0; r < trList2.length; r++) {
|
|
22451
|
+
const trHeight = trList2[r].height * scale;
|
|
22452
|
+
if (curPagePreHeight + rowMarginHeight + preHeightScaled + trHeight > height2) {
|
|
22453
|
+
overflowTrIdx = r;
|
|
22454
|
+
break;
|
|
22455
|
+
}
|
|
22456
|
+
preHeightScaled += trHeight;
|
|
22457
|
+
}
|
|
22458
|
+
if (overflowTrIdx >= 0) {
|
|
22459
|
+
const availableScaled = height2 - curPagePreHeight - rowMarginHeight - preHeightScaled;
|
|
22460
|
+
const availableUnscaled = availableScaled / scale;
|
|
22461
|
+
if (availableUnscaled >= defaultTrMinHeight) {
|
|
22462
|
+
const overflowTr = trList2[overflowTrIdx];
|
|
22463
|
+
const originalTrHeight = overflowTr.height;
|
|
22464
|
+
const {
|
|
22465
|
+
table: { tdPadding: defaultTdPadding, defaultTrMinHeight: defaultTrMinHeight2 }
|
|
22466
|
+
} = this.options;
|
|
22467
|
+
const splits = [];
|
|
22468
|
+
let anySplit = false;
|
|
22469
|
+
for (let d = 0; d < overflowTr.tdList.length; d++) {
|
|
22470
|
+
const td = overflowTr.tdList[d];
|
|
22471
|
+
const cellPadding = td.padding || defaultTdPadding;
|
|
22472
|
+
const cellPaddingH = cellPadding[0] + cellPadding[2];
|
|
22473
|
+
const contentAvailableScaled = (availableUnscaled - cellPaddingH) * scale;
|
|
22474
|
+
if (!td.rowList || td.rowList.length === 0) {
|
|
22475
|
+
splits.push({
|
|
22476
|
+
elemIdx: td.value.length,
|
|
22477
|
+
rowIdx: 0
|
|
22478
|
+
});
|
|
22479
|
+
continue;
|
|
22480
|
+
}
|
|
22481
|
+
let cumHeight = 0;
|
|
22482
|
+
let elemIdx = td.value.length;
|
|
22483
|
+
let rowIdx = td.rowList.length;
|
|
22484
|
+
for (let ri = 0; ri < td.rowList.length; ri++) {
|
|
22485
|
+
const row = td.rowList[ri];
|
|
22486
|
+
if (cumHeight + row.height > contentAvailableScaled) {
|
|
22487
|
+
elemIdx = row.startIndex;
|
|
22488
|
+
rowIdx = ri;
|
|
22489
|
+
break;
|
|
22490
|
+
}
|
|
22491
|
+
cumHeight += row.height;
|
|
22492
|
+
}
|
|
22493
|
+
if (elemIdx > 0 && elemIdx < td.value.length) {
|
|
22494
|
+
anySplit = true;
|
|
22495
|
+
}
|
|
22496
|
+
splits.push({ elemIdx, rowIdx });
|
|
22497
|
+
}
|
|
22498
|
+
if (anySplit) {
|
|
22499
|
+
if (!activeSplitRange) {
|
|
22500
|
+
const posCtx = this.position.getPositionContext();
|
|
22501
|
+
const { startIndex, endIndex } = this.range.getRange();
|
|
22502
|
+
if (posCtx.isTable && posCtx.trId === overflowTr.id && startIndex === endIndex && posCtx.tdIndex !== void 0) {
|
|
22503
|
+
const splitIdx = splits[posCtx.tdIndex]?.elemIdx;
|
|
22504
|
+
if (splitIdx !== void 0 && startIndex >= splitIdx && splitIdx < overflowTr.tdList[posCtx.tdIndex].value.length) {
|
|
22505
|
+
activeSplitRange = {
|
|
22506
|
+
tdIndex: posCtx.tdIndex,
|
|
22507
|
+
mergedIndex: startIndex,
|
|
22508
|
+
trId: overflowTr.id
|
|
22509
|
+
};
|
|
22510
|
+
}
|
|
22511
|
+
}
|
|
22512
|
+
}
|
|
22513
|
+
const continuationTrHeight = originalTrHeight - availableUnscaled;
|
|
22514
|
+
const splitRootId = overflowTr.splitRootId || overflowTr.id;
|
|
22515
|
+
const splitLevel = (overflowTr.splitLevel || 0) + 1;
|
|
22516
|
+
const newTrId = `${splitRootId}_c${splitLevel}`;
|
|
22517
|
+
const continuationTdList = overflowTr.tdList.map(
|
|
22518
|
+
(td, d) => {
|
|
22519
|
+
const splitIdx = splits[d].elemIdx;
|
|
22520
|
+
const newTdId = getUUID();
|
|
22521
|
+
const initialListState2 = this.getListStateBeforeIndex(
|
|
22522
|
+
td.value,
|
|
22523
|
+
splitIdx
|
|
22524
|
+
);
|
|
22525
|
+
const overflowElements = td.value.slice(splitIdx);
|
|
22526
|
+
const overflowStartElement = overflowElements[0];
|
|
22527
|
+
let splitSyntheticLeadingZero = false;
|
|
22528
|
+
if (!overflowElements.length || overflowElements[0]?.value !== ZERO) {
|
|
22529
|
+
overflowElements.unshift({
|
|
22530
|
+
value: ZERO,
|
|
22531
|
+
type: "text" /* TEXT */,
|
|
22532
|
+
listId: overflowStartElement?.listId,
|
|
22533
|
+
listType: overflowStartElement?.listType,
|
|
22534
|
+
listStyle: overflowStartElement?.listStyle,
|
|
22535
|
+
listLevel: overflowStartElement?.listLevel,
|
|
22536
|
+
listPreset: overflowStartElement?.listPreset,
|
|
22537
|
+
listWrap: !!overflowStartElement?.listId
|
|
22538
|
+
});
|
|
22539
|
+
splitSyntheticLeadingZero = true;
|
|
22540
|
+
}
|
|
22541
|
+
this.syncTableElementContext(overflowElements, {
|
|
22542
|
+
tableId: element.id,
|
|
22543
|
+
trId: newTrId,
|
|
22544
|
+
tdId: newTdId
|
|
22545
|
+
});
|
|
22546
|
+
const {
|
|
22547
|
+
id: _tdId,
|
|
22548
|
+
value: _v,
|
|
22549
|
+
rowList: _rl,
|
|
22550
|
+
positionList: _pl,
|
|
22551
|
+
splitSyntheticLeadingZero: _slz,
|
|
22552
|
+
splitListState: _sls,
|
|
22553
|
+
...tdMeta
|
|
22554
|
+
} = td;
|
|
22555
|
+
return {
|
|
22556
|
+
...deepClone(tdMeta),
|
|
22557
|
+
id: newTdId,
|
|
22558
|
+
value: overflowElements,
|
|
22559
|
+
splitSyntheticLeadingZero,
|
|
22560
|
+
splitListState: initialListState2,
|
|
22561
|
+
height: continuationTrHeight,
|
|
22562
|
+
rowList: void 0,
|
|
22563
|
+
positionList: void 0,
|
|
22564
|
+
mainHeight: void 0,
|
|
22565
|
+
realHeight: void 0,
|
|
22566
|
+
realMinHeight: void 0
|
|
22567
|
+
};
|
|
22568
|
+
}
|
|
22569
|
+
);
|
|
22570
|
+
const continuationTr = {
|
|
22571
|
+
id: newTrId,
|
|
22572
|
+
height: continuationTrHeight,
|
|
22573
|
+
minHeight: defaultTrMinHeight2,
|
|
22574
|
+
tdList: continuationTdList,
|
|
22575
|
+
splitParentId: overflowTr.id,
|
|
22576
|
+
splitRootId,
|
|
22577
|
+
splitLevel
|
|
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
|
+
}
|
|
22592
|
+
const positionContext = this.position.getPositionContext();
|
|
22593
|
+
if (!isLogicalSplitCursorHandled && activeSplitRange && positionContext.isTable && positionContext.trId === activeSplitRange.trId) {
|
|
22594
|
+
const splitIdx = splits[activeSplitRange.tdIndex]?.elemIdx;
|
|
22595
|
+
const continuationTd = continuationTdList[activeSplitRange.tdIndex];
|
|
22596
|
+
if (splitIdx !== void 0 && continuationTd && activeSplitRange.mergedIndex >= splitIdx) {
|
|
22597
|
+
const hasPrependedZero = !!continuationTd.splitSyntheticLeadingZero && continuationTd.value[0]?.value === ZERO;
|
|
22598
|
+
const continuationCursorIndex = activeSplitRange.mergedIndex - splitIdx + (hasPrependedZero ? 1 : 0);
|
|
22599
|
+
positionContext.index = i;
|
|
22600
|
+
positionContext.trIndex = overflowTrIdx + 1;
|
|
22601
|
+
positionContext.tdIndex = activeSplitRange.tdIndex;
|
|
22602
|
+
positionContext.tdId = continuationTd.id;
|
|
22603
|
+
positionContext.trId = continuationTr.id;
|
|
22604
|
+
positionContext.tableId = element.id;
|
|
22605
|
+
this.position.setPositionContext(positionContext);
|
|
22606
|
+
this.range.setRange(
|
|
22607
|
+
continuationCursorIndex,
|
|
22608
|
+
continuationCursorIndex
|
|
22609
|
+
);
|
|
22610
|
+
this.pendingTableCursorIndex = continuationCursorIndex;
|
|
22611
|
+
}
|
|
22612
|
+
}
|
|
22613
|
+
for (let d = 0; d < overflowTr.tdList.length; d++) {
|
|
22614
|
+
const td = overflowTr.tdList[d];
|
|
22615
|
+
const { elemIdx, rowIdx } = splits[d];
|
|
22616
|
+
td.value = td.value.slice(0, elemIdx);
|
|
22617
|
+
td.rowList = td.rowList ? td.rowList.slice(0, rowIdx) : void 0;
|
|
22618
|
+
td.positionList = void 0;
|
|
22619
|
+
td.height = availableUnscaled;
|
|
22620
|
+
td.mainHeight = void 0;
|
|
22621
|
+
td.realHeight = void 0;
|
|
22622
|
+
td.realMinHeight = void 0;
|
|
22623
|
+
}
|
|
22624
|
+
overflowTr.height = availableUnscaled;
|
|
22625
|
+
overflowTr.minHeight = Math.min(
|
|
22626
|
+
overflowTr.minHeight || defaultTrMinHeight2,
|
|
22627
|
+
availableUnscaled
|
|
22628
|
+
);
|
|
22629
|
+
overflowTr.splitBoundaryBottom = true;
|
|
22630
|
+
continuationTr.splitBoundaryTop = true;
|
|
22631
|
+
trList2.splice(overflowTrIdx + 1, 0, continuationTr);
|
|
22632
|
+
deleteStart = overflowTrIdx + 1;
|
|
22633
|
+
deleteCount = trList2.length - deleteStart;
|
|
22634
|
+
}
|
|
22635
|
+
}
|
|
22636
|
+
}
|
|
22637
|
+
}
|
|
21586
22638
|
if (deleteCount) {
|
|
21587
22639
|
const cloneTrList = trList2.splice(deleteStart, deleteCount);
|
|
21588
22640
|
const cloneTrHeight = cloneTrList.reduce(
|
|
@@ -21595,16 +22647,26 @@ var Draw = class {
|
|
|
21595
22647
|
element.height -= cloneTrHeight;
|
|
21596
22648
|
metrics.height -= cloneTrRealHeight;
|
|
21597
22649
|
metrics.boundingBoxDescent -= cloneTrRealHeight;
|
|
21598
|
-
const
|
|
21599
|
-
|
|
21600
|
-
|
|
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
|
+
};
|
|
21601
22664
|
const repeatTrList = trList2.filter((tr) => tr.pagingRepeat);
|
|
21602
22665
|
if (repeatTrList.length) {
|
|
21603
22666
|
const cloneRepeatTrList = deepClone(repeatTrList);
|
|
21604
22667
|
cloneRepeatTrList.forEach((tr) => tr.id = getUUID());
|
|
21605
22668
|
cloneTrList.unshift(...cloneRepeatTrList);
|
|
21606
22669
|
}
|
|
21607
|
-
cloneElement.trList = cloneTrList;
|
|
21608
22670
|
cloneElement.id = getUUID();
|
|
21609
22671
|
this.spliceElementList(elementList, i + 1, 0, [cloneElement]);
|
|
21610
22672
|
}
|
|
@@ -21632,6 +22694,21 @@ var Draw = class {
|
|
|
21632
22694
|
positionContext.index = newPositionContextIndex;
|
|
21633
22695
|
positionContext.trIndex = newPositionContextTrIndex;
|
|
21634
22696
|
this.position.setPositionContext(positionContext);
|
|
22697
|
+
} else if (mergedSplitFallback && positionContext.trId === mergedSplitFallback.trId) {
|
|
22698
|
+
const fallbackTd = element.trList?.[mergedSplitFallback.parentTrIndex]?.tdList[mergedSplitFallback.tdIndex];
|
|
22699
|
+
const fallbackCursorIndex = Math.min(
|
|
22700
|
+
mergedSplitFallback.mergedIndex,
|
|
22701
|
+
Math.max((fallbackTd?.value.length || 1) - 1, 0)
|
|
22702
|
+
);
|
|
22703
|
+
positionContext.index = i;
|
|
22704
|
+
positionContext.trIndex = mergedSplitFallback.parentTrIndex;
|
|
22705
|
+
positionContext.tdIndex = mergedSplitFallback.tdIndex;
|
|
22706
|
+
positionContext.tdId = mergedSplitFallback.parentTdId;
|
|
22707
|
+
positionContext.trId = mergedSplitFallback.parentTrId;
|
|
22708
|
+
positionContext.tableId = element.id;
|
|
22709
|
+
this.position.setPositionContext(positionContext);
|
|
22710
|
+
this.range.setRange(fallbackCursorIndex, fallbackCursorIndex);
|
|
22711
|
+
this.pendingTableCursorIndex = fallbackCursorIndex;
|
|
21635
22712
|
}
|
|
21636
22713
|
}
|
|
21637
22714
|
}
|
|
@@ -21764,39 +22841,7 @@ var Draw = class {
|
|
|
21764
22841
|
curRowWidth += punctuationWidth * scale;
|
|
21765
22842
|
}
|
|
21766
22843
|
}
|
|
21767
|
-
|
|
21768
|
-
const curLevel = element.listLevel ?? 0;
|
|
21769
|
-
if (element.listId !== listId) {
|
|
21770
|
-
listIndex = 0;
|
|
21771
|
-
listLevelIndex = /* @__PURE__ */ new Map();
|
|
21772
|
-
listLevelIndex.set(curLevel, 0);
|
|
21773
|
-
prevListLevel = curLevel;
|
|
21774
|
-
} else if (element.value === ZERO && !element.listWrap) {
|
|
21775
|
-
if (curLevel !== prevListLevel) {
|
|
21776
|
-
if (curLevel > prevListLevel) {
|
|
21777
|
-
listLevelIndex.set(curLevel, 0);
|
|
21778
|
-
} else {
|
|
21779
|
-
for (const [lvl] of listLevelIndex) {
|
|
21780
|
-
if (lvl > curLevel) {
|
|
21781
|
-
listLevelIndex.delete(lvl);
|
|
21782
|
-
}
|
|
21783
|
-
}
|
|
21784
|
-
listLevelIndex.set(
|
|
21785
|
-
curLevel,
|
|
21786
|
-
(listLevelIndex.get(curLevel) ?? -1) + 1
|
|
21787
|
-
);
|
|
21788
|
-
}
|
|
21789
|
-
} else {
|
|
21790
|
-
listLevelIndex.set(
|
|
21791
|
-
curLevel,
|
|
21792
|
-
(listLevelIndex.get(curLevel) ?? -1) + 1
|
|
21793
|
-
);
|
|
21794
|
-
}
|
|
21795
|
-
listIndex = listLevelIndex.get(curLevel) ?? 0;
|
|
21796
|
-
prevListLevel = curLevel;
|
|
21797
|
-
}
|
|
21798
|
-
}
|
|
21799
|
-
listId = element.listId;
|
|
22844
|
+
this.advanceListState(element, listState);
|
|
21800
22845
|
const surroundPosition = this.position.setSurroundPosition({
|
|
21801
22846
|
pageNo,
|
|
21802
22847
|
rowElement,
|
|
@@ -21848,7 +22893,7 @@ var Draw = class {
|
|
|
21848
22893
|
const baseListOffset = listStyleMap.get(element.listId) || 0;
|
|
21849
22894
|
const rowListIndent = this.listParticle.getListIndentWidth(element);
|
|
21850
22895
|
row.offsetX = baseListOffset + rowListIndent;
|
|
21851
|
-
row.listIndex = listIndex;
|
|
22896
|
+
row.listIndex = listState.listIndex;
|
|
21852
22897
|
}
|
|
21853
22898
|
row.offsetY = !isFromTable && element.area?.top && element.areaId !== elementList[i - 1]?.areaId ? element.area.top * scale : 0;
|
|
21854
22899
|
rowList.push(row);
|
|
@@ -22069,6 +23114,27 @@ var Draw = class {
|
|
|
22069
23114
|
const isPrintMode = this.isPrintMode();
|
|
22070
23115
|
const isGraffitiMode = this.isGraffitiMode();
|
|
22071
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;
|
|
22072
23138
|
let index = startIndex;
|
|
22073
23139
|
for (let i = 0; i < rowList.length; i++) {
|
|
22074
23140
|
const curRow = rowList[i];
|
|
@@ -22100,6 +23166,9 @@ var Draw = class {
|
|
|
22100
23166
|
this.textParticle.complete();
|
|
22101
23167
|
this.laTexParticle.render(ctx, element, x, y + offsetY);
|
|
22102
23168
|
} else if (element.type === "table" /* TABLE */) {
|
|
23169
|
+
if (tableCellSelection) {
|
|
23170
|
+
tableRangeElement = element;
|
|
23171
|
+
}
|
|
22103
23172
|
if (isCrossRowCol) {
|
|
22104
23173
|
rangeRecord.x = x;
|
|
22105
23174
|
rangeRecord.y = y;
|
|
@@ -22247,11 +23316,14 @@ var Draw = class {
|
|
|
22247
23316
|
startIndex: startIndex2,
|
|
22248
23317
|
endIndex
|
|
22249
23318
|
} = this.range.getRange();
|
|
22250
|
-
|
|
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) {
|
|
22251
23323
|
const positionContext = this.position.getPositionContext();
|
|
22252
|
-
if (!positionContext.isTable && !element.tdId || positionContext.tdId === element.tdId) {
|
|
22253
|
-
if (startIndex2 ===
|
|
22254
|
-
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];
|
|
22255
23327
|
if (nextElement && nextElement.value === ZERO) {
|
|
22256
23328
|
rangeRecord.x = x + metrics.width;
|
|
22257
23329
|
rangeRecord.y = y - (curRow.spaceAbove || 0);
|
|
@@ -22316,7 +23388,7 @@ var Draw = class {
|
|
|
22316
23388
|
this.strikeout.render(ctx);
|
|
22317
23389
|
this.group.render(ctx);
|
|
22318
23390
|
if (!isPrintMode && !isGraffitiMode) {
|
|
22319
|
-
if (rangeRecord.width && rangeRecord.height) {
|
|
23391
|
+
if (!tableCellSelection && rangeRecord.width && rangeRecord.height) {
|
|
22320
23392
|
const { x, y, width, height } = rangeRecord;
|
|
22321
23393
|
this.range.render(ctx, x, y, width, height);
|
|
22322
23394
|
}
|
|
@@ -22328,6 +23400,20 @@ var Draw = class {
|
|
|
22328
23400
|
} = positionList[curRow.startIndex];
|
|
22329
23401
|
this.tableParticle.drawRange(ctx, tableRangeElement, x, y);
|
|
22330
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
|
+
}
|
|
22331
23417
|
}
|
|
22332
23418
|
}
|
|
22333
23419
|
}
|
|
@@ -22517,6 +23603,7 @@ var Draw = class {
|
|
|
22517
23603
|
isFirstRender = false
|
|
22518
23604
|
} = payload || {};
|
|
22519
23605
|
let { curIndex } = payload || {};
|
|
23606
|
+
this.pendingTableCursorIndex = void 0;
|
|
22520
23607
|
const innerWidth = this.getInnerWidth();
|
|
22521
23608
|
const columnWidth = this.getColumnWidth();
|
|
22522
23609
|
const isPagingMode = this.getIsPagingMode();
|
|
@@ -22582,6 +23669,10 @@ var Draw = class {
|
|
|
22582
23669
|
} else {
|
|
22583
23670
|
this._immediateRender();
|
|
22584
23671
|
}
|
|
23672
|
+
if (this.pendingTableCursorIndex !== void 0) {
|
|
23673
|
+
curIndex = this.pendingTableCursorIndex;
|
|
23674
|
+
this.pendingTableCursorIndex = void 0;
|
|
23675
|
+
}
|
|
22585
23676
|
if (isSetCursor) {
|
|
22586
23677
|
curIndex = this.setCursor(curIndex);
|
|
22587
23678
|
} else if (this.range.getIsSelection()) {
|
|
@@ -22623,9 +23714,7 @@ var Draw = class {
|
|
|
22623
23714
|
const positionContext = this.position.getPositionContext();
|
|
22624
23715
|
const positionList = this.position.getPositionList();
|
|
22625
23716
|
if (positionContext.isTable) {
|
|
22626
|
-
const
|
|
22627
|
-
const elementList = this.getOriginalElementList();
|
|
22628
|
-
const tablePositionList = elementList[index].trList?.[trIndex].tdList[tdIndex].positionList;
|
|
23717
|
+
const tablePositionList = this.resolveTableCellContext(this.getOriginalElementList())?.td.positionList;
|
|
22629
23718
|
if (curIndex === void 0 && tablePositionList) {
|
|
22630
23719
|
curIndex = tablePositionList.length - 1;
|
|
22631
23720
|
}
|
|
@@ -22951,6 +24040,34 @@ var CommandAdapt = class {
|
|
|
22951
24040
|
this.zone = draw.getZone();
|
|
22952
24041
|
this.tableOperate = draw.getTableOperate();
|
|
22953
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
|
+
}
|
|
22954
24071
|
mode(payload) {
|
|
22955
24072
|
this.draw.setMode(payload);
|
|
22956
24073
|
}
|
|
@@ -23096,7 +24213,7 @@ var CommandAdapt = class {
|
|
|
23096
24213
|
const { isIgnoreDisabledRule = false } = options || {};
|
|
23097
24214
|
const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
|
|
23098
24215
|
if (isDisabled) return;
|
|
23099
|
-
const selection = this.
|
|
24216
|
+
const selection = this.getStyleSelectionElementList();
|
|
23100
24217
|
let renderOption = {};
|
|
23101
24218
|
let changeElementList = [];
|
|
23102
24219
|
if (selection?.length) {
|
|
@@ -23123,7 +24240,7 @@ var CommandAdapt = class {
|
|
|
23123
24240
|
const { isIgnoreDisabledRule = false } = options || {};
|
|
23124
24241
|
const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
|
|
23125
24242
|
if (isDisabled) return;
|
|
23126
|
-
const selection = this.
|
|
24243
|
+
const selection = this.getStyleSelectionElementList();
|
|
23127
24244
|
if (selection?.length) {
|
|
23128
24245
|
selection.forEach((el) => {
|
|
23129
24246
|
el.font = payload;
|
|
@@ -23157,7 +24274,9 @@ var CommandAdapt = class {
|
|
|
23157
24274
|
if (payload < minSize || payload > maxSize) return;
|
|
23158
24275
|
let renderOption = {};
|
|
23159
24276
|
let changeElementList = [];
|
|
23160
|
-
const selection = this.
|
|
24277
|
+
const selection = this.getStyleSelectionElementList({
|
|
24278
|
+
textLikeOnly: true
|
|
24279
|
+
});
|
|
23161
24280
|
if (selection?.length) {
|
|
23162
24281
|
changeElementList = selection;
|
|
23163
24282
|
renderOption = { isSetCursor: false };
|
|
@@ -23197,7 +24316,9 @@ var CommandAdapt = class {
|
|
|
23197
24316
|
const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
|
|
23198
24317
|
if (isDisabled) return;
|
|
23199
24318
|
const { defaultSize, maxSize } = this.options;
|
|
23200
|
-
const selection = this.
|
|
24319
|
+
const selection = this.getStyleSelectionElementList({
|
|
24320
|
+
textLikeOnly: true
|
|
24321
|
+
});
|
|
23201
24322
|
let renderOption = {};
|
|
23202
24323
|
let changeElementList = [];
|
|
23203
24324
|
if (selection?.length) {
|
|
@@ -23246,7 +24367,9 @@ var CommandAdapt = class {
|
|
|
23246
24367
|
const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
|
|
23247
24368
|
if (isDisabled) return;
|
|
23248
24369
|
const { defaultSize, minSize } = this.options;
|
|
23249
|
-
const selection = this.
|
|
24370
|
+
const selection = this.getStyleSelectionElementList({
|
|
24371
|
+
textLikeOnly: true
|
|
24372
|
+
});
|
|
23250
24373
|
let renderOption = {};
|
|
23251
24374
|
let changeElementList = [];
|
|
23252
24375
|
if (selection?.length) {
|
|
@@ -23294,7 +24417,7 @@ var CommandAdapt = class {
|
|
|
23294
24417
|
const { isIgnoreDisabledRule = false } = options || {};
|
|
23295
24418
|
const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
|
|
23296
24419
|
if (isDisabled) return;
|
|
23297
|
-
const selection = this.
|
|
24420
|
+
const selection = this.getStyleSelectionElementList();
|
|
23298
24421
|
if (selection?.length) {
|
|
23299
24422
|
const noBoldIndex = selection.findIndex((s) => !s.bold);
|
|
23300
24423
|
selection.forEach((el) => {
|
|
@@ -23326,7 +24449,7 @@ var CommandAdapt = class {
|
|
|
23326
24449
|
const { isIgnoreDisabledRule = false } = options || {};
|
|
23327
24450
|
const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
|
|
23328
24451
|
if (isDisabled) return;
|
|
23329
|
-
const selection = this.
|
|
24452
|
+
const selection = this.getStyleSelectionElementList();
|
|
23330
24453
|
if (selection?.length) {
|
|
23331
24454
|
const noItalicIndex = selection.findIndex((s) => !s.italic);
|
|
23332
24455
|
selection.forEach((el) => {
|
|
@@ -23358,7 +24481,7 @@ var CommandAdapt = class {
|
|
|
23358
24481
|
const { isIgnoreDisabledRule = false } = options || {};
|
|
23359
24482
|
const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
|
|
23360
24483
|
if (isDisabled) return;
|
|
23361
|
-
const selection = this.
|
|
24484
|
+
const selection = this.getStyleSelectionElementList();
|
|
23362
24485
|
if (selection?.length) {
|
|
23363
24486
|
const isSetUnderline = selection.some(
|
|
23364
24487
|
(s) => !s.underline || !textDecoration && s.textDecoration || textDecoration && !s.textDecoration || textDecoration && s.textDecoration && !isObjectEqual(s.textDecoration, textDecoration)
|
|
@@ -23400,7 +24523,7 @@ var CommandAdapt = class {
|
|
|
23400
24523
|
const { isIgnoreDisabledRule = false } = options || {};
|
|
23401
24524
|
const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
|
|
23402
24525
|
if (isDisabled) return;
|
|
23403
|
-
const selection = this.
|
|
24526
|
+
const selection = this.getStyleSelectionElementList();
|
|
23404
24527
|
if (selection?.length) {
|
|
23405
24528
|
const noStrikeoutIndex = selection.findIndex((s) => !s.strikeout);
|
|
23406
24529
|
selection.forEach((el) => {
|
|
@@ -23435,7 +24558,7 @@ var CommandAdapt = class {
|
|
|
23435
24558
|
const { isIgnoreDisabledRule = false } = options || {};
|
|
23436
24559
|
const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
|
|
23437
24560
|
if (isDisabled) return;
|
|
23438
|
-
const selection = this.
|
|
24561
|
+
const selection = this.getStyleSelectionElementList();
|
|
23439
24562
|
if (!selection) return;
|
|
23440
24563
|
const superscriptIndex = selection.findIndex(
|
|
23441
24564
|
(s) => s.type === "superscript" /* SUPERSCRIPT */
|
|
@@ -23458,7 +24581,7 @@ var CommandAdapt = class {
|
|
|
23458
24581
|
const { isIgnoreDisabledRule = false } = options || {};
|
|
23459
24582
|
const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
|
|
23460
24583
|
if (isDisabled) return;
|
|
23461
|
-
const selection = this.
|
|
24584
|
+
const selection = this.getStyleSelectionElementList();
|
|
23462
24585
|
if (!selection) return;
|
|
23463
24586
|
const subscriptIndex = selection.findIndex(
|
|
23464
24587
|
(s) => s.type === "subscript" /* SUBSCRIPT */
|
|
@@ -23481,7 +24604,7 @@ var CommandAdapt = class {
|
|
|
23481
24604
|
const { isIgnoreDisabledRule = false } = options || {};
|
|
23482
24605
|
const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
|
|
23483
24606
|
if (isDisabled) return;
|
|
23484
|
-
const selection = this.
|
|
24607
|
+
const selection = this.getStyleSelectionElementList();
|
|
23485
24608
|
if (selection?.length) {
|
|
23486
24609
|
selection.forEach((el) => {
|
|
23487
24610
|
if (payload) {
|
|
@@ -23522,7 +24645,7 @@ var CommandAdapt = class {
|
|
|
23522
24645
|
const { isIgnoreDisabledRule = false } = options || {};
|
|
23523
24646
|
const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
|
|
23524
24647
|
if (isDisabled) return;
|
|
23525
|
-
const selection = this.
|
|
24648
|
+
const selection = this.getStyleSelectionElementList();
|
|
23526
24649
|
if (selection?.length) {
|
|
23527
24650
|
selection.forEach((el) => {
|
|
23528
24651
|
if (payload) {
|
|
@@ -24153,25 +25276,39 @@ var CommandAdapt = class {
|
|
|
24153
25276
|
const endElement = pickElementAttr(elementList[endIndex], {
|
|
24154
25277
|
extraPickAttrs: ["id", "controlComponent"]
|
|
24155
25278
|
});
|
|
24156
|
-
const rowList = this.draw.getRowList();
|
|
24157
25279
|
const positionList = this.position.getPositionList();
|
|
24158
25280
|
const startPosition = positionList[startIndex];
|
|
24159
25281
|
const endPosition = positionList[endIndex];
|
|
25282
|
+
if (!startPosition || !endPosition) return null;
|
|
24160
25283
|
const startPageNo = startPosition.pageNo;
|
|
24161
25284
|
const endPageNo = endPosition.pageNo;
|
|
24162
25285
|
const startRowNo = startPosition.rowIndex;
|
|
24163
25286
|
const endRowNo = endPosition.rowIndex;
|
|
24164
|
-
const
|
|
24165
|
-
|
|
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;
|
|
24166
25303
|
let startColNo = 0;
|
|
24167
25304
|
let endColNo = 0;
|
|
24168
25305
|
if (!this.draw.getCursor().getHitLineStartIndex()) {
|
|
24169
|
-
startColNo =
|
|
25306
|
+
startColNo = startRowStartsWithZero ? startIndex - startRowStartIndex : startIndex - startRowStartIndex + 1;
|
|
24170
25307
|
}
|
|
24171
25308
|
if (startPosition === endPosition) {
|
|
24172
25309
|
endColNo = startColNo;
|
|
24173
25310
|
} else {
|
|
24174
|
-
endColNo =
|
|
25311
|
+
endColNo = endRowStartsWithZero ? endIndex - endRowStartIndex : endIndex - endRowStartIndex + 1;
|
|
24175
25312
|
}
|
|
24176
25313
|
const rangeRects = [];
|
|
24177
25314
|
const height = this.draw.getOriginalHeight();
|
|
@@ -24179,6 +25316,7 @@ var CommandAdapt = class {
|
|
|
24179
25316
|
const selectionPositionList = this.position.getSelectionPositionList();
|
|
24180
25317
|
if (selectionPositionList) {
|
|
24181
25318
|
let currentRowNo = null;
|
|
25319
|
+
let currentPageNo = null;
|
|
24182
25320
|
let currentX = 0;
|
|
24183
25321
|
let rangeRect = null;
|
|
24184
25322
|
for (let p = 0; p < selectionPositionList.length; p++) {
|
|
@@ -24188,7 +25326,7 @@ var CommandAdapt = class {
|
|
|
24188
25326
|
coordinate: { leftTop, rightTop },
|
|
24189
25327
|
lineHeight
|
|
24190
25328
|
} = selectionPositionList[p];
|
|
24191
|
-
if (currentRowNo === null || currentRowNo !== rowNo) {
|
|
25329
|
+
if (currentRowNo === null || currentPageNo === null || currentRowNo !== rowNo || currentPageNo !== pageNo) {
|
|
24192
25330
|
if (rangeRect) {
|
|
24193
25331
|
rangeRects.push(rangeRect);
|
|
24194
25332
|
}
|
|
@@ -24199,6 +25337,7 @@ var CommandAdapt = class {
|
|
|
24199
25337
|
height: lineHeight
|
|
24200
25338
|
};
|
|
24201
25339
|
currentRowNo = rowNo;
|
|
25340
|
+
currentPageNo = pageNo;
|
|
24202
25341
|
currentX = leftTop[0];
|
|
24203
25342
|
} else {
|
|
24204
25343
|
rangeRect.width = rightTop[0] - currentX;
|