@hufe921/canvas-editor 0.9.68 → 0.9.70
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/CHANGELOG.md +61 -0
- package/dist/canvas-editor.es.js +685 -308
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +33 -32
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +1 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +3 -2
- package/dist/src/editor/core/draw/control/Control.d.ts +1 -0
- package/dist/src/editor/core/draw/particle/date/DateParticle.d.ts +0 -2
- package/dist/src/editor/core/event/handlers/keydown/backspace.d.ts +2 -0
- package/dist/src/editor/core/event/handlers/keydown/delete.d.ts +2 -0
- package/dist/src/editor/core/event/handlers/keydown/left.d.ts +2 -0
- package/dist/src/editor/core/event/handlers/keydown/right.d.ts +2 -0
- package/dist/src/editor/core/event/handlers/keydown/tab.d.ts +2 -0
- package/dist/src/editor/core/event/handlers/keydown/updown.d.ts +2 -0
- package/dist/src/editor/core/position/Position.d.ts +1 -0
- package/dist/src/editor/interface/Element.d.ts +1 -0
- package/dist/src/editor/interface/Position.d.ts +2 -0
- package/package.json +1 -1
package/dist/canvas-editor.es.js
CHANGED
|
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23
23
|
return value;
|
|
24
24
|
};
|
|
25
25
|
var index = "";
|
|
26
|
-
const version = "0.9.
|
|
26
|
+
const version = "0.9.70";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -4074,6 +4074,22 @@ function zipElementList(payload) {
|
|
|
4074
4074
|
listElement.valueList = zipElementList(valueList);
|
|
4075
4075
|
element = listElement;
|
|
4076
4076
|
} else if (element.type === ElementType.TABLE) {
|
|
4077
|
+
if (element.pagingId) {
|
|
4078
|
+
let tableIndex = e + 1;
|
|
4079
|
+
let combineCount = 0;
|
|
4080
|
+
while (tableIndex < elementList.length) {
|
|
4081
|
+
const nextElement = elementList[tableIndex];
|
|
4082
|
+
if (nextElement.pagingId === element.pagingId) {
|
|
4083
|
+
element.height += nextElement.height;
|
|
4084
|
+
element.trList.push(...nextElement.trList);
|
|
4085
|
+
tableIndex++;
|
|
4086
|
+
combineCount++;
|
|
4087
|
+
} else {
|
|
4088
|
+
break;
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
e += combineCount;
|
|
4092
|
+
}
|
|
4077
4093
|
if (element.trList) {
|
|
4078
4094
|
for (let t = 0; t < element.trList.length; t++) {
|
|
4079
4095
|
const tr = element.trList[t];
|
|
@@ -4295,22 +4311,57 @@ function splitListElement(elementList) {
|
|
|
4295
4311
|
}
|
|
4296
4312
|
function createDomFromElementList(elementList, options) {
|
|
4297
4313
|
function buildDom(payload) {
|
|
4298
|
-
var _a, _b, _c, _d;
|
|
4314
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4299
4315
|
const clipboardDom = document.createElement("div");
|
|
4300
4316
|
for (let e = 0; e < payload.length; e++) {
|
|
4301
4317
|
const element = payload[e];
|
|
4302
4318
|
if (element.type === ElementType.TABLE) {
|
|
4303
4319
|
const tableDom = document.createElement("table");
|
|
4320
|
+
tableDom.setAttribute("cellSpacing", "0");
|
|
4321
|
+
tableDom.setAttribute("cellpadding", "0");
|
|
4322
|
+
tableDom.setAttribute("border", "0");
|
|
4323
|
+
const borderStyle = "1px solid #000000";
|
|
4324
|
+
if (!element.borderType || element.borderType === TableBorder.ALL) {
|
|
4325
|
+
tableDom.style.borderTop = borderStyle;
|
|
4326
|
+
tableDom.style.borderLeft = borderStyle;
|
|
4327
|
+
} else if (element.borderType === TableBorder.EXTERNAL) {
|
|
4328
|
+
tableDom.style.border = borderStyle;
|
|
4329
|
+
}
|
|
4330
|
+
tableDom.style.width = `${element.width}px`;
|
|
4331
|
+
const colgroupDom = document.createElement("colgroup");
|
|
4332
|
+
for (let c = 0; c < element.colgroup.length; c++) {
|
|
4333
|
+
const colgroup = element.colgroup[c];
|
|
4334
|
+
const colDom = document.createElement("col");
|
|
4335
|
+
colDom.setAttribute("width", `${colgroup.width}`);
|
|
4336
|
+
colgroupDom.append(colDom);
|
|
4337
|
+
}
|
|
4338
|
+
tableDom.append(colgroupDom);
|
|
4304
4339
|
const trList = element.trList;
|
|
4305
4340
|
for (let t = 0; t < trList.length; t++) {
|
|
4306
4341
|
const trDom = document.createElement("tr");
|
|
4307
4342
|
const tr = trList[t];
|
|
4343
|
+
trDom.style.height = `${tr.height}px`;
|
|
4308
4344
|
for (let d = 0; d < tr.tdList.length; d++) {
|
|
4309
4345
|
const tdDom = document.createElement("td");
|
|
4310
|
-
|
|
4346
|
+
if (!element.borderType || element.borderType === TableBorder.ALL) {
|
|
4347
|
+
tdDom.style.borderBottom = tdDom.style.borderRight = "1px solid";
|
|
4348
|
+
}
|
|
4311
4349
|
const td = tr.tdList[d];
|
|
4312
4350
|
tdDom.colSpan = td.colspan;
|
|
4313
4351
|
tdDom.rowSpan = td.rowspan;
|
|
4352
|
+
tdDom.style.verticalAlign = td.verticalAlign || "top";
|
|
4353
|
+
if ((_a = td.borderTypes) == null ? void 0 : _a.includes(TdBorder.TOP)) {
|
|
4354
|
+
tdDom.style.borderTop = borderStyle;
|
|
4355
|
+
}
|
|
4356
|
+
if ((_b = td.borderTypes) == null ? void 0 : _b.includes(TdBorder.RIGHT)) {
|
|
4357
|
+
tdDom.style.borderRight = borderStyle;
|
|
4358
|
+
}
|
|
4359
|
+
if ((_c = td.borderTypes) == null ? void 0 : _c.includes(TdBorder.BOTTOM)) {
|
|
4360
|
+
tdDom.style.borderBottom = borderStyle;
|
|
4361
|
+
}
|
|
4362
|
+
if ((_d = td.borderTypes) == null ? void 0 : _d.includes(TdBorder.LEFT)) {
|
|
4363
|
+
tdDom.style.borderLeft = borderStyle;
|
|
4364
|
+
}
|
|
4314
4365
|
const childDom = buildDom(zipElementList(td.value));
|
|
4315
4366
|
tdDom.innerHTML = childDom.innerHTML;
|
|
4316
4367
|
if (td.backgroundColor) {
|
|
@@ -4361,30 +4412,30 @@ function createDomFromElementList(elementList, options) {
|
|
|
4361
4412
|
} else if (element.type === ElementType.CHECKBOX) {
|
|
4362
4413
|
const checkbox = document.createElement("input");
|
|
4363
4414
|
checkbox.type = "checkbox";
|
|
4364
|
-
if ((
|
|
4415
|
+
if ((_e = element.checkbox) == null ? void 0 : _e.value) {
|
|
4365
4416
|
checkbox.setAttribute("checked", "true");
|
|
4366
4417
|
}
|
|
4367
4418
|
clipboardDom.append(checkbox);
|
|
4368
4419
|
} else if (element.type === ElementType.TAB) {
|
|
4369
|
-
const
|
|
4370
|
-
|
|
4371
|
-
clipboardDom.append(
|
|
4420
|
+
const tab2 = document.createElement("span");
|
|
4421
|
+
tab2.innerHTML = `${NON_BREAKING_SPACE}${NON_BREAKING_SPACE}`;
|
|
4422
|
+
clipboardDom.append(tab2);
|
|
4372
4423
|
} else if (element.type === ElementType.CONTROL) {
|
|
4373
4424
|
const controlElement = document.createElement("span");
|
|
4374
|
-
const childDom = buildDom(zipElementList(((
|
|
4425
|
+
const childDom = buildDom(zipElementList(((_f = element.control) == null ? void 0 : _f.value) || []));
|
|
4375
4426
|
controlElement.innerHTML = childDom.innerHTML;
|
|
4376
4427
|
clipboardDom.append(controlElement);
|
|
4377
4428
|
} else if (!element.type || element.type === ElementType.LATEX || TEXTLIKE_ELEMENT_TYPE.includes(element.type)) {
|
|
4378
4429
|
let text = "";
|
|
4379
4430
|
if (element.type === ElementType.DATE) {
|
|
4380
|
-
text = ((
|
|
4431
|
+
text = ((_g = element.valueList) == null ? void 0 : _g.map((v) => v.value).join("")) || "";
|
|
4381
4432
|
} else {
|
|
4382
4433
|
text = element.value;
|
|
4383
4434
|
}
|
|
4384
4435
|
if (!text)
|
|
4385
4436
|
continue;
|
|
4386
4437
|
const dom = convertElementToDom(element, options);
|
|
4387
|
-
if (((
|
|
4438
|
+
if (((_h = payload[e - 1]) == null ? void 0 : _h.type) === ElementType.TITLE) {
|
|
4388
4439
|
text = text.replace(/^\n/, "");
|
|
4389
4440
|
}
|
|
4390
4441
|
if (dom.tagName === "P") {
|
|
@@ -4684,6 +4735,9 @@ function writeClipboardItem(text, html, elementList) {
|
|
|
4684
4735
|
document.body.append(fakeElement);
|
|
4685
4736
|
const selection = window.getSelection();
|
|
4686
4737
|
const range = document.createRange();
|
|
4738
|
+
const br = document.createElement("span");
|
|
4739
|
+
br.innerText = "\n";
|
|
4740
|
+
fakeElement.append(br);
|
|
4687
4741
|
range.selectNodeContents(fakeElement);
|
|
4688
4742
|
selection == null ? void 0 : selection.removeAllRanges();
|
|
4689
4743
|
selection == null ? void 0 : selection.addRange(range);
|
|
@@ -5057,9 +5111,9 @@ class Cursor {
|
|
|
5057
5111
|
rect.right = window.innerWidth;
|
|
5058
5112
|
rect.bottom = window.innerHeight;
|
|
5059
5113
|
} else {
|
|
5060
|
-
const { left, right, top, bottom } = scrollContainer.getBoundingClientRect();
|
|
5061
|
-
rect.left =
|
|
5062
|
-
rect.right =
|
|
5114
|
+
const { left: left2, right: right2, top, bottom } = scrollContainer.getBoundingClientRect();
|
|
5115
|
+
rect.left = left2;
|
|
5116
|
+
rect.right = right2;
|
|
5063
5117
|
rect.top = top;
|
|
5064
5118
|
rect.bottom = bottom;
|
|
5065
5119
|
}
|
|
@@ -5688,6 +5742,99 @@ var WordBreak;
|
|
|
5688
5742
|
WordBreak2["BREAK_ALL"] = "break-all";
|
|
5689
5743
|
WordBreak2["BREAK_WORD"] = "break-word";
|
|
5690
5744
|
})(WordBreak || (WordBreak = {}));
|
|
5745
|
+
function backspace(evt, host) {
|
|
5746
|
+
const draw = host.getDraw();
|
|
5747
|
+
const isReadonly = draw.isReadonly();
|
|
5748
|
+
if (isReadonly)
|
|
5749
|
+
return;
|
|
5750
|
+
const control = draw.getControl();
|
|
5751
|
+
const activeControl = control.getActiveControl();
|
|
5752
|
+
if (control.isPartRangeInControlOutside())
|
|
5753
|
+
return;
|
|
5754
|
+
const rangeManager = draw.getRange();
|
|
5755
|
+
let curIndex;
|
|
5756
|
+
if (activeControl) {
|
|
5757
|
+
curIndex = control.keydown(evt);
|
|
5758
|
+
} else {
|
|
5759
|
+
const position = draw.getPosition();
|
|
5760
|
+
const cursorPosition = position.getCursorPosition();
|
|
5761
|
+
if (!cursorPosition)
|
|
5762
|
+
return;
|
|
5763
|
+
const { index: index2 } = cursorPosition;
|
|
5764
|
+
const { startIndex, endIndex } = rangeManager.getRange();
|
|
5765
|
+
const isCollapsed = rangeManager.getIsCollapsed();
|
|
5766
|
+
const elementList = draw.getElementList();
|
|
5767
|
+
if (isCollapsed && index2 === 0) {
|
|
5768
|
+
const firstElement = elementList[index2];
|
|
5769
|
+
if (firstElement.value === ZERO) {
|
|
5770
|
+
if (firstElement.listId) {
|
|
5771
|
+
draw.getListParticle().unsetList();
|
|
5772
|
+
}
|
|
5773
|
+
evt.preventDefault();
|
|
5774
|
+
return;
|
|
5775
|
+
}
|
|
5776
|
+
}
|
|
5777
|
+
const startElement = elementList[startIndex];
|
|
5778
|
+
if (isCollapsed && startElement.rowFlex && startElement.value === ZERO) {
|
|
5779
|
+
const rowList = draw.getRowList();
|
|
5780
|
+
const positionList = position.getPositionList();
|
|
5781
|
+
const rowNo = positionList[startIndex].rowNo;
|
|
5782
|
+
const rowFlexElementList = rowList[rowNo].elementList;
|
|
5783
|
+
rowFlexElementList.forEach((element) => {
|
|
5784
|
+
delete element.rowFlex;
|
|
5785
|
+
});
|
|
5786
|
+
}
|
|
5787
|
+
if (!isCollapsed) {
|
|
5788
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
5789
|
+
} else {
|
|
5790
|
+
draw.spliceElementList(elementList, index2, 1);
|
|
5791
|
+
}
|
|
5792
|
+
curIndex = isCollapsed ? index2 - 1 : startIndex;
|
|
5793
|
+
}
|
|
5794
|
+
if (curIndex === null)
|
|
5795
|
+
return;
|
|
5796
|
+
draw.getGlobalEvent().setCanvasEventAbility();
|
|
5797
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
5798
|
+
draw.render({ curIndex });
|
|
5799
|
+
}
|
|
5800
|
+
function del(evt, host) {
|
|
5801
|
+
var _a;
|
|
5802
|
+
const draw = host.getDraw();
|
|
5803
|
+
const isReadonly = draw.isReadonly();
|
|
5804
|
+
if (isReadonly)
|
|
5805
|
+
return;
|
|
5806
|
+
const control = draw.getControl();
|
|
5807
|
+
const activeControl = control.getActiveControl();
|
|
5808
|
+
if (control.isPartRangeInControlOutside())
|
|
5809
|
+
return;
|
|
5810
|
+
const rangeManager = draw.getRange();
|
|
5811
|
+
const { startIndex, endIndex } = rangeManager.getRange();
|
|
5812
|
+
const elementList = draw.getElementList();
|
|
5813
|
+
let curIndex;
|
|
5814
|
+
if (activeControl) {
|
|
5815
|
+
curIndex = control.keydown(evt);
|
|
5816
|
+
} else if ((_a = elementList[endIndex + 1]) == null ? void 0 : _a.controlId) {
|
|
5817
|
+
curIndex = control.removeControl(endIndex + 1);
|
|
5818
|
+
} else {
|
|
5819
|
+
const position = draw.getPosition();
|
|
5820
|
+
const cursorPosition = position.getCursorPosition();
|
|
5821
|
+
if (!cursorPosition)
|
|
5822
|
+
return;
|
|
5823
|
+
const { index: index2 } = cursorPosition;
|
|
5824
|
+
const isCollapsed = rangeManager.getIsCollapsed();
|
|
5825
|
+
if (!isCollapsed) {
|
|
5826
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
5827
|
+
} else {
|
|
5828
|
+
draw.spliceElementList(elementList, index2 + 1, 1);
|
|
5829
|
+
}
|
|
5830
|
+
curIndex = isCollapsed ? index2 : startIndex;
|
|
5831
|
+
}
|
|
5832
|
+
if (curIndex === null)
|
|
5833
|
+
return;
|
|
5834
|
+
draw.getGlobalEvent().setCanvasEventAbility();
|
|
5835
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
5836
|
+
draw.render({ curIndex });
|
|
5837
|
+
}
|
|
5691
5838
|
function enter(evt, host) {
|
|
5692
5839
|
var _a, _b;
|
|
5693
5840
|
const draw = host.getDraw();
|
|
@@ -5747,277 +5894,408 @@ function enter(evt, host) {
|
|
|
5747
5894
|
}
|
|
5748
5895
|
evt.preventDefault();
|
|
5749
5896
|
}
|
|
5750
|
-
function
|
|
5751
|
-
var _a
|
|
5752
|
-
if (host.isComposing)
|
|
5753
|
-
return;
|
|
5897
|
+
function left(evt, host) {
|
|
5898
|
+
var _a;
|
|
5754
5899
|
const draw = host.getDraw();
|
|
5900
|
+
const isReadonly = draw.isReadonly();
|
|
5901
|
+
if (isReadonly)
|
|
5902
|
+
return;
|
|
5755
5903
|
const position = draw.getPosition();
|
|
5756
5904
|
const cursorPosition = position.getCursorPosition();
|
|
5757
5905
|
if (!cursorPosition)
|
|
5758
5906
|
return;
|
|
5759
|
-
const
|
|
5760
|
-
const historyManager = draw.getHistoryManager();
|
|
5761
|
-
const elementList = draw.getElementList();
|
|
5762
|
-
const positionList = position.getPositionList();
|
|
5907
|
+
const positionContext = position.getPositionContext();
|
|
5763
5908
|
const { index: index2 } = cursorPosition;
|
|
5909
|
+
if (index2 <= 0 && !positionContext.isTable)
|
|
5910
|
+
return;
|
|
5764
5911
|
const rangeManager = draw.getRange();
|
|
5765
5912
|
const { startIndex, endIndex } = rangeManager.getRange();
|
|
5766
|
-
const isCollapsed =
|
|
5767
|
-
const
|
|
5768
|
-
|
|
5769
|
-
if (evt
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
if (isCollapsed && startElement.rowFlex && startElement.value === ZERO) {
|
|
5782
|
-
const rowList = draw.getRowList();
|
|
5783
|
-
const rowNo = positionList[startIndex].rowNo;
|
|
5784
|
-
const rowFlexElementList = rowList[rowNo].elementList;
|
|
5785
|
-
rowFlexElementList.forEach((element) => {
|
|
5786
|
-
delete element.rowFlex;
|
|
5787
|
-
});
|
|
5788
|
-
}
|
|
5789
|
-
if (!isCollapsed) {
|
|
5790
|
-
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
5791
|
-
} else {
|
|
5792
|
-
draw.spliceElementList(elementList, index2, 1);
|
|
5913
|
+
const isCollapsed = rangeManager.getIsCollapsed();
|
|
5914
|
+
const elementList = draw.getElementList();
|
|
5915
|
+
let moveCount = 1;
|
|
5916
|
+
if (isMod(evt)) {
|
|
5917
|
+
const LETTER_REG = draw.getLetterReg();
|
|
5918
|
+
const moveStartIndex = evt.shiftKey && !isCollapsed && startIndex === (cursorPosition == null ? void 0 : cursorPosition.index) ? endIndex : startIndex;
|
|
5919
|
+
if (LETTER_REG.test((_a = elementList[moveStartIndex]) == null ? void 0 : _a.value)) {
|
|
5920
|
+
let i = moveStartIndex - 1;
|
|
5921
|
+
while (i > 0) {
|
|
5922
|
+
const element = elementList[i];
|
|
5923
|
+
if (!LETTER_REG.test(element.value)) {
|
|
5924
|
+
break;
|
|
5925
|
+
}
|
|
5926
|
+
moveCount++;
|
|
5927
|
+
i--;
|
|
5793
5928
|
}
|
|
5794
|
-
curIndex = isCollapsed ? index2 - 1 : startIndex;
|
|
5795
5929
|
}
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
if (activeControl) {
|
|
5806
|
-
curIndex = control.keydown(evt);
|
|
5807
|
-
} else if ((_a = elementList[endIndex + 1]) == null ? void 0 : _a.controlId) {
|
|
5808
|
-
curIndex = control.removeControl(endIndex + 1);
|
|
5809
|
-
} else {
|
|
5810
|
-
if (!isCollapsed) {
|
|
5811
|
-
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
5930
|
+
}
|
|
5931
|
+
const curIndex = startIndex - moveCount;
|
|
5932
|
+
let anchorStartIndex = curIndex;
|
|
5933
|
+
let anchorEndIndex = curIndex;
|
|
5934
|
+
if (evt.shiftKey && cursorPosition) {
|
|
5935
|
+
if (startIndex !== endIndex) {
|
|
5936
|
+
if (startIndex === cursorPosition.index) {
|
|
5937
|
+
anchorStartIndex = startIndex;
|
|
5938
|
+
anchorEndIndex = endIndex - moveCount;
|
|
5812
5939
|
} else {
|
|
5813
|
-
|
|
5940
|
+
anchorStartIndex = curIndex;
|
|
5941
|
+
anchorEndIndex = endIndex;
|
|
5814
5942
|
}
|
|
5815
|
-
|
|
5943
|
+
} else {
|
|
5944
|
+
anchorEndIndex = endIndex;
|
|
5816
5945
|
}
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
let i = moveStartIndex - 1;
|
|
5835
|
-
while (i > 0) {
|
|
5836
|
-
const element = elementList[i];
|
|
5837
|
-
if (!LETTER_REG.test(element.value)) {
|
|
5838
|
-
break;
|
|
5839
|
-
}
|
|
5840
|
-
moveCount++;
|
|
5841
|
-
i--;
|
|
5842
|
-
}
|
|
5843
|
-
}
|
|
5844
|
-
}
|
|
5845
|
-
const curIndex = startIndex - moveCount;
|
|
5846
|
-
let anchorStartIndex = curIndex;
|
|
5847
|
-
let anchorEndIndex = curIndex;
|
|
5848
|
-
if (evt.shiftKey && cursorPosition2) {
|
|
5849
|
-
if (startIndex !== endIndex) {
|
|
5850
|
-
if (startIndex === cursorPosition2.index) {
|
|
5851
|
-
anchorStartIndex = startIndex;
|
|
5852
|
-
anchorEndIndex = endIndex - moveCount;
|
|
5853
|
-
} else {
|
|
5854
|
-
anchorStartIndex = curIndex;
|
|
5855
|
-
anchorEndIndex = endIndex;
|
|
5856
|
-
}
|
|
5857
|
-
} else {
|
|
5858
|
-
anchorEndIndex = endIndex;
|
|
5859
|
-
}
|
|
5860
|
-
}
|
|
5861
|
-
if (!~anchorStartIndex || !~anchorEndIndex)
|
|
5862
|
-
return;
|
|
5863
|
-
rangeManager.setRange(anchorStartIndex, anchorEndIndex);
|
|
5864
|
-
const isAnchorCollapsed = anchorStartIndex === anchorEndIndex;
|
|
5865
|
-
draw.render({
|
|
5866
|
-
curIndex: isAnchorCollapsed ? anchorStartIndex : void 0,
|
|
5867
|
-
isSetCursor: isAnchorCollapsed,
|
|
5868
|
-
isSubmitHistory: false,
|
|
5869
|
-
isCompute: false
|
|
5946
|
+
}
|
|
5947
|
+
if (!evt.shiftKey) {
|
|
5948
|
+
const element = elementList[startIndex];
|
|
5949
|
+
if (element.type === ElementType.TABLE) {
|
|
5950
|
+
const trList = element.trList;
|
|
5951
|
+
const lastTrIndex = trList.length - 1;
|
|
5952
|
+
const lastTr = trList[lastTrIndex];
|
|
5953
|
+
const lastTdIndex = lastTr.tdList.length - 1;
|
|
5954
|
+
const lastTd = lastTr.tdList[lastTdIndex];
|
|
5955
|
+
position.setPositionContext({
|
|
5956
|
+
isTable: true,
|
|
5957
|
+
index: startIndex,
|
|
5958
|
+
trIndex: lastTrIndex,
|
|
5959
|
+
tdIndex: lastTdIndex,
|
|
5960
|
+
tdId: lastTd.id,
|
|
5961
|
+
trId: lastTr.id,
|
|
5962
|
+
tableId: element.id
|
|
5870
5963
|
});
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
if (
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
let
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5964
|
+
anchorStartIndex = lastTd.value.length - 1;
|
|
5965
|
+
anchorEndIndex = anchorStartIndex;
|
|
5966
|
+
draw.getTableTool().render();
|
|
5967
|
+
} else if (element.tableId) {
|
|
5968
|
+
if (startIndex === 0) {
|
|
5969
|
+
const originalElementList = draw.getOriginalElementList();
|
|
5970
|
+
const trList = originalElementList[positionContext.index].trList;
|
|
5971
|
+
for (let r = 0; r < trList.length; r++) {
|
|
5972
|
+
const tr = trList[r];
|
|
5973
|
+
if (tr.id !== element.trId)
|
|
5974
|
+
continue;
|
|
5975
|
+
const tdList = tr.tdList;
|
|
5976
|
+
for (let d = 0; d < tdList.length; d++) {
|
|
5977
|
+
const td = tdList[d];
|
|
5978
|
+
if (td.id !== element.tdId)
|
|
5979
|
+
continue;
|
|
5980
|
+
if (r === 0 && d === 0) {
|
|
5981
|
+
position.setPositionContext({
|
|
5982
|
+
isTable: false
|
|
5983
|
+
});
|
|
5984
|
+
anchorStartIndex = positionContext.index - 1;
|
|
5985
|
+
anchorEndIndex = anchorStartIndex;
|
|
5986
|
+
draw.getTableTool().dispose();
|
|
5987
|
+
} else {
|
|
5988
|
+
let preTrIndex = r;
|
|
5989
|
+
let preTdIndex = d - 1;
|
|
5990
|
+
if (preTdIndex < 0) {
|
|
5991
|
+
preTrIndex = r - 1;
|
|
5992
|
+
preTdIndex = trList[preTrIndex].tdList.length - 1;
|
|
5993
|
+
}
|
|
5994
|
+
const preTr = trList[preTrIndex];
|
|
5995
|
+
const preTd = preTr.tdList[preTdIndex];
|
|
5996
|
+
position.setPositionContext({
|
|
5997
|
+
isTable: true,
|
|
5998
|
+
index: positionContext.index,
|
|
5999
|
+
trIndex: preTrIndex,
|
|
6000
|
+
tdIndex: preTdIndex,
|
|
6001
|
+
tdId: preTr.id,
|
|
6002
|
+
trId: preTd.id,
|
|
6003
|
+
tableId: element.id
|
|
6004
|
+
});
|
|
6005
|
+
anchorStartIndex = preTd.value.length - 1;
|
|
6006
|
+
anchorEndIndex = anchorStartIndex;
|
|
6007
|
+
draw.getTableTool().render();
|
|
5888
6008
|
}
|
|
5889
|
-
|
|
5890
|
-
i++;
|
|
6009
|
+
break;
|
|
5891
6010
|
}
|
|
5892
6011
|
}
|
|
5893
6012
|
}
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
6013
|
+
}
|
|
6014
|
+
}
|
|
6015
|
+
if (!~anchorStartIndex || !~anchorEndIndex)
|
|
6016
|
+
return;
|
|
6017
|
+
rangeManager.setRange(anchorStartIndex, anchorEndIndex);
|
|
6018
|
+
const isAnchorCollapsed = anchorStartIndex === anchorEndIndex;
|
|
6019
|
+
draw.render({
|
|
6020
|
+
curIndex: isAnchorCollapsed ? anchorStartIndex : void 0,
|
|
6021
|
+
isSetCursor: isAnchorCollapsed,
|
|
6022
|
+
isSubmitHistory: false,
|
|
6023
|
+
isCompute: false
|
|
6024
|
+
});
|
|
6025
|
+
evt.preventDefault();
|
|
6026
|
+
}
|
|
6027
|
+
function right(evt, host) {
|
|
6028
|
+
var _a;
|
|
6029
|
+
const draw = host.getDraw();
|
|
6030
|
+
const isReadonly = draw.isReadonly();
|
|
6031
|
+
if (isReadonly)
|
|
6032
|
+
return;
|
|
6033
|
+
const position = draw.getPosition();
|
|
6034
|
+
const cursorPosition = position.getCursorPosition();
|
|
6035
|
+
if (!cursorPosition)
|
|
6036
|
+
return;
|
|
6037
|
+
const { index: index2 } = cursorPosition;
|
|
6038
|
+
const positionList = position.getPositionList();
|
|
6039
|
+
const positionContext = position.getPositionContext();
|
|
6040
|
+
if (index2 > positionList.length - 1 && !positionContext.isTable)
|
|
6041
|
+
return;
|
|
6042
|
+
const rangeManager = draw.getRange();
|
|
6043
|
+
const { startIndex, endIndex } = rangeManager.getRange();
|
|
6044
|
+
const isCollapsed = rangeManager.getIsCollapsed();
|
|
6045
|
+
let elementList = draw.getElementList();
|
|
6046
|
+
let moveCount = 1;
|
|
6047
|
+
if (isMod(evt)) {
|
|
6048
|
+
const LETTER_REG = draw.getLetterReg();
|
|
6049
|
+
const moveStartIndex = evt.shiftKey && !isCollapsed && startIndex === (cursorPosition == null ? void 0 : cursorPosition.index) ? endIndex : startIndex;
|
|
6050
|
+
if (LETTER_REG.test((_a = elementList[moveStartIndex + 1]) == null ? void 0 : _a.value)) {
|
|
6051
|
+
let i = moveStartIndex + 2;
|
|
6052
|
+
while (i < elementList.length) {
|
|
6053
|
+
const element = elementList[i];
|
|
6054
|
+
if (!LETTER_REG.test(element.value)) {
|
|
6055
|
+
break;
|
|
5908
6056
|
}
|
|
6057
|
+
moveCount++;
|
|
6058
|
+
i++;
|
|
5909
6059
|
}
|
|
5910
|
-
const maxElementListIndex = elementList.length - 1;
|
|
5911
|
-
if (anchorStartIndex > maxElementListIndex || anchorEndIndex > maxElementListIndex) {
|
|
5912
|
-
return;
|
|
5913
|
-
}
|
|
5914
|
-
rangeManager.setRange(anchorStartIndex, anchorEndIndex);
|
|
5915
|
-
const isAnchorCollapsed = anchorStartIndex === anchorEndIndex;
|
|
5916
|
-
draw.render({
|
|
5917
|
-
curIndex: isAnchorCollapsed ? anchorStartIndex : void 0,
|
|
5918
|
-
isSetCursor: isAnchorCollapsed,
|
|
5919
|
-
isSubmitHistory: false,
|
|
5920
|
-
isCompute: false
|
|
5921
|
-
});
|
|
5922
|
-
evt.preventDefault();
|
|
5923
6060
|
}
|
|
5924
|
-
}
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
6061
|
+
}
|
|
6062
|
+
const curIndex = endIndex + moveCount;
|
|
6063
|
+
let anchorStartIndex = curIndex;
|
|
6064
|
+
let anchorEndIndex = curIndex;
|
|
6065
|
+
if (evt.shiftKey && cursorPosition) {
|
|
6066
|
+
if (startIndex !== endIndex) {
|
|
5929
6067
|
if (startIndex === cursorPosition.index) {
|
|
5930
|
-
|
|
6068
|
+
anchorStartIndex = startIndex;
|
|
6069
|
+
anchorEndIndex = curIndex;
|
|
5931
6070
|
} else {
|
|
5932
|
-
|
|
6071
|
+
anchorStartIndex = startIndex + moveCount;
|
|
6072
|
+
anchorEndIndex = endIndex;
|
|
5933
6073
|
}
|
|
6074
|
+
} else {
|
|
6075
|
+
anchorStartIndex = startIndex;
|
|
5934
6076
|
}
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
6077
|
+
}
|
|
6078
|
+
if (!evt.shiftKey) {
|
|
6079
|
+
const element = elementList[endIndex];
|
|
6080
|
+
const nextElement = elementList[endIndex + 1];
|
|
6081
|
+
if ((nextElement == null ? void 0 : nextElement.type) === ElementType.TABLE) {
|
|
6082
|
+
const trList = nextElement.trList;
|
|
6083
|
+
const nextTr = trList[0];
|
|
6084
|
+
const nextTd = nextTr.tdList[0];
|
|
6085
|
+
position.setPositionContext({
|
|
6086
|
+
isTable: true,
|
|
6087
|
+
index: endIndex + 1,
|
|
6088
|
+
trIndex: 0,
|
|
6089
|
+
tdIndex: 0,
|
|
6090
|
+
tdId: nextTd.id,
|
|
6091
|
+
trId: nextTr.id,
|
|
6092
|
+
tableId: nextElement.id
|
|
6093
|
+
});
|
|
6094
|
+
anchorStartIndex = 0;
|
|
6095
|
+
anchorEndIndex = 0;
|
|
6096
|
+
draw.getTableTool().render();
|
|
6097
|
+
} else if (element.tableId) {
|
|
6098
|
+
if (!nextElement) {
|
|
6099
|
+
const originalElementList = draw.getOriginalElementList();
|
|
6100
|
+
const trList = originalElementList[positionContext.index].trList;
|
|
6101
|
+
for (let r = 0; r < trList.length; r++) {
|
|
6102
|
+
const tr = trList[r];
|
|
6103
|
+
if (tr.id !== element.trId)
|
|
6104
|
+
continue;
|
|
6105
|
+
const tdList = tr.tdList;
|
|
6106
|
+
for (let d = 0; d < tdList.length; d++) {
|
|
6107
|
+
const td = tdList[d];
|
|
6108
|
+
if (td.id !== element.tdId)
|
|
6109
|
+
continue;
|
|
6110
|
+
if (r === trList.length - 1 && d === tdList.length - 1) {
|
|
6111
|
+
position.setPositionContext({
|
|
6112
|
+
isTable: false
|
|
6113
|
+
});
|
|
6114
|
+
anchorStartIndex = positionContext.index;
|
|
6115
|
+
anchorEndIndex = anchorStartIndex;
|
|
6116
|
+
elementList = draw.getElementList();
|
|
6117
|
+
draw.getTableTool().dispose();
|
|
6118
|
+
} else {
|
|
6119
|
+
let nextTrIndex = r;
|
|
6120
|
+
let nextTdIndex = d + 1;
|
|
6121
|
+
if (nextTdIndex > tdList.length - 1) {
|
|
6122
|
+
nextTrIndex = r + 1;
|
|
6123
|
+
nextTdIndex = 0;
|
|
6124
|
+
}
|
|
6125
|
+
const preTr = trList[nextTrIndex];
|
|
6126
|
+
const preTd = preTr.tdList[nextTdIndex];
|
|
6127
|
+
position.setPositionContext({
|
|
6128
|
+
isTable: true,
|
|
6129
|
+
index: positionContext.index,
|
|
6130
|
+
trIndex: nextTrIndex,
|
|
6131
|
+
tdIndex: nextTdIndex,
|
|
6132
|
+
tdId: preTr.id,
|
|
6133
|
+
trId: preTd.id,
|
|
6134
|
+
tableId: element.id
|
|
6135
|
+
});
|
|
6136
|
+
anchorStartIndex = 0;
|
|
6137
|
+
anchorEndIndex = anchorStartIndex;
|
|
6138
|
+
draw.getTableTool().render();
|
|
6139
|
+
}
|
|
6140
|
+
break;
|
|
6141
|
+
}
|
|
5950
6142
|
}
|
|
5951
|
-
probablePosition.unshift(position2);
|
|
5952
6143
|
}
|
|
6144
|
+
}
|
|
6145
|
+
}
|
|
6146
|
+
const maxElementListIndex = elementList.length - 1;
|
|
6147
|
+
if (anchorStartIndex > maxElementListIndex || anchorEndIndex > maxElementListIndex) {
|
|
6148
|
+
return;
|
|
6149
|
+
}
|
|
6150
|
+
rangeManager.setRange(anchorStartIndex, anchorEndIndex);
|
|
6151
|
+
const isAnchorCollapsed = anchorStartIndex === anchorEndIndex;
|
|
6152
|
+
draw.render({
|
|
6153
|
+
curIndex: isAnchorCollapsed ? anchorStartIndex : void 0,
|
|
6154
|
+
isSetCursor: isAnchorCollapsed,
|
|
6155
|
+
isSubmitHistory: false,
|
|
6156
|
+
isCompute: false
|
|
6157
|
+
});
|
|
6158
|
+
evt.preventDefault();
|
|
6159
|
+
}
|
|
6160
|
+
function tab(evt, host) {
|
|
6161
|
+
const draw = host.getDraw();
|
|
6162
|
+
const isReadonly = draw.isReadonly();
|
|
6163
|
+
if (isReadonly)
|
|
6164
|
+
return;
|
|
6165
|
+
const tabElement = {
|
|
6166
|
+
type: ElementType.TAB,
|
|
6167
|
+
value: ""
|
|
6168
|
+
};
|
|
6169
|
+
const rangeManager = draw.getRange();
|
|
6170
|
+
const { startIndex } = rangeManager.getRange();
|
|
6171
|
+
const elementList = draw.getElementList();
|
|
6172
|
+
formatElementContext(elementList, [tabElement], startIndex);
|
|
6173
|
+
draw.insertElementList([tabElement]);
|
|
6174
|
+
evt.preventDefault();
|
|
6175
|
+
}
|
|
6176
|
+
function updown(evt, host) {
|
|
6177
|
+
const draw = host.getDraw();
|
|
6178
|
+
const isReadonly = draw.isReadonly();
|
|
6179
|
+
if (isReadonly)
|
|
6180
|
+
return;
|
|
6181
|
+
const position = draw.getPosition();
|
|
6182
|
+
const cursorPosition = position.getCursorPosition();
|
|
6183
|
+
if (!cursorPosition)
|
|
6184
|
+
return;
|
|
6185
|
+
const rangeManager = draw.getRange();
|
|
6186
|
+
const { startIndex, endIndex } = rangeManager.getRange();
|
|
6187
|
+
const positionList = position.getPositionList();
|
|
6188
|
+
let anchorPosition = cursorPosition;
|
|
6189
|
+
if (evt.shiftKey) {
|
|
6190
|
+
if (startIndex === cursorPosition.index) {
|
|
6191
|
+
anchorPosition = positionList[endIndex];
|
|
5953
6192
|
} else {
|
|
5954
|
-
|
|
5955
|
-
while (p < positionList.length) {
|
|
5956
|
-
const position2 = positionList[p];
|
|
5957
|
-
p++;
|
|
5958
|
-
if (position2.rowNo === rowNo)
|
|
5959
|
-
continue;
|
|
5960
|
-
if (probablePosition[0] && probablePosition[0].rowNo !== position2.rowNo) {
|
|
5961
|
-
break;
|
|
5962
|
-
}
|
|
5963
|
-
probablePosition.push(position2);
|
|
5964
|
-
}
|
|
6193
|
+
anchorPosition = positionList[startIndex];
|
|
5965
6194
|
}
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
6195
|
+
}
|
|
6196
|
+
const { index: index2, rowNo, rowIndex, coordinate: { leftTop: [curLeftX], rightTop: [curRightX] } } = anchorPosition;
|
|
6197
|
+
const isUp = evt.key === KeyMap.Up;
|
|
6198
|
+
if (isUp && rowIndex === 0 || !isUp && rowIndex === draw.getRowCount() - 1) {
|
|
6199
|
+
return;
|
|
6200
|
+
}
|
|
6201
|
+
const probablePosition = [];
|
|
6202
|
+
if (isUp) {
|
|
6203
|
+
let p = index2 - 1;
|
|
6204
|
+
while (p > 0) {
|
|
6205
|
+
const position2 = positionList[p];
|
|
6206
|
+
p--;
|
|
6207
|
+
if (position2.rowNo === rowNo)
|
|
6208
|
+
continue;
|
|
6209
|
+
if (probablePosition[0] && probablePosition[0].rowNo !== position2.rowNo) {
|
|
6210
|
+
break;
|
|
5972
6211
|
}
|
|
5973
|
-
|
|
6212
|
+
probablePosition.unshift(position2);
|
|
6213
|
+
}
|
|
6214
|
+
} else {
|
|
6215
|
+
let p = index2 + 1;
|
|
6216
|
+
while (p < positionList.length) {
|
|
6217
|
+
const position2 = positionList[p];
|
|
6218
|
+
p++;
|
|
6219
|
+
if (position2.rowNo === rowNo)
|
|
5974
6220
|
continue;
|
|
6221
|
+
if (probablePosition[0] && probablePosition[0].rowNo !== position2.rowNo) {
|
|
6222
|
+
break;
|
|
6223
|
+
}
|
|
6224
|
+
probablePosition.push(position2);
|
|
6225
|
+
}
|
|
6226
|
+
}
|
|
6227
|
+
let nextIndex = 0;
|
|
6228
|
+
for (let p = 0; p < probablePosition.length; p++) {
|
|
6229
|
+
const nextPosition = probablePosition[p];
|
|
6230
|
+
const { coordinate: { leftTop: [nextLeftX], rightTop: [nextRightX] } } = nextPosition;
|
|
6231
|
+
if (p === probablePosition.length - 1) {
|
|
5975
6232
|
nextIndex = nextPosition.index;
|
|
5976
|
-
break;
|
|
5977
6233
|
}
|
|
5978
|
-
if (
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
6234
|
+
if (curRightX <= nextLeftX || curLeftX >= nextRightX)
|
|
6235
|
+
continue;
|
|
6236
|
+
nextIndex = nextPosition.index;
|
|
6237
|
+
break;
|
|
6238
|
+
}
|
|
6239
|
+
if (!nextIndex)
|
|
6240
|
+
return;
|
|
6241
|
+
let anchorStartIndex = nextIndex;
|
|
6242
|
+
let anchorEndIndex = nextIndex;
|
|
6243
|
+
if (evt.shiftKey) {
|
|
6244
|
+
if (startIndex !== endIndex) {
|
|
6245
|
+
if (startIndex === cursorPosition.index) {
|
|
6246
|
+
anchorStartIndex = startIndex;
|
|
5989
6247
|
} else {
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
6248
|
+
anchorEndIndex = endIndex;
|
|
6249
|
+
}
|
|
6250
|
+
} else {
|
|
6251
|
+
if (isUp) {
|
|
6252
|
+
anchorEndIndex = endIndex;
|
|
6253
|
+
} else {
|
|
6254
|
+
anchorStartIndex = startIndex;
|
|
5995
6255
|
}
|
|
5996
6256
|
}
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6257
|
+
}
|
|
6258
|
+
if (anchorStartIndex > anchorEndIndex) {
|
|
6259
|
+
[anchorStartIndex, anchorEndIndex] = [anchorEndIndex, anchorStartIndex];
|
|
6260
|
+
}
|
|
6261
|
+
rangeManager.setRange(anchorStartIndex, anchorEndIndex);
|
|
6262
|
+
const isCollapsed = anchorStartIndex === anchorEndIndex;
|
|
6263
|
+
draw.render({
|
|
6264
|
+
curIndex: isCollapsed ? anchorStartIndex : void 0,
|
|
6265
|
+
isSetCursor: isCollapsed,
|
|
6266
|
+
isSubmitHistory: false,
|
|
6267
|
+
isCompute: false
|
|
6268
|
+
});
|
|
6269
|
+
draw.getCursor().moveCursorToVisible({
|
|
6270
|
+
cursorPosition: positionList[isUp ? anchorStartIndex : anchorEndIndex],
|
|
6271
|
+
direction: isUp ? MoveDirection.UP : MoveDirection.DOWN
|
|
6272
|
+
});
|
|
6273
|
+
}
|
|
6274
|
+
function keydown(evt, host) {
|
|
6275
|
+
if (host.isComposing)
|
|
6276
|
+
return;
|
|
6277
|
+
const draw = host.getDraw();
|
|
6278
|
+
if (evt.key === KeyMap.Backspace) {
|
|
6279
|
+
backspace(evt, host);
|
|
6280
|
+
} else if (evt.key === KeyMap.Delete) {
|
|
6281
|
+
del(evt, host);
|
|
6282
|
+
} else if (evt.key === KeyMap.Enter) {
|
|
6283
|
+
enter(evt, host);
|
|
6284
|
+
} else if (evt.key === KeyMap.Left) {
|
|
6285
|
+
left(evt, host);
|
|
6286
|
+
} else if (evt.key === KeyMap.Right) {
|
|
6287
|
+
right(evt, host);
|
|
6288
|
+
} else if (evt.key === KeyMap.Up || evt.key === KeyMap.Down) {
|
|
6289
|
+
updown(evt, host);
|
|
6012
6290
|
} else if (isMod(evt) && evt.key === KeyMap.Z) {
|
|
6013
|
-
if (isReadonly && draw.getMode() !== EditorMode.FORM)
|
|
6291
|
+
if (draw.isReadonly() && draw.getMode() !== EditorMode.FORM)
|
|
6014
6292
|
return;
|
|
6015
|
-
|
|
6293
|
+
draw.getHistoryManager().undo();
|
|
6016
6294
|
evt.preventDefault();
|
|
6017
6295
|
} else if (isMod(evt) && evt.key === KeyMap.Y) {
|
|
6018
|
-
if (isReadonly && draw.getMode() !== EditorMode.FORM)
|
|
6296
|
+
if (draw.isReadonly() && draw.getMode() !== EditorMode.FORM)
|
|
6019
6297
|
return;
|
|
6020
|
-
|
|
6298
|
+
draw.getHistoryManager().redo();
|
|
6021
6299
|
evt.preventDefault();
|
|
6022
6300
|
} else if (isMod(evt) && evt.key === KeyMap.C) {
|
|
6023
6301
|
host.copy();
|
|
@@ -6029,7 +6307,7 @@ function keydown(evt, host) {
|
|
|
6029
6307
|
host.selectAll();
|
|
6030
6308
|
evt.preventDefault();
|
|
6031
6309
|
} else if (isMod(evt) && evt.key === KeyMap.S) {
|
|
6032
|
-
if (isReadonly)
|
|
6310
|
+
if (draw.isReadonly())
|
|
6033
6311
|
return;
|
|
6034
6312
|
const listener = draw.getListener();
|
|
6035
6313
|
if (listener.saved) {
|
|
@@ -6048,13 +6326,7 @@ function keydown(evt, host) {
|
|
|
6048
6326
|
}
|
|
6049
6327
|
evt.preventDefault();
|
|
6050
6328
|
} else if (evt.key === KeyMap.TAB) {
|
|
6051
|
-
|
|
6052
|
-
type: ElementType.TAB,
|
|
6053
|
-
value: ""
|
|
6054
|
-
};
|
|
6055
|
-
formatElementContext(elementList, [tabElement], startIndex);
|
|
6056
|
-
draw.insertElementList([tabElement]);
|
|
6057
|
-
evt.preventDefault();
|
|
6329
|
+
tab(evt, host);
|
|
6058
6330
|
}
|
|
6059
6331
|
}
|
|
6060
6332
|
function input(data2, host) {
|
|
@@ -6239,6 +6511,10 @@ function dblclick(host, evt) {
|
|
|
6239
6511
|
if (draw.getIsPagingMode()) {
|
|
6240
6512
|
if (!~positionContext.index && positionContext.zone) {
|
|
6241
6513
|
draw.getZone().setZone(positionContext.zone);
|
|
6514
|
+
draw.clearSideEffect();
|
|
6515
|
+
position.setPositionContext({
|
|
6516
|
+
isTable: false
|
|
6517
|
+
});
|
|
6242
6518
|
return;
|
|
6243
6519
|
}
|
|
6244
6520
|
}
|
|
@@ -6768,8 +7044,11 @@ class Position {
|
|
|
6768
7044
|
setPositionList(payload) {
|
|
6769
7045
|
this.positionList = payload;
|
|
6770
7046
|
}
|
|
7047
|
+
setFloatPositionList(payload) {
|
|
7048
|
+
this.floatPositionList = payload;
|
|
7049
|
+
}
|
|
6771
7050
|
computePageRowPosition(payload) {
|
|
6772
|
-
const { positionList, rowList, pageNo, startX, startY, startRowIndex, startIndex, innerWidth } = payload;
|
|
7051
|
+
const { positionList, rowList, pageNo, startX, startY, startRowIndex, startIndex, innerWidth, zone: zone2 } = payload;
|
|
6773
7052
|
const { scale, tdPadding } = this.options;
|
|
6774
7053
|
let x = startX;
|
|
6775
7054
|
let y = startY;
|
|
@@ -6816,6 +7095,12 @@ class Position {
|
|
|
6816
7095
|
positionItem.metrics = prePosition.metrics;
|
|
6817
7096
|
positionItem.coordinate = prePosition.coordinate;
|
|
6818
7097
|
}
|
|
7098
|
+
if (!element.imgFloatPosition) {
|
|
7099
|
+
element.imgFloatPosition = {
|
|
7100
|
+
x,
|
|
7101
|
+
y
|
|
7102
|
+
};
|
|
7103
|
+
}
|
|
6819
7104
|
this.floatPositionList.push({
|
|
6820
7105
|
pageNo,
|
|
6821
7106
|
element,
|
|
@@ -6824,7 +7109,8 @@ class Position {
|
|
|
6824
7109
|
index: payload.index,
|
|
6825
7110
|
tdIndex: payload.tdIndex,
|
|
6826
7111
|
trIndex: payload.trIndex,
|
|
6827
|
-
tdValueIndex: index2
|
|
7112
|
+
tdValueIndex: index2,
|
|
7113
|
+
zone: zone2
|
|
6828
7114
|
});
|
|
6829
7115
|
}
|
|
6830
7116
|
positionList.push(positionItem);
|
|
@@ -6851,7 +7137,8 @@ class Position {
|
|
|
6851
7137
|
isTable: true,
|
|
6852
7138
|
index: index2 - 1,
|
|
6853
7139
|
tdIndex: d,
|
|
6854
|
-
trIndex: t
|
|
7140
|
+
trIndex: t,
|
|
7141
|
+
zone: zone2
|
|
6855
7142
|
});
|
|
6856
7143
|
if (td.verticalAlign === VerticalAlign.MIDDLE || td.verticalAlign === VerticalAlign.BOTTOM) {
|
|
6857
7144
|
const rowsHeight = rowList2.reduce((pre, cur) => pre + cur.height, 0);
|
|
@@ -6883,7 +7170,6 @@ class Position {
|
|
|
6883
7170
|
computePositionList() {
|
|
6884
7171
|
var _a;
|
|
6885
7172
|
this.positionList = [];
|
|
6886
|
-
this.floatPositionList = [];
|
|
6887
7173
|
const innerWidth = this.draw.getInnerWidth();
|
|
6888
7174
|
const pageRowList = this.draw.getPageRowList();
|
|
6889
7175
|
const margins = this.draw.getMargins();
|
|
@@ -6957,10 +7243,10 @@ class Position {
|
|
|
6957
7243
|
return floatTopPosition;
|
|
6958
7244
|
}
|
|
6959
7245
|
for (let j = 0; j < positionList.length; j++) {
|
|
6960
|
-
const { index: index2, pageNo, left, isFirstLetter, coordinate: { leftTop, rightTop, leftBottom } } = positionList[j];
|
|
7246
|
+
const { index: index2, pageNo, left: left2, isFirstLetter, coordinate: { leftTop, rightTop, leftBottom } } = positionList[j];
|
|
6961
7247
|
if (positionNo !== pageNo)
|
|
6962
7248
|
continue;
|
|
6963
|
-
if (leftTop[0] -
|
|
7249
|
+
if (leftTop[0] - left2 <= x && rightTop[0] >= x && leftTop[1] <= y && leftBottom[1] >= y) {
|
|
6964
7250
|
let curPositionIndex2 = j;
|
|
6965
7251
|
const element = elementList[j];
|
|
6966
7252
|
if (element.type === ElementType.TABLE) {
|
|
@@ -7121,9 +7407,10 @@ class Position {
|
|
|
7121
7407
|
}
|
|
7122
7408
|
getFloatPositionByXY(payload) {
|
|
7123
7409
|
const { x, y } = payload;
|
|
7410
|
+
const currentZone = this.draw.getZone().getZone();
|
|
7124
7411
|
for (let f = 0; f < this.floatPositionList.length; f++) {
|
|
7125
|
-
const { position, element, isTable, index: index2, trIndex, tdIndex, tdValueIndex } = this.floatPositionList[f];
|
|
7126
|
-
if (element.type === ElementType.IMAGE && element.imgDisplay === payload.imgDisplay) {
|
|
7412
|
+
const { position, element, isTable, index: index2, trIndex, tdIndex, tdValueIndex, zone: floatElementZone } = this.floatPositionList[f];
|
|
7413
|
+
if (element.type === ElementType.IMAGE && element.imgDisplay === payload.imgDisplay && (!floatElementZone || floatElementZone === currentZone)) {
|
|
7127
7414
|
const imgFloatPosition = element.imgFloatPosition;
|
|
7128
7415
|
if (x >= imgFloatPosition.x && x <= imgFloatPosition.x + element.width && y >= imgFloatPosition.y && y <= imgFloatPosition.y + element.height) {
|
|
7129
7416
|
if (isTable) {
|
|
@@ -9140,12 +9427,12 @@ class HyperlinkParticle {
|
|
|
9140
9427
|
return { hyperlinkPopupContainer, hyperlinkDom };
|
|
9141
9428
|
}
|
|
9142
9429
|
drawHyperlinkPopup(element, position) {
|
|
9143
|
-
const { coordinate: { leftTop: [
|
|
9430
|
+
const { coordinate: { leftTop: [left2, top] }, lineHeight } = position;
|
|
9144
9431
|
const height = this.draw.getHeight();
|
|
9145
9432
|
const pageGap = this.draw.getPageGap();
|
|
9146
9433
|
const preY = this.draw.getPageNo() * (height + pageGap);
|
|
9147
9434
|
this.hyperlinkPopupContainer.style.display = "block";
|
|
9148
|
-
this.hyperlinkPopupContainer.style.left = `${
|
|
9435
|
+
this.hyperlinkPopupContainer.style.left = `${left2}px`;
|
|
9149
9436
|
this.hyperlinkPopupContainer.style.top = `${top + preY + lineHeight}px`;
|
|
9150
9437
|
const url = element.url || "#";
|
|
9151
9438
|
this.hyperlinkDom.href = url;
|
|
@@ -9229,7 +9516,8 @@ class Header {
|
|
|
9229
9516
|
startIndex: 0,
|
|
9230
9517
|
startX,
|
|
9231
9518
|
startY,
|
|
9232
|
-
innerWidth
|
|
9519
|
+
innerWidth,
|
|
9520
|
+
zone: EditorZone.HEADER
|
|
9233
9521
|
});
|
|
9234
9522
|
}
|
|
9235
9523
|
getHeaderTop() {
|
|
@@ -9691,9 +9979,9 @@ class SelectControl {
|
|
|
9691
9979
|
ul.append(li);
|
|
9692
9980
|
}
|
|
9693
9981
|
selectPopupContainer.append(ul);
|
|
9694
|
-
const { coordinate: { leftTop: [
|
|
9982
|
+
const { coordinate: { leftTop: [left2, top] }, lineHeight } = position;
|
|
9695
9983
|
const preY = this.control.getPreY();
|
|
9696
|
-
selectPopupContainer.style.left = `${
|
|
9984
|
+
selectPopupContainer.style.left = `${left2}px`;
|
|
9697
9985
|
selectPopupContainer.style.top = `${top + preY + lineHeight}px`;
|
|
9698
9986
|
const container = this.control.getContainer();
|
|
9699
9987
|
container.append(selectPopupContainer);
|
|
@@ -10493,6 +10781,23 @@ class Control {
|
|
|
10493
10781
|
isSetCursor: false
|
|
10494
10782
|
});
|
|
10495
10783
|
}
|
|
10784
|
+
getList() {
|
|
10785
|
+
const data2 = [
|
|
10786
|
+
this.draw.getHeader().getElementList(),
|
|
10787
|
+
this.draw.getOriginalMainElementList(),
|
|
10788
|
+
this.draw.getFooter().getElementList()
|
|
10789
|
+
];
|
|
10790
|
+
const controlElementList = [];
|
|
10791
|
+
for (const elementList of data2) {
|
|
10792
|
+
for (let e = 0; e < elementList.length; e++) {
|
|
10793
|
+
const element = elementList[e];
|
|
10794
|
+
if (element.controlId) {
|
|
10795
|
+
controlElementList.push(element);
|
|
10796
|
+
}
|
|
10797
|
+
}
|
|
10798
|
+
}
|
|
10799
|
+
return zipElementList(controlElementList);
|
|
10800
|
+
}
|
|
10496
10801
|
}
|
|
10497
10802
|
class CheckboxParticle {
|
|
10498
10803
|
constructor(draw) {
|
|
@@ -10518,7 +10823,7 @@ class CheckboxParticle {
|
|
|
10518
10823
|
render(ctx, element, x, y) {
|
|
10519
10824
|
const { checkbox: { gap, lineWidth, fillStyle, fontStyle }, scale } = this.options;
|
|
10520
10825
|
const { metrics, checkbox } = element;
|
|
10521
|
-
const
|
|
10826
|
+
const left2 = Math.round(x + gap * scale);
|
|
10522
10827
|
const top = Math.round(y - metrics.height + lineWidth);
|
|
10523
10828
|
const width = metrics.width - gap * 2 * scale;
|
|
10524
10829
|
const height = metrics.height;
|
|
@@ -10528,22 +10833,22 @@ class CheckboxParticle {
|
|
|
10528
10833
|
if (checkbox == null ? void 0 : checkbox.value) {
|
|
10529
10834
|
ctx.lineWidth = lineWidth;
|
|
10530
10835
|
ctx.strokeStyle = fillStyle;
|
|
10531
|
-
ctx.rect(
|
|
10836
|
+
ctx.rect(left2, top, width, height);
|
|
10532
10837
|
ctx.stroke();
|
|
10533
10838
|
ctx.beginPath();
|
|
10534
10839
|
ctx.fillStyle = fillStyle;
|
|
10535
|
-
ctx.fillRect(
|
|
10840
|
+
ctx.fillRect(left2, top, width, height);
|
|
10536
10841
|
ctx.beginPath();
|
|
10537
10842
|
ctx.strokeStyle = fontStyle;
|
|
10538
10843
|
ctx.lineWidth = lineWidth * 2;
|
|
10539
|
-
ctx.moveTo(
|
|
10540
|
-
ctx.lineTo(
|
|
10541
|
-
ctx.moveTo(
|
|
10542
|
-
ctx.lineTo(
|
|
10844
|
+
ctx.moveTo(left2 + 2 * scale, top + 7 * scale);
|
|
10845
|
+
ctx.lineTo(left2 + 7 * scale, top + 11 * scale);
|
|
10846
|
+
ctx.moveTo(left2 + 6.5 * scale, top + 11 * scale);
|
|
10847
|
+
ctx.lineTo(left2 + 12 * scale, top + 3 * scale);
|
|
10543
10848
|
ctx.stroke();
|
|
10544
10849
|
} else {
|
|
10545
10850
|
ctx.lineWidth = lineWidth;
|
|
10546
|
-
ctx.rect(
|
|
10851
|
+
ctx.rect(left2, top, width, height);
|
|
10547
10852
|
ctx.stroke();
|
|
10548
10853
|
}
|
|
10549
10854
|
ctx.closePath();
|
|
@@ -10688,8 +10993,8 @@ class Previewer {
|
|
|
10688
10993
|
x = element.imgFloatPosition.x;
|
|
10689
10994
|
y = element.imgFloatPosition.y + preY;
|
|
10690
10995
|
} else if (position) {
|
|
10691
|
-
const { coordinate: { leftTop: [
|
|
10692
|
-
x =
|
|
10996
|
+
const { coordinate: { leftTop: [left2, top] }, ascent } = position;
|
|
10997
|
+
x = left2;
|
|
10693
10998
|
y = top + preY + ascent;
|
|
10694
10999
|
}
|
|
10695
11000
|
return { x, y };
|
|
@@ -10952,9 +11257,9 @@ class Previewer {
|
|
|
10952
11257
|
this.resizerSelection.style.width = `${width}px`;
|
|
10953
11258
|
this.resizerSelection.style.height = `${height}px`;
|
|
10954
11259
|
for (let i = 0; i < 8; i++) {
|
|
10955
|
-
const
|
|
11260
|
+
const left2 = i === 0 || i === 6 || i === 7 ? -handleSize : i === 1 || i === 5 ? width / 2 : width - handleSize;
|
|
10956
11261
|
const top = i === 0 || i === 1 || i === 2 ? -handleSize : i === 3 || i === 7 ? height / 2 - handleSize : height - handleSize;
|
|
10957
|
-
this.resizerHandleList[i].style.left = `${
|
|
11262
|
+
this.resizerHandleList[i].style.left = `${left2}px`;
|
|
10958
11263
|
this.resizerHandleList[i].style.top = `${top}px`;
|
|
10959
11264
|
}
|
|
10960
11265
|
}
|
|
@@ -11275,8 +11580,8 @@ class DatePicker {
|
|
|
11275
11580
|
_setPosition() {
|
|
11276
11581
|
if (!this.renderOptions)
|
|
11277
11582
|
return;
|
|
11278
|
-
const { position: { coordinate: { leftTop: [
|
|
11279
|
-
this.dom.container.style.left = `${
|
|
11583
|
+
const { position: { coordinate: { leftTop: [left2, top] }, lineHeight }, startTop } = this.renderOptions;
|
|
11584
|
+
this.dom.container.style.left = `${left2}px`;
|
|
11280
11585
|
this.dom.container.style.top = `${top + (startTop || 0) + lineHeight}px`;
|
|
11281
11586
|
}
|
|
11282
11587
|
isInvalidDate(value) {
|
|
@@ -11620,15 +11925,6 @@ class DateParticle {
|
|
|
11620
11925
|
startTop
|
|
11621
11926
|
});
|
|
11622
11927
|
}
|
|
11623
|
-
render(ctx, element, x, y) {
|
|
11624
|
-
ctx.save();
|
|
11625
|
-
ctx.font = element.style;
|
|
11626
|
-
if (element.color) {
|
|
11627
|
-
ctx.fillStyle = element.color;
|
|
11628
|
-
}
|
|
11629
|
-
ctx.fillText(element.value, x, y);
|
|
11630
|
-
ctx.restore();
|
|
11631
|
-
}
|
|
11632
11928
|
}
|
|
11633
11929
|
var BlockType;
|
|
11634
11930
|
(function(BlockType2) {
|
|
@@ -11992,10 +12288,10 @@ class ZoneTip {
|
|
|
11992
12288
|
tipContent
|
|
11993
12289
|
};
|
|
11994
12290
|
}
|
|
11995
|
-
_updateZoneTip(visible,
|
|
12291
|
+
_updateZoneTip(visible, left2, top) {
|
|
11996
12292
|
if (visible) {
|
|
11997
12293
|
this.tipContainer.classList.add("show");
|
|
11998
|
-
this.tipContainer.style.left = `${
|
|
12294
|
+
this.tipContainer.style.left = `${left2}px`;
|
|
11999
12295
|
this.tipContainer.style.top = `${top}px`;
|
|
12000
12296
|
this.tipContent.innerText = this.i18n.t(`zone.${this.currentMoveZone === EditorZone.HEADER ? "headerTip" : "footerTip"}`);
|
|
12001
12297
|
} else {
|
|
@@ -12188,7 +12484,8 @@ class Footer {
|
|
|
12188
12484
|
startIndex: 0,
|
|
12189
12485
|
startX,
|
|
12190
12486
|
startY,
|
|
12191
|
-
innerWidth
|
|
12487
|
+
innerWidth,
|
|
12488
|
+
zone: EditorZone.FOOTER
|
|
12192
12489
|
});
|
|
12193
12490
|
}
|
|
12194
12491
|
getFooterBottom() {
|
|
@@ -13035,6 +13332,11 @@ class Draw {
|
|
|
13035
13332
|
}
|
|
13036
13333
|
this.spliceElementList(elementList, start, 0, ...payload);
|
|
13037
13334
|
curIndex = startIndex + payload.length;
|
|
13335
|
+
const preElement = elementList[start - 1];
|
|
13336
|
+
if (payload[0].listId && preElement && !preElement.listId && (preElement == null ? void 0 : preElement.value) === ZERO && (!preElement.type || preElement.type === ElementType.TEXT)) {
|
|
13337
|
+
elementList.splice(startIndex, 1);
|
|
13338
|
+
curIndex -= 1;
|
|
13339
|
+
}
|
|
13038
13340
|
}
|
|
13039
13341
|
if (~curIndex) {
|
|
13040
13342
|
this.range.setRange(curIndex, curIndex);
|
|
@@ -13490,6 +13792,24 @@ class Draw {
|
|
|
13490
13792
|
} else if (element.type === ElementType.TABLE) {
|
|
13491
13793
|
const tdPaddingWidth = tdPadding[1] + tdPadding[3];
|
|
13492
13794
|
const tdPaddingHeight = tdPadding[0] + tdPadding[2];
|
|
13795
|
+
if (element.pagingId) {
|
|
13796
|
+
let tableIndex = i + 1;
|
|
13797
|
+
let combineCount = 0;
|
|
13798
|
+
while (tableIndex < elementList.length) {
|
|
13799
|
+
const nextElement2 = elementList[tableIndex];
|
|
13800
|
+
if (nextElement2.pagingId === element.pagingId) {
|
|
13801
|
+
element.trList.push(...nextElement2.trList);
|
|
13802
|
+
element.height += nextElement2.height;
|
|
13803
|
+
tableIndex++;
|
|
13804
|
+
combineCount++;
|
|
13805
|
+
} else {
|
|
13806
|
+
break;
|
|
13807
|
+
}
|
|
13808
|
+
}
|
|
13809
|
+
if (combineCount) {
|
|
13810
|
+
elementList.splice(i + 1, combineCount);
|
|
13811
|
+
}
|
|
13812
|
+
}
|
|
13493
13813
|
this.tableParticle.computeRowColInfo(element);
|
|
13494
13814
|
const trList = element.trList;
|
|
13495
13815
|
for (let t = 0; t < trList.length; t++) {
|
|
@@ -13567,6 +13887,9 @@ class Draw {
|
|
|
13567
13887
|
}
|
|
13568
13888
|
}
|
|
13569
13889
|
const rowMarginHeight = rowMargin * 2 * scale;
|
|
13890
|
+
if (curPagePreHeight + element.trList[0].height + rowMarginHeight > height2) {
|
|
13891
|
+
curPagePreHeight = marginHeight;
|
|
13892
|
+
}
|
|
13570
13893
|
if (curPagePreHeight + rowMarginHeight + elementHeight > height2) {
|
|
13571
13894
|
const trList2 = element.trList;
|
|
13572
13895
|
let deleteStart = 0;
|
|
@@ -13591,17 +13914,39 @@ class Draw {
|
|
|
13591
13914
|
if (deleteCount) {
|
|
13592
13915
|
const cloneTrList = trList2.splice(deleteStart, deleteCount);
|
|
13593
13916
|
const cloneTrHeight = cloneTrList.reduce((pre, cur) => pre + cur.height, 0);
|
|
13917
|
+
const pagingId = element.pagingId || getUUID();
|
|
13918
|
+
element.pagingId = pagingId;
|
|
13594
13919
|
element.height -= cloneTrHeight;
|
|
13595
13920
|
metrics.height -= cloneTrHeight;
|
|
13596
13921
|
metrics.boundingBoxDescent -= cloneTrHeight;
|
|
13597
13922
|
const cloneElement = deepClone(element);
|
|
13923
|
+
cloneElement.pagingId = pagingId;
|
|
13598
13924
|
cloneElement.trList = cloneTrList;
|
|
13599
13925
|
cloneElement.id = getUUID();
|
|
13600
13926
|
this.spliceElementList(elementList, i + 1, 0, cloneElement);
|
|
13601
|
-
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13927
|
+
}
|
|
13928
|
+
}
|
|
13929
|
+
if (element.pagingId) {
|
|
13930
|
+
const positionContext = this.position.getPositionContext();
|
|
13931
|
+
if (positionContext.isTable) {
|
|
13932
|
+
let newPositionContextIndex = -1;
|
|
13933
|
+
let newPositionContextTrIndex = -1;
|
|
13934
|
+
let tableIndex = i;
|
|
13935
|
+
while (tableIndex < elementList.length) {
|
|
13936
|
+
const curElement = elementList[tableIndex];
|
|
13937
|
+
if (curElement.pagingId !== element.pagingId)
|
|
13938
|
+
break;
|
|
13939
|
+
const trIndex = curElement.trList.findIndex((r) => r.id === positionContext.trId);
|
|
13940
|
+
if (~trIndex) {
|
|
13941
|
+
newPositionContextIndex = tableIndex;
|
|
13942
|
+
newPositionContextTrIndex = trIndex;
|
|
13943
|
+
break;
|
|
13944
|
+
}
|
|
13945
|
+
tableIndex++;
|
|
13946
|
+
}
|
|
13947
|
+
if (~newPositionContextIndex) {
|
|
13948
|
+
positionContext.index = newPositionContextIndex;
|
|
13949
|
+
positionContext.trIndex = newPositionContextTrIndex;
|
|
13605
13950
|
this.position.setPositionContext(positionContext);
|
|
13606
13951
|
}
|
|
13607
13952
|
}
|
|
@@ -13671,9 +14016,9 @@ class Draw {
|
|
|
13671
14016
|
const extraWidth = rowElement.control.minWidth - controlRealWidth;
|
|
13672
14017
|
if (extraWidth > 0) {
|
|
13673
14018
|
const rowRemainingWidth = availableWidth - curRow.width - metrics.width;
|
|
13674
|
-
const
|
|
13675
|
-
rowElement.left =
|
|
13676
|
-
curRow.width +=
|
|
14019
|
+
const left2 = Math.min(rowRemainingWidth, extraWidth) * scale;
|
|
14020
|
+
rowElement.left = left2;
|
|
14021
|
+
curRow.width += left2;
|
|
13677
14022
|
} else {
|
|
13678
14023
|
rowElement.left = 0;
|
|
13679
14024
|
}
|
|
@@ -13845,8 +14190,14 @@ class Draw {
|
|
|
13845
14190
|
this._drawRichText(ctx);
|
|
13846
14191
|
this.hyperlinkParticle.render(ctx, element, x, y + offsetY);
|
|
13847
14192
|
} else if (element.type === ElementType.DATE) {
|
|
13848
|
-
|
|
13849
|
-
|
|
14193
|
+
const nextElement = curRow.elementList[j + 1];
|
|
14194
|
+
if (!preElement || preElement.dateId !== element.dateId) {
|
|
14195
|
+
this._drawRichText(ctx);
|
|
14196
|
+
}
|
|
14197
|
+
this.textParticle.record(ctx, element, x, y + offsetY);
|
|
14198
|
+
if (!nextElement || nextElement.dateId !== element.dateId) {
|
|
14199
|
+
this._drawRichText(ctx);
|
|
14200
|
+
}
|
|
13850
14201
|
} else if (element.type === ElementType.SUPERSCRIPT) {
|
|
13851
14202
|
this._drawRichText(ctx);
|
|
13852
14203
|
this.superscriptParticle.render(ctx, element, x, y + offsetY);
|
|
@@ -13973,7 +14324,7 @@ class Draw {
|
|
|
13973
14324
|
for (let e = 0; e < floatPositionList.length; e++) {
|
|
13974
14325
|
const floatPosition = floatPositionList[e];
|
|
13975
14326
|
const element = floatPosition.element;
|
|
13976
|
-
if (pageNo === floatPosition.pageNo && element.imgDisplay === imgDisplay && element.type === ElementType.IMAGE) {
|
|
14327
|
+
if ((pageNo === floatPosition.pageNo || floatPosition.zone === EditorZone.HEADER || floatPosition.zone == EditorZone.FOOTER) && element.imgDisplay === imgDisplay && element.type === ElementType.IMAGE) {
|
|
13977
14328
|
const imgFloatPosition = element.imgFloatPosition;
|
|
13978
14329
|
this.imageParticle.render(ctx, element, imgFloatPosition.x, imgFloatPosition.y);
|
|
13979
14330
|
}
|
|
@@ -14082,6 +14433,7 @@ class Draw {
|
|
|
14082
14433
|
const innerWidth = this.getInnerWidth();
|
|
14083
14434
|
const isPagingMode = this.getIsPagingMode();
|
|
14084
14435
|
if (isCompute) {
|
|
14436
|
+
this.position.setFloatPositionList([]);
|
|
14085
14437
|
if (isPagingMode) {
|
|
14086
14438
|
if (!header.disabled) {
|
|
14087
14439
|
this.header.compute();
|
|
@@ -14302,6 +14654,7 @@ class Command {
|
|
|
14302
14654
|
__publicField(this, "getLocale");
|
|
14303
14655
|
__publicField(this, "getGroupIds");
|
|
14304
14656
|
__publicField(this, "getControlValue");
|
|
14657
|
+
__publicField(this, "getControlList");
|
|
14305
14658
|
__publicField(this, "getContainer");
|
|
14306
14659
|
this.executeMode = adapt.mode.bind(adapt);
|
|
14307
14660
|
this.executeCut = adapt.cut.bind(adapt);
|
|
@@ -14410,6 +14763,7 @@ class Command {
|
|
|
14410
14763
|
this.executeSetControlProperties = adapt.setControlProperties.bind(adapt);
|
|
14411
14764
|
this.executeSetControlHighlight = adapt.setControlHighlight.bind(adapt);
|
|
14412
14765
|
this.getControlValue = adapt.getControlValue.bind(adapt);
|
|
14766
|
+
this.getControlList = adapt.getControlList.bind(adapt);
|
|
14413
14767
|
}
|
|
14414
14768
|
}
|
|
14415
14769
|
const defaultWatermarkOption = {
|
|
@@ -14599,6 +14953,10 @@ class CommandAdapt {
|
|
|
14599
14953
|
this.historyManager.redo();
|
|
14600
14954
|
}
|
|
14601
14955
|
painter(options) {
|
|
14956
|
+
if (!options.isDblclick && this.draw.getPainterStyle()) {
|
|
14957
|
+
this.canvasEvent.clearPainterStyle();
|
|
14958
|
+
return;
|
|
14959
|
+
}
|
|
14602
14960
|
const selection = this.range.getSelection();
|
|
14603
14961
|
if (!selection)
|
|
14604
14962
|
return;
|
|
@@ -14934,7 +15292,11 @@ class CommandAdapt {
|
|
|
14934
15292
|
const selection = this.range.getSelectionElementList();
|
|
14935
15293
|
if (selection == null ? void 0 : selection.length) {
|
|
14936
15294
|
selection.forEach((el) => {
|
|
14937
|
-
|
|
15295
|
+
if (payload) {
|
|
15296
|
+
el.color = payload;
|
|
15297
|
+
} else {
|
|
15298
|
+
delete el.color;
|
|
15299
|
+
}
|
|
14938
15300
|
});
|
|
14939
15301
|
this.draw.render({
|
|
14940
15302
|
isSetCursor: false,
|
|
@@ -14945,7 +15307,11 @@ class CommandAdapt {
|
|
|
14945
15307
|
const elementList = this.draw.getElementList();
|
|
14946
15308
|
const enterElement = elementList[endIndex];
|
|
14947
15309
|
if ((enterElement == null ? void 0 : enterElement.value) === ZERO) {
|
|
14948
|
-
|
|
15310
|
+
if (payload) {
|
|
15311
|
+
enterElement.color = payload;
|
|
15312
|
+
} else {
|
|
15313
|
+
delete enterElement.color;
|
|
15314
|
+
}
|
|
14949
15315
|
this.draw.render({ curIndex: endIndex, isCompute: false });
|
|
14950
15316
|
}
|
|
14951
15317
|
}
|
|
@@ -14957,7 +15323,11 @@ class CommandAdapt {
|
|
|
14957
15323
|
const selection = this.range.getSelectionElementList();
|
|
14958
15324
|
if (selection == null ? void 0 : selection.length) {
|
|
14959
15325
|
selection.forEach((el) => {
|
|
14960
|
-
|
|
15326
|
+
if (payload) {
|
|
15327
|
+
el.highlight = payload;
|
|
15328
|
+
} else {
|
|
15329
|
+
delete el.highlight;
|
|
15330
|
+
}
|
|
14961
15331
|
});
|
|
14962
15332
|
this.draw.render({
|
|
14963
15333
|
isSetCursor: false,
|
|
@@ -14968,7 +15338,11 @@ class CommandAdapt {
|
|
|
14968
15338
|
const elementList = this.draw.getElementList();
|
|
14969
15339
|
const enterElement = elementList[endIndex];
|
|
14970
15340
|
if ((enterElement == null ? void 0 : enterElement.value) === ZERO) {
|
|
14971
|
-
|
|
15341
|
+
if (payload) {
|
|
15342
|
+
enterElement.highlight = payload;
|
|
15343
|
+
} else {
|
|
15344
|
+
delete enterElement.highlight;
|
|
15345
|
+
}
|
|
14972
15346
|
this.draw.render({ curIndex: endIndex, isCompute: false });
|
|
14973
15347
|
}
|
|
14974
15348
|
}
|
|
@@ -16523,6 +16897,9 @@ class CommandAdapt {
|
|
|
16523
16897
|
setControlHighlight(payload) {
|
|
16524
16898
|
this.draw.getControl().setHighlightList(payload);
|
|
16525
16899
|
}
|
|
16900
|
+
getControlList() {
|
|
16901
|
+
return this.draw.getControl().getList();
|
|
16902
|
+
}
|
|
16526
16903
|
getContainer() {
|
|
16527
16904
|
return this.draw.getContainer();
|
|
16528
16905
|
}
|
|
@@ -17179,7 +17556,7 @@ class ContextMenu {
|
|
|
17179
17556
|
}
|
|
17180
17557
|
_render(payload) {
|
|
17181
17558
|
var _a;
|
|
17182
|
-
const { contextMenuList, left, top, parentMenuContainer } = payload;
|
|
17559
|
+
const { contextMenuList, left: left2, top, parentMenuContainer } = payload;
|
|
17183
17560
|
const contextMenuContainer = this._createContextMenuContainer();
|
|
17184
17561
|
const contextMenuContent = document.createElement("div");
|
|
17185
17562
|
contextMenuContent.classList.add(`${EDITOR_PREFIX}-contextmenu-content`);
|
|
@@ -17207,11 +17584,11 @@ class ContextMenu {
|
|
|
17207
17584
|
this._setHoverStatus(menuItem, true);
|
|
17208
17585
|
this._removeSubMenu(contextMenuContainer);
|
|
17209
17586
|
const subMenuRect = menuItem.getBoundingClientRect();
|
|
17210
|
-
const
|
|
17587
|
+
const left22 = subMenuRect.left + subMenuRect.width;
|
|
17211
17588
|
const top2 = subMenuRect.top;
|
|
17212
17589
|
childMenuContainer = this._render({
|
|
17213
17590
|
contextMenuList: childMenus,
|
|
17214
|
-
left:
|
|
17591
|
+
left: left22,
|
|
17215
17592
|
top: top2,
|
|
17216
17593
|
parentMenuContainer: contextMenuContainer
|
|
17217
17594
|
});
|
|
@@ -17260,7 +17637,7 @@ class ContextMenu {
|
|
|
17260
17637
|
const innerWidth = window.innerWidth;
|
|
17261
17638
|
const contextmenuRect = contextMenuContainer.getBoundingClientRect();
|
|
17262
17639
|
const contextMenuWidth = contextmenuRect.width;
|
|
17263
|
-
const adjustLeft =
|
|
17640
|
+
const adjustLeft = left2 + contextMenuWidth > innerWidth ? left2 - contextMenuWidth : left2;
|
|
17264
17641
|
contextMenuContainer.style.left = `${adjustLeft}px`;
|
|
17265
17642
|
const innerHeight = window.innerHeight;
|
|
17266
17643
|
const contextMenuHeight = contextmenuRect.height;
|