@windoc/core 0.3.19 → 0.3.21
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 +27 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +599 -116
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +599 -116
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -78,7 +78,7 @@ __export(index_exports, {
|
|
|
78
78
|
module.exports = __toCommonJS(index_exports);
|
|
79
79
|
|
|
80
80
|
// src/version.ts
|
|
81
|
-
var version = "0.3.
|
|
81
|
+
var version = "0.3.21";
|
|
82
82
|
|
|
83
83
|
// src/dataset/enum/Common.ts
|
|
84
84
|
var MaxHeightRatio = /* @__PURE__ */ ((MaxHeightRatio2) => {
|
|
@@ -7403,6 +7403,71 @@ function mousemove(evt, host) {
|
|
|
7403
7403
|
});
|
|
7404
7404
|
}
|
|
7405
7405
|
|
|
7406
|
+
// src/core/event/handlers/keydown/tableSplit.ts
|
|
7407
|
+
function moveEmptySplitTdCursorToParent(host) {
|
|
7408
|
+
const draw = host.getDraw();
|
|
7409
|
+
const position = draw.getPosition();
|
|
7410
|
+
const positionContext = position.getPositionContext();
|
|
7411
|
+
const cursorPosition = position.getCursorPosition();
|
|
7412
|
+
if (!positionContext.isTable || !cursorPosition || cursorPosition.index !== 0) {
|
|
7413
|
+
return null;
|
|
7414
|
+
}
|
|
7415
|
+
const elementList = draw.getOriginalElementList();
|
|
7416
|
+
const resolved = draw.resolveTableCellContext(elementList, positionContext);
|
|
7417
|
+
if (!resolved) return null;
|
|
7418
|
+
const currentTr = resolved.element.trList?.[resolved.trIndex];
|
|
7419
|
+
const currentTd = resolved.td;
|
|
7420
|
+
if (!currentTr?.splitParentId || currentTd.value.length !== 1 || currentTd.value[0]?.value !== ZERO) {
|
|
7421
|
+
return null;
|
|
7422
|
+
}
|
|
7423
|
+
const pagingId = resolved.element.pagingId;
|
|
7424
|
+
if (!pagingId) return null;
|
|
7425
|
+
let parentTarget;
|
|
7426
|
+
for (let i = resolved.index; i >= 0; i--) {
|
|
7427
|
+
const tableElement = elementList[i];
|
|
7428
|
+
if (tableElement.type !== "table" /* TABLE */) continue;
|
|
7429
|
+
if (tableElement.pagingId !== pagingId) {
|
|
7430
|
+
if (i < resolved.index) break;
|
|
7431
|
+
continue;
|
|
7432
|
+
}
|
|
7433
|
+
const parentTrIndex = tableElement.trList?.findIndex((tr) => tr.id === currentTr.splitParentId) ?? -1;
|
|
7434
|
+
if (parentTrIndex < 0) continue;
|
|
7435
|
+
const parentTr2 = tableElement.trList[parentTrIndex];
|
|
7436
|
+
const parentTdIndex = parentTr2.tdList.findIndex(
|
|
7437
|
+
(td) => td.colIndex === currentTd.colIndex
|
|
7438
|
+
);
|
|
7439
|
+
if (parentTdIndex < 0) return null;
|
|
7440
|
+
parentTarget = {
|
|
7441
|
+
tableId: tableElement.id,
|
|
7442
|
+
tableIndex: i,
|
|
7443
|
+
trIndex: parentTrIndex,
|
|
7444
|
+
tdIndex: parentTdIndex
|
|
7445
|
+
};
|
|
7446
|
+
break;
|
|
7447
|
+
}
|
|
7448
|
+
if (!parentTarget) return null;
|
|
7449
|
+
const parentElement = elementList[parentTarget.tableIndex];
|
|
7450
|
+
const parentTr = parentElement.trList[parentTarget.trIndex];
|
|
7451
|
+
const parentTd = parentTr.tdList[parentTarget.tdIndex];
|
|
7452
|
+
if (!currentTd.splitSyntheticLeadingZero) {
|
|
7453
|
+
currentTd.value.splice(0, 1);
|
|
7454
|
+
currentTd.rowList = void 0;
|
|
7455
|
+
currentTd.positionList = void 0;
|
|
7456
|
+
}
|
|
7457
|
+
const curIndex = Math.max(parentTd.value.length - 1, 0);
|
|
7458
|
+
position.setPositionContext({
|
|
7459
|
+
isTable: true,
|
|
7460
|
+
index: parentTarget.tableIndex,
|
|
7461
|
+
trIndex: parentTarget.trIndex,
|
|
7462
|
+
tdIndex: parentTarget.tdIndex,
|
|
7463
|
+
tdId: parentTd.id,
|
|
7464
|
+
trId: parentTr.id,
|
|
7465
|
+
tableId: parentTarget.tableId
|
|
7466
|
+
});
|
|
7467
|
+
draw.getRange().setRange(curIndex, curIndex);
|
|
7468
|
+
return curIndex;
|
|
7469
|
+
}
|
|
7470
|
+
|
|
7406
7471
|
// src/core/event/handlers/keydown/backspace.ts
|
|
7407
7472
|
function backspaceHideElement(host) {
|
|
7408
7473
|
const draw = host.getDraw();
|
|
@@ -7444,6 +7509,18 @@ function backspace(evt, host) {
|
|
|
7444
7509
|
if (draw.isReadonly()) return;
|
|
7445
7510
|
const rangeManager = draw.getRange();
|
|
7446
7511
|
if (!rangeManager.getIsCanInput()) return;
|
|
7512
|
+
if (rangeManager.getIsCollapsed()) {
|
|
7513
|
+
const splitParentIndex = moveEmptySplitTdCursorToParent(host);
|
|
7514
|
+
if (splitParentIndex !== null) {
|
|
7515
|
+
draw.getGlobalEvent().setCanvasEventAbility();
|
|
7516
|
+
draw.render({
|
|
7517
|
+
curIndex: splitParentIndex,
|
|
7518
|
+
isSubmitHistory: false
|
|
7519
|
+
});
|
|
7520
|
+
evt.preventDefault();
|
|
7521
|
+
return;
|
|
7522
|
+
}
|
|
7523
|
+
}
|
|
7447
7524
|
if (rangeManager.getIsCollapsed()) {
|
|
7448
7525
|
backspaceHideElement(host);
|
|
7449
7526
|
}
|
|
@@ -7589,6 +7666,18 @@ function del(evt, host) {
|
|
|
7589
7666
|
if (draw.isReadonly()) return;
|
|
7590
7667
|
const rangeManager = draw.getRange();
|
|
7591
7668
|
if (!rangeManager.getIsCanInput()) return;
|
|
7669
|
+
if (rangeManager.getIsCollapsed()) {
|
|
7670
|
+
const splitParentIndex = moveEmptySplitTdCursorToParent(host);
|
|
7671
|
+
if (splitParentIndex !== null) {
|
|
7672
|
+
draw.getGlobalEvent().setCanvasEventAbility();
|
|
7673
|
+
draw.render({
|
|
7674
|
+
curIndex: splitParentIndex,
|
|
7675
|
+
isSubmitHistory: false
|
|
7676
|
+
});
|
|
7677
|
+
evt.preventDefault();
|
|
7678
|
+
return;
|
|
7679
|
+
}
|
|
7680
|
+
}
|
|
7592
7681
|
const { startIndex, endIndex, isCrossRowCol } = rangeManager.getRange();
|
|
7593
7682
|
const elementList = draw.getElementList();
|
|
7594
7683
|
const control = draw.getControl();
|
|
@@ -9284,8 +9373,7 @@ var Position = class {
|
|
|
9284
9373
|
return this.floatPositionList;
|
|
9285
9374
|
}
|
|
9286
9375
|
getTablePositionList(sourceElementList) {
|
|
9287
|
-
|
|
9288
|
-
return sourceElementList[index].trList[trIndex].tdList[tdIndex].positionList || [];
|
|
9376
|
+
return this.draw.resolveTableCellContext(sourceElementList, this.positionContext)?.td.positionList || [];
|
|
9289
9377
|
}
|
|
9290
9378
|
getPositionList() {
|
|
9291
9379
|
return this.positionContext.isTable ? this.getTablePositionList(this.draw.getOriginalElementList()) : this.getOriginalPositionList();
|
|
@@ -9939,6 +10027,46 @@ var Position = class {
|
|
|
9939
10027
|
positionResult.index = newIndex;
|
|
9940
10028
|
}
|
|
9941
10029
|
}
|
|
10030
|
+
if (positionResult.isTable && positionResult.trId != null) {
|
|
10031
|
+
const elementList = this.draw.getOriginalMainElementList();
|
|
10032
|
+
const tableElement = elementList[positionResult.index];
|
|
10033
|
+
if (tableElement?.trList) {
|
|
10034
|
+
const matchedTr = tableElement.trList.find(
|
|
10035
|
+
(r) => r.id === positionResult.trId
|
|
10036
|
+
);
|
|
10037
|
+
if (matchedTr?.splitRootId) {
|
|
10038
|
+
const matchedTd = matchedTr.tdList[positionResult.tdIndex];
|
|
10039
|
+
if (matchedTd && matchedTd.splitSyntheticLeadingZero && matchedTd.value.length === 1 && matchedTd.value[0].value === ZERO) {
|
|
10040
|
+
const pagingId = tableElement.pagingId;
|
|
10041
|
+
if (pagingId) {
|
|
10042
|
+
for (let i = positionResult.index - 1; i >= 0; i--) {
|
|
10043
|
+
const prevElement = elementList[i];
|
|
10044
|
+
if (prevElement.pagingId !== pagingId) break;
|
|
10045
|
+
const rootTr = prevElement.trList?.find(
|
|
10046
|
+
(r) => r.id === matchedTr.splitRootId
|
|
10047
|
+
);
|
|
10048
|
+
if (rootTr) {
|
|
10049
|
+
const rootTd = rootTr.tdList.find(
|
|
10050
|
+
(t) => t.colIndex === matchedTd.colIndex
|
|
10051
|
+
);
|
|
10052
|
+
const isRootTdEmpty = !!rootTd && rootTd.value.length === 1 && rootTd.value[0].value === ZERO;
|
|
10053
|
+
if (rootTd && isRootTdEmpty) {
|
|
10054
|
+
positionResult.index = i;
|
|
10055
|
+
positionResult.trIndex = prevElement.trList.indexOf(rootTr);
|
|
10056
|
+
positionResult.tdIndex = rootTr.tdList.indexOf(rootTd);
|
|
10057
|
+
positionResult.trId = rootTr.id;
|
|
10058
|
+
positionResult.tdId = rootTd.id;
|
|
10059
|
+
positionResult.tableId = prevElement.id;
|
|
10060
|
+
positionResult.tdValueIndex = 0;
|
|
10061
|
+
}
|
|
10062
|
+
break;
|
|
10063
|
+
}
|
|
10064
|
+
}
|
|
10065
|
+
}
|
|
10066
|
+
}
|
|
10067
|
+
}
|
|
10068
|
+
}
|
|
10069
|
+
}
|
|
9942
10070
|
const {
|
|
9943
10071
|
index,
|
|
9944
10072
|
isCheckbox,
|
|
@@ -11655,13 +11783,18 @@ var TableParticle = class {
|
|
|
11655
11783
|
ctx.beginPath();
|
|
11656
11784
|
const x = Math.round(startX);
|
|
11657
11785
|
const y = Math.round(startY);
|
|
11786
|
+
const rx = Math.round(startX + width);
|
|
11787
|
+
const ry = Math.round(startY + height);
|
|
11658
11788
|
ctx.translate(0.5, 0.5);
|
|
11659
11789
|
if (isDrawFullBorder) {
|
|
11660
|
-
ctx.rect(x, y,
|
|
11790
|
+
ctx.rect(x, y, rx - x, ry - y);
|
|
11791
|
+
} else if (borderExternalWidth) {
|
|
11792
|
+
ctx.moveTo(x, ry);
|
|
11793
|
+
ctx.lineTo(x, y);
|
|
11794
|
+
ctx.lineTo(rx, y);
|
|
11661
11795
|
} else {
|
|
11662
|
-
ctx.moveTo(x,
|
|
11796
|
+
ctx.moveTo(x, ry);
|
|
11663
11797
|
ctx.lineTo(x, y);
|
|
11664
|
-
ctx.lineTo(x + width, y);
|
|
11665
11798
|
}
|
|
11666
11799
|
ctx.stroke();
|
|
11667
11800
|
if (borderExternalWidth) {
|
|
@@ -11669,20 +11802,32 @@ var TableParticle = class {
|
|
|
11669
11802
|
}
|
|
11670
11803
|
ctx.translate(-0.5, -0.5);
|
|
11671
11804
|
}
|
|
11805
|
+
_drawHorizontalBorder(payload) {
|
|
11806
|
+
const { ctx, startX, endX, y } = payload;
|
|
11807
|
+
const x = Math.round(startX);
|
|
11808
|
+
const rx = Math.round(endX);
|
|
11809
|
+
const ty = Math.round(y);
|
|
11810
|
+
ctx.beginPath();
|
|
11811
|
+
ctx.translate(0.5, 0.5);
|
|
11812
|
+
ctx.moveTo(x, ty);
|
|
11813
|
+
ctx.lineTo(rx, ty);
|
|
11814
|
+
ctx.stroke();
|
|
11815
|
+
ctx.translate(-0.5, -0.5);
|
|
11816
|
+
}
|
|
11672
11817
|
_drawSlash(ctx, td, startX, startY) {
|
|
11673
11818
|
const { scale } = this.options;
|
|
11674
11819
|
ctx.save();
|
|
11675
|
-
const
|
|
11676
|
-
const
|
|
11677
|
-
const
|
|
11678
|
-
const
|
|
11820
|
+
const lx = Math.round(td.x * scale + startX);
|
|
11821
|
+
const ty = Math.round(td.y * scale + startY);
|
|
11822
|
+
const rx = Math.round((td.x + td.width) * scale + startX);
|
|
11823
|
+
const by = Math.round((td.y + td.height) * scale + startY);
|
|
11679
11824
|
if (td.slashTypes?.includes("forward" /* FORWARD */)) {
|
|
11680
|
-
ctx.moveTo(
|
|
11681
|
-
ctx.lineTo(
|
|
11825
|
+
ctx.moveTo(rx, ty);
|
|
11826
|
+
ctx.lineTo(lx, by);
|
|
11682
11827
|
}
|
|
11683
11828
|
if (td.slashTypes?.includes("back" /* BACK */)) {
|
|
11684
|
-
ctx.moveTo(
|
|
11685
|
-
ctx.lineTo(
|
|
11829
|
+
ctx.moveTo(lx, ty);
|
|
11830
|
+
ctx.lineTo(rx, by);
|
|
11686
11831
|
}
|
|
11687
11832
|
ctx.stroke();
|
|
11688
11833
|
ctx.restore();
|
|
@@ -11723,6 +11868,8 @@ var TableParticle = class {
|
|
|
11723
11868
|
isDrawFullBorder: isExternalBorderType
|
|
11724
11869
|
});
|
|
11725
11870
|
}
|
|
11871
|
+
const firstTr = trList[0];
|
|
11872
|
+
const lastTr = trList[trList.length - 1];
|
|
11726
11873
|
for (let t = 0; t < trList.length; t++) {
|
|
11727
11874
|
const tr = trList[t];
|
|
11728
11875
|
for (let d = 0; d < tr.tdList.length; d++) {
|
|
@@ -11733,10 +11880,10 @@ var TableParticle = class {
|
|
|
11733
11880
|
if (!td.borderTypes?.length && (isEmptyBorderType || isExternalBorderType)) {
|
|
11734
11881
|
continue;
|
|
11735
11882
|
}
|
|
11736
|
-
const
|
|
11737
|
-
const
|
|
11738
|
-
const
|
|
11739
|
-
const
|
|
11883
|
+
const lx = Math.round(td.x * scale + startX);
|
|
11884
|
+
const ty = Math.round(td.y * scale + startY);
|
|
11885
|
+
const rx = Math.round((td.x + td.width) * scale + startX);
|
|
11886
|
+
const by = Math.round((td.y + td.height) * scale + startY);
|
|
11740
11887
|
if (td.borderColor) {
|
|
11741
11888
|
ctx.save();
|
|
11742
11889
|
ctx.strokeStyle = td.borderColor;
|
|
@@ -11744,29 +11891,33 @@ var TableParticle = class {
|
|
|
11744
11891
|
ctx.translate(0.5, 0.5);
|
|
11745
11892
|
ctx.beginPath();
|
|
11746
11893
|
if (td.borderTypes?.includes("top" /* TOP */)) {
|
|
11747
|
-
ctx.moveTo(
|
|
11748
|
-
ctx.lineTo(
|
|
11894
|
+
ctx.moveTo(lx, ty);
|
|
11895
|
+
ctx.lineTo(rx, ty);
|
|
11749
11896
|
ctx.stroke();
|
|
11750
11897
|
}
|
|
11751
11898
|
if (td.borderTypes?.includes("right" /* RIGHT */)) {
|
|
11752
|
-
ctx.moveTo(
|
|
11753
|
-
ctx.lineTo(
|
|
11899
|
+
ctx.moveTo(rx, ty);
|
|
11900
|
+
ctx.lineTo(rx, by);
|
|
11754
11901
|
ctx.stroke();
|
|
11755
11902
|
}
|
|
11756
11903
|
if (td.borderTypes?.includes("bottom" /* BOTTOM */)) {
|
|
11757
|
-
ctx.moveTo(
|
|
11758
|
-
ctx.lineTo(
|
|
11904
|
+
ctx.moveTo(rx, by);
|
|
11905
|
+
ctx.lineTo(lx, by);
|
|
11759
11906
|
ctx.stroke();
|
|
11760
11907
|
}
|
|
11761
11908
|
if (td.borderTypes?.includes("left" /* LEFT */)) {
|
|
11762
|
-
ctx.moveTo(
|
|
11763
|
-
ctx.lineTo(
|
|
11909
|
+
ctx.moveTo(lx, ty);
|
|
11910
|
+
ctx.lineTo(lx, by);
|
|
11764
11911
|
ctx.stroke();
|
|
11765
11912
|
}
|
|
11766
11913
|
if (!isEmptyBorderType && !isExternalBorderType) {
|
|
11914
|
+
if (td.rowIndex === 0 && !borderExternalWidth) {
|
|
11915
|
+
ctx.moveTo(lx, ty);
|
|
11916
|
+
ctx.lineTo(rx, ty);
|
|
11917
|
+
}
|
|
11767
11918
|
if (!isInternalBorderType || td.colIndex + td.colspan < colgroup.length) {
|
|
11768
|
-
ctx.moveTo(
|
|
11769
|
-
ctx.lineTo(
|
|
11919
|
+
ctx.moveTo(rx, ty);
|
|
11920
|
+
ctx.lineTo(rx, by);
|
|
11770
11921
|
if (borderExternalWidth && borderExternalWidth !== borderWidth && td.colIndex + td.colspan === colgroup.length) {
|
|
11771
11922
|
const lineWidth = ctx.lineWidth;
|
|
11772
11923
|
ctx.lineWidth = borderExternalWidth * scale;
|
|
@@ -11776,13 +11927,14 @@ var TableParticle = class {
|
|
|
11776
11927
|
}
|
|
11777
11928
|
}
|
|
11778
11929
|
if (!isInternalBorderType || td.rowIndex + td.rowspan < trList.length) {
|
|
11779
|
-
const
|
|
11930
|
+
const isBottomEdge = td.rowIndex + td.rowspan === trList.length;
|
|
11931
|
+
const isSetExternalBottomBorder = borderExternalWidth && borderExternalWidth !== borderWidth && isBottomEdge;
|
|
11780
11932
|
if (isSetExternalBottomBorder) {
|
|
11781
11933
|
ctx.stroke();
|
|
11782
11934
|
ctx.beginPath();
|
|
11783
11935
|
}
|
|
11784
|
-
ctx.moveTo(
|
|
11785
|
-
ctx.lineTo(
|
|
11936
|
+
ctx.moveTo(rx, by);
|
|
11937
|
+
ctx.lineTo(lx, by);
|
|
11786
11938
|
if (isSetExternalBottomBorder) {
|
|
11787
11939
|
const lineWidth = ctx.lineWidth;
|
|
11788
11940
|
ctx.lineWidth = borderExternalWidth * scale;
|
|
@@ -11798,12 +11950,12 @@ var TableParticle = class {
|
|
|
11798
11950
|
ctx.translate(0.5, 0.5);
|
|
11799
11951
|
ctx.beginPath();
|
|
11800
11952
|
if (td.rowIndex === 0) {
|
|
11801
|
-
ctx.moveTo(
|
|
11802
|
-
ctx.lineTo(
|
|
11953
|
+
ctx.moveTo(lx, ty);
|
|
11954
|
+
ctx.lineTo(rx, ty);
|
|
11803
11955
|
}
|
|
11804
11956
|
if (td.colIndex === 0) {
|
|
11805
|
-
ctx.moveTo(
|
|
11806
|
-
ctx.lineTo(
|
|
11957
|
+
ctx.moveTo(lx, ty);
|
|
11958
|
+
ctx.lineTo(lx, by);
|
|
11807
11959
|
}
|
|
11808
11960
|
if (td.rowIndex === 0 || td.colIndex === 0) {
|
|
11809
11961
|
ctx.stroke();
|
|
@@ -11815,6 +11967,22 @@ var TableParticle = class {
|
|
|
11815
11967
|
}
|
|
11816
11968
|
}
|
|
11817
11969
|
}
|
|
11970
|
+
if (!isEmptyBorderType && !isExternalBorderType && !borderExternalWidth && firstTr?.splitBoundaryTop) {
|
|
11971
|
+
this._drawHorizontalBorder({
|
|
11972
|
+
ctx,
|
|
11973
|
+
startX,
|
|
11974
|
+
endX: startX + tableWidth,
|
|
11975
|
+
y: startY
|
|
11976
|
+
});
|
|
11977
|
+
}
|
|
11978
|
+
if (!isEmptyBorderType && !isExternalBorderType && !borderExternalWidth && lastTr?.splitBoundaryBottom) {
|
|
11979
|
+
this._drawHorizontalBorder({
|
|
11980
|
+
ctx,
|
|
11981
|
+
startX,
|
|
11982
|
+
endX: startX + tableWidth,
|
|
11983
|
+
y: startY + tableHeight
|
|
11984
|
+
});
|
|
11985
|
+
}
|
|
11818
11986
|
ctx.restore();
|
|
11819
11987
|
}
|
|
11820
11988
|
_drawBackgroundColor(ctx, element, startX, startY) {
|
|
@@ -11827,12 +11995,12 @@ var TableParticle = class {
|
|
|
11827
11995
|
const td = tr.tdList[d];
|
|
11828
11996
|
if (!td.backgroundColor) continue;
|
|
11829
11997
|
ctx.save();
|
|
11830
|
-
const
|
|
11831
|
-
const
|
|
11832
|
-
const
|
|
11833
|
-
const
|
|
11998
|
+
const lx = Math.round(td.x * scale + startX);
|
|
11999
|
+
const ty = Math.round(td.y * scale + startY);
|
|
12000
|
+
const rx = Math.round((td.x + td.width) * scale + startX);
|
|
12001
|
+
const by = Math.round((td.y + td.height) * scale + startY);
|
|
11834
12002
|
ctx.fillStyle = td.backgroundColor;
|
|
11835
|
-
ctx.fillRect(
|
|
12003
|
+
ctx.fillRect(lx, ty, rx - lx, by - ty);
|
|
11836
12004
|
ctx.restore();
|
|
11837
12005
|
}
|
|
11838
12006
|
}
|
|
@@ -15242,7 +15410,12 @@ var Control = class {
|
|
|
15242
15410
|
let element;
|
|
15243
15411
|
const newIndex = position.isTable ? tdValueIndex : index;
|
|
15244
15412
|
if (position.isTable) {
|
|
15245
|
-
elementList =
|
|
15413
|
+
elementList = this.draw.resolveTableCellContext(elementList, {
|
|
15414
|
+
isTable: true,
|
|
15415
|
+
index,
|
|
15416
|
+
trIndex,
|
|
15417
|
+
tdIndex
|
|
15418
|
+
})?.td.value || [];
|
|
15246
15419
|
element = elementList[tdValueIndex];
|
|
15247
15420
|
} else {
|
|
15248
15421
|
element = elementList[index];
|
|
@@ -20495,6 +20668,7 @@ var Draw = class {
|
|
|
20495
20668
|
this.intersectionPageNo = 0;
|
|
20496
20669
|
this.lazyRenderIntersectionObserver = null;
|
|
20497
20670
|
this.printModeData = null;
|
|
20671
|
+
this.pendingTableCursorIndex = void 0;
|
|
20498
20672
|
if (this.mode === "print" /* PRINT */) {
|
|
20499
20673
|
this.setPrintData();
|
|
20500
20674
|
}
|
|
@@ -20656,9 +20830,8 @@ var Draw = class {
|
|
|
20656
20830
|
getContextInnerWidth() {
|
|
20657
20831
|
const positionContext = this.position.getPositionContext();
|
|
20658
20832
|
if (positionContext.isTable) {
|
|
20659
|
-
const
|
|
20660
|
-
|
|
20661
|
-
const td = elementList[index].trList[trIndex].tdList[tdIndex];
|
|
20833
|
+
const td = this.resolveTableCellContext(this.getOriginalElementList())?.td;
|
|
20834
|
+
if (!td) return this.getColumnWidth() / this.options.scale;
|
|
20662
20835
|
const tdPadding = this.getTdPadding();
|
|
20663
20836
|
return td.width - tdPadding[1] - tdPadding[3];
|
|
20664
20837
|
}
|
|
@@ -20742,6 +20915,56 @@ var Draw = class {
|
|
|
20742
20915
|
getPage(pageNo = -1) {
|
|
20743
20916
|
return this.pageList[~pageNo ? pageNo : this.pageNo];
|
|
20744
20917
|
}
|
|
20918
|
+
resolveTableCellContext(sourceElementList = this.getOriginalElementList(), context = this.position.getPositionContext()) {
|
|
20919
|
+
if (!context.isTable) return null;
|
|
20920
|
+
const candidateIndexes = [];
|
|
20921
|
+
if (context.index !== void 0 && sourceElementList[context.index]?.type === "table" /* TABLE */) {
|
|
20922
|
+
candidateIndexes.push(context.index);
|
|
20923
|
+
}
|
|
20924
|
+
if (context.tableId) {
|
|
20925
|
+
const tableIndex = sourceElementList.findIndex((el) => el.id === context.tableId);
|
|
20926
|
+
if (~tableIndex && !candidateIndexes.includes(tableIndex)) {
|
|
20927
|
+
candidateIndexes.push(tableIndex);
|
|
20928
|
+
}
|
|
20929
|
+
}
|
|
20930
|
+
for (let i = 0; i < sourceElementList.length; i++) {
|
|
20931
|
+
const element = sourceElementList[i];
|
|
20932
|
+
if (element.type !== "table" /* TABLE */ || candidateIndexes.includes(i)) {
|
|
20933
|
+
continue;
|
|
20934
|
+
}
|
|
20935
|
+
candidateIndexes.push(i);
|
|
20936
|
+
}
|
|
20937
|
+
for (const tableIndex of candidateIndexes) {
|
|
20938
|
+
const element = sourceElementList[tableIndex];
|
|
20939
|
+
const trList = element.trList;
|
|
20940
|
+
if (!trList?.length) continue;
|
|
20941
|
+
let resolvedTrIndex = -1;
|
|
20942
|
+
if (context.trId) {
|
|
20943
|
+
resolvedTrIndex = trList.findIndex((tr) => tr.id === context.trId);
|
|
20944
|
+
}
|
|
20945
|
+
if (resolvedTrIndex < 0 && context.trIndex !== void 0 && trList[context.trIndex]) {
|
|
20946
|
+
resolvedTrIndex = context.trIndex;
|
|
20947
|
+
}
|
|
20948
|
+
if (resolvedTrIndex < 0) continue;
|
|
20949
|
+
const tdList = trList[resolvedTrIndex].tdList;
|
|
20950
|
+
let resolvedTdIndex = -1;
|
|
20951
|
+
if (context.tdId) {
|
|
20952
|
+
resolvedTdIndex = tdList.findIndex((td) => td.id === context.tdId);
|
|
20953
|
+
}
|
|
20954
|
+
if (resolvedTdIndex < 0 && context.tdIndex !== void 0 && tdList[context.tdIndex]) {
|
|
20955
|
+
resolvedTdIndex = context.tdIndex;
|
|
20956
|
+
}
|
|
20957
|
+
if (resolvedTdIndex < 0) continue;
|
|
20958
|
+
return {
|
|
20959
|
+
index: tableIndex,
|
|
20960
|
+
trIndex: resolvedTrIndex,
|
|
20961
|
+
tdIndex: resolvedTdIndex,
|
|
20962
|
+
element,
|
|
20963
|
+
td: tdList[resolvedTdIndex]
|
|
20964
|
+
};
|
|
20965
|
+
}
|
|
20966
|
+
return null;
|
|
20967
|
+
}
|
|
20745
20968
|
getPageList() {
|
|
20746
20969
|
return this.pageList;
|
|
20747
20970
|
}
|
|
@@ -20749,9 +20972,7 @@ var Draw = class {
|
|
|
20749
20972
|
return this.pageList.length;
|
|
20750
20973
|
}
|
|
20751
20974
|
getTableRowList(sourceElementList) {
|
|
20752
|
-
|
|
20753
|
-
const { index, trIndex, tdIndex } = positionContext;
|
|
20754
|
-
return sourceElementList[index].trList[trIndex].tdList[tdIndex].rowList;
|
|
20975
|
+
return this.resolveTableCellContext(sourceElementList)?.td.rowList || [];
|
|
20755
20976
|
}
|
|
20756
20977
|
getOriginalRowList() {
|
|
20757
20978
|
const zoneManager = this.getZone();
|
|
@@ -20810,9 +21031,7 @@ var Draw = class {
|
|
|
20810
21031
|
return this.header.getElementList();
|
|
20811
21032
|
}
|
|
20812
21033
|
getTableElementList(sourceElementList) {
|
|
20813
|
-
|
|
20814
|
-
const { index, trIndex, tdIndex } = positionContext;
|
|
20815
|
-
return sourceElementList[index].trList?.[trIndex].tdList[tdIndex].value || [];
|
|
21034
|
+
return this.resolveTableCellContext(sourceElementList)?.td.value || [];
|
|
20816
21035
|
}
|
|
20817
21036
|
getElementList() {
|
|
20818
21037
|
const positionContext = this.position.getPositionContext();
|
|
@@ -20840,13 +21059,7 @@ var Draw = class {
|
|
|
20840
21059
|
return this.footer.getElementList();
|
|
20841
21060
|
}
|
|
20842
21061
|
getTd() {
|
|
20843
|
-
|
|
20844
|
-
const { index, trIndex, tdIndex, isTable } = positionContext;
|
|
20845
|
-
if (isTable) {
|
|
20846
|
-
const elementList = this.getOriginalElementList();
|
|
20847
|
-
return elementList[index].trList[trIndex].tdList[tdIndex];
|
|
20848
|
-
}
|
|
20849
|
-
return null;
|
|
21062
|
+
return this.resolveTableCellContext(this.getOriginalElementList())?.td || null;
|
|
20850
21063
|
}
|
|
20851
21064
|
insertElementList(payload, options = {}) {
|
|
20852
21065
|
if (!payload.length || !this.range.getIsCanInput()) return;
|
|
@@ -21185,25 +21398,14 @@ var Draw = class {
|
|
|
21185
21398
|
setPaperSize(width, height) {
|
|
21186
21399
|
this.options.width = width;
|
|
21187
21400
|
this.options.height = height;
|
|
21188
|
-
|
|
21189
|
-
const realWidth = this.getWidth();
|
|
21190
|
-
const realHeight = this.getHeight();
|
|
21191
|
-
this.container.style.width = `${realWidth}px`;
|
|
21192
|
-
this.pageList.forEach((p, i) => {
|
|
21193
|
-
p.width = realWidth * dpr;
|
|
21194
|
-
p.height = realHeight * dpr;
|
|
21195
|
-
p.style.width = `${realWidth}px`;
|
|
21196
|
-
p.style.height = `${realHeight}px`;
|
|
21197
|
-
this._initPageContext(this.ctxList[i]);
|
|
21198
|
-
});
|
|
21199
|
-
this.render({
|
|
21200
|
-
isSubmitHistory: false,
|
|
21201
|
-
isSetCursor: false
|
|
21202
|
-
});
|
|
21401
|
+
this.refreshPageSize();
|
|
21203
21402
|
}
|
|
21204
21403
|
setPaperDirection(payload) {
|
|
21205
|
-
const dpr = this.getPagePixelRatio();
|
|
21206
21404
|
this.options.paperDirection = payload;
|
|
21405
|
+
this.refreshPageSize();
|
|
21406
|
+
}
|
|
21407
|
+
refreshPageSize() {
|
|
21408
|
+
const dpr = this.getPagePixelRatio();
|
|
21207
21409
|
const width = this.getWidth();
|
|
21208
21410
|
const height = this.getHeight();
|
|
21209
21411
|
this.container.style.width = `${width}px`;
|
|
@@ -21373,6 +21575,72 @@ var Draw = class {
|
|
|
21373
21575
|
}
|
|
21374
21576
|
return defaultBasicRowMarginHeight * ratio * (el.rowMargin ?? defaultRowMargin) * scale;
|
|
21375
21577
|
}
|
|
21578
|
+
createListStateSeed(initialListState) {
|
|
21579
|
+
const listLevelIndex = /* @__PURE__ */ new Map();
|
|
21580
|
+
if (initialListState?.listLevelIndex) {
|
|
21581
|
+
Object.entries(initialListState.listLevelIndex).forEach(
|
|
21582
|
+
([level, index]) => {
|
|
21583
|
+
listLevelIndex.set(Number(level), index);
|
|
21584
|
+
}
|
|
21585
|
+
);
|
|
21586
|
+
}
|
|
21587
|
+
return {
|
|
21588
|
+
listId: initialListState?.listId,
|
|
21589
|
+
listIndex: initialListState?.listIndex ?? 0,
|
|
21590
|
+
prevListLevel: initialListState?.prevListLevel ?? 0,
|
|
21591
|
+
listLevelIndex
|
|
21592
|
+
};
|
|
21593
|
+
}
|
|
21594
|
+
advanceListState(element, listState) {
|
|
21595
|
+
if (element.listId) {
|
|
21596
|
+
const curLevel = element.listLevel ?? 0;
|
|
21597
|
+
if (element.listId !== listState.listId) {
|
|
21598
|
+
listState.listIndex = 0;
|
|
21599
|
+
listState.listLevelIndex = /* @__PURE__ */ new Map();
|
|
21600
|
+
listState.listLevelIndex.set(curLevel, 0);
|
|
21601
|
+
listState.prevListLevel = curLevel;
|
|
21602
|
+
} else if (element.value === ZERO && !element.listWrap) {
|
|
21603
|
+
if (curLevel !== listState.prevListLevel) {
|
|
21604
|
+
if (curLevel > listState.prevListLevel) {
|
|
21605
|
+
listState.listLevelIndex.set(curLevel, 0);
|
|
21606
|
+
} else {
|
|
21607
|
+
for (const [lvl] of listState.listLevelIndex) {
|
|
21608
|
+
if (lvl > curLevel) {
|
|
21609
|
+
listState.listLevelIndex.delete(lvl);
|
|
21610
|
+
}
|
|
21611
|
+
}
|
|
21612
|
+
listState.listLevelIndex.set(
|
|
21613
|
+
curLevel,
|
|
21614
|
+
(listState.listLevelIndex.get(curLevel) ?? -1) + 1
|
|
21615
|
+
);
|
|
21616
|
+
}
|
|
21617
|
+
} else {
|
|
21618
|
+
listState.listLevelIndex.set(
|
|
21619
|
+
curLevel,
|
|
21620
|
+
(listState.listLevelIndex.get(curLevel) ?? -1) + 1
|
|
21621
|
+
);
|
|
21622
|
+
}
|
|
21623
|
+
listState.listIndex = listState.listLevelIndex.get(curLevel) ?? 0;
|
|
21624
|
+
listState.prevListLevel = curLevel;
|
|
21625
|
+
}
|
|
21626
|
+
}
|
|
21627
|
+
listState.listId = element.listId;
|
|
21628
|
+
}
|
|
21629
|
+
getListStateBeforeIndex(elementList, endExclusive) {
|
|
21630
|
+
const limit = Math.min(endExclusive, elementList.length);
|
|
21631
|
+
if (limit <= 0) return;
|
|
21632
|
+
const listState = this.createListStateSeed();
|
|
21633
|
+
for (let i = 0; i < limit; i++) {
|
|
21634
|
+
this.advanceListState(elementList[i], listState);
|
|
21635
|
+
}
|
|
21636
|
+
if (!listState.listId) return;
|
|
21637
|
+
return {
|
|
21638
|
+
listId: listState.listId,
|
|
21639
|
+
listIndex: listState.listIndex,
|
|
21640
|
+
prevListLevel: listState.prevListLevel,
|
|
21641
|
+
listLevelIndex: Object.fromEntries(listState.listLevelIndex)
|
|
21642
|
+
};
|
|
21643
|
+
}
|
|
21376
21644
|
computeRowList(payload) {
|
|
21377
21645
|
const {
|
|
21378
21646
|
innerWidth,
|
|
@@ -21383,7 +21651,8 @@ var Draw = class {
|
|
|
21383
21651
|
startY = 0,
|
|
21384
21652
|
pageHeight = 0,
|
|
21385
21653
|
mainOuterHeight = 0,
|
|
21386
|
-
surroundElementList = []
|
|
21654
|
+
surroundElementList = [],
|
|
21655
|
+
initialListState
|
|
21387
21656
|
} = payload;
|
|
21388
21657
|
const {
|
|
21389
21658
|
defaultSize,
|
|
@@ -21410,10 +21679,7 @@ var Draw = class {
|
|
|
21410
21679
|
let x = startX;
|
|
21411
21680
|
let y = startY;
|
|
21412
21681
|
let pageNo = 0;
|
|
21413
|
-
|
|
21414
|
-
let listIndex = 0;
|
|
21415
|
-
let listLevelIndex = /* @__PURE__ */ new Map();
|
|
21416
|
-
let prevListLevel = 0;
|
|
21682
|
+
const listState = this.createListStateSeed(initialListState);
|
|
21417
21683
|
let controlRealWidth = 0;
|
|
21418
21684
|
for (let i = 0; i < elementList.length; i++) {
|
|
21419
21685
|
const curRow = rowList[rowList.length - 1];
|
|
@@ -21459,6 +21725,8 @@ var Draw = class {
|
|
|
21459
21725
|
}
|
|
21460
21726
|
metrics.boundingBoxAscent = 0;
|
|
21461
21727
|
} else if (element.type === "table" /* TABLE */) {
|
|
21728
|
+
let activeSplitRange;
|
|
21729
|
+
let mergedSplitFallback;
|
|
21462
21730
|
if (element.pagingId) {
|
|
21463
21731
|
let tableIndex = i + 1;
|
|
21464
21732
|
let combineCount = 0;
|
|
@@ -21479,11 +21747,61 @@ var Draw = class {
|
|
|
21479
21747
|
if (combineCount) {
|
|
21480
21748
|
elementList.splice(i + 1, combineCount);
|
|
21481
21749
|
}
|
|
21750
|
+
const mergedTrList = element.trList;
|
|
21751
|
+
for (let t = mergedTrList.length - 1; t >= 0; t--) {
|
|
21752
|
+
const splitTr = mergedTrList[t];
|
|
21753
|
+
if (!splitTr.splitParentId) continue;
|
|
21754
|
+
const parentTrIdx = mergedTrList.findIndex(
|
|
21755
|
+
(r) => r.id === splitTr.splitParentId
|
|
21756
|
+
);
|
|
21757
|
+
if (!~parentTrIdx) continue;
|
|
21758
|
+
const parentTr = mergedTrList[parentTrIdx];
|
|
21759
|
+
const posCtx = this.position.getPositionContext();
|
|
21760
|
+
const { startIndex, endIndex } = this.range.getRange();
|
|
21761
|
+
if (posCtx.isTable && posCtx.trId === splitTr.id && startIndex === endIndex && posCtx.tdIndex !== void 0) {
|
|
21762
|
+
const splitTd = splitTr.tdList[posCtx.tdIndex];
|
|
21763
|
+
const parentTd = parentTr.tdList[posCtx.tdIndex];
|
|
21764
|
+
if (splitTd && parentTd) {
|
|
21765
|
+
const hasSyntheticLeadingZero = !!splitTd.splitSyntheticLeadingZero && splitTd.value[0]?.value === ZERO;
|
|
21766
|
+
const mergedIndex = parentTd.value.length + startIndex - (hasSyntheticLeadingZero ? 1 : 0);
|
|
21767
|
+
activeSplitRange = {
|
|
21768
|
+
tdIndex: posCtx.tdIndex,
|
|
21769
|
+
mergedIndex,
|
|
21770
|
+
trId: splitTr.id
|
|
21771
|
+
};
|
|
21772
|
+
mergedSplitFallback = {
|
|
21773
|
+
tdIndex: posCtx.tdIndex,
|
|
21774
|
+
mergedIndex,
|
|
21775
|
+
trId: splitTr.id,
|
|
21776
|
+
parentTrId: parentTr.id,
|
|
21777
|
+
parentTdId: parentTd.id,
|
|
21778
|
+
parentTrIndex: parentTrIdx
|
|
21779
|
+
};
|
|
21780
|
+
}
|
|
21781
|
+
}
|
|
21782
|
+
for (let d = 0; d < parentTr.tdList.length; d++) {
|
|
21783
|
+
const parentTd = parentTr.tdList[d];
|
|
21784
|
+
const splitTd = splitTr.tdList[d];
|
|
21785
|
+
if (!splitTd) continue;
|
|
21786
|
+
const hasSyntheticLeadingZero = !!splitTd.splitSyntheticLeadingZero && splitTd.value[0]?.value === ZERO;
|
|
21787
|
+
const splitValue = hasSyntheticLeadingZero ? splitTd.value.slice(1) : splitTd.value;
|
|
21788
|
+
parentTd.value.push(...splitValue);
|
|
21789
|
+
parentTd.rowList = void 0;
|
|
21790
|
+
parentTd.positionList = void 0;
|
|
21791
|
+
}
|
|
21792
|
+
if (posCtx.isTable && posCtx.trId === splitTr.id) {
|
|
21793
|
+
posCtx.index = i;
|
|
21794
|
+
this.position.setPositionContext(posCtx);
|
|
21795
|
+
}
|
|
21796
|
+
mergedTrList.splice(t, 1);
|
|
21797
|
+
}
|
|
21482
21798
|
}
|
|
21483
21799
|
element.pagingIndex = element.pagingIndex ?? 0;
|
|
21484
21800
|
const trList = element.trList;
|
|
21485
21801
|
for (let t = 0; t < trList.length; t++) {
|
|
21486
21802
|
const tr = trList[t];
|
|
21803
|
+
delete tr.splitBoundaryTop;
|
|
21804
|
+
delete tr.splitBoundaryBottom;
|
|
21487
21805
|
tr.height = tr.minHeight || defaultTrMinHeight;
|
|
21488
21806
|
tr.minHeight = tr.height;
|
|
21489
21807
|
}
|
|
@@ -21498,6 +21816,7 @@ var Draw = class {
|
|
|
21498
21816
|
const rowList2 = this.computeRowList({
|
|
21499
21817
|
innerWidth: (td.width - cellPaddingWidth) * scale,
|
|
21500
21818
|
elementList: td.value,
|
|
21819
|
+
initialListState: td.splitListState,
|
|
21501
21820
|
isFromTable: true,
|
|
21502
21821
|
isPagingMode
|
|
21503
21822
|
});
|
|
@@ -21580,6 +21899,7 @@ var Draw = class {
|
|
|
21580
21899
|
const tdRowList = this.computeRowList({
|
|
21581
21900
|
innerWidth: (td.width - cellPaddingWidth) * scale,
|
|
21582
21901
|
elementList: td.value,
|
|
21902
|
+
initialListState: td.splitListState,
|
|
21583
21903
|
isFromTable: true,
|
|
21584
21904
|
isPagingMode
|
|
21585
21905
|
});
|
|
@@ -21673,6 +21993,178 @@ var Draw = class {
|
|
|
21673
21993
|
}
|
|
21674
21994
|
}
|
|
21675
21995
|
}
|
|
21996
|
+
if (deleteCount === 0) {
|
|
21997
|
+
let overflowTrIdx = -1;
|
|
21998
|
+
let preHeightScaled = 0;
|
|
21999
|
+
for (let r = 0; r < trList2.length; r++) {
|
|
22000
|
+
const trHeight = trList2[r].height * scale;
|
|
22001
|
+
if (curPagePreHeight + rowMarginHeight + preHeightScaled + trHeight > height2) {
|
|
22002
|
+
overflowTrIdx = r;
|
|
22003
|
+
break;
|
|
22004
|
+
}
|
|
22005
|
+
preHeightScaled += trHeight;
|
|
22006
|
+
}
|
|
22007
|
+
if (overflowTrIdx >= 0) {
|
|
22008
|
+
const availableScaled = height2 - curPagePreHeight - rowMarginHeight - preHeightScaled;
|
|
22009
|
+
const availableUnscaled = availableScaled / scale;
|
|
22010
|
+
if (availableUnscaled >= defaultTrMinHeight) {
|
|
22011
|
+
const overflowTr = trList2[overflowTrIdx];
|
|
22012
|
+
const originalTrHeight = overflowTr.height;
|
|
22013
|
+
const {
|
|
22014
|
+
table: { tdPadding: defaultTdPadding, defaultTrMinHeight: defaultTrMinHeight2 }
|
|
22015
|
+
} = this.options;
|
|
22016
|
+
const splits = [];
|
|
22017
|
+
let anySplit = false;
|
|
22018
|
+
for (let d = 0; d < overflowTr.tdList.length; d++) {
|
|
22019
|
+
const td = overflowTr.tdList[d];
|
|
22020
|
+
const cellPadding = td.padding || defaultTdPadding;
|
|
22021
|
+
const cellPaddingH = cellPadding[0] + cellPadding[2];
|
|
22022
|
+
const contentAvailableScaled = (availableUnscaled - cellPaddingH) * scale;
|
|
22023
|
+
if (!td.rowList || td.rowList.length === 0) {
|
|
22024
|
+
splits.push({
|
|
22025
|
+
elemIdx: td.value.length,
|
|
22026
|
+
rowIdx: 0
|
|
22027
|
+
});
|
|
22028
|
+
continue;
|
|
22029
|
+
}
|
|
22030
|
+
let cumHeight = 0;
|
|
22031
|
+
let elemIdx = td.value.length;
|
|
22032
|
+
let rowIdx = td.rowList.length;
|
|
22033
|
+
for (let ri = 0; ri < td.rowList.length; ri++) {
|
|
22034
|
+
const row = td.rowList[ri];
|
|
22035
|
+
if (cumHeight + row.height > contentAvailableScaled) {
|
|
22036
|
+
elemIdx = row.startIndex;
|
|
22037
|
+
rowIdx = ri;
|
|
22038
|
+
break;
|
|
22039
|
+
}
|
|
22040
|
+
cumHeight += row.height;
|
|
22041
|
+
}
|
|
22042
|
+
if (elemIdx > 0 && elemIdx < td.value.length) {
|
|
22043
|
+
anySplit = true;
|
|
22044
|
+
}
|
|
22045
|
+
splits.push({ elemIdx, rowIdx });
|
|
22046
|
+
}
|
|
22047
|
+
if (anySplit) {
|
|
22048
|
+
if (!activeSplitRange) {
|
|
22049
|
+
const posCtx = this.position.getPositionContext();
|
|
22050
|
+
const { startIndex, endIndex } = this.range.getRange();
|
|
22051
|
+
if (posCtx.isTable && posCtx.trId === overflowTr.id && startIndex === endIndex && posCtx.tdIndex !== void 0) {
|
|
22052
|
+
const splitIdx = splits[posCtx.tdIndex]?.elemIdx;
|
|
22053
|
+
if (splitIdx !== void 0 && startIndex >= splitIdx && splitIdx < overflowTr.tdList[posCtx.tdIndex].value.length) {
|
|
22054
|
+
activeSplitRange = {
|
|
22055
|
+
tdIndex: posCtx.tdIndex,
|
|
22056
|
+
mergedIndex: startIndex,
|
|
22057
|
+
trId: overflowTr.id
|
|
22058
|
+
};
|
|
22059
|
+
}
|
|
22060
|
+
}
|
|
22061
|
+
}
|
|
22062
|
+
const continuationTrHeight = originalTrHeight - availableUnscaled;
|
|
22063
|
+
const splitRootId = overflowTr.splitRootId || overflowTr.id;
|
|
22064
|
+
const splitLevel = (overflowTr.splitLevel || 0) + 1;
|
|
22065
|
+
const newTrId = `${splitRootId}_c${splitLevel}`;
|
|
22066
|
+
const continuationTdList = overflowTr.tdList.map(
|
|
22067
|
+
(td, d) => {
|
|
22068
|
+
const splitIdx = splits[d].elemIdx;
|
|
22069
|
+
const initialListState2 = this.getListStateBeforeIndex(
|
|
22070
|
+
td.value,
|
|
22071
|
+
splitIdx
|
|
22072
|
+
);
|
|
22073
|
+
const overflowElements = deepClone(
|
|
22074
|
+
td.value.slice(splitIdx)
|
|
22075
|
+
);
|
|
22076
|
+
const overflowStartElement = overflowElements[0];
|
|
22077
|
+
let splitSyntheticLeadingZero = false;
|
|
22078
|
+
if (!overflowElements.length || overflowElements[0]?.value !== ZERO) {
|
|
22079
|
+
overflowElements.unshift({
|
|
22080
|
+
value: ZERO,
|
|
22081
|
+
type: "text" /* TEXT */,
|
|
22082
|
+
listId: overflowStartElement?.listId,
|
|
22083
|
+
listType: overflowStartElement?.listType,
|
|
22084
|
+
listStyle: overflowStartElement?.listStyle,
|
|
22085
|
+
listLevel: overflowStartElement?.listLevel,
|
|
22086
|
+
listPreset: overflowStartElement?.listPreset,
|
|
22087
|
+
listWrap: !!overflowStartElement?.listId
|
|
22088
|
+
});
|
|
22089
|
+
splitSyntheticLeadingZero = true;
|
|
22090
|
+
}
|
|
22091
|
+
const {
|
|
22092
|
+
value: _v,
|
|
22093
|
+
rowList: _rl,
|
|
22094
|
+
positionList: _pl,
|
|
22095
|
+
splitSyntheticLeadingZero: _slz,
|
|
22096
|
+
splitListState: _sls,
|
|
22097
|
+
...tdMeta
|
|
22098
|
+
} = td;
|
|
22099
|
+
return {
|
|
22100
|
+
...deepClone(tdMeta),
|
|
22101
|
+
value: overflowElements,
|
|
22102
|
+
splitSyntheticLeadingZero,
|
|
22103
|
+
splitListState: initialListState2,
|
|
22104
|
+
height: continuationTrHeight,
|
|
22105
|
+
rowList: void 0,
|
|
22106
|
+
positionList: void 0,
|
|
22107
|
+
mainHeight: void 0,
|
|
22108
|
+
realHeight: void 0,
|
|
22109
|
+
realMinHeight: void 0
|
|
22110
|
+
};
|
|
22111
|
+
}
|
|
22112
|
+
);
|
|
22113
|
+
const continuationTr = {
|
|
22114
|
+
id: newTrId,
|
|
22115
|
+
height: continuationTrHeight,
|
|
22116
|
+
minHeight: defaultTrMinHeight2,
|
|
22117
|
+
tdList: continuationTdList,
|
|
22118
|
+
splitParentId: overflowTr.id,
|
|
22119
|
+
splitRootId,
|
|
22120
|
+
splitLevel
|
|
22121
|
+
};
|
|
22122
|
+
const positionContext = this.position.getPositionContext();
|
|
22123
|
+
if (activeSplitRange && positionContext.isTable && positionContext.trId === activeSplitRange.trId) {
|
|
22124
|
+
const splitIdx = splits[activeSplitRange.tdIndex]?.elemIdx;
|
|
22125
|
+
const continuationTd = continuationTdList[activeSplitRange.tdIndex];
|
|
22126
|
+
if (splitIdx !== void 0 && continuationTd && activeSplitRange.mergedIndex >= splitIdx) {
|
|
22127
|
+
const hasPrependedZero = !!continuationTd.splitSyntheticLeadingZero && continuationTd.value[0]?.value === ZERO;
|
|
22128
|
+
const continuationCursorIndex = activeSplitRange.mergedIndex - splitIdx + (hasPrependedZero ? 1 : 0);
|
|
22129
|
+
positionContext.index = i;
|
|
22130
|
+
positionContext.trIndex = overflowTrIdx + 1;
|
|
22131
|
+
positionContext.tdIndex = activeSplitRange.tdIndex;
|
|
22132
|
+
positionContext.tdId = continuationTd.id;
|
|
22133
|
+
positionContext.trId = continuationTr.id;
|
|
22134
|
+
positionContext.tableId = element.id;
|
|
22135
|
+
this.position.setPositionContext(positionContext);
|
|
22136
|
+
this.range.setRange(
|
|
22137
|
+
continuationCursorIndex,
|
|
22138
|
+
continuationCursorIndex
|
|
22139
|
+
);
|
|
22140
|
+
this.pendingTableCursorIndex = continuationCursorIndex;
|
|
22141
|
+
}
|
|
22142
|
+
}
|
|
22143
|
+
for (let d = 0; d < overflowTr.tdList.length; d++) {
|
|
22144
|
+
const td = overflowTr.tdList[d];
|
|
22145
|
+
const { elemIdx, rowIdx } = splits[d];
|
|
22146
|
+
td.value = td.value.slice(0, elemIdx);
|
|
22147
|
+
td.rowList = td.rowList ? td.rowList.slice(0, rowIdx) : void 0;
|
|
22148
|
+
td.positionList = void 0;
|
|
22149
|
+
td.height = availableUnscaled;
|
|
22150
|
+
td.mainHeight = void 0;
|
|
22151
|
+
td.realHeight = void 0;
|
|
22152
|
+
td.realMinHeight = void 0;
|
|
22153
|
+
}
|
|
22154
|
+
overflowTr.height = availableUnscaled;
|
|
22155
|
+
overflowTr.minHeight = Math.min(
|
|
22156
|
+
overflowTr.minHeight || defaultTrMinHeight2,
|
|
22157
|
+
availableUnscaled
|
|
22158
|
+
);
|
|
22159
|
+
overflowTr.splitBoundaryBottom = true;
|
|
22160
|
+
continuationTr.splitBoundaryTop = true;
|
|
22161
|
+
trList2.splice(overflowTrIdx + 1, 0, continuationTr);
|
|
22162
|
+
deleteStart = overflowTrIdx + 1;
|
|
22163
|
+
deleteCount = trList2.length - deleteStart;
|
|
22164
|
+
}
|
|
22165
|
+
}
|
|
22166
|
+
}
|
|
22167
|
+
}
|
|
21676
22168
|
if (deleteCount) {
|
|
21677
22169
|
const cloneTrList = trList2.splice(deleteStart, deleteCount);
|
|
21678
22170
|
const cloneTrHeight = cloneTrList.reduce(
|
|
@@ -21722,6 +22214,21 @@ var Draw = class {
|
|
|
21722
22214
|
positionContext.index = newPositionContextIndex;
|
|
21723
22215
|
positionContext.trIndex = newPositionContextTrIndex;
|
|
21724
22216
|
this.position.setPositionContext(positionContext);
|
|
22217
|
+
} else if (mergedSplitFallback && positionContext.trId === mergedSplitFallback.trId) {
|
|
22218
|
+
const fallbackTd = element.trList?.[mergedSplitFallback.parentTrIndex]?.tdList[mergedSplitFallback.tdIndex];
|
|
22219
|
+
const fallbackCursorIndex = Math.min(
|
|
22220
|
+
mergedSplitFallback.mergedIndex,
|
|
22221
|
+
Math.max((fallbackTd?.value.length || 1) - 1, 0)
|
|
22222
|
+
);
|
|
22223
|
+
positionContext.index = i;
|
|
22224
|
+
positionContext.trIndex = mergedSplitFallback.parentTrIndex;
|
|
22225
|
+
positionContext.tdIndex = mergedSplitFallback.tdIndex;
|
|
22226
|
+
positionContext.tdId = mergedSplitFallback.parentTdId;
|
|
22227
|
+
positionContext.trId = mergedSplitFallback.parentTrId;
|
|
22228
|
+
positionContext.tableId = element.id;
|
|
22229
|
+
this.position.setPositionContext(positionContext);
|
|
22230
|
+
this.range.setRange(fallbackCursorIndex, fallbackCursorIndex);
|
|
22231
|
+
this.pendingTableCursorIndex = fallbackCursorIndex;
|
|
21725
22232
|
}
|
|
21726
22233
|
}
|
|
21727
22234
|
}
|
|
@@ -21854,39 +22361,7 @@ var Draw = class {
|
|
|
21854
22361
|
curRowWidth += punctuationWidth * scale;
|
|
21855
22362
|
}
|
|
21856
22363
|
}
|
|
21857
|
-
|
|
21858
|
-
const curLevel = element.listLevel ?? 0;
|
|
21859
|
-
if (element.listId !== listId) {
|
|
21860
|
-
listIndex = 0;
|
|
21861
|
-
listLevelIndex = /* @__PURE__ */ new Map();
|
|
21862
|
-
listLevelIndex.set(curLevel, 0);
|
|
21863
|
-
prevListLevel = curLevel;
|
|
21864
|
-
} else if (element.value === ZERO && !element.listWrap) {
|
|
21865
|
-
if (curLevel !== prevListLevel) {
|
|
21866
|
-
if (curLevel > prevListLevel) {
|
|
21867
|
-
listLevelIndex.set(curLevel, 0);
|
|
21868
|
-
} else {
|
|
21869
|
-
for (const [lvl] of listLevelIndex) {
|
|
21870
|
-
if (lvl > curLevel) {
|
|
21871
|
-
listLevelIndex.delete(lvl);
|
|
21872
|
-
}
|
|
21873
|
-
}
|
|
21874
|
-
listLevelIndex.set(
|
|
21875
|
-
curLevel,
|
|
21876
|
-
(listLevelIndex.get(curLevel) ?? -1) + 1
|
|
21877
|
-
);
|
|
21878
|
-
}
|
|
21879
|
-
} else {
|
|
21880
|
-
listLevelIndex.set(
|
|
21881
|
-
curLevel,
|
|
21882
|
-
(listLevelIndex.get(curLevel) ?? -1) + 1
|
|
21883
|
-
);
|
|
21884
|
-
}
|
|
21885
|
-
listIndex = listLevelIndex.get(curLevel) ?? 0;
|
|
21886
|
-
prevListLevel = curLevel;
|
|
21887
|
-
}
|
|
21888
|
-
}
|
|
21889
|
-
listId = element.listId;
|
|
22364
|
+
this.advanceListState(element, listState);
|
|
21890
22365
|
const surroundPosition = this.position.setSurroundPosition({
|
|
21891
22366
|
pageNo,
|
|
21892
22367
|
rowElement,
|
|
@@ -21938,7 +22413,7 @@ var Draw = class {
|
|
|
21938
22413
|
const baseListOffset = listStyleMap.get(element.listId) || 0;
|
|
21939
22414
|
const rowListIndent = this.listParticle.getListIndentWidth(element);
|
|
21940
22415
|
row.offsetX = baseListOffset + rowListIndent;
|
|
21941
|
-
row.listIndex = listIndex;
|
|
22416
|
+
row.listIndex = listState.listIndex;
|
|
21942
22417
|
}
|
|
21943
22418
|
row.offsetY = !isFromTable && element.area?.top && element.areaId !== elementList[i - 1]?.areaId ? element.area.top * scale : 0;
|
|
21944
22419
|
rowList.push(row);
|
|
@@ -22607,6 +23082,7 @@ var Draw = class {
|
|
|
22607
23082
|
isFirstRender = false
|
|
22608
23083
|
} = payload || {};
|
|
22609
23084
|
let { curIndex } = payload || {};
|
|
23085
|
+
this.pendingTableCursorIndex = void 0;
|
|
22610
23086
|
const innerWidth = this.getInnerWidth();
|
|
22611
23087
|
const columnWidth = this.getColumnWidth();
|
|
22612
23088
|
const isPagingMode = this.getIsPagingMode();
|
|
@@ -22672,6 +23148,10 @@ var Draw = class {
|
|
|
22672
23148
|
} else {
|
|
22673
23149
|
this._immediateRender();
|
|
22674
23150
|
}
|
|
23151
|
+
if (this.pendingTableCursorIndex !== void 0) {
|
|
23152
|
+
curIndex = this.pendingTableCursorIndex;
|
|
23153
|
+
this.pendingTableCursorIndex = void 0;
|
|
23154
|
+
}
|
|
22675
23155
|
if (isSetCursor) {
|
|
22676
23156
|
curIndex = this.setCursor(curIndex);
|
|
22677
23157
|
} else if (this.range.getIsSelection()) {
|
|
@@ -22713,9 +23193,7 @@ var Draw = class {
|
|
|
22713
23193
|
const positionContext = this.position.getPositionContext();
|
|
22714
23194
|
const positionList = this.position.getPositionList();
|
|
22715
23195
|
if (positionContext.isTable) {
|
|
22716
|
-
const
|
|
22717
|
-
const elementList = this.getOriginalElementList();
|
|
22718
|
-
const tablePositionList = elementList[index].trList?.[trIndex].tdList[tdIndex].positionList;
|
|
23196
|
+
const tablePositionList = this.resolveTableCellContext(this.getOriginalElementList())?.td.positionList;
|
|
22719
23197
|
if (curIndex === void 0 && tablePositionList) {
|
|
22720
23198
|
curIndex = tablePositionList.length - 1;
|
|
22721
23199
|
}
|
|
@@ -24866,7 +25344,12 @@ var CommandAdapt = class {
|
|
|
24866
25344
|
Object.keys(payload).forEach((key) => {
|
|
24867
25345
|
Reflect.set(this.options, key, newOption[key]);
|
|
24868
25346
|
});
|
|
24869
|
-
|
|
25347
|
+
const layoutKeys = ["paperDirection", "width", "height"];
|
|
25348
|
+
if (layoutKeys.some((k) => k in payload)) {
|
|
25349
|
+
this.draw.refreshPageSize();
|
|
25350
|
+
} else {
|
|
25351
|
+
this.forceUpdate();
|
|
25352
|
+
}
|
|
24870
25353
|
const { scale, paperDirection, width, height } = this.options;
|
|
24871
25354
|
this.draw.getListener().optionsChange?.({ scale, paperDirection, width, height });
|
|
24872
25355
|
}
|