@hufe921/canvas-editor 0.9.98 → 0.9.99
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 +26 -0
- package/dist/canvas-editor.es.js +229 -41
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +31 -31
- 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 +5 -2
- package/dist/src/editor/core/draw/Draw.d.ts +3 -0
- package/dist/src/editor/core/draw/control/Control.d.ts +1 -0
- package/dist/src/editor/core/draw/control/number/NumberControl.d.ts +3 -0
- package/dist/src/editor/core/draw/frame/Badge.d.ts +14 -0
- package/dist/src/editor/core/draw/interactive/Area.d.ts +1 -0
- package/dist/src/editor/dataset/constant/Badge.d.ts +2 -0
- package/dist/src/editor/dataset/enum/Common.d.ts +4 -0
- package/dist/src/editor/dataset/enum/Control.d.ts +2 -1
- package/dist/src/editor/index.d.ts +4 -3
- package/dist/src/editor/interface/Badge.d.ts +15 -0
- package/dist/src/editor/interface/Control.d.ts +7 -1
- package/dist/src/editor/interface/Editor.d.ts +2 -0
- package/package.json +1 -1
- /package/dist/src/editor/core/draw/particle/{PageBreak.d.ts → PageBreakParticle.d.ts} +0 -0
- /package/dist/src/editor/core/draw/particle/{Separator.d.ts → SeparatorParticle.d.ts} +0 -0
- /package/dist/src/editor/core/draw/particle/{Subscript.d.ts → SubscriptParticle.d.ts} +0 -0
- /package/dist/src/editor/core/draw/particle/{Superscript.d.ts → SuperscriptParticle.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## [0.9.99](https://github.com/Hufe921/canvas-editor/compare/v0.9.98...v0.9.99) (2024-12-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* locate catalog when the context is within the table ([012dc7d](https://github.com/Hufe921/canvas-editor/commit/012dc7debcce4366c8e094cbc2af1a7892227ad2))
|
|
7
|
+
* optimize image caching method #933 ([8516931](https://github.com/Hufe921/canvas-editor/commit/85169313bd8f51feb9f442cb32b774dcbc580e96)), closes [#933](https://github.com/Hufe921/canvas-editor/issues/933)
|
|
8
|
+
* verify control integrity boundary error #920 ([77a2550](https://github.com/Hufe921/canvas-editor/commit/77a25504bc40caaf20390944f286748bdf113e39)), closes [#920](https://github.com/Hufe921/canvas-editor/issues/920)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Chores
|
|
12
|
+
|
|
13
|
+
* rename some particles ([b5d18d3](https://github.com/Hufe921/canvas-editor/commit/b5d18d3a59f89a701758af160fc889e49ba1f5c6))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* add badge option #918 ([190785a](https://github.com/Hufe921/canvas-editor/commit/190785ac69f6187d10abb070eab32a523e394b34)), closes [#918](https://github.com/Hufe921/canvas-editor/issues/918)
|
|
19
|
+
* add control flex direction option #652 ([c599d56](https://github.com/Hufe921/canvas-editor/commit/c599d563b631f29a6bea6fe94624afa05c6879ef)), closes [#652](https://github.com/Hufe921/canvas-editor/issues/652)
|
|
20
|
+
* add number control #925 ([aff4979](https://github.com/Hufe921/canvas-editor/commit/aff49797da3f7e966b9f692269468ccb792af309)), closes [#925](https://github.com/Hufe921/canvas-editor/issues/925)
|
|
21
|
+
* delete control by id or conceptId #905 ([5d434bd](https://github.com/Hufe921/canvas-editor/commit/5d434bd7d3dce31f761a0e1f6c81dfa7a80bb03e)), closes [#905](https://github.com/Hufe921/canvas-editor/issues/905)
|
|
22
|
+
* element id support customization ([c79be3a](https://github.com/Hufe921/canvas-editor/commit/c79be3ab72e9e1cda75e7af2b8b8d50e1ba2085a))
|
|
23
|
+
* optimize cursor focus when dragging elements #926 ([3679cbd](https://github.com/Hufe921/canvas-editor/commit/3679cbd4205427a1337e023c318ea98be3c952f8)), closes [#926](https://github.com/Hufe921/canvas-editor/issues/926)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
1
27
|
## [0.9.98](https://github.com/Hufe921/canvas-editor/compare/v0.9.97...v0.9.98) (2024-12-01)
|
|
2
28
|
|
|
3
29
|
|
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.99";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -48,6 +48,11 @@ var LocationPosition;
|
|
|
48
48
|
LocationPosition2["BEFORE"] = "before";
|
|
49
49
|
LocationPosition2["AFTER"] = "after";
|
|
50
50
|
})(LocationPosition || (LocationPosition = {}));
|
|
51
|
+
var FlexDirection;
|
|
52
|
+
(function(FlexDirection2) {
|
|
53
|
+
FlexDirection2["ROW"] = "row";
|
|
54
|
+
FlexDirection2["COLUMN"] = "column";
|
|
55
|
+
})(FlexDirection || (FlexDirection = {}));
|
|
51
56
|
const ZERO = "\u200B";
|
|
52
57
|
const WRAP = "\n";
|
|
53
58
|
const NBSP = " ";
|
|
@@ -647,8 +652,8 @@ class ImageParticle {
|
|
|
647
652
|
const { scale } = this.options;
|
|
648
653
|
const width = element.width * scale;
|
|
649
654
|
const height = element.height * scale;
|
|
650
|
-
if (this.imageCache.has(element.
|
|
651
|
-
const img = this.imageCache.get(element.
|
|
655
|
+
if (this.imageCache.has(element.value)) {
|
|
656
|
+
const img = this.imageCache.get(element.value);
|
|
652
657
|
ctx.drawImage(img, x, y, width, height);
|
|
653
658
|
} else {
|
|
654
659
|
const imageLoadPromise = new Promise((resolve, reject) => {
|
|
@@ -656,7 +661,7 @@ class ImageParticle {
|
|
|
656
661
|
img.setAttribute("crossOrigin", "Anonymous");
|
|
657
662
|
img.src = element.value;
|
|
658
663
|
img.onload = () => {
|
|
659
|
-
this.imageCache.set(element.
|
|
664
|
+
this.imageCache.set(element.value, img);
|
|
660
665
|
resolve(element);
|
|
661
666
|
if (element.imgDisplay === ImageDisplay.FLOAT_BOTTOM) {
|
|
662
667
|
this.draw.render({
|
|
@@ -672,7 +677,7 @@ class ImageParticle {
|
|
|
672
677
|
const fallbackImage = this.getFallbackImage(width, height);
|
|
673
678
|
fallbackImage.onload = () => {
|
|
674
679
|
ctx.drawImage(fallbackImage, x, y, width, height);
|
|
675
|
-
this.imageCache.set(element.
|
|
680
|
+
this.imageCache.set(element.value, fallbackImage);
|
|
676
681
|
};
|
|
677
682
|
reject(error);
|
|
678
683
|
};
|
|
@@ -3771,6 +3776,7 @@ var ControlType;
|
|
|
3771
3776
|
ControlType2["CHECKBOX"] = "checkbox";
|
|
3772
3777
|
ControlType2["RADIO"] = "radio";
|
|
3773
3778
|
ControlType2["DATE"] = "date";
|
|
3779
|
+
ControlType2["NUMBER"] = "number";
|
|
3774
3780
|
})(ControlType || (ControlType = {}));
|
|
3775
3781
|
var ControlComponent;
|
|
3776
3782
|
(function(ControlComponent2) {
|
|
@@ -3990,6 +3996,10 @@ var RenderMode;
|
|
|
3990
3996
|
RenderMode2["SPEED"] = "speed";
|
|
3991
3997
|
RenderMode2["COMPATIBILITY"] = "compatibility";
|
|
3992
3998
|
})(RenderMode || (RenderMode = {}));
|
|
3999
|
+
const defaultBadgeOption = {
|
|
4000
|
+
top: 0,
|
|
4001
|
+
left: 5
|
|
4002
|
+
};
|
|
3993
4003
|
function mergeOption(options = {}) {
|
|
3994
4004
|
const tableOptions = __spreadValues(__spreadValues({}, defaultTableOption), options.table);
|
|
3995
4005
|
const headerOptions = __spreadValues(__spreadValues({}, defaultHeaderOption), options.header);
|
|
@@ -4010,6 +4020,7 @@ function mergeOption(options = {}) {
|
|
|
4010
4020
|
const separatorOptions = __spreadValues(__spreadValues({}, defaultSeparatorOption), options.separator);
|
|
4011
4021
|
const lineNumberOptions = __spreadValues(__spreadValues({}, defaultLineNumberOption), options.lineNumber);
|
|
4012
4022
|
const pageBorderOptions = __spreadValues(__spreadValues({}, defaultPageBorderOption), options.pageBorder);
|
|
4023
|
+
const badgeOptions = __spreadValues(__spreadValues({}, defaultBadgeOption), options.badge);
|
|
4013
4024
|
return __spreadProps(__spreadValues({
|
|
4014
4025
|
mode: EditorMode.EDIT,
|
|
4015
4026
|
defaultType: "TEXT",
|
|
@@ -4070,7 +4081,8 @@ function mergeOption(options = {}) {
|
|
|
4070
4081
|
lineBreak: lineBreakOptions,
|
|
4071
4082
|
separator: separatorOptions,
|
|
4072
4083
|
lineNumber: lineNumberOptions,
|
|
4073
|
-
pageBorder: pageBorderOptions
|
|
4084
|
+
pageBorder: pageBorderOptions,
|
|
4085
|
+
badge: badgeOptions
|
|
4074
4086
|
});
|
|
4075
4087
|
}
|
|
4076
4088
|
function unzipElementList(elementList) {
|
|
@@ -4179,13 +4191,13 @@ function formatElementList(elementList, options) {
|
|
|
4179
4191
|
}
|
|
4180
4192
|
i--;
|
|
4181
4193
|
} else if (el.type === ElementType.TABLE) {
|
|
4182
|
-
const tableId = getUUID();
|
|
4194
|
+
const tableId = el.id || getUUID();
|
|
4183
4195
|
el.id = tableId;
|
|
4184
4196
|
if (el.trList) {
|
|
4185
4197
|
const { defaultTrMinHeight } = editorOptions.table;
|
|
4186
4198
|
for (let t = 0; t < el.trList.length; t++) {
|
|
4187
4199
|
const tr = el.trList[t];
|
|
4188
|
-
const trId = getUUID();
|
|
4200
|
+
const trId = tr.id || getUUID();
|
|
4189
4201
|
tr.id = trId;
|
|
4190
4202
|
if (!tr.minHeight || tr.minHeight < defaultTrMinHeight) {
|
|
4191
4203
|
tr.minHeight = defaultTrMinHeight;
|
|
@@ -4195,7 +4207,7 @@ function formatElementList(elementList, options) {
|
|
|
4195
4207
|
}
|
|
4196
4208
|
for (let d = 0; d < tr.tdList.length; d++) {
|
|
4197
4209
|
const td = tr.tdList[d];
|
|
4198
|
-
const tdId = getUUID();
|
|
4210
|
+
const tdId = td.id || getUUID();
|
|
4199
4211
|
td.id = tdId;
|
|
4200
4212
|
formatElementList(td.value, __spreadProps(__spreadValues({}, options), {
|
|
4201
4213
|
isHandleFirstElement: true,
|
|
@@ -4440,14 +4452,14 @@ function formatElementList(elementList, options) {
|
|
|
4440
4452
|
el.value = ZERO;
|
|
4441
4453
|
}
|
|
4442
4454
|
if (el.type === ElementType.IMAGE || el.type === ElementType.BLOCK) {
|
|
4443
|
-
el.id = getUUID();
|
|
4455
|
+
el.id = el.id || getUUID();
|
|
4444
4456
|
}
|
|
4445
4457
|
if (el.type === ElementType.LATEX) {
|
|
4446
4458
|
const { svg, width, height } = LaTexParticle.convertLaTextToSVG(el.value);
|
|
4447
4459
|
el.width = el.width || width;
|
|
4448
4460
|
el.height = el.height || height;
|
|
4449
4461
|
el.laTexSVG = svg;
|
|
4450
|
-
el.id = getUUID();
|
|
4462
|
+
el.id = el.id || getUUID();
|
|
4451
4463
|
}
|
|
4452
4464
|
i++;
|
|
4453
4465
|
}
|
|
@@ -7821,7 +7833,8 @@ function dragover(evt, host) {
|
|
|
7821
7833
|
cursor.drawCursor({
|
|
7822
7834
|
width: dragWidth,
|
|
7823
7835
|
color: dragColor,
|
|
7824
|
-
isBlink: false
|
|
7836
|
+
isBlink: false,
|
|
7837
|
+
isFocus: false
|
|
7825
7838
|
});
|
|
7826
7839
|
}
|
|
7827
7840
|
var drag = {
|
|
@@ -12574,6 +12587,8 @@ class DateControl {
|
|
|
12574
12587
|
this.destroy();
|
|
12575
12588
|
}
|
|
12576
12589
|
}
|
|
12590
|
+
class NumberControl extends TextControl {
|
|
12591
|
+
}
|
|
12577
12592
|
class Control {
|
|
12578
12593
|
constructor(draw) {
|
|
12579
12594
|
__publicField(this, "controlBorder");
|
|
@@ -12781,9 +12796,32 @@ class Control {
|
|
|
12781
12796
|
getActiveControl() {
|
|
12782
12797
|
return this.activeControl;
|
|
12783
12798
|
}
|
|
12799
|
+
getControlElementList(context = {}) {
|
|
12800
|
+
const elementList = context.elementList || this.getElementList();
|
|
12801
|
+
const { startIndex } = context.range || this.getRange();
|
|
12802
|
+
const startElement = elementList[startIndex];
|
|
12803
|
+
const data2 = [];
|
|
12804
|
+
let preIndex = startIndex;
|
|
12805
|
+
while (preIndex > 0) {
|
|
12806
|
+
const preElement = elementList[preIndex];
|
|
12807
|
+
if (preElement.controlId !== startElement.controlId)
|
|
12808
|
+
break;
|
|
12809
|
+
data2.unshift(preElement);
|
|
12810
|
+
preIndex--;
|
|
12811
|
+
}
|
|
12812
|
+
let nextIndex = startIndex + 1;
|
|
12813
|
+
while (nextIndex < elementList.length) {
|
|
12814
|
+
const nextElement = elementList[nextIndex];
|
|
12815
|
+
if (nextElement.controlId !== startElement.controlId)
|
|
12816
|
+
break;
|
|
12817
|
+
data2.push(nextElement);
|
|
12818
|
+
nextIndex++;
|
|
12819
|
+
}
|
|
12820
|
+
return data2;
|
|
12821
|
+
}
|
|
12784
12822
|
updateActiveControlValue() {
|
|
12785
12823
|
if (this.activeControl) {
|
|
12786
|
-
this.activeControlValue = this.
|
|
12824
|
+
this.activeControlValue = this.getControlElementList();
|
|
12787
12825
|
}
|
|
12788
12826
|
}
|
|
12789
12827
|
initControl() {
|
|
@@ -12824,6 +12862,8 @@ class Control {
|
|
|
12824
12862
|
const dateControl = new DateControl(element, this);
|
|
12825
12863
|
this.activeControl = dateControl;
|
|
12826
12864
|
dateControl.awake();
|
|
12865
|
+
} else if (control.type === ControlType.NUMBER) {
|
|
12866
|
+
this.activeControl = new NumberControl(element, this);
|
|
12827
12867
|
}
|
|
12828
12868
|
this.updateActiveControlValue();
|
|
12829
12869
|
const isSubscribeControlChange = this.eventBus.isSubscribe("controlChange");
|
|
@@ -13125,13 +13165,13 @@ class Control {
|
|
|
13125
13165
|
const nextElement = elementList[j];
|
|
13126
13166
|
if (nextElement.controlId !== element.controlId)
|
|
13127
13167
|
break;
|
|
13128
|
-
if ((type === ControlType.TEXT || type === ControlType.DATE) && nextElement.controlComponent === ControlComponent.VALUE) {
|
|
13168
|
+
if ((type === ControlType.TEXT || type === ControlType.DATE || type === ControlType.NUMBER) && nextElement.controlComponent === ControlComponent.VALUE) {
|
|
13129
13169
|
textControlValue += nextElement.value;
|
|
13130
13170
|
textControlElementList.push(omitObject(nextElement, CONTROL_CONTEXT_ATTR));
|
|
13131
13171
|
}
|
|
13132
13172
|
j++;
|
|
13133
13173
|
}
|
|
13134
|
-
if (type === ControlType.TEXT || type === ControlType.DATE) {
|
|
13174
|
+
if (type === ControlType.TEXT || type === ControlType.DATE || type === ControlType.NUMBER) {
|
|
13135
13175
|
result.push(__spreadProps(__spreadValues({}, element.control), {
|
|
13136
13176
|
zone: zone2,
|
|
13137
13177
|
value: textControlValue || null,
|
|
@@ -13261,6 +13301,19 @@ class Control {
|
|
|
13261
13301
|
} else {
|
|
13262
13302
|
date.clearSelect(controlContext, controlRule);
|
|
13263
13303
|
}
|
|
13304
|
+
} else if (type === ControlType.NUMBER) {
|
|
13305
|
+
const formatValue = Array.isArray(value) ? value : [{ value }];
|
|
13306
|
+
formatElementList(formatValue, {
|
|
13307
|
+
isHandleFirstElement: false,
|
|
13308
|
+
editorOptions: this.options
|
|
13309
|
+
});
|
|
13310
|
+
const text = new NumberControl(element, this);
|
|
13311
|
+
this.activeControl = text;
|
|
13312
|
+
if (value) {
|
|
13313
|
+
text.setValue(formatValue, controlContext, controlRule);
|
|
13314
|
+
} else {
|
|
13315
|
+
text.clearValue(controlContext, controlRule);
|
|
13316
|
+
}
|
|
13264
13317
|
}
|
|
13265
13318
|
this.activeControl = null;
|
|
13266
13319
|
let newEndIndex = i;
|
|
@@ -16456,6 +16509,9 @@ class Area {
|
|
|
16456
16509
|
this.range = draw.getRange();
|
|
16457
16510
|
this.position = draw.getPosition();
|
|
16458
16511
|
}
|
|
16512
|
+
getAreaInfo() {
|
|
16513
|
+
return this.areaInfoMap;
|
|
16514
|
+
}
|
|
16459
16515
|
getActiveAreaId() {
|
|
16460
16516
|
if (!this.areaInfoMap.size)
|
|
16461
16517
|
return null;
|
|
@@ -16610,6 +16666,72 @@ class Area {
|
|
|
16610
16666
|
});
|
|
16611
16667
|
}
|
|
16612
16668
|
}
|
|
16669
|
+
class Badge {
|
|
16670
|
+
constructor(draw) {
|
|
16671
|
+
__publicField(this, "draw");
|
|
16672
|
+
__publicField(this, "options");
|
|
16673
|
+
__publicField(this, "imageCache");
|
|
16674
|
+
__publicField(this, "mainBadge");
|
|
16675
|
+
__publicField(this, "areaBadgeMap");
|
|
16676
|
+
this.draw = draw;
|
|
16677
|
+
this.options = draw.getOptions();
|
|
16678
|
+
this.imageCache = new Map();
|
|
16679
|
+
this.mainBadge = null;
|
|
16680
|
+
this.areaBadgeMap = new Map();
|
|
16681
|
+
}
|
|
16682
|
+
setMainBadge(payload) {
|
|
16683
|
+
this.mainBadge = payload;
|
|
16684
|
+
}
|
|
16685
|
+
setAreaBadgeMap(payload) {
|
|
16686
|
+
this.areaBadgeMap.clear();
|
|
16687
|
+
payload.forEach((areaBadge) => {
|
|
16688
|
+
this.areaBadgeMap.set(areaBadge.areaId, areaBadge.badge);
|
|
16689
|
+
});
|
|
16690
|
+
}
|
|
16691
|
+
_drawImage(ctx, x, y, width, height, value) {
|
|
16692
|
+
if (this.imageCache.has(value)) {
|
|
16693
|
+
const img = this.imageCache.get(value);
|
|
16694
|
+
ctx.drawImage(img, x, y, width, height);
|
|
16695
|
+
} else {
|
|
16696
|
+
const img = new Image();
|
|
16697
|
+
img.setAttribute("crossOrigin", "Anonymous");
|
|
16698
|
+
img.src = value;
|
|
16699
|
+
img.onload = () => {
|
|
16700
|
+
this.imageCache.set(value, img);
|
|
16701
|
+
ctx.drawImage(img, x, y, width, height);
|
|
16702
|
+
};
|
|
16703
|
+
}
|
|
16704
|
+
}
|
|
16705
|
+
render(ctx, pageNo) {
|
|
16706
|
+
if (pageNo === 0 && this.mainBadge) {
|
|
16707
|
+
const { scale, badge } = this.options;
|
|
16708
|
+
const { left: left2, top, width, height, value } = this.mainBadge;
|
|
16709
|
+
const headerTop = this.draw.getMargins()[0] + this.draw.getHeader().getExtraHeight();
|
|
16710
|
+
const x = (left2 || badge.left) * scale;
|
|
16711
|
+
const y = (top || badge.top) * scale + headerTop;
|
|
16712
|
+
this._drawImage(ctx, x, y, width * scale, height * scale, value);
|
|
16713
|
+
}
|
|
16714
|
+
if (this.areaBadgeMap.size) {
|
|
16715
|
+
const areaInfo = this.draw.getArea().getAreaInfo();
|
|
16716
|
+
if (areaInfo.size) {
|
|
16717
|
+
const { scale, badge } = this.options;
|
|
16718
|
+
for (const areaItem of areaInfo) {
|
|
16719
|
+
const { positionList } = areaItem[1];
|
|
16720
|
+
const firstPosition = positionList[0];
|
|
16721
|
+
if (firstPosition.pageNo !== pageNo)
|
|
16722
|
+
continue;
|
|
16723
|
+
const badgeItem = this.areaBadgeMap.get(areaItem[0]);
|
|
16724
|
+
if (!badgeItem)
|
|
16725
|
+
continue;
|
|
16726
|
+
const { left: left2, top, width, height, value } = badgeItem;
|
|
16727
|
+
const x = (left2 || badge.left) * scale;
|
|
16728
|
+
const y = (top || badge.top) * scale + firstPosition.coordinate.leftTop[1];
|
|
16729
|
+
this._drawImage(ctx, x, y, width * scale, height * scale, value);
|
|
16730
|
+
}
|
|
16731
|
+
}
|
|
16732
|
+
}
|
|
16733
|
+
}
|
|
16734
|
+
}
|
|
16613
16735
|
class Draw {
|
|
16614
16736
|
constructor(rootContainer, options, data2, listener, eventBus, override) {
|
|
16615
16737
|
__publicField(this, "container");
|
|
@@ -16633,6 +16755,7 @@ class Draw {
|
|
|
16633
16755
|
__publicField(this, "range");
|
|
16634
16756
|
__publicField(this, "margin");
|
|
16635
16757
|
__publicField(this, "background");
|
|
16758
|
+
__publicField(this, "badge");
|
|
16636
16759
|
__publicField(this, "search");
|
|
16637
16760
|
__publicField(this, "group");
|
|
16638
16761
|
__publicField(this, "area");
|
|
@@ -16701,6 +16824,7 @@ class Draw {
|
|
|
16701
16824
|
this.range = new RangeManager(this);
|
|
16702
16825
|
this.margin = new Margin(this);
|
|
16703
16826
|
this.background = new Background(this);
|
|
16827
|
+
this.badge = new Badge(this);
|
|
16704
16828
|
this.search = new Search(this);
|
|
16705
16829
|
this.group = new Group(this);
|
|
16706
16830
|
this.area = new Area(this);
|
|
@@ -16996,6 +17120,9 @@ class Draw {
|
|
|
16996
17120
|
getArea() {
|
|
16997
17121
|
return this.area;
|
|
16998
17122
|
}
|
|
17123
|
+
getBadge() {
|
|
17124
|
+
return this.badge;
|
|
17125
|
+
}
|
|
16999
17126
|
getHistoryManager() {
|
|
17000
17127
|
return this.historyManager;
|
|
17001
17128
|
}
|
|
@@ -17535,7 +17662,7 @@ class Draw {
|
|
|
17535
17662
|
return defaultBasicRowMarginHeight * ((_a = el.rowMargin) != null ? _a : defaultRowMargin) * scale;
|
|
17536
17663
|
}
|
|
17537
17664
|
computeRowList(payload) {
|
|
17538
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
17665
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
17539
17666
|
const { innerWidth, elementList, isPagingMode = false, isFromTable = false, startX = 0, startY = 0, pageHeight = 0, mainOuterHeight = 0, surroundElementList = [] } = payload;
|
|
17540
17667
|
const { defaultSize, defaultRowMargin, scale, table: { tdPadding, defaultTrMinHeight }, defaultTabWidth } = this.options;
|
|
17541
17668
|
const defaultBasicRowMarginHeight = this.getDefaultBasicRowMarginHeight();
|
|
@@ -17913,7 +18040,7 @@ class Draw {
|
|
|
17913
18040
|
x = surroundPosition.x;
|
|
17914
18041
|
curRowWidth += surroundPosition.rowIncreaseWidth;
|
|
17915
18042
|
x += metrics.width;
|
|
17916
|
-
const isForceBreak = element.type === ElementType.SEPARATOR || element.type === ElementType.TABLE || (preElement == null ? void 0 : preElement.type) === ElementType.TABLE || (preElement == null ? void 0 : preElement.type) === ElementType.BLOCK || element.type === ElementType.BLOCK || (preElement == null ? void 0 : preElement.imgDisplay) === ImageDisplay.INLINE || element.imgDisplay === ImageDisplay.INLINE || (preElement == null ? void 0 : preElement.listId) !== element.listId || (preElement == null ? void 0 : preElement.areaId) !== element.areaId || i !== 0 && element.value === ZERO;
|
|
18043
|
+
const isForceBreak = element.type === ElementType.SEPARATOR || element.type === ElementType.TABLE || (preElement == null ? void 0 : preElement.type) === ElementType.TABLE || (preElement == null ? void 0 : preElement.type) === ElementType.BLOCK || element.type === ElementType.BLOCK || (preElement == null ? void 0 : preElement.imgDisplay) === ImageDisplay.INLINE || element.imgDisplay === ImageDisplay.INLINE || (preElement == null ? void 0 : preElement.listId) !== element.listId || (preElement == null ? void 0 : preElement.areaId) !== element.areaId || ((_i = element.control) == null ? void 0 : _i.flexDirection) === FlexDirection.COLUMN && (element.controlComponent === ControlComponent.CHECKBOX || element.controlComponent === ControlComponent.RADIO) && (preElement == null ? void 0 : preElement.controlComponent) === ControlComponent.VALUE || i !== 0 && element.value === ZERO;
|
|
17917
18044
|
const isWidthNotEnough = curRowWidth > availableWidth;
|
|
17918
18045
|
const isWrap = isForceBreak || isWidthNotEnough;
|
|
17919
18046
|
if (isWrap) {
|
|
@@ -17924,10 +18051,10 @@ class Draw {
|
|
|
17924
18051
|
elementList: [rowElement],
|
|
17925
18052
|
ascent,
|
|
17926
18053
|
rowIndex: curRow.rowIndex + 1,
|
|
17927
|
-
rowFlex: ((
|
|
18054
|
+
rowFlex: ((_j = elementList[i]) == null ? void 0 : _j.rowFlex) || ((_k = elementList[i + 1]) == null ? void 0 : _k.rowFlex),
|
|
17928
18055
|
isPageBreak: element.type === ElementType.PAGE_BREAK
|
|
17929
18056
|
};
|
|
17930
|
-
if (rowElement.controlComponent !== ControlComponent.PREFIX && ((
|
|
18057
|
+
if (rowElement.controlComponent !== ControlComponent.PREFIX && ((_l = rowElement.control) == null ? void 0 : _l.indentation) === ControlIndentation.VALUE_START) {
|
|
17931
18058
|
const preStartIndex = curRow.elementList.findIndex((el) => el.controlId === rowElement.controlId && el.controlComponent !== ControlComponent.PREFIX);
|
|
17932
18059
|
if (~preStartIndex) {
|
|
17933
18060
|
const preRowPositionList = this.position.computeRowPosition({
|
|
@@ -17945,11 +18072,11 @@ class Draw {
|
|
|
17945
18072
|
row.offsetX = listStyleMap.get(element.listId);
|
|
17946
18073
|
row.listIndex = listIndex;
|
|
17947
18074
|
}
|
|
17948
|
-
row.offsetY = !isFromTable && ((
|
|
18075
|
+
row.offsetY = !isFromTable && ((_m = element.area) == null ? void 0 : _m.top) && element.areaId !== ((_n = elementList[i - 1]) == null ? void 0 : _n.areaId) ? element.area.top * scale : 0;
|
|
17949
18076
|
rowList.push(row);
|
|
17950
18077
|
} else {
|
|
17951
18078
|
curRow.width += metrics.width;
|
|
17952
|
-
if (i === 0 && (getIsBlockElement(elementList[1]) || !!((
|
|
18079
|
+
if (i === 0 && (getIsBlockElement(elementList[1]) || !!((_o = elementList[1]) == null ? void 0 : _o.areaId))) {
|
|
17953
18080
|
curRow.height = defaultBasicRowMarginHeight;
|
|
17954
18081
|
curRow.ascent = defaultBasicRowMarginHeight;
|
|
17955
18082
|
} else if (curRow.height < height) {
|
|
@@ -17961,7 +18088,7 @@ class Draw {
|
|
|
17961
18088
|
if (isWrap || i === elementList.length - 1) {
|
|
17962
18089
|
curRow.isWidthNotEnough = isWidthNotEnough && !isForceBreak;
|
|
17963
18090
|
if (!curRow.isSurround && ((preElement == null ? void 0 : preElement.rowFlex) === RowFlex.JUSTIFY || (preElement == null ? void 0 : preElement.rowFlex) === RowFlex.ALIGNMENT && curRow.isWidthNotEnough)) {
|
|
17964
|
-
const rowElementList = ((
|
|
18091
|
+
const rowElementList = ((_p = curRow.elementList[0]) == null ? void 0 : _p.value) === ZERO ? curRow.elementList.slice(1) : curRow.elementList;
|
|
17965
18092
|
const gap = (availableWidth - curRow.width) / (rowElementList.length - 1);
|
|
17966
18093
|
for (let e = 0; e < rowElementList.length - 1; e++) {
|
|
17967
18094
|
const el = rowElementList[e];
|
|
@@ -18359,6 +18486,7 @@ class Draw {
|
|
|
18359
18486
|
if (!pageBorder.disabled) {
|
|
18360
18487
|
this.pageBorder.render(ctx);
|
|
18361
18488
|
}
|
|
18489
|
+
this.badge.render(ctx, pageNo);
|
|
18362
18490
|
}
|
|
18363
18491
|
_disconnectLazyRender() {
|
|
18364
18492
|
var _a;
|
|
@@ -18641,6 +18769,8 @@ class Command {
|
|
|
18641
18769
|
__publicField(this, "executePaperSize");
|
|
18642
18770
|
__publicField(this, "executePaperDirection");
|
|
18643
18771
|
__publicField(this, "executeSetPaperMargin");
|
|
18772
|
+
__publicField(this, "executeSetMainBadge");
|
|
18773
|
+
__publicField(this, "executeSetAreaBadge");
|
|
18644
18774
|
__publicField(this, "executeInsertElementList");
|
|
18645
18775
|
__publicField(this, "executeInsertArea");
|
|
18646
18776
|
__publicField(this, "executeSetAreaProperties");
|
|
@@ -18765,6 +18895,8 @@ class Command {
|
|
|
18765
18895
|
this.executePaperSize = adapt.paperSize.bind(adapt);
|
|
18766
18896
|
this.executePaperDirection = adapt.paperDirection.bind(adapt);
|
|
18767
18897
|
this.executeSetPaperMargin = adapt.setPaperMargin.bind(adapt);
|
|
18898
|
+
this.executeSetMainBadge = adapt.setMainBadge.bind(adapt);
|
|
18899
|
+
this.executeSetAreaBadge = adapt.setAreaBadge.bind(adapt);
|
|
18768
18900
|
this.getAreaValue = adapt.getAreaValue.bind(adapt);
|
|
18769
18901
|
this.executeInsertArea = adapt.insertArea.bind(adapt);
|
|
18770
18902
|
this.executeSetAreaProperties = adapt.setAreaProperties.bind(adapt);
|
|
@@ -20079,7 +20211,6 @@ class CommandAdapt {
|
|
|
20079
20211
|
const element = elementList[startIndex];
|
|
20080
20212
|
if (!element || element.type !== ElementType.IMAGE)
|
|
20081
20213
|
return;
|
|
20082
|
-
element.id = getUUID();
|
|
20083
20214
|
element.value = payload;
|
|
20084
20215
|
this.draw.render({
|
|
20085
20216
|
isSetCursor: false
|
|
@@ -20338,6 +20469,20 @@ class CommandAdapt {
|
|
|
20338
20469
|
setPaperMargin(payload) {
|
|
20339
20470
|
return this.draw.setPaperMargin(payload);
|
|
20340
20471
|
}
|
|
20472
|
+
setMainBadge(payload) {
|
|
20473
|
+
this.draw.getBadge().setMainBadge(payload);
|
|
20474
|
+
this.draw.render({
|
|
20475
|
+
isCompute: false,
|
|
20476
|
+
isSubmitHistory: false
|
|
20477
|
+
});
|
|
20478
|
+
}
|
|
20479
|
+
setAreaBadge(payload) {
|
|
20480
|
+
this.draw.getBadge().setAreaBadgeMap(payload);
|
|
20481
|
+
this.draw.render({
|
|
20482
|
+
isCompute: false,
|
|
20483
|
+
isSubmitHistory: false
|
|
20484
|
+
});
|
|
20485
|
+
}
|
|
20341
20486
|
insertElementList(payload) {
|
|
20342
20487
|
if (!payload.length)
|
|
20343
20488
|
return;
|
|
@@ -20426,22 +20571,62 @@ class CommandAdapt {
|
|
|
20426
20571
|
setValue(payload, options) {
|
|
20427
20572
|
this.draw.setValue(payload, options);
|
|
20428
20573
|
}
|
|
20429
|
-
removeControl() {
|
|
20430
|
-
|
|
20431
|
-
|
|
20432
|
-
|
|
20433
|
-
|
|
20434
|
-
|
|
20435
|
-
|
|
20436
|
-
|
|
20437
|
-
|
|
20438
|
-
|
|
20439
|
-
|
|
20440
|
-
|
|
20441
|
-
|
|
20442
|
-
|
|
20443
|
-
|
|
20444
|
-
|
|
20574
|
+
removeControl(payload) {
|
|
20575
|
+
if ((payload == null ? void 0 : payload.id) || (payload == null ? void 0 : payload.conceptId)) {
|
|
20576
|
+
const { id, conceptId } = payload;
|
|
20577
|
+
let isExistRemove = false;
|
|
20578
|
+
const remove = (elementList) => {
|
|
20579
|
+
let i = elementList.length - 1;
|
|
20580
|
+
while (i >= 0) {
|
|
20581
|
+
const element = elementList[i];
|
|
20582
|
+
if (element.type === ElementType.TABLE) {
|
|
20583
|
+
const trList = element.trList;
|
|
20584
|
+
for (let r = 0; r < trList.length; r++) {
|
|
20585
|
+
const tr = trList[r];
|
|
20586
|
+
for (let d = 0; d < tr.tdList.length; d++) {
|
|
20587
|
+
const td = tr.tdList[d];
|
|
20588
|
+
remove(td.value);
|
|
20589
|
+
}
|
|
20590
|
+
}
|
|
20591
|
+
}
|
|
20592
|
+
i--;
|
|
20593
|
+
if (!element.control || id && element.controlId !== id || conceptId && element.control.conceptId !== conceptId) {
|
|
20594
|
+
continue;
|
|
20595
|
+
}
|
|
20596
|
+
isExistRemove = true;
|
|
20597
|
+
elementList.splice(i + 1, 1);
|
|
20598
|
+
}
|
|
20599
|
+
};
|
|
20600
|
+
const data2 = [
|
|
20601
|
+
this.draw.getHeaderElementList(),
|
|
20602
|
+
this.draw.getOriginalMainElementList(),
|
|
20603
|
+
this.draw.getFooterElementList()
|
|
20604
|
+
];
|
|
20605
|
+
for (const elementList of data2) {
|
|
20606
|
+
remove(elementList);
|
|
20607
|
+
}
|
|
20608
|
+
if (isExistRemove) {
|
|
20609
|
+
this.draw.render({
|
|
20610
|
+
isSetCursor: false
|
|
20611
|
+
});
|
|
20612
|
+
}
|
|
20613
|
+
} else {
|
|
20614
|
+
const { startIndex, endIndex } = this.range.getRange();
|
|
20615
|
+
if (startIndex !== endIndex)
|
|
20616
|
+
return;
|
|
20617
|
+
const elementList = this.draw.getElementList();
|
|
20618
|
+
const element = elementList[startIndex];
|
|
20619
|
+
if (!element.controlId)
|
|
20620
|
+
return;
|
|
20621
|
+
const control = this.draw.getControl();
|
|
20622
|
+
const newIndex = control.removeControl(startIndex);
|
|
20623
|
+
if (newIndex === null)
|
|
20624
|
+
return;
|
|
20625
|
+
this.range.setRange(newIndex, newIndex);
|
|
20626
|
+
this.draw.render({
|
|
20627
|
+
curIndex: newIndex
|
|
20628
|
+
});
|
|
20629
|
+
}
|
|
20445
20630
|
}
|
|
20446
20631
|
setLocale(payload) {
|
|
20447
20632
|
this.i18n.setLocale(payload);
|
|
@@ -20454,7 +20639,7 @@ class CommandAdapt {
|
|
|
20454
20639
|
}
|
|
20455
20640
|
locationCatalog(titleId) {
|
|
20456
20641
|
var _a;
|
|
20457
|
-
const elementList = this.draw.
|
|
20642
|
+
const elementList = this.draw.getOriginalMainElementList();
|
|
20458
20643
|
let newIndex = -1;
|
|
20459
20644
|
for (let e = 0; e < elementList.length; e++) {
|
|
20460
20645
|
const element = elementList[e];
|
|
@@ -20465,6 +20650,9 @@ class CommandAdapt {
|
|
|
20465
20650
|
}
|
|
20466
20651
|
if (!~newIndex)
|
|
20467
20652
|
return;
|
|
20653
|
+
this.position.setPositionContext({
|
|
20654
|
+
isTable: false
|
|
20655
|
+
});
|
|
20468
20656
|
this.range.setRange(newIndex, newIndex);
|
|
20469
20657
|
this.draw.render({
|
|
20470
20658
|
curIndex: newIndex,
|
|
@@ -21996,5 +22184,5 @@ class Editor {
|
|
|
21996
22184
|
this.use = plugin.use.bind(plugin);
|
|
21997
22185
|
}
|
|
21998
22186
|
}
|
|
21999
|
-
export { AreaMode, BackgroundRepeat, BackgroundSize, BlockType, Command, ControlIndentation, ControlState, ControlType, EDITOR_CLIPBOARD, EDITOR_COMPONENT, Editor, EditorComponent, EditorMode, EditorZone, ElementType, INTERNAL_CONTEXT_MENU_KEY, ImageDisplay, KeyMap, LETTER_CLASS, LineNumberType, ListStyle, ListType, LocationPosition, MaxHeightRatio, NumberType, PageMode, PaperDirection, RenderMode, RowFlex, TableBorder, TdBorder, TdSlash, TextDecorationStyle, TitleLevel, VerticalAlign, WordBreak, createDomFromElementList, Editor as default, getElementListByHTML, getTextFromElementList, splitText };
|
|
22187
|
+
export { AreaMode, BackgroundRepeat, BackgroundSize, BlockType, Command, ControlIndentation, ControlState, ControlType, EDITOR_CLIPBOARD, EDITOR_COMPONENT, Editor, EditorComponent, EditorMode, EditorZone, ElementType, FlexDirection, INTERNAL_CONTEXT_MENU_KEY, ImageDisplay, KeyMap, LETTER_CLASS, LineNumberType, ListStyle, ListType, LocationPosition, MaxHeightRatio, NumberType, PageMode, PaperDirection, RenderMode, RowFlex, TableBorder, TdBorder, TdSlash, TextDecorationStyle, TitleLevel, VerticalAlign, WordBreak, createDomFromElementList, Editor as default, getElementListByHTML, getTextFromElementList, splitText };
|
|
22000
22188
|
//# sourceMappingURL=canvas-editor.es.js.map
|