@hufe921/canvas-editor 0.9.41 → 0.9.42
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 +17 -0
- package/dist/canvas-editor.es.js +47 -23
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +21 -21
- 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 +1 -0
- package/dist/src/editor/core/draw/Draw.d.ts +0 -2
- package/dist/src/editor/core/draw/frame/Footer.d.ts +1 -1
- package/dist/src/editor/core/draw/frame/Header.d.ts +1 -1
- package/dist/src/editor/interface/Draw.d.ts +1 -0
- package/dist/src/editor/utils/index.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [0.9.42](https://github.com/Hufe921/canvas-editor/compare/v0.9.41...v0.9.42) (2023-07-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* contentChange call error during initialization #224 ([1b25afb](https://github.com/Hufe921/canvas-editor/commit/1b25afb664b6feff8a0e96dda53a0a3b252663c7)), closes [#224](https://github.com/Hufe921/canvas-editor/issues/224)
|
|
7
|
+
* control value style not affected by prefix #227 ([cf5dd35](https://github.com/Hufe921/canvas-editor/commit/cf5dd356869ac272dd8d3a1948ff5f4c6536b23d)), closes [#227](https://github.com/Hufe921/canvas-editor/issues/227)
|
|
8
|
+
* limit word break element type ([73014dc](https://github.com/Hufe921/canvas-editor/commit/73014dc87be5360ab8f09e211a12b06dfcbb77e2))
|
|
9
|
+
* set header and footer data error #224 ([b22f0b4](https://github.com/Hufe921/canvas-editor/commit/b22f0b45418b76ba008a2f6200bf8210f3c6f0dd)), closes [#224](https://github.com/Hufe921/canvas-editor/issues/224)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* add SetHTML api ([52f7500](https://github.com/Hufe921/canvas-editor/commit/52f7500ae3e27b1746af423dcbf1faffc9134948))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
1
18
|
## [0.9.41](https://github.com/Hufe921/canvas-editor/compare/v0.9.40...v0.9.41) (2023-07-27)
|
|
2
19
|
|
|
3
20
|
|
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.42";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -228,6 +228,15 @@ function cloneProperty(properties, sourceElement, targetElement) {
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
+
function omitObject(object, keys) {
|
|
232
|
+
const cloneObject = deepClone(object);
|
|
233
|
+
for (const key in object) {
|
|
234
|
+
if (keys.includes(key)) {
|
|
235
|
+
delete cloneObject[key];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return cloneObject;
|
|
239
|
+
}
|
|
231
240
|
function convertStringToBase64(input2) {
|
|
232
241
|
const encoder = new TextEncoder();
|
|
233
242
|
const data2 = encoder.encode(input2);
|
|
@@ -7225,7 +7234,7 @@ class TextParticle {
|
|
|
7225
7234
|
let i = curIndex;
|
|
7226
7235
|
while (i < elementList.length) {
|
|
7227
7236
|
const element = elementList[i];
|
|
7228
|
-
if (!LETTER_REG.test(element.value)) {
|
|
7237
|
+
if (element.type && element.type !== ElementType.TEXT || !LETTER_REG.test(element.value)) {
|
|
7229
7238
|
endElement = element;
|
|
7230
7239
|
break;
|
|
7231
7240
|
}
|
|
@@ -8096,7 +8105,7 @@ class HyperlinkParticle {
|
|
|
8096
8105
|
}
|
|
8097
8106
|
}
|
|
8098
8107
|
class Header {
|
|
8099
|
-
constructor(draw) {
|
|
8108
|
+
constructor(draw, data2) {
|
|
8100
8109
|
__publicField(this, "draw");
|
|
8101
8110
|
__publicField(this, "position");
|
|
8102
8111
|
__publicField(this, "options");
|
|
@@ -8106,7 +8115,7 @@ class Header {
|
|
|
8106
8115
|
this.draw = draw;
|
|
8107
8116
|
this.position = draw.getPosition();
|
|
8108
8117
|
this.options = draw.getOptions();
|
|
8109
|
-
this.elementList =
|
|
8118
|
+
this.elementList = data2 || [];
|
|
8110
8119
|
this.rowList = [];
|
|
8111
8120
|
this.positionList = [];
|
|
8112
8121
|
}
|
|
@@ -8433,11 +8442,12 @@ class SelectControl {
|
|
|
8433
8442
|
this.control.removePlaceholder(startIndex);
|
|
8434
8443
|
const elementList = this.control.getElementList();
|
|
8435
8444
|
const startElement = elementList[startIndex];
|
|
8445
|
+
const anchorElement = startElement.controlComponent === ControlComponent.PREFIX ? omitObject(startElement, EDITOR_ELEMENT_STYLE_ATTR) : startElement;
|
|
8436
8446
|
const start = startIndex + 1;
|
|
8437
8447
|
const data2 = splitText(valueSet.value);
|
|
8438
8448
|
const draw = this.control.getDraw();
|
|
8439
8449
|
for (let i = 0; i < data2.length; i++) {
|
|
8440
|
-
const newElement = __spreadProps(__spreadValues({},
|
|
8450
|
+
const newElement = __spreadProps(__spreadValues({}, anchorElement), {
|
|
8441
8451
|
value: data2[i],
|
|
8442
8452
|
controlComponent: ControlComponent.VALUE
|
|
8443
8453
|
});
|
|
@@ -8554,9 +8564,10 @@ class TextControl {
|
|
|
8554
8564
|
this.control.removePlaceholder(startIndex);
|
|
8555
8565
|
}
|
|
8556
8566
|
const startElement = elementList[startIndex];
|
|
8567
|
+
const anchorElement = startElement.controlComponent === ControlComponent.PREFIX ? omitObject(startElement, EDITOR_ELEMENT_STYLE_ATTR) : startElement;
|
|
8557
8568
|
const start = range.startIndex + 1;
|
|
8558
8569
|
for (let i = 0; i < data2.length; i++) {
|
|
8559
|
-
const newElement = __spreadProps(__spreadValues(__spreadValues({},
|
|
8570
|
+
const newElement = __spreadProps(__spreadValues(__spreadValues({}, anchorElement), data2[i]), {
|
|
8560
8571
|
controlComponent: ControlComponent.VALUE
|
|
8561
8572
|
});
|
|
8562
8573
|
formatElementContext(elementList, [newElement], startIndex);
|
|
@@ -10333,7 +10344,7 @@ class Zone {
|
|
|
10333
10344
|
}
|
|
10334
10345
|
}
|
|
10335
10346
|
class Footer {
|
|
10336
|
-
constructor(draw) {
|
|
10347
|
+
constructor(draw, data2) {
|
|
10337
10348
|
__publicField(this, "draw");
|
|
10338
10349
|
__publicField(this, "position");
|
|
10339
10350
|
__publicField(this, "options");
|
|
@@ -10343,7 +10354,7 @@ class Footer {
|
|
|
10343
10354
|
this.draw = draw;
|
|
10344
10355
|
this.position = draw.getPosition();
|
|
10345
10356
|
this.options = draw.getOptions();
|
|
10346
|
-
this.elementList =
|
|
10357
|
+
this.elementList = data2 || [];
|
|
10347
10358
|
this.rowList = [];
|
|
10348
10359
|
this.positionList = [];
|
|
10349
10360
|
}
|
|
@@ -10607,9 +10618,7 @@ class Draw {
|
|
|
10607
10618
|
__publicField(this, "options");
|
|
10608
10619
|
__publicField(this, "position");
|
|
10609
10620
|
__publicField(this, "zone");
|
|
10610
|
-
__publicField(this, "headerElementList");
|
|
10611
10621
|
__publicField(this, "elementList");
|
|
10612
|
-
__publicField(this, "footerElementList");
|
|
10613
10622
|
__publicField(this, "listener");
|
|
10614
10623
|
__publicField(this, "eventBus");
|
|
10615
10624
|
__publicField(this, "i18n");
|
|
@@ -10663,9 +10672,7 @@ class Draw {
|
|
|
10663
10672
|
this.pagePixelRatio = null;
|
|
10664
10673
|
this.mode = options.mode;
|
|
10665
10674
|
this.options = options;
|
|
10666
|
-
this.headerElementList = data2.header || [];
|
|
10667
10675
|
this.elementList = data2.main;
|
|
10668
|
-
this.footerElementList = data2.footer || [];
|
|
10669
10676
|
this.listener = listener;
|
|
10670
10677
|
this.eventBus = eventBus;
|
|
10671
10678
|
this._formatContainer();
|
|
@@ -10691,8 +10698,8 @@ class Draw {
|
|
|
10691
10698
|
this.pageNumber = new PageNumber(this);
|
|
10692
10699
|
this.waterMark = new Watermark(this);
|
|
10693
10700
|
this.placeholder = new Placeholder(this);
|
|
10694
|
-
this.header = new Header(this);
|
|
10695
|
-
this.footer = new Footer(this);
|
|
10701
|
+
this.header = new Header(this, data2.header);
|
|
10702
|
+
this.footer = new Footer(this, data2.footer);
|
|
10696
10703
|
this.hyperlinkParticle = new HyperlinkParticle(this);
|
|
10697
10704
|
this.dateParticle = new DateParticle(this);
|
|
10698
10705
|
this.separatorParticle = new SeparatorParticle();
|
|
@@ -10719,7 +10726,10 @@ class Draw {
|
|
|
10719
10726
|
this.visiblePageNoList = [];
|
|
10720
10727
|
this.intersectionPageNo = 0;
|
|
10721
10728
|
this.lazyRenderIntersectionObserver = null;
|
|
10722
|
-
this.render({
|
|
10729
|
+
this.render({
|
|
10730
|
+
isInit: true,
|
|
10731
|
+
isSetCursor: false
|
|
10732
|
+
});
|
|
10723
10733
|
}
|
|
10724
10734
|
getMode() {
|
|
10725
10735
|
return this.mode;
|
|
@@ -10884,7 +10894,7 @@ class Draw {
|
|
|
10884
10894
|
return this.range;
|
|
10885
10895
|
}
|
|
10886
10896
|
getHeaderElementList() {
|
|
10887
|
-
return this.
|
|
10897
|
+
return this.header.getElementList();
|
|
10888
10898
|
}
|
|
10889
10899
|
getTableElementList(sourceElementList) {
|
|
10890
10900
|
const positionContext = this.position.getPositionContext();
|
|
@@ -10903,10 +10913,10 @@ class Draw {
|
|
|
10903
10913
|
getOriginalElementList() {
|
|
10904
10914
|
const zoneManager = this.getZone();
|
|
10905
10915
|
if (zoneManager.isHeaderActive()) {
|
|
10906
|
-
return this.
|
|
10916
|
+
return this.getHeaderElementList();
|
|
10907
10917
|
}
|
|
10908
10918
|
if (zoneManager.isFooterActive()) {
|
|
10909
|
-
return this.
|
|
10919
|
+
return this.getFooterElementList();
|
|
10910
10920
|
}
|
|
10911
10921
|
return this.elementList;
|
|
10912
10922
|
}
|
|
@@ -10914,7 +10924,7 @@ class Draw {
|
|
|
10914
10924
|
return this.elementList;
|
|
10915
10925
|
}
|
|
10916
10926
|
getFooterElementList() {
|
|
10917
|
-
return this.
|
|
10927
|
+
return this.footer.getElementList();
|
|
10918
10928
|
}
|
|
10919
10929
|
insertElementList(payload) {
|
|
10920
10930
|
if (!payload.length)
|
|
@@ -11217,9 +11227,9 @@ class Draw {
|
|
|
11217
11227
|
mainElementList = this.pageRowList[pageNo].flatMap((row) => row.elementList);
|
|
11218
11228
|
}
|
|
11219
11229
|
const data2 = {
|
|
11220
|
-
header: zipElementList(this.
|
|
11230
|
+
header: zipElementList(this.getHeaderElementList()),
|
|
11221
11231
|
main: zipElementList(mainElementList),
|
|
11222
|
-
footer: zipElementList(this.
|
|
11232
|
+
footer: zipElementList(this.getFooterElementList())
|
|
11223
11233
|
};
|
|
11224
11234
|
return {
|
|
11225
11235
|
version,
|
|
@@ -11863,7 +11873,7 @@ class Draw {
|
|
|
11863
11873
|
render(payload) {
|
|
11864
11874
|
var _a;
|
|
11865
11875
|
const { header, footer } = this.options;
|
|
11866
|
-
const { isSubmitHistory = true, isSetCursor = true, isCompute = true, isLazy = true } = payload || {};
|
|
11876
|
+
const { isSubmitHistory = true, isSetCursor = true, isCompute = true, isLazy = true, isInit = false } = payload || {};
|
|
11867
11877
|
let { curIndex } = payload || {};
|
|
11868
11878
|
const innerWidth = this.getInnerWidth();
|
|
11869
11879
|
const isPagingMode = this.getIsPagingMode();
|
|
@@ -11953,7 +11963,7 @@ class Draw {
|
|
|
11953
11963
|
if (this.eventBus.isSubscribe("pageSizeChange")) {
|
|
11954
11964
|
this.eventBus.emit("pageSizeChange", this.pageRowList.length);
|
|
11955
11965
|
}
|
|
11956
|
-
if (isSubmitHistory) {
|
|
11966
|
+
if (isSubmitHistory && !isInit) {
|
|
11957
11967
|
if (this.listener.contentChange) {
|
|
11958
11968
|
this.listener.contentChange();
|
|
11959
11969
|
}
|
|
@@ -12044,6 +12054,7 @@ class Command {
|
|
|
12044
12054
|
__publicField(this, "executeSetLocale");
|
|
12045
12055
|
__publicField(this, "executeLocationCatalog");
|
|
12046
12056
|
__publicField(this, "executeWordTool");
|
|
12057
|
+
__publicField(this, "executeSetHTML");
|
|
12047
12058
|
__publicField(this, "getCatalog");
|
|
12048
12059
|
__publicField(this, "getImage");
|
|
12049
12060
|
__publicField(this, "getValue");
|
|
@@ -12125,6 +12136,7 @@ class Command {
|
|
|
12125
12136
|
this.executeSetLocale = adapt.setLocale.bind(adapt);
|
|
12126
12137
|
this.executeLocationCatalog = adapt.locationCatalog.bind(adapt);
|
|
12127
12138
|
this.executeWordTool = adapt.wordTool.bind(adapt);
|
|
12139
|
+
this.executeSetHTML = adapt.setHTML.bind(adapt);
|
|
12128
12140
|
this.getImage = adapt.getImage.bind(adapt);
|
|
12129
12141
|
this.getValue = adapt.getValue.bind(adapt);
|
|
12130
12142
|
this.getHTML = adapt.getHTML.bind(adapt);
|
|
@@ -13861,6 +13873,18 @@ class CommandAdapt {
|
|
|
13861
13873
|
});
|
|
13862
13874
|
}
|
|
13863
13875
|
}
|
|
13876
|
+
setHTML(payload) {
|
|
13877
|
+
const { header, main, footer } = payload;
|
|
13878
|
+
const innerWidth = this.draw.getOriginalInnerWidth();
|
|
13879
|
+
const getElementList = (htmlText) => htmlText !== void 0 ? getElementListByHTML(htmlText, {
|
|
13880
|
+
innerWidth
|
|
13881
|
+
}) : void 0;
|
|
13882
|
+
this.setValue({
|
|
13883
|
+
header: getElementList(header),
|
|
13884
|
+
main: getElementList(main),
|
|
13885
|
+
footer: getElementList(footer)
|
|
13886
|
+
});
|
|
13887
|
+
}
|
|
13864
13888
|
}
|
|
13865
13889
|
class Listener {
|
|
13866
13890
|
constructor() {
|