@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.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var version = "0.3.
|
|
2
|
+
var version = "0.3.21";
|
|
3
3
|
|
|
4
4
|
// src/dataset/enum/Common.ts
|
|
5
5
|
var MaxHeightRatio = /* @__PURE__ */ ((MaxHeightRatio2) => {
|
|
@@ -7324,6 +7324,71 @@ function mousemove(evt, host) {
|
|
|
7324
7324
|
});
|
|
7325
7325
|
}
|
|
7326
7326
|
|
|
7327
|
+
// src/core/event/handlers/keydown/tableSplit.ts
|
|
7328
|
+
function moveEmptySplitTdCursorToParent(host) {
|
|
7329
|
+
const draw = host.getDraw();
|
|
7330
|
+
const position = draw.getPosition();
|
|
7331
|
+
const positionContext = position.getPositionContext();
|
|
7332
|
+
const cursorPosition = position.getCursorPosition();
|
|
7333
|
+
if (!positionContext.isTable || !cursorPosition || cursorPosition.index !== 0) {
|
|
7334
|
+
return null;
|
|
7335
|
+
}
|
|
7336
|
+
const elementList = draw.getOriginalElementList();
|
|
7337
|
+
const resolved = draw.resolveTableCellContext(elementList, positionContext);
|
|
7338
|
+
if (!resolved) return null;
|
|
7339
|
+
const currentTr = resolved.element.trList?.[resolved.trIndex];
|
|
7340
|
+
const currentTd = resolved.td;
|
|
7341
|
+
if (!currentTr?.splitParentId || currentTd.value.length !== 1 || currentTd.value[0]?.value !== ZERO) {
|
|
7342
|
+
return null;
|
|
7343
|
+
}
|
|
7344
|
+
const pagingId = resolved.element.pagingId;
|
|
7345
|
+
if (!pagingId) return null;
|
|
7346
|
+
let parentTarget;
|
|
7347
|
+
for (let i = resolved.index; i >= 0; i--) {
|
|
7348
|
+
const tableElement = elementList[i];
|
|
7349
|
+
if (tableElement.type !== "table" /* TABLE */) continue;
|
|
7350
|
+
if (tableElement.pagingId !== pagingId) {
|
|
7351
|
+
if (i < resolved.index) break;
|
|
7352
|
+
continue;
|
|
7353
|
+
}
|
|
7354
|
+
const parentTrIndex = tableElement.trList?.findIndex((tr) => tr.id === currentTr.splitParentId) ?? -1;
|
|
7355
|
+
if (parentTrIndex < 0) continue;
|
|
7356
|
+
const parentTr2 = tableElement.trList[parentTrIndex];
|
|
7357
|
+
const parentTdIndex = parentTr2.tdList.findIndex(
|
|
7358
|
+
(td) => td.colIndex === currentTd.colIndex
|
|
7359
|
+
);
|
|
7360
|
+
if (parentTdIndex < 0) return null;
|
|
7361
|
+
parentTarget = {
|
|
7362
|
+
tableId: tableElement.id,
|
|
7363
|
+
tableIndex: i,
|
|
7364
|
+
trIndex: parentTrIndex,
|
|
7365
|
+
tdIndex: parentTdIndex
|
|
7366
|
+
};
|
|
7367
|
+
break;
|
|
7368
|
+
}
|
|
7369
|
+
if (!parentTarget) return null;
|
|
7370
|
+
const parentElement = elementList[parentTarget.tableIndex];
|
|
7371
|
+
const parentTr = parentElement.trList[parentTarget.trIndex];
|
|
7372
|
+
const parentTd = parentTr.tdList[parentTarget.tdIndex];
|
|
7373
|
+
if (!currentTd.splitSyntheticLeadingZero) {
|
|
7374
|
+
currentTd.value.splice(0, 1);
|
|
7375
|
+
currentTd.rowList = void 0;
|
|
7376
|
+
currentTd.positionList = void 0;
|
|
7377
|
+
}
|
|
7378
|
+
const curIndex = Math.max(parentTd.value.length - 1, 0);
|
|
7379
|
+
position.setPositionContext({
|
|
7380
|
+
isTable: true,
|
|
7381
|
+
index: parentTarget.tableIndex,
|
|
7382
|
+
trIndex: parentTarget.trIndex,
|
|
7383
|
+
tdIndex: parentTarget.tdIndex,
|
|
7384
|
+
tdId: parentTd.id,
|
|
7385
|
+
trId: parentTr.id,
|
|
7386
|
+
tableId: parentTarget.tableId
|
|
7387
|
+
});
|
|
7388
|
+
draw.getRange().setRange(curIndex, curIndex);
|
|
7389
|
+
return curIndex;
|
|
7390
|
+
}
|
|
7391
|
+
|
|
7327
7392
|
// src/core/event/handlers/keydown/backspace.ts
|
|
7328
7393
|
function backspaceHideElement(host) {
|
|
7329
7394
|
const draw = host.getDraw();
|
|
@@ -7365,6 +7430,18 @@ function backspace(evt, host) {
|
|
|
7365
7430
|
if (draw.isReadonly()) return;
|
|
7366
7431
|
const rangeManager = draw.getRange();
|
|
7367
7432
|
if (!rangeManager.getIsCanInput()) return;
|
|
7433
|
+
if (rangeManager.getIsCollapsed()) {
|
|
7434
|
+
const splitParentIndex = moveEmptySplitTdCursorToParent(host);
|
|
7435
|
+
if (splitParentIndex !== null) {
|
|
7436
|
+
draw.getGlobalEvent().setCanvasEventAbility();
|
|
7437
|
+
draw.render({
|
|
7438
|
+
curIndex: splitParentIndex,
|
|
7439
|
+
isSubmitHistory: false
|
|
7440
|
+
});
|
|
7441
|
+
evt.preventDefault();
|
|
7442
|
+
return;
|
|
7443
|
+
}
|
|
7444
|
+
}
|
|
7368
7445
|
if (rangeManager.getIsCollapsed()) {
|
|
7369
7446
|
backspaceHideElement(host);
|
|
7370
7447
|
}
|
|
@@ -7510,6 +7587,18 @@ function del(evt, host) {
|
|
|
7510
7587
|
if (draw.isReadonly()) return;
|
|
7511
7588
|
const rangeManager = draw.getRange();
|
|
7512
7589
|
if (!rangeManager.getIsCanInput()) return;
|
|
7590
|
+
if (rangeManager.getIsCollapsed()) {
|
|
7591
|
+
const splitParentIndex = moveEmptySplitTdCursorToParent(host);
|
|
7592
|
+
if (splitParentIndex !== null) {
|
|
7593
|
+
draw.getGlobalEvent().setCanvasEventAbility();
|
|
7594
|
+
draw.render({
|
|
7595
|
+
curIndex: splitParentIndex,
|
|
7596
|
+
isSubmitHistory: false
|
|
7597
|
+
});
|
|
7598
|
+
evt.preventDefault();
|
|
7599
|
+
return;
|
|
7600
|
+
}
|
|
7601
|
+
}
|
|
7513
7602
|
const { startIndex, endIndex, isCrossRowCol } = rangeManager.getRange();
|
|
7514
7603
|
const elementList = draw.getElementList();
|
|
7515
7604
|
const control = draw.getControl();
|
|
@@ -9205,8 +9294,7 @@ var Position = class {
|
|
|
9205
9294
|
return this.floatPositionList;
|
|
9206
9295
|
}
|
|
9207
9296
|
getTablePositionList(sourceElementList) {
|
|
9208
|
-
|
|
9209
|
-
return sourceElementList[index].trList[trIndex].tdList[tdIndex].positionList || [];
|
|
9297
|
+
return this.draw.resolveTableCellContext(sourceElementList, this.positionContext)?.td.positionList || [];
|
|
9210
9298
|
}
|
|
9211
9299
|
getPositionList() {
|
|
9212
9300
|
return this.positionContext.isTable ? this.getTablePositionList(this.draw.getOriginalElementList()) : this.getOriginalPositionList();
|
|
@@ -9860,6 +9948,46 @@ var Position = class {
|
|
|
9860
9948
|
positionResult.index = newIndex;
|
|
9861
9949
|
}
|
|
9862
9950
|
}
|
|
9951
|
+
if (positionResult.isTable && positionResult.trId != null) {
|
|
9952
|
+
const elementList = this.draw.getOriginalMainElementList();
|
|
9953
|
+
const tableElement = elementList[positionResult.index];
|
|
9954
|
+
if (tableElement?.trList) {
|
|
9955
|
+
const matchedTr = tableElement.trList.find(
|
|
9956
|
+
(r) => r.id === positionResult.trId
|
|
9957
|
+
);
|
|
9958
|
+
if (matchedTr?.splitRootId) {
|
|
9959
|
+
const matchedTd = matchedTr.tdList[positionResult.tdIndex];
|
|
9960
|
+
if (matchedTd && matchedTd.splitSyntheticLeadingZero && matchedTd.value.length === 1 && matchedTd.value[0].value === ZERO) {
|
|
9961
|
+
const pagingId = tableElement.pagingId;
|
|
9962
|
+
if (pagingId) {
|
|
9963
|
+
for (let i = positionResult.index - 1; i >= 0; i--) {
|
|
9964
|
+
const prevElement = elementList[i];
|
|
9965
|
+
if (prevElement.pagingId !== pagingId) break;
|
|
9966
|
+
const rootTr = prevElement.trList?.find(
|
|
9967
|
+
(r) => r.id === matchedTr.splitRootId
|
|
9968
|
+
);
|
|
9969
|
+
if (rootTr) {
|
|
9970
|
+
const rootTd = rootTr.tdList.find(
|
|
9971
|
+
(t) => t.colIndex === matchedTd.colIndex
|
|
9972
|
+
);
|
|
9973
|
+
const isRootTdEmpty = !!rootTd && rootTd.value.length === 1 && rootTd.value[0].value === ZERO;
|
|
9974
|
+
if (rootTd && isRootTdEmpty) {
|
|
9975
|
+
positionResult.index = i;
|
|
9976
|
+
positionResult.trIndex = prevElement.trList.indexOf(rootTr);
|
|
9977
|
+
positionResult.tdIndex = rootTr.tdList.indexOf(rootTd);
|
|
9978
|
+
positionResult.trId = rootTr.id;
|
|
9979
|
+
positionResult.tdId = rootTd.id;
|
|
9980
|
+
positionResult.tableId = prevElement.id;
|
|
9981
|
+
positionResult.tdValueIndex = 0;
|
|
9982
|
+
}
|
|
9983
|
+
break;
|
|
9984
|
+
}
|
|
9985
|
+
}
|
|
9986
|
+
}
|
|
9987
|
+
}
|
|
9988
|
+
}
|
|
9989
|
+
}
|
|
9990
|
+
}
|
|
9863
9991
|
const {
|
|
9864
9992
|
index,
|
|
9865
9993
|
isCheckbox,
|
|
@@ -11576,13 +11704,18 @@ var TableParticle = class {
|
|
|
11576
11704
|
ctx.beginPath();
|
|
11577
11705
|
const x = Math.round(startX);
|
|
11578
11706
|
const y = Math.round(startY);
|
|
11707
|
+
const rx = Math.round(startX + width);
|
|
11708
|
+
const ry = Math.round(startY + height);
|
|
11579
11709
|
ctx.translate(0.5, 0.5);
|
|
11580
11710
|
if (isDrawFullBorder) {
|
|
11581
|
-
ctx.rect(x, y,
|
|
11711
|
+
ctx.rect(x, y, rx - x, ry - y);
|
|
11712
|
+
} else if (borderExternalWidth) {
|
|
11713
|
+
ctx.moveTo(x, ry);
|
|
11714
|
+
ctx.lineTo(x, y);
|
|
11715
|
+
ctx.lineTo(rx, y);
|
|
11582
11716
|
} else {
|
|
11583
|
-
ctx.moveTo(x,
|
|
11717
|
+
ctx.moveTo(x, ry);
|
|
11584
11718
|
ctx.lineTo(x, y);
|
|
11585
|
-
ctx.lineTo(x + width, y);
|
|
11586
11719
|
}
|
|
11587
11720
|
ctx.stroke();
|
|
11588
11721
|
if (borderExternalWidth) {
|
|
@@ -11590,20 +11723,32 @@ var TableParticle = class {
|
|
|
11590
11723
|
}
|
|
11591
11724
|
ctx.translate(-0.5, -0.5);
|
|
11592
11725
|
}
|
|
11726
|
+
_drawHorizontalBorder(payload) {
|
|
11727
|
+
const { ctx, startX, endX, y } = payload;
|
|
11728
|
+
const x = Math.round(startX);
|
|
11729
|
+
const rx = Math.round(endX);
|
|
11730
|
+
const ty = Math.round(y);
|
|
11731
|
+
ctx.beginPath();
|
|
11732
|
+
ctx.translate(0.5, 0.5);
|
|
11733
|
+
ctx.moveTo(x, ty);
|
|
11734
|
+
ctx.lineTo(rx, ty);
|
|
11735
|
+
ctx.stroke();
|
|
11736
|
+
ctx.translate(-0.5, -0.5);
|
|
11737
|
+
}
|
|
11593
11738
|
_drawSlash(ctx, td, startX, startY) {
|
|
11594
11739
|
const { scale } = this.options;
|
|
11595
11740
|
ctx.save();
|
|
11596
|
-
const
|
|
11597
|
-
const
|
|
11598
|
-
const
|
|
11599
|
-
const
|
|
11741
|
+
const lx = Math.round(td.x * scale + startX);
|
|
11742
|
+
const ty = Math.round(td.y * scale + startY);
|
|
11743
|
+
const rx = Math.round((td.x + td.width) * scale + startX);
|
|
11744
|
+
const by = Math.round((td.y + td.height) * scale + startY);
|
|
11600
11745
|
if (td.slashTypes?.includes("forward" /* FORWARD */)) {
|
|
11601
|
-
ctx.moveTo(
|
|
11602
|
-
ctx.lineTo(
|
|
11746
|
+
ctx.moveTo(rx, ty);
|
|
11747
|
+
ctx.lineTo(lx, by);
|
|
11603
11748
|
}
|
|
11604
11749
|
if (td.slashTypes?.includes("back" /* BACK */)) {
|
|
11605
|
-
ctx.moveTo(
|
|
11606
|
-
ctx.lineTo(
|
|
11750
|
+
ctx.moveTo(lx, ty);
|
|
11751
|
+
ctx.lineTo(rx, by);
|
|
11607
11752
|
}
|
|
11608
11753
|
ctx.stroke();
|
|
11609
11754
|
ctx.restore();
|
|
@@ -11644,6 +11789,8 @@ var TableParticle = class {
|
|
|
11644
11789
|
isDrawFullBorder: isExternalBorderType
|
|
11645
11790
|
});
|
|
11646
11791
|
}
|
|
11792
|
+
const firstTr = trList[0];
|
|
11793
|
+
const lastTr = trList[trList.length - 1];
|
|
11647
11794
|
for (let t = 0; t < trList.length; t++) {
|
|
11648
11795
|
const tr = trList[t];
|
|
11649
11796
|
for (let d = 0; d < tr.tdList.length; d++) {
|
|
@@ -11654,10 +11801,10 @@ var TableParticle = class {
|
|
|
11654
11801
|
if (!td.borderTypes?.length && (isEmptyBorderType || isExternalBorderType)) {
|
|
11655
11802
|
continue;
|
|
11656
11803
|
}
|
|
11657
|
-
const
|
|
11658
|
-
const
|
|
11659
|
-
const
|
|
11660
|
-
const
|
|
11804
|
+
const lx = Math.round(td.x * scale + startX);
|
|
11805
|
+
const ty = Math.round(td.y * scale + startY);
|
|
11806
|
+
const rx = Math.round((td.x + td.width) * scale + startX);
|
|
11807
|
+
const by = Math.round((td.y + td.height) * scale + startY);
|
|
11661
11808
|
if (td.borderColor) {
|
|
11662
11809
|
ctx.save();
|
|
11663
11810
|
ctx.strokeStyle = td.borderColor;
|
|
@@ -11665,29 +11812,33 @@ var TableParticle = class {
|
|
|
11665
11812
|
ctx.translate(0.5, 0.5);
|
|
11666
11813
|
ctx.beginPath();
|
|
11667
11814
|
if (td.borderTypes?.includes("top" /* TOP */)) {
|
|
11668
|
-
ctx.moveTo(
|
|
11669
|
-
ctx.lineTo(
|
|
11815
|
+
ctx.moveTo(lx, ty);
|
|
11816
|
+
ctx.lineTo(rx, ty);
|
|
11670
11817
|
ctx.stroke();
|
|
11671
11818
|
}
|
|
11672
11819
|
if (td.borderTypes?.includes("right" /* RIGHT */)) {
|
|
11673
|
-
ctx.moveTo(
|
|
11674
|
-
ctx.lineTo(
|
|
11820
|
+
ctx.moveTo(rx, ty);
|
|
11821
|
+
ctx.lineTo(rx, by);
|
|
11675
11822
|
ctx.stroke();
|
|
11676
11823
|
}
|
|
11677
11824
|
if (td.borderTypes?.includes("bottom" /* BOTTOM */)) {
|
|
11678
|
-
ctx.moveTo(
|
|
11679
|
-
ctx.lineTo(
|
|
11825
|
+
ctx.moveTo(rx, by);
|
|
11826
|
+
ctx.lineTo(lx, by);
|
|
11680
11827
|
ctx.stroke();
|
|
11681
11828
|
}
|
|
11682
11829
|
if (td.borderTypes?.includes("left" /* LEFT */)) {
|
|
11683
|
-
ctx.moveTo(
|
|
11684
|
-
ctx.lineTo(
|
|
11830
|
+
ctx.moveTo(lx, ty);
|
|
11831
|
+
ctx.lineTo(lx, by);
|
|
11685
11832
|
ctx.stroke();
|
|
11686
11833
|
}
|
|
11687
11834
|
if (!isEmptyBorderType && !isExternalBorderType) {
|
|
11835
|
+
if (td.rowIndex === 0 && !borderExternalWidth) {
|
|
11836
|
+
ctx.moveTo(lx, ty);
|
|
11837
|
+
ctx.lineTo(rx, ty);
|
|
11838
|
+
}
|
|
11688
11839
|
if (!isInternalBorderType || td.colIndex + td.colspan < colgroup.length) {
|
|
11689
|
-
ctx.moveTo(
|
|
11690
|
-
ctx.lineTo(
|
|
11840
|
+
ctx.moveTo(rx, ty);
|
|
11841
|
+
ctx.lineTo(rx, by);
|
|
11691
11842
|
if (borderExternalWidth && borderExternalWidth !== borderWidth && td.colIndex + td.colspan === colgroup.length) {
|
|
11692
11843
|
const lineWidth = ctx.lineWidth;
|
|
11693
11844
|
ctx.lineWidth = borderExternalWidth * scale;
|
|
@@ -11697,13 +11848,14 @@ var TableParticle = class {
|
|
|
11697
11848
|
}
|
|
11698
11849
|
}
|
|
11699
11850
|
if (!isInternalBorderType || td.rowIndex + td.rowspan < trList.length) {
|
|
11700
|
-
const
|
|
11851
|
+
const isBottomEdge = td.rowIndex + td.rowspan === trList.length;
|
|
11852
|
+
const isSetExternalBottomBorder = borderExternalWidth && borderExternalWidth !== borderWidth && isBottomEdge;
|
|
11701
11853
|
if (isSetExternalBottomBorder) {
|
|
11702
11854
|
ctx.stroke();
|
|
11703
11855
|
ctx.beginPath();
|
|
11704
11856
|
}
|
|
11705
|
-
ctx.moveTo(
|
|
11706
|
-
ctx.lineTo(
|
|
11857
|
+
ctx.moveTo(rx, by);
|
|
11858
|
+
ctx.lineTo(lx, by);
|
|
11707
11859
|
if (isSetExternalBottomBorder) {
|
|
11708
11860
|
const lineWidth = ctx.lineWidth;
|
|
11709
11861
|
ctx.lineWidth = borderExternalWidth * scale;
|
|
@@ -11719,12 +11871,12 @@ var TableParticle = class {
|
|
|
11719
11871
|
ctx.translate(0.5, 0.5);
|
|
11720
11872
|
ctx.beginPath();
|
|
11721
11873
|
if (td.rowIndex === 0) {
|
|
11722
|
-
ctx.moveTo(
|
|
11723
|
-
ctx.lineTo(
|
|
11874
|
+
ctx.moveTo(lx, ty);
|
|
11875
|
+
ctx.lineTo(rx, ty);
|
|
11724
11876
|
}
|
|
11725
11877
|
if (td.colIndex === 0) {
|
|
11726
|
-
ctx.moveTo(
|
|
11727
|
-
ctx.lineTo(
|
|
11878
|
+
ctx.moveTo(lx, ty);
|
|
11879
|
+
ctx.lineTo(lx, by);
|
|
11728
11880
|
}
|
|
11729
11881
|
if (td.rowIndex === 0 || td.colIndex === 0) {
|
|
11730
11882
|
ctx.stroke();
|
|
@@ -11736,6 +11888,22 @@ var TableParticle = class {
|
|
|
11736
11888
|
}
|
|
11737
11889
|
}
|
|
11738
11890
|
}
|
|
11891
|
+
if (!isEmptyBorderType && !isExternalBorderType && !borderExternalWidth && firstTr?.splitBoundaryTop) {
|
|
11892
|
+
this._drawHorizontalBorder({
|
|
11893
|
+
ctx,
|
|
11894
|
+
startX,
|
|
11895
|
+
endX: startX + tableWidth,
|
|
11896
|
+
y: startY
|
|
11897
|
+
});
|
|
11898
|
+
}
|
|
11899
|
+
if (!isEmptyBorderType && !isExternalBorderType && !borderExternalWidth && lastTr?.splitBoundaryBottom) {
|
|
11900
|
+
this._drawHorizontalBorder({
|
|
11901
|
+
ctx,
|
|
11902
|
+
startX,
|
|
11903
|
+
endX: startX + tableWidth,
|
|
11904
|
+
y: startY + tableHeight
|
|
11905
|
+
});
|
|
11906
|
+
}
|
|
11739
11907
|
ctx.restore();
|
|
11740
11908
|
}
|
|
11741
11909
|
_drawBackgroundColor(ctx, element, startX, startY) {
|
|
@@ -11748,12 +11916,12 @@ var TableParticle = class {
|
|
|
11748
11916
|
const td = tr.tdList[d];
|
|
11749
11917
|
if (!td.backgroundColor) continue;
|
|
11750
11918
|
ctx.save();
|
|
11751
|
-
const
|
|
11752
|
-
const
|
|
11753
|
-
const
|
|
11754
|
-
const
|
|
11919
|
+
const lx = Math.round(td.x * scale + startX);
|
|
11920
|
+
const ty = Math.round(td.y * scale + startY);
|
|
11921
|
+
const rx = Math.round((td.x + td.width) * scale + startX);
|
|
11922
|
+
const by = Math.round((td.y + td.height) * scale + startY);
|
|
11755
11923
|
ctx.fillStyle = td.backgroundColor;
|
|
11756
|
-
ctx.fillRect(
|
|
11924
|
+
ctx.fillRect(lx, ty, rx - lx, by - ty);
|
|
11757
11925
|
ctx.restore();
|
|
11758
11926
|
}
|
|
11759
11927
|
}
|
|
@@ -15163,7 +15331,12 @@ var Control = class {
|
|
|
15163
15331
|
let element;
|
|
15164
15332
|
const newIndex = position.isTable ? tdValueIndex : index;
|
|
15165
15333
|
if (position.isTable) {
|
|
15166
|
-
elementList =
|
|
15334
|
+
elementList = this.draw.resolveTableCellContext(elementList, {
|
|
15335
|
+
isTable: true,
|
|
15336
|
+
index,
|
|
15337
|
+
trIndex,
|
|
15338
|
+
tdIndex
|
|
15339
|
+
})?.td.value || [];
|
|
15167
15340
|
element = elementList[tdValueIndex];
|
|
15168
15341
|
} else {
|
|
15169
15342
|
element = elementList[index];
|
|
@@ -20416,6 +20589,7 @@ var Draw = class {
|
|
|
20416
20589
|
this.intersectionPageNo = 0;
|
|
20417
20590
|
this.lazyRenderIntersectionObserver = null;
|
|
20418
20591
|
this.printModeData = null;
|
|
20592
|
+
this.pendingTableCursorIndex = void 0;
|
|
20419
20593
|
if (this.mode === "print" /* PRINT */) {
|
|
20420
20594
|
this.setPrintData();
|
|
20421
20595
|
}
|
|
@@ -20577,9 +20751,8 @@ var Draw = class {
|
|
|
20577
20751
|
getContextInnerWidth() {
|
|
20578
20752
|
const positionContext = this.position.getPositionContext();
|
|
20579
20753
|
if (positionContext.isTable) {
|
|
20580
|
-
const
|
|
20581
|
-
|
|
20582
|
-
const td = elementList[index].trList[trIndex].tdList[tdIndex];
|
|
20754
|
+
const td = this.resolveTableCellContext(this.getOriginalElementList())?.td;
|
|
20755
|
+
if (!td) return this.getColumnWidth() / this.options.scale;
|
|
20583
20756
|
const tdPadding = this.getTdPadding();
|
|
20584
20757
|
return td.width - tdPadding[1] - tdPadding[3];
|
|
20585
20758
|
}
|
|
@@ -20663,6 +20836,56 @@ var Draw = class {
|
|
|
20663
20836
|
getPage(pageNo = -1) {
|
|
20664
20837
|
return this.pageList[~pageNo ? pageNo : this.pageNo];
|
|
20665
20838
|
}
|
|
20839
|
+
resolveTableCellContext(sourceElementList = this.getOriginalElementList(), context = this.position.getPositionContext()) {
|
|
20840
|
+
if (!context.isTable) return null;
|
|
20841
|
+
const candidateIndexes = [];
|
|
20842
|
+
if (context.index !== void 0 && sourceElementList[context.index]?.type === "table" /* TABLE */) {
|
|
20843
|
+
candidateIndexes.push(context.index);
|
|
20844
|
+
}
|
|
20845
|
+
if (context.tableId) {
|
|
20846
|
+
const tableIndex = sourceElementList.findIndex((el) => el.id === context.tableId);
|
|
20847
|
+
if (~tableIndex && !candidateIndexes.includes(tableIndex)) {
|
|
20848
|
+
candidateIndexes.push(tableIndex);
|
|
20849
|
+
}
|
|
20850
|
+
}
|
|
20851
|
+
for (let i = 0; i < sourceElementList.length; i++) {
|
|
20852
|
+
const element = sourceElementList[i];
|
|
20853
|
+
if (element.type !== "table" /* TABLE */ || candidateIndexes.includes(i)) {
|
|
20854
|
+
continue;
|
|
20855
|
+
}
|
|
20856
|
+
candidateIndexes.push(i);
|
|
20857
|
+
}
|
|
20858
|
+
for (const tableIndex of candidateIndexes) {
|
|
20859
|
+
const element = sourceElementList[tableIndex];
|
|
20860
|
+
const trList = element.trList;
|
|
20861
|
+
if (!trList?.length) continue;
|
|
20862
|
+
let resolvedTrIndex = -1;
|
|
20863
|
+
if (context.trId) {
|
|
20864
|
+
resolvedTrIndex = trList.findIndex((tr) => tr.id === context.trId);
|
|
20865
|
+
}
|
|
20866
|
+
if (resolvedTrIndex < 0 && context.trIndex !== void 0 && trList[context.trIndex]) {
|
|
20867
|
+
resolvedTrIndex = context.trIndex;
|
|
20868
|
+
}
|
|
20869
|
+
if (resolvedTrIndex < 0) continue;
|
|
20870
|
+
const tdList = trList[resolvedTrIndex].tdList;
|
|
20871
|
+
let resolvedTdIndex = -1;
|
|
20872
|
+
if (context.tdId) {
|
|
20873
|
+
resolvedTdIndex = tdList.findIndex((td) => td.id === context.tdId);
|
|
20874
|
+
}
|
|
20875
|
+
if (resolvedTdIndex < 0 && context.tdIndex !== void 0 && tdList[context.tdIndex]) {
|
|
20876
|
+
resolvedTdIndex = context.tdIndex;
|
|
20877
|
+
}
|
|
20878
|
+
if (resolvedTdIndex < 0) continue;
|
|
20879
|
+
return {
|
|
20880
|
+
index: tableIndex,
|
|
20881
|
+
trIndex: resolvedTrIndex,
|
|
20882
|
+
tdIndex: resolvedTdIndex,
|
|
20883
|
+
element,
|
|
20884
|
+
td: tdList[resolvedTdIndex]
|
|
20885
|
+
};
|
|
20886
|
+
}
|
|
20887
|
+
return null;
|
|
20888
|
+
}
|
|
20666
20889
|
getPageList() {
|
|
20667
20890
|
return this.pageList;
|
|
20668
20891
|
}
|
|
@@ -20670,9 +20893,7 @@ var Draw = class {
|
|
|
20670
20893
|
return this.pageList.length;
|
|
20671
20894
|
}
|
|
20672
20895
|
getTableRowList(sourceElementList) {
|
|
20673
|
-
|
|
20674
|
-
const { index, trIndex, tdIndex } = positionContext;
|
|
20675
|
-
return sourceElementList[index].trList[trIndex].tdList[tdIndex].rowList;
|
|
20896
|
+
return this.resolveTableCellContext(sourceElementList)?.td.rowList || [];
|
|
20676
20897
|
}
|
|
20677
20898
|
getOriginalRowList() {
|
|
20678
20899
|
const zoneManager = this.getZone();
|
|
@@ -20731,9 +20952,7 @@ var Draw = class {
|
|
|
20731
20952
|
return this.header.getElementList();
|
|
20732
20953
|
}
|
|
20733
20954
|
getTableElementList(sourceElementList) {
|
|
20734
|
-
|
|
20735
|
-
const { index, trIndex, tdIndex } = positionContext;
|
|
20736
|
-
return sourceElementList[index].trList?.[trIndex].tdList[tdIndex].value || [];
|
|
20955
|
+
return this.resolveTableCellContext(sourceElementList)?.td.value || [];
|
|
20737
20956
|
}
|
|
20738
20957
|
getElementList() {
|
|
20739
20958
|
const positionContext = this.position.getPositionContext();
|
|
@@ -20761,13 +20980,7 @@ var Draw = class {
|
|
|
20761
20980
|
return this.footer.getElementList();
|
|
20762
20981
|
}
|
|
20763
20982
|
getTd() {
|
|
20764
|
-
|
|
20765
|
-
const { index, trIndex, tdIndex, isTable } = positionContext;
|
|
20766
|
-
if (isTable) {
|
|
20767
|
-
const elementList = this.getOriginalElementList();
|
|
20768
|
-
return elementList[index].trList[trIndex].tdList[tdIndex];
|
|
20769
|
-
}
|
|
20770
|
-
return null;
|
|
20983
|
+
return this.resolveTableCellContext(this.getOriginalElementList())?.td || null;
|
|
20771
20984
|
}
|
|
20772
20985
|
insertElementList(payload, options = {}) {
|
|
20773
20986
|
if (!payload.length || !this.range.getIsCanInput()) return;
|
|
@@ -21106,25 +21319,14 @@ var Draw = class {
|
|
|
21106
21319
|
setPaperSize(width, height) {
|
|
21107
21320
|
this.options.width = width;
|
|
21108
21321
|
this.options.height = height;
|
|
21109
|
-
|
|
21110
|
-
const realWidth = this.getWidth();
|
|
21111
|
-
const realHeight = this.getHeight();
|
|
21112
|
-
this.container.style.width = `${realWidth}px`;
|
|
21113
|
-
this.pageList.forEach((p, i) => {
|
|
21114
|
-
p.width = realWidth * dpr;
|
|
21115
|
-
p.height = realHeight * dpr;
|
|
21116
|
-
p.style.width = `${realWidth}px`;
|
|
21117
|
-
p.style.height = `${realHeight}px`;
|
|
21118
|
-
this._initPageContext(this.ctxList[i]);
|
|
21119
|
-
});
|
|
21120
|
-
this.render({
|
|
21121
|
-
isSubmitHistory: false,
|
|
21122
|
-
isSetCursor: false
|
|
21123
|
-
});
|
|
21322
|
+
this.refreshPageSize();
|
|
21124
21323
|
}
|
|
21125
21324
|
setPaperDirection(payload) {
|
|
21126
|
-
const dpr = this.getPagePixelRatio();
|
|
21127
21325
|
this.options.paperDirection = payload;
|
|
21326
|
+
this.refreshPageSize();
|
|
21327
|
+
}
|
|
21328
|
+
refreshPageSize() {
|
|
21329
|
+
const dpr = this.getPagePixelRatio();
|
|
21128
21330
|
const width = this.getWidth();
|
|
21129
21331
|
const height = this.getHeight();
|
|
21130
21332
|
this.container.style.width = `${width}px`;
|
|
@@ -21294,6 +21496,72 @@ var Draw = class {
|
|
|
21294
21496
|
}
|
|
21295
21497
|
return defaultBasicRowMarginHeight * ratio * (el.rowMargin ?? defaultRowMargin) * scale;
|
|
21296
21498
|
}
|
|
21499
|
+
createListStateSeed(initialListState) {
|
|
21500
|
+
const listLevelIndex = /* @__PURE__ */ new Map();
|
|
21501
|
+
if (initialListState?.listLevelIndex) {
|
|
21502
|
+
Object.entries(initialListState.listLevelIndex).forEach(
|
|
21503
|
+
([level, index]) => {
|
|
21504
|
+
listLevelIndex.set(Number(level), index);
|
|
21505
|
+
}
|
|
21506
|
+
);
|
|
21507
|
+
}
|
|
21508
|
+
return {
|
|
21509
|
+
listId: initialListState?.listId,
|
|
21510
|
+
listIndex: initialListState?.listIndex ?? 0,
|
|
21511
|
+
prevListLevel: initialListState?.prevListLevel ?? 0,
|
|
21512
|
+
listLevelIndex
|
|
21513
|
+
};
|
|
21514
|
+
}
|
|
21515
|
+
advanceListState(element, listState) {
|
|
21516
|
+
if (element.listId) {
|
|
21517
|
+
const curLevel = element.listLevel ?? 0;
|
|
21518
|
+
if (element.listId !== listState.listId) {
|
|
21519
|
+
listState.listIndex = 0;
|
|
21520
|
+
listState.listLevelIndex = /* @__PURE__ */ new Map();
|
|
21521
|
+
listState.listLevelIndex.set(curLevel, 0);
|
|
21522
|
+
listState.prevListLevel = curLevel;
|
|
21523
|
+
} else if (element.value === ZERO && !element.listWrap) {
|
|
21524
|
+
if (curLevel !== listState.prevListLevel) {
|
|
21525
|
+
if (curLevel > listState.prevListLevel) {
|
|
21526
|
+
listState.listLevelIndex.set(curLevel, 0);
|
|
21527
|
+
} else {
|
|
21528
|
+
for (const [lvl] of listState.listLevelIndex) {
|
|
21529
|
+
if (lvl > curLevel) {
|
|
21530
|
+
listState.listLevelIndex.delete(lvl);
|
|
21531
|
+
}
|
|
21532
|
+
}
|
|
21533
|
+
listState.listLevelIndex.set(
|
|
21534
|
+
curLevel,
|
|
21535
|
+
(listState.listLevelIndex.get(curLevel) ?? -1) + 1
|
|
21536
|
+
);
|
|
21537
|
+
}
|
|
21538
|
+
} else {
|
|
21539
|
+
listState.listLevelIndex.set(
|
|
21540
|
+
curLevel,
|
|
21541
|
+
(listState.listLevelIndex.get(curLevel) ?? -1) + 1
|
|
21542
|
+
);
|
|
21543
|
+
}
|
|
21544
|
+
listState.listIndex = listState.listLevelIndex.get(curLevel) ?? 0;
|
|
21545
|
+
listState.prevListLevel = curLevel;
|
|
21546
|
+
}
|
|
21547
|
+
}
|
|
21548
|
+
listState.listId = element.listId;
|
|
21549
|
+
}
|
|
21550
|
+
getListStateBeforeIndex(elementList, endExclusive) {
|
|
21551
|
+
const limit = Math.min(endExclusive, elementList.length);
|
|
21552
|
+
if (limit <= 0) return;
|
|
21553
|
+
const listState = this.createListStateSeed();
|
|
21554
|
+
for (let i = 0; i < limit; i++) {
|
|
21555
|
+
this.advanceListState(elementList[i], listState);
|
|
21556
|
+
}
|
|
21557
|
+
if (!listState.listId) return;
|
|
21558
|
+
return {
|
|
21559
|
+
listId: listState.listId,
|
|
21560
|
+
listIndex: listState.listIndex,
|
|
21561
|
+
prevListLevel: listState.prevListLevel,
|
|
21562
|
+
listLevelIndex: Object.fromEntries(listState.listLevelIndex)
|
|
21563
|
+
};
|
|
21564
|
+
}
|
|
21297
21565
|
computeRowList(payload) {
|
|
21298
21566
|
const {
|
|
21299
21567
|
innerWidth,
|
|
@@ -21304,7 +21572,8 @@ var Draw = class {
|
|
|
21304
21572
|
startY = 0,
|
|
21305
21573
|
pageHeight = 0,
|
|
21306
21574
|
mainOuterHeight = 0,
|
|
21307
|
-
surroundElementList = []
|
|
21575
|
+
surroundElementList = [],
|
|
21576
|
+
initialListState
|
|
21308
21577
|
} = payload;
|
|
21309
21578
|
const {
|
|
21310
21579
|
defaultSize,
|
|
@@ -21331,10 +21600,7 @@ var Draw = class {
|
|
|
21331
21600
|
let x = startX;
|
|
21332
21601
|
let y = startY;
|
|
21333
21602
|
let pageNo = 0;
|
|
21334
|
-
|
|
21335
|
-
let listIndex = 0;
|
|
21336
|
-
let listLevelIndex = /* @__PURE__ */ new Map();
|
|
21337
|
-
let prevListLevel = 0;
|
|
21603
|
+
const listState = this.createListStateSeed(initialListState);
|
|
21338
21604
|
let controlRealWidth = 0;
|
|
21339
21605
|
for (let i = 0; i < elementList.length; i++) {
|
|
21340
21606
|
const curRow = rowList[rowList.length - 1];
|
|
@@ -21380,6 +21646,8 @@ var Draw = class {
|
|
|
21380
21646
|
}
|
|
21381
21647
|
metrics.boundingBoxAscent = 0;
|
|
21382
21648
|
} else if (element.type === "table" /* TABLE */) {
|
|
21649
|
+
let activeSplitRange;
|
|
21650
|
+
let mergedSplitFallback;
|
|
21383
21651
|
if (element.pagingId) {
|
|
21384
21652
|
let tableIndex = i + 1;
|
|
21385
21653
|
let combineCount = 0;
|
|
@@ -21400,11 +21668,61 @@ var Draw = class {
|
|
|
21400
21668
|
if (combineCount) {
|
|
21401
21669
|
elementList.splice(i + 1, combineCount);
|
|
21402
21670
|
}
|
|
21671
|
+
const mergedTrList = element.trList;
|
|
21672
|
+
for (let t = mergedTrList.length - 1; t >= 0; t--) {
|
|
21673
|
+
const splitTr = mergedTrList[t];
|
|
21674
|
+
if (!splitTr.splitParentId) continue;
|
|
21675
|
+
const parentTrIdx = mergedTrList.findIndex(
|
|
21676
|
+
(r) => r.id === splitTr.splitParentId
|
|
21677
|
+
);
|
|
21678
|
+
if (!~parentTrIdx) continue;
|
|
21679
|
+
const parentTr = mergedTrList[parentTrIdx];
|
|
21680
|
+
const posCtx = this.position.getPositionContext();
|
|
21681
|
+
const { startIndex, endIndex } = this.range.getRange();
|
|
21682
|
+
if (posCtx.isTable && posCtx.trId === splitTr.id && startIndex === endIndex && posCtx.tdIndex !== void 0) {
|
|
21683
|
+
const splitTd = splitTr.tdList[posCtx.tdIndex];
|
|
21684
|
+
const parentTd = parentTr.tdList[posCtx.tdIndex];
|
|
21685
|
+
if (splitTd && parentTd) {
|
|
21686
|
+
const hasSyntheticLeadingZero = !!splitTd.splitSyntheticLeadingZero && splitTd.value[0]?.value === ZERO;
|
|
21687
|
+
const mergedIndex = parentTd.value.length + startIndex - (hasSyntheticLeadingZero ? 1 : 0);
|
|
21688
|
+
activeSplitRange = {
|
|
21689
|
+
tdIndex: posCtx.tdIndex,
|
|
21690
|
+
mergedIndex,
|
|
21691
|
+
trId: splitTr.id
|
|
21692
|
+
};
|
|
21693
|
+
mergedSplitFallback = {
|
|
21694
|
+
tdIndex: posCtx.tdIndex,
|
|
21695
|
+
mergedIndex,
|
|
21696
|
+
trId: splitTr.id,
|
|
21697
|
+
parentTrId: parentTr.id,
|
|
21698
|
+
parentTdId: parentTd.id,
|
|
21699
|
+
parentTrIndex: parentTrIdx
|
|
21700
|
+
};
|
|
21701
|
+
}
|
|
21702
|
+
}
|
|
21703
|
+
for (let d = 0; d < parentTr.tdList.length; d++) {
|
|
21704
|
+
const parentTd = parentTr.tdList[d];
|
|
21705
|
+
const splitTd = splitTr.tdList[d];
|
|
21706
|
+
if (!splitTd) continue;
|
|
21707
|
+
const hasSyntheticLeadingZero = !!splitTd.splitSyntheticLeadingZero && splitTd.value[0]?.value === ZERO;
|
|
21708
|
+
const splitValue = hasSyntheticLeadingZero ? splitTd.value.slice(1) : splitTd.value;
|
|
21709
|
+
parentTd.value.push(...splitValue);
|
|
21710
|
+
parentTd.rowList = void 0;
|
|
21711
|
+
parentTd.positionList = void 0;
|
|
21712
|
+
}
|
|
21713
|
+
if (posCtx.isTable && posCtx.trId === splitTr.id) {
|
|
21714
|
+
posCtx.index = i;
|
|
21715
|
+
this.position.setPositionContext(posCtx);
|
|
21716
|
+
}
|
|
21717
|
+
mergedTrList.splice(t, 1);
|
|
21718
|
+
}
|
|
21403
21719
|
}
|
|
21404
21720
|
element.pagingIndex = element.pagingIndex ?? 0;
|
|
21405
21721
|
const trList = element.trList;
|
|
21406
21722
|
for (let t = 0; t < trList.length; t++) {
|
|
21407
21723
|
const tr = trList[t];
|
|
21724
|
+
delete tr.splitBoundaryTop;
|
|
21725
|
+
delete tr.splitBoundaryBottom;
|
|
21408
21726
|
tr.height = tr.minHeight || defaultTrMinHeight;
|
|
21409
21727
|
tr.minHeight = tr.height;
|
|
21410
21728
|
}
|
|
@@ -21419,6 +21737,7 @@ var Draw = class {
|
|
|
21419
21737
|
const rowList2 = this.computeRowList({
|
|
21420
21738
|
innerWidth: (td.width - cellPaddingWidth) * scale,
|
|
21421
21739
|
elementList: td.value,
|
|
21740
|
+
initialListState: td.splitListState,
|
|
21422
21741
|
isFromTable: true,
|
|
21423
21742
|
isPagingMode
|
|
21424
21743
|
});
|
|
@@ -21501,6 +21820,7 @@ var Draw = class {
|
|
|
21501
21820
|
const tdRowList = this.computeRowList({
|
|
21502
21821
|
innerWidth: (td.width - cellPaddingWidth) * scale,
|
|
21503
21822
|
elementList: td.value,
|
|
21823
|
+
initialListState: td.splitListState,
|
|
21504
21824
|
isFromTable: true,
|
|
21505
21825
|
isPagingMode
|
|
21506
21826
|
});
|
|
@@ -21594,6 +21914,178 @@ var Draw = class {
|
|
|
21594
21914
|
}
|
|
21595
21915
|
}
|
|
21596
21916
|
}
|
|
21917
|
+
if (deleteCount === 0) {
|
|
21918
|
+
let overflowTrIdx = -1;
|
|
21919
|
+
let preHeightScaled = 0;
|
|
21920
|
+
for (let r = 0; r < trList2.length; r++) {
|
|
21921
|
+
const trHeight = trList2[r].height * scale;
|
|
21922
|
+
if (curPagePreHeight + rowMarginHeight + preHeightScaled + trHeight > height2) {
|
|
21923
|
+
overflowTrIdx = r;
|
|
21924
|
+
break;
|
|
21925
|
+
}
|
|
21926
|
+
preHeightScaled += trHeight;
|
|
21927
|
+
}
|
|
21928
|
+
if (overflowTrIdx >= 0) {
|
|
21929
|
+
const availableScaled = height2 - curPagePreHeight - rowMarginHeight - preHeightScaled;
|
|
21930
|
+
const availableUnscaled = availableScaled / scale;
|
|
21931
|
+
if (availableUnscaled >= defaultTrMinHeight) {
|
|
21932
|
+
const overflowTr = trList2[overflowTrIdx];
|
|
21933
|
+
const originalTrHeight = overflowTr.height;
|
|
21934
|
+
const {
|
|
21935
|
+
table: { tdPadding: defaultTdPadding, defaultTrMinHeight: defaultTrMinHeight2 }
|
|
21936
|
+
} = this.options;
|
|
21937
|
+
const splits = [];
|
|
21938
|
+
let anySplit = false;
|
|
21939
|
+
for (let d = 0; d < overflowTr.tdList.length; d++) {
|
|
21940
|
+
const td = overflowTr.tdList[d];
|
|
21941
|
+
const cellPadding = td.padding || defaultTdPadding;
|
|
21942
|
+
const cellPaddingH = cellPadding[0] + cellPadding[2];
|
|
21943
|
+
const contentAvailableScaled = (availableUnscaled - cellPaddingH) * scale;
|
|
21944
|
+
if (!td.rowList || td.rowList.length === 0) {
|
|
21945
|
+
splits.push({
|
|
21946
|
+
elemIdx: td.value.length,
|
|
21947
|
+
rowIdx: 0
|
|
21948
|
+
});
|
|
21949
|
+
continue;
|
|
21950
|
+
}
|
|
21951
|
+
let cumHeight = 0;
|
|
21952
|
+
let elemIdx = td.value.length;
|
|
21953
|
+
let rowIdx = td.rowList.length;
|
|
21954
|
+
for (let ri = 0; ri < td.rowList.length; ri++) {
|
|
21955
|
+
const row = td.rowList[ri];
|
|
21956
|
+
if (cumHeight + row.height > contentAvailableScaled) {
|
|
21957
|
+
elemIdx = row.startIndex;
|
|
21958
|
+
rowIdx = ri;
|
|
21959
|
+
break;
|
|
21960
|
+
}
|
|
21961
|
+
cumHeight += row.height;
|
|
21962
|
+
}
|
|
21963
|
+
if (elemIdx > 0 && elemIdx < td.value.length) {
|
|
21964
|
+
anySplit = true;
|
|
21965
|
+
}
|
|
21966
|
+
splits.push({ elemIdx, rowIdx });
|
|
21967
|
+
}
|
|
21968
|
+
if (anySplit) {
|
|
21969
|
+
if (!activeSplitRange) {
|
|
21970
|
+
const posCtx = this.position.getPositionContext();
|
|
21971
|
+
const { startIndex, endIndex } = this.range.getRange();
|
|
21972
|
+
if (posCtx.isTable && posCtx.trId === overflowTr.id && startIndex === endIndex && posCtx.tdIndex !== void 0) {
|
|
21973
|
+
const splitIdx = splits[posCtx.tdIndex]?.elemIdx;
|
|
21974
|
+
if (splitIdx !== void 0 && startIndex >= splitIdx && splitIdx < overflowTr.tdList[posCtx.tdIndex].value.length) {
|
|
21975
|
+
activeSplitRange = {
|
|
21976
|
+
tdIndex: posCtx.tdIndex,
|
|
21977
|
+
mergedIndex: startIndex,
|
|
21978
|
+
trId: overflowTr.id
|
|
21979
|
+
};
|
|
21980
|
+
}
|
|
21981
|
+
}
|
|
21982
|
+
}
|
|
21983
|
+
const continuationTrHeight = originalTrHeight - availableUnscaled;
|
|
21984
|
+
const splitRootId = overflowTr.splitRootId || overflowTr.id;
|
|
21985
|
+
const splitLevel = (overflowTr.splitLevel || 0) + 1;
|
|
21986
|
+
const newTrId = `${splitRootId}_c${splitLevel}`;
|
|
21987
|
+
const continuationTdList = overflowTr.tdList.map(
|
|
21988
|
+
(td, d) => {
|
|
21989
|
+
const splitIdx = splits[d].elemIdx;
|
|
21990
|
+
const initialListState2 = this.getListStateBeforeIndex(
|
|
21991
|
+
td.value,
|
|
21992
|
+
splitIdx
|
|
21993
|
+
);
|
|
21994
|
+
const overflowElements = deepClone(
|
|
21995
|
+
td.value.slice(splitIdx)
|
|
21996
|
+
);
|
|
21997
|
+
const overflowStartElement = overflowElements[0];
|
|
21998
|
+
let splitSyntheticLeadingZero = false;
|
|
21999
|
+
if (!overflowElements.length || overflowElements[0]?.value !== ZERO) {
|
|
22000
|
+
overflowElements.unshift({
|
|
22001
|
+
value: ZERO,
|
|
22002
|
+
type: "text" /* TEXT */,
|
|
22003
|
+
listId: overflowStartElement?.listId,
|
|
22004
|
+
listType: overflowStartElement?.listType,
|
|
22005
|
+
listStyle: overflowStartElement?.listStyle,
|
|
22006
|
+
listLevel: overflowStartElement?.listLevel,
|
|
22007
|
+
listPreset: overflowStartElement?.listPreset,
|
|
22008
|
+
listWrap: !!overflowStartElement?.listId
|
|
22009
|
+
});
|
|
22010
|
+
splitSyntheticLeadingZero = true;
|
|
22011
|
+
}
|
|
22012
|
+
const {
|
|
22013
|
+
value: _v,
|
|
22014
|
+
rowList: _rl,
|
|
22015
|
+
positionList: _pl,
|
|
22016
|
+
splitSyntheticLeadingZero: _slz,
|
|
22017
|
+
splitListState: _sls,
|
|
22018
|
+
...tdMeta
|
|
22019
|
+
} = td;
|
|
22020
|
+
return {
|
|
22021
|
+
...deepClone(tdMeta),
|
|
22022
|
+
value: overflowElements,
|
|
22023
|
+
splitSyntheticLeadingZero,
|
|
22024
|
+
splitListState: initialListState2,
|
|
22025
|
+
height: continuationTrHeight,
|
|
22026
|
+
rowList: void 0,
|
|
22027
|
+
positionList: void 0,
|
|
22028
|
+
mainHeight: void 0,
|
|
22029
|
+
realHeight: void 0,
|
|
22030
|
+
realMinHeight: void 0
|
|
22031
|
+
};
|
|
22032
|
+
}
|
|
22033
|
+
);
|
|
22034
|
+
const continuationTr = {
|
|
22035
|
+
id: newTrId,
|
|
22036
|
+
height: continuationTrHeight,
|
|
22037
|
+
minHeight: defaultTrMinHeight2,
|
|
22038
|
+
tdList: continuationTdList,
|
|
22039
|
+
splitParentId: overflowTr.id,
|
|
22040
|
+
splitRootId,
|
|
22041
|
+
splitLevel
|
|
22042
|
+
};
|
|
22043
|
+
const positionContext = this.position.getPositionContext();
|
|
22044
|
+
if (activeSplitRange && positionContext.isTable && positionContext.trId === activeSplitRange.trId) {
|
|
22045
|
+
const splitIdx = splits[activeSplitRange.tdIndex]?.elemIdx;
|
|
22046
|
+
const continuationTd = continuationTdList[activeSplitRange.tdIndex];
|
|
22047
|
+
if (splitIdx !== void 0 && continuationTd && activeSplitRange.mergedIndex >= splitIdx) {
|
|
22048
|
+
const hasPrependedZero = !!continuationTd.splitSyntheticLeadingZero && continuationTd.value[0]?.value === ZERO;
|
|
22049
|
+
const continuationCursorIndex = activeSplitRange.mergedIndex - splitIdx + (hasPrependedZero ? 1 : 0);
|
|
22050
|
+
positionContext.index = i;
|
|
22051
|
+
positionContext.trIndex = overflowTrIdx + 1;
|
|
22052
|
+
positionContext.tdIndex = activeSplitRange.tdIndex;
|
|
22053
|
+
positionContext.tdId = continuationTd.id;
|
|
22054
|
+
positionContext.trId = continuationTr.id;
|
|
22055
|
+
positionContext.tableId = element.id;
|
|
22056
|
+
this.position.setPositionContext(positionContext);
|
|
22057
|
+
this.range.setRange(
|
|
22058
|
+
continuationCursorIndex,
|
|
22059
|
+
continuationCursorIndex
|
|
22060
|
+
);
|
|
22061
|
+
this.pendingTableCursorIndex = continuationCursorIndex;
|
|
22062
|
+
}
|
|
22063
|
+
}
|
|
22064
|
+
for (let d = 0; d < overflowTr.tdList.length; d++) {
|
|
22065
|
+
const td = overflowTr.tdList[d];
|
|
22066
|
+
const { elemIdx, rowIdx } = splits[d];
|
|
22067
|
+
td.value = td.value.slice(0, elemIdx);
|
|
22068
|
+
td.rowList = td.rowList ? td.rowList.slice(0, rowIdx) : void 0;
|
|
22069
|
+
td.positionList = void 0;
|
|
22070
|
+
td.height = availableUnscaled;
|
|
22071
|
+
td.mainHeight = void 0;
|
|
22072
|
+
td.realHeight = void 0;
|
|
22073
|
+
td.realMinHeight = void 0;
|
|
22074
|
+
}
|
|
22075
|
+
overflowTr.height = availableUnscaled;
|
|
22076
|
+
overflowTr.minHeight = Math.min(
|
|
22077
|
+
overflowTr.minHeight || defaultTrMinHeight2,
|
|
22078
|
+
availableUnscaled
|
|
22079
|
+
);
|
|
22080
|
+
overflowTr.splitBoundaryBottom = true;
|
|
22081
|
+
continuationTr.splitBoundaryTop = true;
|
|
22082
|
+
trList2.splice(overflowTrIdx + 1, 0, continuationTr);
|
|
22083
|
+
deleteStart = overflowTrIdx + 1;
|
|
22084
|
+
deleteCount = trList2.length - deleteStart;
|
|
22085
|
+
}
|
|
22086
|
+
}
|
|
22087
|
+
}
|
|
22088
|
+
}
|
|
21597
22089
|
if (deleteCount) {
|
|
21598
22090
|
const cloneTrList = trList2.splice(deleteStart, deleteCount);
|
|
21599
22091
|
const cloneTrHeight = cloneTrList.reduce(
|
|
@@ -21643,6 +22135,21 @@ var Draw = class {
|
|
|
21643
22135
|
positionContext.index = newPositionContextIndex;
|
|
21644
22136
|
positionContext.trIndex = newPositionContextTrIndex;
|
|
21645
22137
|
this.position.setPositionContext(positionContext);
|
|
22138
|
+
} else if (mergedSplitFallback && positionContext.trId === mergedSplitFallback.trId) {
|
|
22139
|
+
const fallbackTd = element.trList?.[mergedSplitFallback.parentTrIndex]?.tdList[mergedSplitFallback.tdIndex];
|
|
22140
|
+
const fallbackCursorIndex = Math.min(
|
|
22141
|
+
mergedSplitFallback.mergedIndex,
|
|
22142
|
+
Math.max((fallbackTd?.value.length || 1) - 1, 0)
|
|
22143
|
+
);
|
|
22144
|
+
positionContext.index = i;
|
|
22145
|
+
positionContext.trIndex = mergedSplitFallback.parentTrIndex;
|
|
22146
|
+
positionContext.tdIndex = mergedSplitFallback.tdIndex;
|
|
22147
|
+
positionContext.tdId = mergedSplitFallback.parentTdId;
|
|
22148
|
+
positionContext.trId = mergedSplitFallback.parentTrId;
|
|
22149
|
+
positionContext.tableId = element.id;
|
|
22150
|
+
this.position.setPositionContext(positionContext);
|
|
22151
|
+
this.range.setRange(fallbackCursorIndex, fallbackCursorIndex);
|
|
22152
|
+
this.pendingTableCursorIndex = fallbackCursorIndex;
|
|
21646
22153
|
}
|
|
21647
22154
|
}
|
|
21648
22155
|
}
|
|
@@ -21775,39 +22282,7 @@ var Draw = class {
|
|
|
21775
22282
|
curRowWidth += punctuationWidth * scale;
|
|
21776
22283
|
}
|
|
21777
22284
|
}
|
|
21778
|
-
|
|
21779
|
-
const curLevel = element.listLevel ?? 0;
|
|
21780
|
-
if (element.listId !== listId) {
|
|
21781
|
-
listIndex = 0;
|
|
21782
|
-
listLevelIndex = /* @__PURE__ */ new Map();
|
|
21783
|
-
listLevelIndex.set(curLevel, 0);
|
|
21784
|
-
prevListLevel = curLevel;
|
|
21785
|
-
} else if (element.value === ZERO && !element.listWrap) {
|
|
21786
|
-
if (curLevel !== prevListLevel) {
|
|
21787
|
-
if (curLevel > prevListLevel) {
|
|
21788
|
-
listLevelIndex.set(curLevel, 0);
|
|
21789
|
-
} else {
|
|
21790
|
-
for (const [lvl] of listLevelIndex) {
|
|
21791
|
-
if (lvl > curLevel) {
|
|
21792
|
-
listLevelIndex.delete(lvl);
|
|
21793
|
-
}
|
|
21794
|
-
}
|
|
21795
|
-
listLevelIndex.set(
|
|
21796
|
-
curLevel,
|
|
21797
|
-
(listLevelIndex.get(curLevel) ?? -1) + 1
|
|
21798
|
-
);
|
|
21799
|
-
}
|
|
21800
|
-
} else {
|
|
21801
|
-
listLevelIndex.set(
|
|
21802
|
-
curLevel,
|
|
21803
|
-
(listLevelIndex.get(curLevel) ?? -1) + 1
|
|
21804
|
-
);
|
|
21805
|
-
}
|
|
21806
|
-
listIndex = listLevelIndex.get(curLevel) ?? 0;
|
|
21807
|
-
prevListLevel = curLevel;
|
|
21808
|
-
}
|
|
21809
|
-
}
|
|
21810
|
-
listId = element.listId;
|
|
22285
|
+
this.advanceListState(element, listState);
|
|
21811
22286
|
const surroundPosition = this.position.setSurroundPosition({
|
|
21812
22287
|
pageNo,
|
|
21813
22288
|
rowElement,
|
|
@@ -21859,7 +22334,7 @@ var Draw = class {
|
|
|
21859
22334
|
const baseListOffset = listStyleMap.get(element.listId) || 0;
|
|
21860
22335
|
const rowListIndent = this.listParticle.getListIndentWidth(element);
|
|
21861
22336
|
row.offsetX = baseListOffset + rowListIndent;
|
|
21862
|
-
row.listIndex = listIndex;
|
|
22337
|
+
row.listIndex = listState.listIndex;
|
|
21863
22338
|
}
|
|
21864
22339
|
row.offsetY = !isFromTable && element.area?.top && element.areaId !== elementList[i - 1]?.areaId ? element.area.top * scale : 0;
|
|
21865
22340
|
rowList.push(row);
|
|
@@ -22528,6 +23003,7 @@ var Draw = class {
|
|
|
22528
23003
|
isFirstRender = false
|
|
22529
23004
|
} = payload || {};
|
|
22530
23005
|
let { curIndex } = payload || {};
|
|
23006
|
+
this.pendingTableCursorIndex = void 0;
|
|
22531
23007
|
const innerWidth = this.getInnerWidth();
|
|
22532
23008
|
const columnWidth = this.getColumnWidth();
|
|
22533
23009
|
const isPagingMode = this.getIsPagingMode();
|
|
@@ -22593,6 +23069,10 @@ var Draw = class {
|
|
|
22593
23069
|
} else {
|
|
22594
23070
|
this._immediateRender();
|
|
22595
23071
|
}
|
|
23072
|
+
if (this.pendingTableCursorIndex !== void 0) {
|
|
23073
|
+
curIndex = this.pendingTableCursorIndex;
|
|
23074
|
+
this.pendingTableCursorIndex = void 0;
|
|
23075
|
+
}
|
|
22596
23076
|
if (isSetCursor) {
|
|
22597
23077
|
curIndex = this.setCursor(curIndex);
|
|
22598
23078
|
} else if (this.range.getIsSelection()) {
|
|
@@ -22634,9 +23114,7 @@ var Draw = class {
|
|
|
22634
23114
|
const positionContext = this.position.getPositionContext();
|
|
22635
23115
|
const positionList = this.position.getPositionList();
|
|
22636
23116
|
if (positionContext.isTable) {
|
|
22637
|
-
const
|
|
22638
|
-
const elementList = this.getOriginalElementList();
|
|
22639
|
-
const tablePositionList = elementList[index].trList?.[trIndex].tdList[tdIndex].positionList;
|
|
23117
|
+
const tablePositionList = this.resolveTableCellContext(this.getOriginalElementList())?.td.positionList;
|
|
22640
23118
|
if (curIndex === void 0 && tablePositionList) {
|
|
22641
23119
|
curIndex = tablePositionList.length - 1;
|
|
22642
23120
|
}
|
|
@@ -24787,7 +25265,12 @@ var CommandAdapt = class {
|
|
|
24787
25265
|
Object.keys(payload).forEach((key) => {
|
|
24788
25266
|
Reflect.set(this.options, key, newOption[key]);
|
|
24789
25267
|
});
|
|
24790
|
-
|
|
25268
|
+
const layoutKeys = ["paperDirection", "width", "height"];
|
|
25269
|
+
if (layoutKeys.some((k) => k in payload)) {
|
|
25270
|
+
this.draw.refreshPageSize();
|
|
25271
|
+
} else {
|
|
25272
|
+
this.forceUpdate();
|
|
25273
|
+
}
|
|
24791
25274
|
const { scale, paperDirection, width, height } = this.options;
|
|
24792
25275
|
this.draw.getListener().optionsChange?.({ scale, paperDirection, width, height });
|
|
24793
25276
|
}
|