@hufe921/canvas-editor 0.9.63 → 0.9.65
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 +34 -0
- package/dist/canvas-editor.es.js +211 -95
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +32 -32
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +2 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +3 -1
- package/dist/src/editor/core/draw/control/Control.d.ts +3 -1
- package/dist/src/editor/core/event/handlers/paste.d.ts +3 -1
- package/dist/src/editor/dataset/constant/Editor.d.ts +1 -0
- package/dist/src/editor/interface/Control.d.ts +4 -0
- package/dist/src/editor/utils/clipboard.d.ts +8 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
## [0.9.65](https://github.com/Hufe921/canvas-editor/compare/v0.9.64...v0.9.65) (2024-02-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* cursor position error when scaling the page #434 ([e03feb2](https://github.com/Hufe921/canvas-editor/commit/e03feb210282779ecebb7af3d9a3801392b66979)), closes [#434](https://github.com/Hufe921/canvas-editor/issues/434)
|
|
7
|
+
* insert image render error when scaling the page #433 ([acb0d3f](https://github.com/Hufe921/canvas-editor/commit/acb0d3fc47953c822b2daa5b1b437780a2c0f67e)), closes [#433](https://github.com/Hufe921/canvas-editor/issues/433)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* add getRange api #429 ([2a6a41c](https://github.com/Hufe921/canvas-editor/commit/2a6a41c8c9ebe8188de08d43f10db89c77016950)), closes [#429](https://github.com/Hufe921/canvas-editor/issues/429)
|
|
13
|
+
* paste original elements by api ([7ab103e](https://github.com/Hufe921/canvas-editor/commit/7ab103edd9c3dbfa3c94b31167fc68487656a4d0))
|
|
14
|
+
* set margin style when printing #431 ([4015707](https://github.com/Hufe921/canvas-editor/commit/4015707025689648be2d3082dfbcbe2e597b55d1)), closes [#431](https://github.com/Hufe921/canvas-editor/issues/431)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [0.9.64](https://github.com/Hufe921/canvas-editor/compare/v0.9.63...v0.9.64) (2024-01-28)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* error inserting image within control #422 ([ea4ac33](https://github.com/Hufe921/canvas-editor/commit/ea4ac339c7de962845f639a1c5ac24d8e3640485)), closes [#422](https://github.com/Hufe921/canvas-editor/issues/422)
|
|
24
|
+
* render error when row element is empty #420 ([8999f28](https://github.com/Hufe921/canvas-editor/commit/8999f283bb87d92fe58b1aa8330bf4d9d75b9064)), closes [#420](https://github.com/Hufe921/canvas-editor/issues/420)
|
|
25
|
+
* zone tip position error in firefox browser #423 ([3cf911c](https://github.com/Hufe921/canvas-editor/commit/3cf911c501a0c0af85d994d5b50c657c6cd77692)), closes [#423](https://github.com/Hufe921/canvas-editor/issues/423)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* add executeSetControlProperties api #391 ([3ffb6b9](https://github.com/Hufe921/canvas-editor/commit/3ffb6b94b57a0d0fe81cc778a26d4e2a234e24ab)), closes [#391](https://github.com/Hufe921/canvas-editor/issues/391)
|
|
31
|
+
* copy and paste original elements #397 (#426) ([2fc16de](https://github.com/Hufe921/canvas-editor/commit/2fc16de4e15578cdd181c4186b4cf978924b5207)), closes [#397](https://github.com/Hufe921/canvas-editor/issues/397) [#426](https://github.com/Hufe921/canvas-editor/issues/426)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
1
35
|
## [0.9.63](https://github.com/Hufe921/canvas-editor/compare/v0.9.62...v0.9.63) (2024-01-19)
|
|
2
36
|
|
|
3
37
|
|
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.65";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -327,6 +327,7 @@ const defaultCursorOption = {
|
|
|
327
327
|
};
|
|
328
328
|
const EDITOR_COMPONENT = "editor-component";
|
|
329
329
|
const EDITOR_PREFIX = "ce";
|
|
330
|
+
const EDITOR_CLIPBOARD = `${EDITOR_PREFIX}-clipboard`;
|
|
330
331
|
var MoveDirection;
|
|
331
332
|
(function(MoveDirection2) {
|
|
332
333
|
MoveDirection2["UP"] = "top";
|
|
@@ -3747,6 +3748,10 @@ function formatElementList(elementList, options) {
|
|
|
3747
3748
|
}
|
|
3748
3749
|
i--;
|
|
3749
3750
|
} else if (el.type === ElementType.CONTROL) {
|
|
3751
|
+
if (!el.control) {
|
|
3752
|
+
i++;
|
|
3753
|
+
continue;
|
|
3754
|
+
}
|
|
3750
3755
|
const { prefix, postfix, value, placeholder, code, type, valueSets } = el.control;
|
|
3751
3756
|
const { editorOptions: { control: controlOption, checkbox: checkboxOption } } = options;
|
|
3752
3757
|
const controlId = getUUID();
|
|
@@ -4549,35 +4554,81 @@ ${listIndex + 1}.${buildText(listElementList)}${isLast ? `
|
|
|
4549
4554
|
}
|
|
4550
4555
|
return buildText(zipElementList(elementList));
|
|
4551
4556
|
}
|
|
4552
|
-
function
|
|
4557
|
+
function setClipboardData(data2) {
|
|
4558
|
+
localStorage.setItem(EDITOR_CLIPBOARD, JSON.stringify({
|
|
4559
|
+
text: data2.text,
|
|
4560
|
+
elementList: data2.elementList
|
|
4561
|
+
}));
|
|
4562
|
+
}
|
|
4563
|
+
function getClipboardData() {
|
|
4564
|
+
const clipboardText = localStorage.getItem(EDITOR_CLIPBOARD);
|
|
4565
|
+
return clipboardText ? JSON.parse(clipboardText) : null;
|
|
4566
|
+
}
|
|
4567
|
+
function removeClipboardData() {
|
|
4568
|
+
localStorage.removeItem(EDITOR_CLIPBOARD);
|
|
4569
|
+
}
|
|
4570
|
+
function writeClipboardItem(text, html, elementList) {
|
|
4571
|
+
if (!text && !html && !elementList.length)
|
|
4572
|
+
return;
|
|
4573
|
+
const plainText = new Blob([text], { type: "text/plain" });
|
|
4574
|
+
const htmlText = new Blob([html], { type: "text/html" });
|
|
4575
|
+
if (window.ClipboardItem) {
|
|
4576
|
+
const item = new ClipboardItem({
|
|
4577
|
+
[plainText.type]: plainText,
|
|
4578
|
+
[htmlText.type]: htmlText
|
|
4579
|
+
});
|
|
4580
|
+
window.navigator.clipboard.write([item]);
|
|
4581
|
+
} else {
|
|
4582
|
+
const fakeElement = document.createElement("div");
|
|
4583
|
+
fakeElement.setAttribute("contenteditable", "true");
|
|
4584
|
+
fakeElement.innerHTML = html;
|
|
4585
|
+
document.body.append(fakeElement);
|
|
4586
|
+
const selection = window.getSelection();
|
|
4587
|
+
const range = document.createRange();
|
|
4588
|
+
range.selectNodeContents(fakeElement);
|
|
4589
|
+
selection == null ? void 0 : selection.removeAllRanges();
|
|
4590
|
+
selection == null ? void 0 : selection.addRange(range);
|
|
4591
|
+
document.execCommand("copy");
|
|
4592
|
+
fakeElement.remove();
|
|
4593
|
+
}
|
|
4594
|
+
setClipboardData({ text, elementList });
|
|
4595
|
+
}
|
|
4596
|
+
function writeElementList(elementList, options) {
|
|
4597
|
+
const clipboardDom = createDomFromElementList(elementList, options);
|
|
4598
|
+
document.body.append(clipboardDom);
|
|
4599
|
+
const text = clipboardDom.innerText;
|
|
4600
|
+
clipboardDom.remove();
|
|
4601
|
+
const html = clipboardDom.innerHTML;
|
|
4602
|
+
if (!text && !html && !elementList.length)
|
|
4603
|
+
return;
|
|
4604
|
+
writeClipboardItem(text, html, zipElementList(elementList));
|
|
4605
|
+
}
|
|
4606
|
+
function pasteElement(host, elementList) {
|
|
4553
4607
|
const draw = host.getDraw();
|
|
4554
4608
|
const isReadonly = draw.isReadonly();
|
|
4555
4609
|
if (isReadonly)
|
|
4556
4610
|
return;
|
|
4557
4611
|
const rangeManager = draw.getRange();
|
|
4558
4612
|
const { startIndex } = rangeManager.getRange();
|
|
4559
|
-
const
|
|
4560
|
-
const pasteElementList = getElementListByHTML(htmlText, {
|
|
4561
|
-
innerWidth: draw.getOriginalInnerWidth()
|
|
4562
|
-
});
|
|
4613
|
+
const originalElementList = draw.getElementList();
|
|
4563
4614
|
if (~startIndex && !rangeManager.getIsSelectAll()) {
|
|
4564
|
-
const anchorElement =
|
|
4615
|
+
const anchorElement = originalElementList[startIndex];
|
|
4565
4616
|
if ((anchorElement == null ? void 0 : anchorElement.titleId) || (anchorElement == null ? void 0 : anchorElement.listId)) {
|
|
4566
4617
|
let start = 0;
|
|
4567
|
-
while (start <
|
|
4568
|
-
const
|
|
4569
|
-
if (anchorElement.titleId && /^\n/.test(
|
|
4618
|
+
while (start < elementList.length) {
|
|
4619
|
+
const pasteElement2 = elementList[start];
|
|
4620
|
+
if (anchorElement.titleId && /^\n/.test(pasteElement2.value)) {
|
|
4570
4621
|
break;
|
|
4571
4622
|
}
|
|
4572
|
-
if (VIRTUAL_ELEMENT_TYPE.includes(
|
|
4573
|
-
|
|
4574
|
-
if (
|
|
4575
|
-
for (let v = 0; v <
|
|
4576
|
-
const element =
|
|
4623
|
+
if (VIRTUAL_ELEMENT_TYPE.includes(pasteElement2.type)) {
|
|
4624
|
+
elementList.splice(start, 1);
|
|
4625
|
+
if (pasteElement2.valueList) {
|
|
4626
|
+
for (let v = 0; v < pasteElement2.valueList.length; v++) {
|
|
4627
|
+
const element = pasteElement2.valueList[v];
|
|
4577
4628
|
if (element.value === ZERO || element.value === "\n") {
|
|
4578
4629
|
continue;
|
|
4579
4630
|
}
|
|
4580
|
-
|
|
4631
|
+
elementList.splice(start, 0, element);
|
|
4581
4632
|
start++;
|
|
4582
4633
|
}
|
|
4583
4634
|
}
|
|
@@ -4586,11 +4637,21 @@ function pastHTML(host, htmlText) {
|
|
|
4586
4637
|
start++;
|
|
4587
4638
|
}
|
|
4588
4639
|
}
|
|
4589
|
-
formatElementContext(
|
|
4640
|
+
formatElementContext(originalElementList, elementList, startIndex, {
|
|
4590
4641
|
isBreakWhenWrap: true
|
|
4591
4642
|
});
|
|
4592
4643
|
}
|
|
4593
|
-
draw.insertElementList(
|
|
4644
|
+
draw.insertElementList(elementList);
|
|
4645
|
+
}
|
|
4646
|
+
function pasteHTML(host, htmlText) {
|
|
4647
|
+
const draw = host.getDraw();
|
|
4648
|
+
const isReadonly = draw.isReadonly();
|
|
4649
|
+
if (isReadonly)
|
|
4650
|
+
return;
|
|
4651
|
+
const elementList = getElementListByHTML(htmlText, {
|
|
4652
|
+
innerWidth: draw.getOriginalInnerWidth()
|
|
4653
|
+
});
|
|
4654
|
+
pasteElement(host, elementList);
|
|
4594
4655
|
}
|
|
4595
4656
|
function pasteImage(host, file) {
|
|
4596
4657
|
const draw = host.getDraw();
|
|
@@ -4633,6 +4694,13 @@ function pasteByEvent(host, evt) {
|
|
|
4633
4694
|
paste(evt);
|
|
4634
4695
|
return;
|
|
4635
4696
|
}
|
|
4697
|
+
const clipboardText = clipboardData.getData("text");
|
|
4698
|
+
const editorClipboardData = getClipboardData();
|
|
4699
|
+
if (clipboardText === (editorClipboardData == null ? void 0 : editorClipboardData.text)) {
|
|
4700
|
+
pasteElement(host, editorClipboardData.elementList);
|
|
4701
|
+
return;
|
|
4702
|
+
}
|
|
4703
|
+
removeClipboardData();
|
|
4636
4704
|
let isHTML = false;
|
|
4637
4705
|
for (let i = 0; i < clipboardData.items.length; i++) {
|
|
4638
4706
|
const item = clipboardData.items[i];
|
|
@@ -4652,7 +4720,7 @@ function pasteByEvent(host, evt) {
|
|
|
4652
4720
|
}
|
|
4653
4721
|
if (item.type === "text/html" && isHTML) {
|
|
4654
4722
|
item.getAsString((htmlText) => {
|
|
4655
|
-
|
|
4723
|
+
pasteHTML(host, htmlText);
|
|
4656
4724
|
});
|
|
4657
4725
|
break;
|
|
4658
4726
|
}
|
|
@@ -4676,10 +4744,16 @@ async function pasteByApi(host, options) {
|
|
|
4676
4744
|
paste();
|
|
4677
4745
|
return;
|
|
4678
4746
|
}
|
|
4747
|
+
const clipboardText = await navigator.clipboard.readText();
|
|
4748
|
+
const editorClipboardData = getClipboardData();
|
|
4749
|
+
if (clipboardText === (editorClipboardData == null ? void 0 : editorClipboardData.text)) {
|
|
4750
|
+
pasteElement(host, editorClipboardData.elementList);
|
|
4751
|
+
return;
|
|
4752
|
+
}
|
|
4753
|
+
removeClipboardData();
|
|
4679
4754
|
if (options == null ? void 0 : options.isPlainText) {
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
host.input(text);
|
|
4755
|
+
if (clipboardText) {
|
|
4756
|
+
host.input(clipboardText);
|
|
4683
4757
|
}
|
|
4684
4758
|
} else {
|
|
4685
4759
|
const clipboardData = await navigator.clipboard.read();
|
|
@@ -4701,7 +4775,7 @@ async function pasteByApi(host, options) {
|
|
|
4701
4775
|
const htmlTextBlob = await item.getType("text/html");
|
|
4702
4776
|
const htmlText = await htmlTextBlob.text();
|
|
4703
4777
|
if (htmlText) {
|
|
4704
|
-
|
|
4778
|
+
pasteHTML(host, htmlText);
|
|
4705
4779
|
}
|
|
4706
4780
|
} else if (item.types.some((type) => type.startsWith("image/"))) {
|
|
4707
4781
|
const type = item.types.find((type2) => type2.startsWith("image/"));
|
|
@@ -5901,41 +5975,6 @@ function removeComposingInput(host) {
|
|
|
5901
5975
|
rangeManager.setRange(startIndex, startIndex);
|
|
5902
5976
|
host.compositionInfo = null;
|
|
5903
5977
|
}
|
|
5904
|
-
function writeClipboardItem(text, html) {
|
|
5905
|
-
if (!text || !html)
|
|
5906
|
-
return;
|
|
5907
|
-
const plainText = new Blob([text], { type: "text/plain" });
|
|
5908
|
-
const htmlText = new Blob([html], { type: "text/html" });
|
|
5909
|
-
if (window.ClipboardItem) {
|
|
5910
|
-
const item = new ClipboardItem({
|
|
5911
|
-
[plainText.type]: plainText,
|
|
5912
|
-
[htmlText.type]: htmlText
|
|
5913
|
-
});
|
|
5914
|
-
window.navigator.clipboard.write([item]);
|
|
5915
|
-
} else {
|
|
5916
|
-
const fakeElement = document.createElement("div");
|
|
5917
|
-
fakeElement.setAttribute("contenteditable", "true");
|
|
5918
|
-
fakeElement.innerHTML = html;
|
|
5919
|
-
document.body.append(fakeElement);
|
|
5920
|
-
const selection = window.getSelection();
|
|
5921
|
-
const range = document.createRange();
|
|
5922
|
-
range.selectNodeContents(fakeElement);
|
|
5923
|
-
selection == null ? void 0 : selection.removeAllRanges();
|
|
5924
|
-
selection == null ? void 0 : selection.addRange(range);
|
|
5925
|
-
document.execCommand("copy");
|
|
5926
|
-
fakeElement.remove();
|
|
5927
|
-
}
|
|
5928
|
-
}
|
|
5929
|
-
function writeElementList(elementList, options) {
|
|
5930
|
-
const clipboardDom = createDomFromElementList(elementList, options);
|
|
5931
|
-
document.body.append(clipboardDom);
|
|
5932
|
-
const text = clipboardDom.innerText;
|
|
5933
|
-
clipboardDom.remove();
|
|
5934
|
-
const html = clipboardDom.innerHTML;
|
|
5935
|
-
if (!text || !html)
|
|
5936
|
-
return;
|
|
5937
|
-
writeClipboardItem(text, html);
|
|
5938
|
-
}
|
|
5939
5978
|
function cut(host) {
|
|
5940
5979
|
const draw = host.getDraw();
|
|
5941
5980
|
const rangeManager = draw.getRange();
|
|
@@ -6638,6 +6677,7 @@ class Position {
|
|
|
6638
6677
|
return { x, y, index: index2 };
|
|
6639
6678
|
}
|
|
6640
6679
|
computePositionList() {
|
|
6680
|
+
var _a;
|
|
6641
6681
|
this.positionList = [];
|
|
6642
6682
|
const innerWidth = this.draw.getInnerWidth();
|
|
6643
6683
|
const pageRowList = this.draw.getPageRowList();
|
|
@@ -6649,7 +6689,7 @@ class Position {
|
|
|
6649
6689
|
let startRowIndex = 0;
|
|
6650
6690
|
for (let i = 0; i < pageRowList.length; i++) {
|
|
6651
6691
|
const rowList = pageRowList[i];
|
|
6652
|
-
const startIndex = rowList[0].startIndex;
|
|
6692
|
+
const startIndex = (_a = rowList[0]) == null ? void 0 : _a.startIndex;
|
|
6653
6693
|
this.computePageRowPosition({
|
|
6654
6694
|
positionList: this.positionList,
|
|
6655
6695
|
rowList,
|
|
@@ -8952,7 +8992,8 @@ class SeparatorParticle {
|
|
|
8952
8992
|
}
|
|
8953
8993
|
render(ctx, element, x, y) {
|
|
8954
8994
|
ctx.save();
|
|
8955
|
-
|
|
8995
|
+
const { scale } = this.options;
|
|
8996
|
+
ctx.lineWidth = scale;
|
|
8956
8997
|
if (element.color) {
|
|
8957
8998
|
ctx.strokeStyle = element.color;
|
|
8958
8999
|
}
|
|
@@ -8962,7 +9003,7 @@ class SeparatorParticle {
|
|
|
8962
9003
|
ctx.translate(0, 0.5);
|
|
8963
9004
|
ctx.beginPath();
|
|
8964
9005
|
ctx.moveTo(x, y);
|
|
8965
|
-
ctx.lineTo(x + element.width, y);
|
|
9006
|
+
ctx.lineTo(x + element.width * scale, y);
|
|
8966
9007
|
ctx.stroke();
|
|
8967
9008
|
ctx.restore();
|
|
8968
9009
|
}
|
|
@@ -8981,7 +9022,7 @@ class PageBreakParticle {
|
|
|
8981
9022
|
const displayName = this.i18n.t("pageBreak.displayName");
|
|
8982
9023
|
const { scale, defaultRowMargin } = this.options;
|
|
8983
9024
|
const size = fontSize * scale;
|
|
8984
|
-
const elementWidth = element.width;
|
|
9025
|
+
const elementWidth = element.width * scale;
|
|
8985
9026
|
const offsetY = this.draw.getDefaultBasicRowMarginHeight() * defaultRowMargin;
|
|
8986
9027
|
ctx.save();
|
|
8987
9028
|
ctx.font = `${size}px ${font}`;
|
|
@@ -9600,6 +9641,17 @@ class Control {
|
|
|
9600
9641
|
}
|
|
9601
9642
|
return false;
|
|
9602
9643
|
}
|
|
9644
|
+
isRangeCanInput() {
|
|
9645
|
+
const { startIndex, endIndex } = this.getRange();
|
|
9646
|
+
if (!~startIndex && !~endIndex)
|
|
9647
|
+
return false;
|
|
9648
|
+
if (startIndex === endIndex)
|
|
9649
|
+
return true;
|
|
9650
|
+
const elementList = this.getElementList();
|
|
9651
|
+
const startElement = elementList[startIndex];
|
|
9652
|
+
const endElement = elementList[endIndex];
|
|
9653
|
+
return !startElement.controlId && !endElement.controlId || (!startElement.controlId || startElement.controlComponent === ControlComponent.POSTFIX) && endElement.controlComponent === ControlComponent.POSTFIX || !!startElement.controlId && endElement.controlId === startElement.controlId && endElement.controlComponent !== ControlComponent.POSTFIX;
|
|
9654
|
+
}
|
|
9603
9655
|
isDisabledControl() {
|
|
9604
9656
|
var _a, _b;
|
|
9605
9657
|
return !!((_b = (_a = this.activeControl) == null ? void 0 : _a.getElement().control) == null ? void 0 : _b.disabled);
|
|
@@ -10066,6 +10118,55 @@ class Control {
|
|
|
10066
10118
|
setExtension(elementList);
|
|
10067
10119
|
}
|
|
10068
10120
|
}
|
|
10121
|
+
setPropertiesByConceptId(payload) {
|
|
10122
|
+
var _a;
|
|
10123
|
+
const isReadonly = this.draw.isReadonly();
|
|
10124
|
+
if (isReadonly)
|
|
10125
|
+
return;
|
|
10126
|
+
const { conceptId, properties } = payload;
|
|
10127
|
+
let isExistUpdate = false;
|
|
10128
|
+
const pageComponentData = {
|
|
10129
|
+
header: this.draw.getHeaderElementList(),
|
|
10130
|
+
main: this.draw.getOriginalMainElementList(),
|
|
10131
|
+
footer: this.draw.getFooterElementList()
|
|
10132
|
+
};
|
|
10133
|
+
for (const key in pageComponentData) {
|
|
10134
|
+
const elementList = pageComponentData[key];
|
|
10135
|
+
let i = 0;
|
|
10136
|
+
while (i < elementList.length) {
|
|
10137
|
+
const element = elementList[i];
|
|
10138
|
+
i++;
|
|
10139
|
+
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
10140
|
+
continue;
|
|
10141
|
+
isExistUpdate = true;
|
|
10142
|
+
element.control = __spreadProps(__spreadValues(__spreadValues({}, element.control), properties), {
|
|
10143
|
+
value: element.control.value
|
|
10144
|
+
});
|
|
10145
|
+
let newEndIndex = i;
|
|
10146
|
+
while (newEndIndex < elementList.length) {
|
|
10147
|
+
const nextElement = elementList[newEndIndex];
|
|
10148
|
+
if (nextElement.controlId !== element.controlId)
|
|
10149
|
+
break;
|
|
10150
|
+
newEndIndex++;
|
|
10151
|
+
}
|
|
10152
|
+
i = newEndIndex;
|
|
10153
|
+
}
|
|
10154
|
+
}
|
|
10155
|
+
if (!isExistUpdate)
|
|
10156
|
+
return;
|
|
10157
|
+
for (const key in pageComponentData) {
|
|
10158
|
+
const pageComponentKey = key;
|
|
10159
|
+
const elementList = zipElementList(pageComponentData[pageComponentKey]);
|
|
10160
|
+
pageComponentData[pageComponentKey] = elementList;
|
|
10161
|
+
formatElementList(elementList, {
|
|
10162
|
+
editorOptions: this.options
|
|
10163
|
+
});
|
|
10164
|
+
}
|
|
10165
|
+
this.draw.setEditorData(pageComponentData);
|
|
10166
|
+
this.draw.render({
|
|
10167
|
+
isSetCursor: false
|
|
10168
|
+
});
|
|
10169
|
+
}
|
|
10069
10170
|
}
|
|
10070
10171
|
class CheckboxParticle {
|
|
10071
10172
|
constructor(draw) {
|
|
@@ -11519,6 +11620,8 @@ class ZoneTip {
|
|
|
11519
11620
|
this.pageContainer.addEventListener("mousemove", throttle((evt) => {
|
|
11520
11621
|
if (this.isDisableMouseMove)
|
|
11521
11622
|
return;
|
|
11623
|
+
if (!evt.offsetY)
|
|
11624
|
+
return;
|
|
11522
11625
|
if (evt.target instanceof HTMLCanvasElement) {
|
|
11523
11626
|
const mousemoveZone = this.zone.getZoneByY(evt.offsetY);
|
|
11524
11627
|
if (!watchZones.includes(mousemoveZone)) {
|
|
@@ -12564,8 +12667,8 @@ class Draw {
|
|
|
12564
12667
|
insertElementList(payload) {
|
|
12565
12668
|
if (!payload.length)
|
|
12566
12669
|
return;
|
|
12567
|
-
const
|
|
12568
|
-
if (
|
|
12670
|
+
const isRangeCanInput = this.control.isRangeCanInput();
|
|
12671
|
+
if (!isRangeCanInput)
|
|
12569
12672
|
return;
|
|
12570
12673
|
const { startIndex, endIndex } = this.range.getRange();
|
|
12571
12674
|
if (!~startIndex && !~endIndex)
|
|
@@ -12575,7 +12678,11 @@ class Draw {
|
|
|
12575
12678
|
editorOptions: this.options
|
|
12576
12679
|
});
|
|
12577
12680
|
let curIndex = -1;
|
|
12578
|
-
|
|
12681
|
+
let activeControl = this.control.getActiveControl();
|
|
12682
|
+
if (!activeControl && this.control.isRangeWithinControl()) {
|
|
12683
|
+
this.control.initControl();
|
|
12684
|
+
activeControl = this.control.getActiveControl();
|
|
12685
|
+
}
|
|
12579
12686
|
if (activeControl && !this.control.isRangInPostfix()) {
|
|
12580
12687
|
curIndex = activeControl.setValue(payload, void 0, {
|
|
12581
12688
|
isIgnoreDisabledRule: true
|
|
@@ -12798,9 +12905,11 @@ class Draw {
|
|
|
12798
12905
|
p.style.marginBottom = `${this.getPageGap()}px`;
|
|
12799
12906
|
this._initPageContext(this.ctxList[i]);
|
|
12800
12907
|
});
|
|
12908
|
+
const cursorPosition = this.position.getCursorPosition();
|
|
12801
12909
|
this.render({
|
|
12802
12910
|
isSubmitHistory: false,
|
|
12803
|
-
isSetCursor:
|
|
12911
|
+
isSetCursor: !!cursorPosition,
|
|
12912
|
+
curIndex: cursorPosition == null ? void 0 : cursorPosition.index
|
|
12804
12913
|
});
|
|
12805
12914
|
if (this.listener.pageScaleChange) {
|
|
12806
12915
|
this.listener.pageScaleChange(payload);
|
|
@@ -13021,11 +13130,12 @@ class Draw {
|
|
|
13021
13130
|
if (curRowWidth2 + elementWidth > availableWidth) {
|
|
13022
13131
|
const surplusWidth = availableWidth - curRowWidth2;
|
|
13023
13132
|
const adaptiveWidth = surplusWidth > 0 ? surplusWidth : Math.min(elementWidth, availableWidth);
|
|
13024
|
-
|
|
13025
|
-
element.
|
|
13026
|
-
|
|
13027
|
-
metrics.
|
|
13028
|
-
metrics.
|
|
13133
|
+
const adaptiveHeight = elementHeight * adaptiveWidth / elementWidth;
|
|
13134
|
+
element.width = adaptiveWidth / scale;
|
|
13135
|
+
element.height = adaptiveHeight / scale;
|
|
13136
|
+
metrics.width = adaptiveWidth;
|
|
13137
|
+
metrics.height = adaptiveHeight;
|
|
13138
|
+
metrics.boundingBoxDescent = adaptiveHeight;
|
|
13029
13139
|
} else {
|
|
13030
13140
|
metrics.width = elementWidth;
|
|
13031
13141
|
metrics.height = elementHeight;
|
|
@@ -13152,20 +13262,20 @@ class Draw {
|
|
|
13152
13262
|
}
|
|
13153
13263
|
}
|
|
13154
13264
|
} else if (element.type === ElementType.SEPARATOR) {
|
|
13155
|
-
element.width = availableWidth;
|
|
13265
|
+
element.width = availableWidth / scale;
|
|
13156
13266
|
metrics.width = availableWidth;
|
|
13157
13267
|
metrics.height = defaultSize;
|
|
13158
13268
|
metrics.boundingBoxAscent = -rowMargin;
|
|
13159
13269
|
metrics.boundingBoxDescent = -rowMargin;
|
|
13160
13270
|
} else if (element.type === ElementType.PAGE_BREAK) {
|
|
13161
|
-
element.width = availableWidth;
|
|
13271
|
+
element.width = availableWidth / scale;
|
|
13162
13272
|
metrics.width = availableWidth;
|
|
13163
13273
|
metrics.height = defaultSize;
|
|
13164
13274
|
} else if (element.type === ElementType.CHECKBOX || element.controlComponent === ControlComponent.CHECKBOX) {
|
|
13165
13275
|
const { width, height: height2, gap } = this.options.checkbox;
|
|
13166
|
-
const elementWidth =
|
|
13276
|
+
const elementWidth = width + gap * 2;
|
|
13167
13277
|
element.width = elementWidth;
|
|
13168
|
-
metrics.width = elementWidth;
|
|
13278
|
+
metrics.width = elementWidth * scale;
|
|
13169
13279
|
metrics.height = height2 * scale;
|
|
13170
13280
|
} else if (element.type === ElementType.TAB) {
|
|
13171
13281
|
metrics.width = defaultTabWidth * scale;
|
|
@@ -13517,7 +13627,7 @@ class Draw {
|
|
|
13517
13627
|
this.blockParticle.clear();
|
|
13518
13628
|
}
|
|
13519
13629
|
_drawPage(payload) {
|
|
13520
|
-
var _a;
|
|
13630
|
+
var _a, _b;
|
|
13521
13631
|
const { elementList, positionList, rowList, pageNo } = payload;
|
|
13522
13632
|
const { inactiveAlpha, pageMode, header, footer, pageNumber } = this.options;
|
|
13523
13633
|
const innerWidth = this.getInnerWidth();
|
|
@@ -13529,7 +13639,7 @@ class Draw {
|
|
|
13529
13639
|
this.margin.render(ctx, pageNo);
|
|
13530
13640
|
}
|
|
13531
13641
|
this.control.renderHighlightList(ctx, pageNo);
|
|
13532
|
-
const index2 = rowList[0].startIndex;
|
|
13642
|
+
const index2 = (_a = rowList[0]) == null ? void 0 : _a.startIndex;
|
|
13533
13643
|
this.drawRow(ctx, {
|
|
13534
13644
|
elementList,
|
|
13535
13645
|
positionList,
|
|
@@ -13556,7 +13666,7 @@ class Draw {
|
|
|
13556
13666
|
if (pageMode !== PageMode.CONTINUITY && this.options.watermark.data) {
|
|
13557
13667
|
this.waterMark.render(ctx);
|
|
13558
13668
|
}
|
|
13559
|
-
if (this.elementList.length <= 1 && !((
|
|
13669
|
+
if (this.elementList.length <= 1 && !((_b = this.elementList[0]) == null ? void 0 : _b.listId)) {
|
|
13560
13670
|
this.placeholder.render(ctx);
|
|
13561
13671
|
}
|
|
13562
13672
|
}
|
|
@@ -13800,6 +13910,7 @@ class Command {
|
|
|
13800
13910
|
__publicField(this, "executeSetZone");
|
|
13801
13911
|
__publicField(this, "executeSetControlValue");
|
|
13802
13912
|
__publicField(this, "executeSetControlExtension");
|
|
13913
|
+
__publicField(this, "executeSetControlProperties");
|
|
13803
13914
|
__publicField(this, "executeSetControlHighlight");
|
|
13804
13915
|
__publicField(this, "getCatalog");
|
|
13805
13916
|
__publicField(this, "getImage");
|
|
@@ -13808,6 +13919,7 @@ class Command {
|
|
|
13808
13919
|
__publicField(this, "getHTML");
|
|
13809
13920
|
__publicField(this, "getText");
|
|
13810
13921
|
__publicField(this, "getWordCount");
|
|
13922
|
+
__publicField(this, "getRange");
|
|
13811
13923
|
__publicField(this, "getRangeText");
|
|
13812
13924
|
__publicField(this, "getRangeContext");
|
|
13813
13925
|
__publicField(this, "getRangeRow");
|
|
@@ -13909,6 +14021,7 @@ class Command {
|
|
|
13909
14021
|
this.getHTML = adapt.getHTML.bind(adapt);
|
|
13910
14022
|
this.getText = adapt.getText.bind(adapt);
|
|
13911
14023
|
this.getWordCount = adapt.getWordCount.bind(adapt);
|
|
14024
|
+
this.getRange = adapt.getRange.bind(adapt);
|
|
13912
14025
|
this.getRangeText = adapt.getRangeText.bind(adapt);
|
|
13913
14026
|
this.getRangeContext = adapt.getRangeContext.bind(adapt);
|
|
13914
14027
|
this.getRangeRow = adapt.getRangeRow.bind(adapt);
|
|
@@ -13922,6 +14035,7 @@ class Command {
|
|
|
13922
14035
|
this.getContainer = adapt.getContainer.bind(adapt);
|
|
13923
14036
|
this.executeSetControlValue = adapt.setControlValue.bind(adapt);
|
|
13924
14037
|
this.executeSetControlExtension = adapt.setControlExtension.bind(adapt);
|
|
14038
|
+
this.executeSetControlProperties = adapt.setControlProperties.bind(adapt);
|
|
13925
14039
|
this.executeSetControlHighlight = adapt.setControlHighlight.bind(adapt);
|
|
13926
14040
|
this.getControlValue = adapt.getControlValue.bind(adapt);
|
|
13927
14041
|
}
|
|
@@ -13961,7 +14075,7 @@ function printImageBase64(base64List, width, height) {
|
|
|
13961
14075
|
container.append(image);
|
|
13962
14076
|
});
|
|
13963
14077
|
const style = document.createElement("style");
|
|
13964
|
-
const stylesheet = `*{margin:0;padding:0;}`;
|
|
14078
|
+
const stylesheet = `*{margin:0;padding:0;}@page{margin:0;}`;
|
|
13965
14079
|
style.append(document.createTextNode(stylesheet));
|
|
13966
14080
|
setTimeout(() => {
|
|
13967
14081
|
doc.write(`${style.outerHTML}${container.innerHTML}`);
|
|
@@ -15473,26 +15587,19 @@ class CommandAdapt {
|
|
|
15473
15587
|
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
15474
15588
|
if (isDisabled)
|
|
15475
15589
|
return;
|
|
15476
|
-
const activeControl = this.control.getActiveControl();
|
|
15477
|
-
if (activeControl)
|
|
15478
|
-
return;
|
|
15479
15590
|
const { startIndex, endIndex } = this.range.getRange();
|
|
15480
15591
|
if (!~startIndex && !~endIndex)
|
|
15481
15592
|
return;
|
|
15482
|
-
const elementList = this.draw.getElementList();
|
|
15483
15593
|
const { value, width, height } = payload;
|
|
15484
|
-
|
|
15485
|
-
|
|
15486
|
-
|
|
15487
|
-
|
|
15488
|
-
|
|
15489
|
-
|
|
15490
|
-
|
|
15491
|
-
|
|
15492
|
-
|
|
15493
|
-
this.draw.spliceElementList(elementList, curIndex, startIndex === endIndex ? 0 : endIndex - startIndex, element);
|
|
15494
|
-
this.range.setRange(curIndex, curIndex);
|
|
15495
|
-
this.draw.render({ curIndex });
|
|
15594
|
+
this.draw.insertElementList([
|
|
15595
|
+
{
|
|
15596
|
+
value,
|
|
15597
|
+
width,
|
|
15598
|
+
height,
|
|
15599
|
+
id: getUUID(),
|
|
15600
|
+
type: ElementType.IMAGE
|
|
15601
|
+
}
|
|
15602
|
+
]);
|
|
15496
15603
|
}
|
|
15497
15604
|
search(payload) {
|
|
15498
15605
|
this.searchManager.setSearchKeyword(payload);
|
|
@@ -15701,6 +15808,9 @@ class CommandAdapt {
|
|
|
15701
15808
|
getWordCount() {
|
|
15702
15809
|
return this.workerManager.getWordCount();
|
|
15703
15810
|
}
|
|
15811
|
+
getRange() {
|
|
15812
|
+
return deepClone(this.range.getRange());
|
|
15813
|
+
}
|
|
15704
15814
|
getRangeText() {
|
|
15705
15815
|
return this.range.toString();
|
|
15706
15816
|
}
|
|
@@ -15975,6 +16085,12 @@ class CommandAdapt {
|
|
|
15975
16085
|
return;
|
|
15976
16086
|
this.draw.getControl().setExtensionByConceptId(payload);
|
|
15977
16087
|
}
|
|
16088
|
+
setControlProperties(payload) {
|
|
16089
|
+
const isReadonly = this.draw.isReadonly();
|
|
16090
|
+
if (isReadonly)
|
|
16091
|
+
return;
|
|
16092
|
+
this.draw.getControl().setPropertiesByConceptId(payload);
|
|
16093
|
+
}
|
|
15978
16094
|
setControlHighlight(payload) {
|
|
15979
16095
|
this.draw.getControl().setHighlightList(payload);
|
|
15980
16096
|
}
|