@hufe921/canvas-editor 0.9.80 → 0.9.82
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 +45 -0
- package/dist/canvas-editor.es.js +222 -49
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +41 -41
- 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 +1 -0
- package/dist/src/editor/core/override/Override.d.ts +1 -0
- package/dist/src/editor/core/zone/ZoneTip.d.ts +1 -0
- package/dist/src/editor/interface/Editor.d.ts +1 -4
- package/dist/src/editor/interface/Element.d.ts +4 -0
- package/dist/src/editor/interface/PageNumber.d.ts +1 -0
- package/dist/src/editor/interface/Position.d.ts +6 -1
- package/dist/src/editor/interface/Range.d.ts +2 -0
- package/dist/src/editor/utils/element.d.ts +9 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
## [0.9.82](https://github.com/Hufe921/canvas-editor/compare/v0.9.81...v0.9.82) (2024-06-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* table cell merge boundary error #645 ([f7da332](https://github.com/Hufe921/canvas-editor/commit/f7da33235419aadb2aea024d3cba4444d6d719fd)), closes [#645](https://github.com/Hufe921/canvas-editor/issues/645)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add executeUpdateElementById api #648 ([5c896bf](https://github.com/Hufe921/canvas-editor/commit/5c896bf95814c6ef2956221763e7df560b3fe98a)), closes [#648](https://github.com/Hufe921/canvas-editor/issues/648)
|
|
12
|
+
* add override internal drop function api #643 ([ec7e076](https://github.com/Hufe921/canvas-editor/commit/ec7e0760c113711fdafc13374ea521605308f867)), closes [#643](https://github.com/Hufe921/canvas-editor/issues/643)
|
|
13
|
+
* move control position by dragging #456 ([cdb0788](https://github.com/Hufe921/canvas-editor/commit/cdb0788dfcecadb70e680eb40a31551e0e096401)), closes [#456](https://github.com/Hufe921/canvas-editor/issues/456)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.9.81](https://github.com/Hufe921/canvas-editor/compare/v0.9.80...v0.9.81) (2024-06-07)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* disable zone tip in continuous page mode #638 ([bf322df](https://github.com/Hufe921/canvas-editor/commit/bf322dfea334ee242a452c44fdb613a1937d963b)), closes [#638](https://github.com/Hufe921/canvas-editor/issues/638)
|
|
23
|
+
* some shortcut keys with shift are invalid #629 ([aca9d34](https://github.com/Hufe921/canvas-editor/commit/aca9d34a46004f2da207f7127f69430e4e59ab25)), closes [#629](https://github.com/Hufe921/canvas-editor/issues/629)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Documentation
|
|
27
|
+
|
|
28
|
+
* update start.md ([55bbe22](https://github.com/Hufe921/canvas-editor/commit/55bbe22578320319d9ab38b26ebbe8687b21f1c1))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* add executeLocationControl api #592 ([53701fc](https://github.com/Hufe921/canvas-editor/commit/53701fc46c347595722801e8bca40647cda74bcb)), closes [#592](https://github.com/Hufe921/canvas-editor/issues/592)
|
|
34
|
+
* add maximum page number option #617 ([afce688](https://github.com/Hufe921/canvas-editor/commit/afce6882493c198595a0575640dd313c8cbdb14f)), closes [#617](https://github.com/Hufe921/canvas-editor/issues/617)
|
|
35
|
+
* add options to the getValue api ([65acd58](https://github.com/Hufe921/canvas-editor/commit/65acd580d6813bd15b8ee079b16ae8d5f9e77767))
|
|
36
|
+
* add selection info to rangeContext ([2df03ed](https://github.com/Hufe921/canvas-editor/commit/2df03ed3867cf8edf5fb656c017986af6725780c))
|
|
37
|
+
* set title style through executeSetHtml api #626 ([ac795b0](https://github.com/Hufe921/canvas-editor/commit/ac795b0bc45f99e92a5292a676414e1d7347cb7e)), closes [#626](https://github.com/Hufe921/canvas-editor/issues/626)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Tests
|
|
41
|
+
|
|
42
|
+
* update watermark test case ([c75482a](https://github.com/Hufe921/canvas-editor/commit/c75482a4f6f18da010963500e790780a63c061c4))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
1
46
|
## [0.9.80](https://github.com/Hufe921/canvas-editor/compare/v0.9.79...v0.9.80) (2024-05-31)
|
|
2
47
|
|
|
3
48
|
|
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.82";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -4081,12 +4081,17 @@ function isSameElementExceptValue(source, target) {
|
|
|
4081
4081
|
}
|
|
4082
4082
|
return true;
|
|
4083
4083
|
}
|
|
4084
|
-
function pickElementAttr(payload) {
|
|
4084
|
+
function pickElementAttr(payload, option = {}) {
|
|
4085
|
+
const { extraPickAttrs } = option;
|
|
4086
|
+
const zipAttrs = EDITOR_ELEMENT_ZIP_ATTR;
|
|
4087
|
+
if (extraPickAttrs) {
|
|
4088
|
+
zipAttrs.push(...extraPickAttrs);
|
|
4089
|
+
}
|
|
4085
4090
|
const element = {
|
|
4086
4091
|
value: payload.value === ZERO ? `
|
|
4087
4092
|
` : payload.value
|
|
4088
4093
|
};
|
|
4089
|
-
|
|
4094
|
+
zipAttrs.forEach((attr) => {
|
|
4090
4095
|
const value = payload[attr];
|
|
4091
4096
|
if (value !== void 0) {
|
|
4092
4097
|
element[attr] = value;
|
|
@@ -4094,7 +4099,8 @@ function pickElementAttr(payload) {
|
|
|
4094
4099
|
});
|
|
4095
4100
|
return element;
|
|
4096
4101
|
}
|
|
4097
|
-
function zipElementList(payload) {
|
|
4102
|
+
function zipElementList(payload, options = {}) {
|
|
4103
|
+
const { extraPickAttrs } = options;
|
|
4098
4104
|
const elementList = deepClone(payload);
|
|
4099
4105
|
const zipElementListData = [];
|
|
4100
4106
|
let e = 0;
|
|
@@ -4126,7 +4132,7 @@ function zipElementList(payload) {
|
|
|
4126
4132
|
valueList.push(titleE);
|
|
4127
4133
|
e++;
|
|
4128
4134
|
}
|
|
4129
|
-
titleElement.valueList = zipElementList(valueList);
|
|
4135
|
+
titleElement.valueList = zipElementList(valueList, options);
|
|
4130
4136
|
element = titleElement;
|
|
4131
4137
|
}
|
|
4132
4138
|
} else if (element.listId && element.listType) {
|
|
@@ -4153,7 +4159,7 @@ function zipElementList(payload) {
|
|
|
4153
4159
|
valueList.push(listE);
|
|
4154
4160
|
e++;
|
|
4155
4161
|
}
|
|
4156
|
-
listElement.valueList = zipElementList(valueList);
|
|
4162
|
+
listElement.valueList = zipElementList(valueList, options);
|
|
4157
4163
|
element = listElement;
|
|
4158
4164
|
}
|
|
4159
4165
|
} else if (element.type === ElementType.TABLE) {
|
|
@@ -4182,7 +4188,7 @@ function zipElementList(payload) {
|
|
|
4182
4188
|
const zipTd = {
|
|
4183
4189
|
colspan: td.colspan,
|
|
4184
4190
|
rowspan: td.rowspan,
|
|
4185
|
-
value: zipElementList(td.value)
|
|
4191
|
+
value: zipElementList(td.value, options)
|
|
4186
4192
|
};
|
|
4187
4193
|
TABLE_TD_ZIP_ATTR.forEach((attr) => {
|
|
4188
4194
|
const value = td[attr];
|
|
@@ -4214,7 +4220,7 @@ function zipElementList(payload) {
|
|
|
4214
4220
|
valueList.push(hyperlinkE);
|
|
4215
4221
|
e++;
|
|
4216
4222
|
}
|
|
4217
|
-
hyperlinkElement.valueList = zipElementList(valueList);
|
|
4223
|
+
hyperlinkElement.valueList = zipElementList(valueList, options);
|
|
4218
4224
|
element = hyperlinkElement;
|
|
4219
4225
|
}
|
|
4220
4226
|
} else if (element.type === ElementType.DATE) {
|
|
@@ -4237,7 +4243,7 @@ function zipElementList(payload) {
|
|
|
4237
4243
|
valueList.push(dateE);
|
|
4238
4244
|
e++;
|
|
4239
4245
|
}
|
|
4240
|
-
dateElement.valueList = zipElementList(valueList);
|
|
4246
|
+
dateElement.valueList = zipElementList(valueList, options);
|
|
4241
4247
|
element = dateElement;
|
|
4242
4248
|
}
|
|
4243
4249
|
} else if (element.controlId) {
|
|
@@ -4248,7 +4254,8 @@ function zipElementList(payload) {
|
|
|
4248
4254
|
const controlElement = __spreadProps(__spreadValues({}, pickObject(element, EDITOR_ROW_ATTR)), {
|
|
4249
4255
|
type: ElementType.CONTROL,
|
|
4250
4256
|
value: "",
|
|
4251
|
-
control
|
|
4257
|
+
control,
|
|
4258
|
+
controlId
|
|
4252
4259
|
});
|
|
4253
4260
|
const valueList = [];
|
|
4254
4261
|
while (e < elementList.length) {
|
|
@@ -4264,16 +4271,16 @@ function zipElementList(payload) {
|
|
|
4264
4271
|
}
|
|
4265
4272
|
e++;
|
|
4266
4273
|
}
|
|
4267
|
-
controlElement.control.value = zipElementList(valueList);
|
|
4268
|
-
element = controlElement;
|
|
4274
|
+
controlElement.control.value = zipElementList(valueList, options);
|
|
4275
|
+
element = pickElementAttr(controlElement, { extraPickAttrs });
|
|
4269
4276
|
}
|
|
4270
4277
|
}
|
|
4271
|
-
const pickElement = pickElementAttr(element);
|
|
4278
|
+
const pickElement = pickElementAttr(element, { extraPickAttrs });
|
|
4272
4279
|
if (!element.type || element.type === ElementType.TEXT || element.type === ElementType.SUBSCRIPT || element.type === ElementType.SUPERSCRIPT) {
|
|
4273
4280
|
while (e < elementList.length) {
|
|
4274
4281
|
const nextElement = elementList[e + 1];
|
|
4275
4282
|
e++;
|
|
4276
|
-
if (nextElement && isSameElementExceptValue(pickElement, pickElementAttr(nextElement))) {
|
|
4283
|
+
if (nextElement && isSameElementExceptValue(pickElement, pickElementAttr(nextElement, { extraPickAttrs }))) {
|
|
4277
4284
|
const nextValue = nextElement.value === ZERO ? "\n" : nextElement.value;
|
|
4278
4285
|
pickElement.value += nextValue;
|
|
4279
4286
|
} else {
|
|
@@ -4692,7 +4699,7 @@ function getElementListByHTML(htmlText, options) {
|
|
|
4692
4699
|
}
|
|
4693
4700
|
} else if (/H[1-6]/.test(node.nodeName)) {
|
|
4694
4701
|
const hElement = node;
|
|
4695
|
-
const valueList = getElementListByHTML(hElement.
|
|
4702
|
+
const valueList = getElementListByHTML(replaceHTMLElementTag(hElement, "div").outerHTML, options);
|
|
4696
4703
|
elementList.push({
|
|
4697
4704
|
value: "",
|
|
4698
4705
|
type: ElementType.TITLE,
|
|
@@ -4772,9 +4779,7 @@ function getElementListByHTML(htmlText, options) {
|
|
|
4772
4779
|
}
|
|
4773
4780
|
tr.tdList.push(td);
|
|
4774
4781
|
});
|
|
4775
|
-
|
|
4776
|
-
element.trList.push(tr);
|
|
4777
|
-
}
|
|
4782
|
+
element.trList.push(tr);
|
|
4778
4783
|
});
|
|
4779
4784
|
if (element.trList.length) {
|
|
4780
4785
|
const tdCount = element.trList[0].tdList.reduce((pre, cur) => pre + cur.colspan, 0);
|
|
@@ -4900,6 +4905,15 @@ function getSlimCloneElementList(elementList) {
|
|
|
4900
4905
|
function getIsBlockElement(element) {
|
|
4901
4906
|
return !!(element == null ? void 0 : element.type) && (BLOCK_ELEMENT_TYPE.includes(element.type) || element.imgDisplay === ImageDisplay.INLINE);
|
|
4902
4907
|
}
|
|
4908
|
+
function replaceHTMLElementTag(oldDom, tagName) {
|
|
4909
|
+
const newDom = document.createElement(tagName);
|
|
4910
|
+
for (let i = 0; i < oldDom.attributes.length; i++) {
|
|
4911
|
+
const attr = oldDom.attributes[i];
|
|
4912
|
+
newDom.setAttribute(attr.name, attr.value);
|
|
4913
|
+
}
|
|
4914
|
+
newDom.innerHTML = oldDom.innerHTML;
|
|
4915
|
+
return newDom;
|
|
4916
|
+
}
|
|
4903
4917
|
function setClipboardData(data2) {
|
|
4904
4918
|
localStorage.setItem(EDITOR_CLIPBOARD, JSON.stringify({
|
|
4905
4919
|
text: data2.text,
|
|
@@ -5783,14 +5797,20 @@ function mouseup(evt, host) {
|
|
|
5783
5797
|
return;
|
|
5784
5798
|
}
|
|
5785
5799
|
}
|
|
5786
|
-
const
|
|
5800
|
+
const control = draw.getControl();
|
|
5787
5801
|
const elementList = draw.getElementList();
|
|
5802
|
+
const isOmitControlAttr = !isContainControl || !!elementList[range.startIndex].controlId || !control.getIsElementListContainFullControl(dragElementList);
|
|
5803
|
+
const editorOptions = draw.getOptions();
|
|
5788
5804
|
const replaceElementList = dragElementList.map((el) => {
|
|
5789
5805
|
if (!el.type || el.type === ElementType.TEXT) {
|
|
5790
5806
|
const newElement = {
|
|
5791
5807
|
value: el.value
|
|
5792
5808
|
};
|
|
5793
|
-
|
|
5809
|
+
const copyAttr = EDITOR_ELEMENT_STYLE_ATTR;
|
|
5810
|
+
if (!isOmitControlAttr) {
|
|
5811
|
+
copyAttr.push(...CONTROL_CONTEXT_ATTR);
|
|
5812
|
+
}
|
|
5813
|
+
copyAttr.forEach((attr) => {
|
|
5794
5814
|
const value = el[attr];
|
|
5795
5815
|
if (value !== void 0) {
|
|
5796
5816
|
newElement[attr] = value;
|
|
@@ -5798,7 +5818,10 @@ function mouseup(evt, host) {
|
|
|
5798
5818
|
});
|
|
5799
5819
|
return newElement;
|
|
5800
5820
|
} else {
|
|
5801
|
-
|
|
5821
|
+
let newElement = deepClone(el);
|
|
5822
|
+
if (isOmitControlAttr) {
|
|
5823
|
+
newElement = omitObject(newElement, CONTROL_CONTEXT_ATTR);
|
|
5824
|
+
}
|
|
5802
5825
|
formatElementList([newElement], {
|
|
5803
5826
|
isHandleFirstElement: false,
|
|
5804
5827
|
editorOptions
|
|
@@ -5814,7 +5837,6 @@ function mouseup(evt, host) {
|
|
|
5814
5837
|
const replaceLength = replaceElementList.length;
|
|
5815
5838
|
let rangeStart = range.startIndex;
|
|
5816
5839
|
let rangeEnd = rangeStart + replaceLength;
|
|
5817
|
-
const control = draw.getControl();
|
|
5818
5840
|
const activeControl = control.getActiveControl();
|
|
5819
5841
|
if (activeControl && cacheElementList[rangeStart].controlComponent !== ControlComponent.POSTFIX) {
|
|
5820
5842
|
rangeEnd = activeControl.setValue(replaceElementList);
|
|
@@ -6963,6 +6985,12 @@ function copy(host) {
|
|
|
6963
6985
|
}
|
|
6964
6986
|
function drop(evt, host) {
|
|
6965
6987
|
var _a, _b;
|
|
6988
|
+
const draw = host.getDraw();
|
|
6989
|
+
const { drop: drop2 } = draw.getOverride();
|
|
6990
|
+
if (drop2) {
|
|
6991
|
+
drop2(evt);
|
|
6992
|
+
return;
|
|
6993
|
+
}
|
|
6966
6994
|
evt.preventDefault();
|
|
6967
6995
|
const data2 = (_a = evt.dataTransfer) == null ? void 0 : _a.getData("text");
|
|
6968
6996
|
if (data2) {
|
|
@@ -9200,7 +9228,8 @@ const defaultPageNumberOption = {
|
|
|
9200
9228
|
numberType: NumberType.ARABIC,
|
|
9201
9229
|
disabled: false,
|
|
9202
9230
|
startPageNo: 1,
|
|
9203
|
-
fromPageNo: 0
|
|
9231
|
+
fromPageNo: 0,
|
|
9232
|
+
maxPageNo: null
|
|
9204
9233
|
};
|
|
9205
9234
|
class PageNumber {
|
|
9206
9235
|
constructor(draw) {
|
|
@@ -9624,12 +9653,10 @@ class TableParticle {
|
|
|
9624
9653
|
const { colgroup, trList } = element;
|
|
9625
9654
|
if (!colgroup || !trList)
|
|
9626
9655
|
return;
|
|
9627
|
-
let
|
|
9628
|
-
let y = 0;
|
|
9656
|
+
let preX = 0;
|
|
9629
9657
|
for (let t = 0; t < trList.length; t++) {
|
|
9630
9658
|
const tr = trList[t];
|
|
9631
9659
|
const isLastTr = trList.length - 1 === t;
|
|
9632
|
-
let rowMinHeight = 0;
|
|
9633
9660
|
for (let d = 0; d < tr.tdList.length; d++) {
|
|
9634
9661
|
const td = tr.tdList[d];
|
|
9635
9662
|
let colIndex = 0;
|
|
@@ -9644,7 +9671,7 @@ class TableParticle {
|
|
|
9644
9671
|
for (let preC = 0; preC < c; preC++) {
|
|
9645
9672
|
preColWidth += colgroup[preC].width;
|
|
9646
9673
|
}
|
|
9647
|
-
|
|
9674
|
+
preX = preColWidth;
|
|
9648
9675
|
break;
|
|
9649
9676
|
}
|
|
9650
9677
|
}
|
|
@@ -9663,9 +9690,6 @@ class TableParticle {
|
|
|
9663
9690
|
const curTr = trList[row + t] || trList[t];
|
|
9664
9691
|
height += curTr.height;
|
|
9665
9692
|
}
|
|
9666
|
-
if (rowMinHeight === 0 || rowMinHeight > height) {
|
|
9667
|
-
rowMinHeight = height;
|
|
9668
|
-
}
|
|
9669
9693
|
const isLastRowTd = tr.tdList.length - 1 === d;
|
|
9670
9694
|
let isLastColTd = isLastTr;
|
|
9671
9695
|
if (!isLastColTd) {
|
|
@@ -9678,16 +9702,26 @@ class TableParticle {
|
|
|
9678
9702
|
td.isLastRowTd = isLastRowTd;
|
|
9679
9703
|
td.isLastColTd = isLastColTd;
|
|
9680
9704
|
td.isLastTd = isLastTd;
|
|
9681
|
-
td.x =
|
|
9682
|
-
|
|
9705
|
+
td.x = preX;
|
|
9706
|
+
let preY = 0;
|
|
9707
|
+
for (let preR = 0; preR < t; preR++) {
|
|
9708
|
+
const preTdList = trList[preR].tdList;
|
|
9709
|
+
for (let preD = 0; preD < preTdList.length; preD++) {
|
|
9710
|
+
const td2 = preTdList[preD];
|
|
9711
|
+
if (colIndex >= td2.colIndex && colIndex < td2.colIndex + td2.colspan) {
|
|
9712
|
+
preY += td2.height;
|
|
9713
|
+
break;
|
|
9714
|
+
}
|
|
9715
|
+
}
|
|
9716
|
+
}
|
|
9717
|
+
td.y = preY;
|
|
9683
9718
|
td.width = width;
|
|
9684
9719
|
td.height = height;
|
|
9685
9720
|
td.rowIndex = t;
|
|
9686
9721
|
td.colIndex = colIndex;
|
|
9687
|
-
|
|
9722
|
+
preX += width;
|
|
9688
9723
|
if (isLastRowTd && !isLastTd) {
|
|
9689
|
-
|
|
9690
|
-
y += rowMinHeight;
|
|
9724
|
+
preX = 0;
|
|
9691
9725
|
}
|
|
9692
9726
|
}
|
|
9693
9727
|
}
|
|
@@ -11680,6 +11714,23 @@ class Control {
|
|
|
11680
11714
|
}
|
|
11681
11715
|
return false;
|
|
11682
11716
|
}
|
|
11717
|
+
getIsElementListContainFullControl(elementList) {
|
|
11718
|
+
if (!elementList.some((element) => element.controlId))
|
|
11719
|
+
return false;
|
|
11720
|
+
let prefixCount = 0;
|
|
11721
|
+
let postfixCount = 0;
|
|
11722
|
+
for (let e = 0; e < elementList.length; e++) {
|
|
11723
|
+
const element = elementList[e];
|
|
11724
|
+
if (element.controlComponent === ControlComponent.PREFIX) {
|
|
11725
|
+
prefixCount++;
|
|
11726
|
+
} else if (element.controlComponent === ControlComponent.POSTFIX) {
|
|
11727
|
+
postfixCount++;
|
|
11728
|
+
}
|
|
11729
|
+
}
|
|
11730
|
+
if (!prefixCount || !postfixCount)
|
|
11731
|
+
return false;
|
|
11732
|
+
return prefixCount === postfixCount;
|
|
11733
|
+
}
|
|
11683
11734
|
getIsDisabledControl() {
|
|
11684
11735
|
var _a, _b;
|
|
11685
11736
|
return !!((_b = (_a = this.activeControl) == null ? void 0 : _a.getElement().control) == null ? void 0 : _b.disabled);
|
|
@@ -12277,7 +12328,9 @@ class Control {
|
|
|
12277
12328
|
for (const elementList of data2) {
|
|
12278
12329
|
getControlElementList(elementList);
|
|
12279
12330
|
}
|
|
12280
|
-
return zipElementList(controlElementList
|
|
12331
|
+
return zipElementList(controlElementList, {
|
|
12332
|
+
extraPickAttrs: ["controlId"]
|
|
12333
|
+
});
|
|
12281
12334
|
}
|
|
12282
12335
|
recordBorderInfo(x, y, width, height) {
|
|
12283
12336
|
this.controlBorder.recordBorderInfo(x, y, width, height);
|
|
@@ -13548,6 +13601,7 @@ class ImageObserver {
|
|
|
13548
13601
|
}
|
|
13549
13602
|
class ZoneTip {
|
|
13550
13603
|
constructor(draw, zone2) {
|
|
13604
|
+
__publicField(this, "draw");
|
|
13551
13605
|
__publicField(this, "zone");
|
|
13552
13606
|
__publicField(this, "i18n");
|
|
13553
13607
|
__publicField(this, "container");
|
|
@@ -13556,6 +13610,7 @@ class ZoneTip {
|
|
|
13556
13610
|
__publicField(this, "tipContainer");
|
|
13557
13611
|
__publicField(this, "tipContent");
|
|
13558
13612
|
__publicField(this, "currentMoveZone");
|
|
13613
|
+
this.draw = draw;
|
|
13559
13614
|
this.zone = zone2;
|
|
13560
13615
|
this.i18n = draw.getI18n();
|
|
13561
13616
|
this.container = draw.getContainer();
|
|
@@ -13579,7 +13634,7 @@ class ZoneTip {
|
|
|
13579
13634
|
}
|
|
13580
13635
|
_watchMouseMoveZoneChange(watchZones) {
|
|
13581
13636
|
this.pageContainer.addEventListener("mousemove", throttle((evt) => {
|
|
13582
|
-
if (this.isDisableMouseMove)
|
|
13637
|
+
if (this.isDisableMouseMove || !this.draw.getIsPagingMode())
|
|
13583
13638
|
return;
|
|
13584
13639
|
if (!evt.offsetY)
|
|
13585
13640
|
return;
|
|
@@ -15048,7 +15103,6 @@ class Draw {
|
|
|
15048
15103
|
});
|
|
15049
15104
|
}
|
|
15050
15105
|
getValue(options = {}) {
|
|
15051
|
-
const { width, height, margins, watermark } = this.options;
|
|
15052
15106
|
const { pageNo } = options;
|
|
15053
15107
|
let mainElementList = this.elementList;
|
|
15054
15108
|
if (Number.isInteger(pageNo) && pageNo >= 0 && pageNo < this.pageRowList.length) {
|
|
@@ -15061,11 +15115,8 @@ class Draw {
|
|
|
15061
15115
|
};
|
|
15062
15116
|
return {
|
|
15063
15117
|
version,
|
|
15064
|
-
|
|
15065
|
-
|
|
15066
|
-
margins,
|
|
15067
|
-
watermark: watermark.data ? watermark : void 0,
|
|
15068
|
-
data: data2
|
|
15118
|
+
data: data2,
|
|
15119
|
+
options: deepClone(this.options)
|
|
15069
15120
|
};
|
|
15070
15121
|
}
|
|
15071
15122
|
setValue(payload) {
|
|
@@ -15558,7 +15609,7 @@ class Draw {
|
|
|
15558
15609
|
_computePageList() {
|
|
15559
15610
|
var _a;
|
|
15560
15611
|
const pageRowList = [[]];
|
|
15561
|
-
const { pageMode } = this.options;
|
|
15612
|
+
const { pageMode, pageNumber: { maxPageNo } } = this.options;
|
|
15562
15613
|
const height = this.getHeight();
|
|
15563
15614
|
const marginHeight = this.getMainOuterHeight();
|
|
15564
15615
|
let pageHeight = marginHeight;
|
|
@@ -15582,6 +15633,10 @@ class Draw {
|
|
|
15582
15633
|
for (let i = 0; i < this.rowList.length; i++) {
|
|
15583
15634
|
const row = this.rowList[i];
|
|
15584
15635
|
if (row.height + pageHeight > height || ((_a = this.rowList[i - 1]) == null ? void 0 : _a.isPageBreak)) {
|
|
15636
|
+
if (Number.isInteger(maxPageNo) && pageNo >= maxPageNo) {
|
|
15637
|
+
this.elementList = this.elementList.slice(0, row.startIndex);
|
|
15638
|
+
break;
|
|
15639
|
+
}
|
|
15585
15640
|
pageHeight = marginHeight + row.height;
|
|
15586
15641
|
pageRowList.push([row]);
|
|
15587
15642
|
pageNo++;
|
|
@@ -16143,6 +16198,7 @@ class Command {
|
|
|
16143
16198
|
__publicField(this, "executeSetPaperMargin");
|
|
16144
16199
|
__publicField(this, "executeInsertElementList");
|
|
16145
16200
|
__publicField(this, "executeAppendElementList");
|
|
16201
|
+
__publicField(this, "executeUpdateElementById");
|
|
16146
16202
|
__publicField(this, "executeSetValue");
|
|
16147
16203
|
__publicField(this, "executeRemoveControl");
|
|
16148
16204
|
__publicField(this, "executeSetLocale");
|
|
@@ -16157,6 +16213,7 @@ class Command {
|
|
|
16157
16213
|
__publicField(this, "executeSetControlExtension");
|
|
16158
16214
|
__publicField(this, "executeSetControlProperties");
|
|
16159
16215
|
__publicField(this, "executeSetControlHighlight");
|
|
16216
|
+
__publicField(this, "executeLocationControl");
|
|
16160
16217
|
__publicField(this, "executeUpdateOptions");
|
|
16161
16218
|
__publicField(this, "executeInsertTitle");
|
|
16162
16219
|
__publicField(this, "getCatalog");
|
|
@@ -16254,6 +16311,7 @@ class Command {
|
|
|
16254
16311
|
this.executeSetPaperMargin = adapt.setPaperMargin.bind(adapt);
|
|
16255
16312
|
this.executeInsertElementList = adapt.insertElementList.bind(adapt);
|
|
16256
16313
|
this.executeAppendElementList = adapt.appendElementList.bind(adapt);
|
|
16314
|
+
this.executeUpdateElementById = adapt.updateElementById.bind(adapt);
|
|
16257
16315
|
this.executeSetValue = adapt.setValue.bind(adapt);
|
|
16258
16316
|
this.executeRemoveControl = adapt.removeControl.bind(adapt);
|
|
16259
16317
|
this.executeSetLocale = adapt.setLocale.bind(adapt);
|
|
@@ -16291,6 +16349,7 @@ class Command {
|
|
|
16291
16349
|
this.executeSetControlHighlight = adapt.setControlHighlight.bind(adapt);
|
|
16292
16350
|
this.getControlValue = adapt.getControlValue.bind(adapt);
|
|
16293
16351
|
this.getControlList = adapt.getControlList.bind(adapt);
|
|
16352
|
+
this.executeLocationControl = adapt.locationControl.bind(adapt);
|
|
16294
16353
|
}
|
|
16295
16354
|
}
|
|
16296
16355
|
const defaultWatermarkOption = {
|
|
@@ -18308,9 +18367,15 @@ class CommandAdapt {
|
|
|
18308
18367
|
if (!~startIndex && !~endIndex)
|
|
18309
18368
|
return null;
|
|
18310
18369
|
const isCollapsed = startIndex === endIndex;
|
|
18370
|
+
const selectionText = this.range.toString();
|
|
18371
|
+
const selectionElementList = zipElementList(this.range.getSelectionElementList() || []);
|
|
18311
18372
|
const elementList = this.draw.getElementList();
|
|
18312
|
-
const startElement = pickElementAttr(elementList[isCollapsed ? startIndex : startIndex + 1]
|
|
18313
|
-
|
|
18373
|
+
const startElement = pickElementAttr(elementList[isCollapsed ? startIndex : startIndex + 1], {
|
|
18374
|
+
extraPickAttrs: ["id"]
|
|
18375
|
+
});
|
|
18376
|
+
const endElement = pickElementAttr(elementList[endIndex], {
|
|
18377
|
+
extraPickAttrs: ["id"]
|
|
18378
|
+
});
|
|
18314
18379
|
const positionList = this.position.getPositionList();
|
|
18315
18380
|
const startPageNo = positionList[startIndex].pageNo;
|
|
18316
18381
|
const endPageNo = positionList[endIndex].pageNo;
|
|
@@ -18375,7 +18440,9 @@ class CommandAdapt {
|
|
|
18375
18440
|
isTable,
|
|
18376
18441
|
trIndex: trIndex != null ? trIndex : null,
|
|
18377
18442
|
tdIndex: tdIndex != null ? tdIndex : null,
|
|
18378
|
-
tableElement
|
|
18443
|
+
tableElement,
|
|
18444
|
+
selectionText,
|
|
18445
|
+
selectionElementList
|
|
18379
18446
|
});
|
|
18380
18447
|
}
|
|
18381
18448
|
getRangeRow() {
|
|
@@ -18444,6 +18511,37 @@ class CommandAdapt {
|
|
|
18444
18511
|
return;
|
|
18445
18512
|
this.draw.appendElementList(deepClone(elementList), options);
|
|
18446
18513
|
}
|
|
18514
|
+
updateElementById(payload) {
|
|
18515
|
+
function getElementIndexById(elementList) {
|
|
18516
|
+
for (let e = 0; e < elementList.length; e++) {
|
|
18517
|
+
const element = elementList[e];
|
|
18518
|
+
if (element.id === payload.id) {
|
|
18519
|
+
return e;
|
|
18520
|
+
}
|
|
18521
|
+
}
|
|
18522
|
+
return -1;
|
|
18523
|
+
}
|
|
18524
|
+
const getElementListFnList = [
|
|
18525
|
+
this.draw.getOriginalMainElementList,
|
|
18526
|
+
this.draw.getHeaderElementList,
|
|
18527
|
+
this.draw.getFooterElementList
|
|
18528
|
+
];
|
|
18529
|
+
for (const getElementList of getElementListFnList) {
|
|
18530
|
+
const elementList = getElementList.call(this.draw);
|
|
18531
|
+
const elementIndex = getElementIndexById(elementList);
|
|
18532
|
+
if (~elementIndex) {
|
|
18533
|
+
elementList[elementIndex] = __spreadValues(__spreadValues({}, elementList[elementIndex]), payload.properties);
|
|
18534
|
+
formatElementList([elementList[elementIndex]], {
|
|
18535
|
+
isHandleFirstElement: false,
|
|
18536
|
+
editorOptions: this.options
|
|
18537
|
+
});
|
|
18538
|
+
this.draw.render({
|
|
18539
|
+
isSetCursor: false
|
|
18540
|
+
});
|
|
18541
|
+
break;
|
|
18542
|
+
}
|
|
18543
|
+
}
|
|
18544
|
+
}
|
|
18447
18545
|
setValue(payload) {
|
|
18448
18546
|
this.draw.setValue(payload);
|
|
18449
18547
|
}
|
|
@@ -18605,6 +18703,80 @@ class CommandAdapt {
|
|
|
18605
18703
|
getControlList() {
|
|
18606
18704
|
return this.draw.getControl().getList();
|
|
18607
18705
|
}
|
|
18706
|
+
locationControl(controlId) {
|
|
18707
|
+
function location(elementList, zone2) {
|
|
18708
|
+
let i = 0;
|
|
18709
|
+
while (i < elementList.length) {
|
|
18710
|
+
const element = elementList[i];
|
|
18711
|
+
i++;
|
|
18712
|
+
if (element.type === ElementType.TABLE) {
|
|
18713
|
+
const trList = element.trList;
|
|
18714
|
+
for (let r = 0; r < trList.length; r++) {
|
|
18715
|
+
const tr = trList[r];
|
|
18716
|
+
for (let d = 0; d < tr.tdList.length; d++) {
|
|
18717
|
+
const td = tr.tdList[d];
|
|
18718
|
+
const locationContext = location(td.value, zone2);
|
|
18719
|
+
if (locationContext) {
|
|
18720
|
+
return __spreadProps(__spreadValues({}, locationContext), {
|
|
18721
|
+
positionContext: {
|
|
18722
|
+
isTable: true,
|
|
18723
|
+
index: i - 1,
|
|
18724
|
+
trIndex: r,
|
|
18725
|
+
tdIndex: d,
|
|
18726
|
+
tdId: element.tdId,
|
|
18727
|
+
trId: element.trId,
|
|
18728
|
+
tableId: element.tableId
|
|
18729
|
+
}
|
|
18730
|
+
});
|
|
18731
|
+
}
|
|
18732
|
+
}
|
|
18733
|
+
}
|
|
18734
|
+
}
|
|
18735
|
+
if ((element == null ? void 0 : element.controlId) !== controlId)
|
|
18736
|
+
continue;
|
|
18737
|
+
const curIndex = i - 1;
|
|
18738
|
+
return {
|
|
18739
|
+
zone: zone2,
|
|
18740
|
+
range: {
|
|
18741
|
+
startIndex: curIndex,
|
|
18742
|
+
endIndex: curIndex
|
|
18743
|
+
},
|
|
18744
|
+
positionContext: {
|
|
18745
|
+
isTable: false
|
|
18746
|
+
}
|
|
18747
|
+
};
|
|
18748
|
+
}
|
|
18749
|
+
return null;
|
|
18750
|
+
}
|
|
18751
|
+
const data2 = [
|
|
18752
|
+
{
|
|
18753
|
+
zone: EditorZone.HEADER,
|
|
18754
|
+
elementList: this.draw.getHeaderElementList()
|
|
18755
|
+
},
|
|
18756
|
+
{
|
|
18757
|
+
zone: EditorZone.MAIN,
|
|
18758
|
+
elementList: this.draw.getOriginalMainElementList()
|
|
18759
|
+
},
|
|
18760
|
+
{
|
|
18761
|
+
zone: EditorZone.FOOTER,
|
|
18762
|
+
elementList: this.draw.getFooterElementList()
|
|
18763
|
+
}
|
|
18764
|
+
];
|
|
18765
|
+
for (const context of data2) {
|
|
18766
|
+
const locationContext = location(context.elementList, context.zone);
|
|
18767
|
+
if (locationContext) {
|
|
18768
|
+
this.setZone(locationContext.zone);
|
|
18769
|
+
this.position.setPositionContext(locationContext.positionContext);
|
|
18770
|
+
this.range.replaceRange(locationContext.range);
|
|
18771
|
+
this.draw.render({
|
|
18772
|
+
curIndex: locationContext.range.startIndex,
|
|
18773
|
+
isCompute: false,
|
|
18774
|
+
isSubmitHistory: false
|
|
18775
|
+
});
|
|
18776
|
+
break;
|
|
18777
|
+
}
|
|
18778
|
+
}
|
|
18779
|
+
}
|
|
18608
18780
|
getContainer() {
|
|
18609
18781
|
return this.draw.getContainer();
|
|
18610
18782
|
}
|
|
@@ -19483,7 +19655,7 @@ class ContextMenu {
|
|
|
19483
19655
|
}
|
|
19484
19656
|
const richtextKeys = [
|
|
19485
19657
|
{
|
|
19486
|
-
key: KeyMap.
|
|
19658
|
+
key: KeyMap.X,
|
|
19487
19659
|
ctrl: true,
|
|
19488
19660
|
shift: true,
|
|
19489
19661
|
callback: (command) => {
|
|
@@ -19700,7 +19872,7 @@ class Shortcut {
|
|
|
19700
19872
|
var _a;
|
|
19701
19873
|
for (let s = 0; s < shortCutList.length; s++) {
|
|
19702
19874
|
const shortCut = shortCutList[s];
|
|
19703
|
-
if ((shortCut.mod ? isMod(evt) === !!shortCut.mod : evt.ctrlKey === !!shortCut.ctrl && evt.metaKey === !!shortCut.meta) && evt.shiftKey === !!shortCut.shift && evt.altKey === !!shortCut.alt && evt.key === shortCut.key) {
|
|
19875
|
+
if ((shortCut.mod ? isMod(evt) === !!shortCut.mod : evt.ctrlKey === !!shortCut.ctrl && evt.metaKey === !!shortCut.meta) && evt.shiftKey === !!shortCut.shift && evt.altKey === !!shortCut.alt && evt.key.toLowerCase() === shortCut.key.toLowerCase()) {
|
|
19704
19876
|
if (!shortCut.disable) {
|
|
19705
19877
|
(_a = shortCut == null ? void 0 : shortCut.callback) == null ? void 0 : _a.call(shortCut, this.command);
|
|
19706
19878
|
evt.preventDefault();
|
|
@@ -19760,6 +19932,7 @@ class Override {
|
|
|
19760
19932
|
constructor() {
|
|
19761
19933
|
__publicField(this, "paste");
|
|
19762
19934
|
__publicField(this, "copy");
|
|
19935
|
+
__publicField(this, "drop");
|
|
19763
19936
|
}
|
|
19764
19937
|
}
|
|
19765
19938
|
class Editor {
|