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