@idraw/util 0.4.0-beta.4 → 0.4.0-beta.40
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/dist/esm/index.d.ts +17 -7
- package/dist/esm/index.js +17 -7
- package/dist/esm/lib/box.d.ts +2 -0
- package/dist/esm/lib/box.js +173 -0
- package/dist/esm/lib/canvas.d.ts +0 -1
- package/dist/esm/lib/canvas.js +26 -50
- package/dist/esm/lib/color.js +9 -6
- package/dist/esm/lib/config.d.ts +5 -10
- package/dist/esm/lib/config.js +9 -9
- package/dist/esm/lib/context2d.d.ts +4 -0
- package/dist/esm/lib/context2d.js +20 -0
- package/dist/esm/lib/controller.d.ts +8 -2
- package/dist/esm/lib/controller.js +184 -9
- package/dist/esm/lib/data.d.ts +7 -2
- package/dist/esm/lib/data.js +114 -4
- package/dist/esm/lib/element.d.ts +5 -0
- package/dist/esm/lib/element.js +54 -1
- package/dist/esm/lib/event.d.ts +4 -2
- package/dist/esm/lib/event.js +31 -11
- package/dist/esm/lib/file.d.ts +2 -1
- package/dist/esm/lib/file.js +4 -1
- package/dist/esm/lib/flat.d.ts +2 -0
- package/dist/esm/lib/flat.js +132 -0
- package/dist/esm/lib/group.d.ts +3 -0
- package/dist/esm/lib/group.js +81 -0
- package/dist/esm/lib/handle-element.d.ts +6 -1
- package/dist/esm/lib/handle-element.js +108 -43
- package/dist/esm/lib/html.d.ts +1 -1
- package/dist/esm/lib/is.d.ts +3 -1
- package/dist/esm/lib/is.js +21 -5
- package/dist/esm/lib/istype.d.ts +1 -0
- package/dist/esm/lib/istype.js +3 -0
- package/dist/esm/lib/merge.d.ts +1 -0
- package/dist/esm/lib/merge.js +17 -0
- package/dist/esm/lib/modify-recorder.d.ts +15 -0
- package/dist/esm/lib/modify-recorder.js +177 -0
- package/dist/esm/lib/modify.d.ts +6 -0
- package/dist/esm/lib/modify.js +99 -0
- package/dist/esm/lib/omit.d.ts +1 -0
- package/dist/esm/lib/omit.js +7 -0
- package/dist/esm/lib/point-move-element.d.ts +5 -0
- package/dist/esm/lib/point-move-element.js +26 -0
- package/dist/esm/lib/rect.js +9 -9
- package/dist/esm/lib/resize-element.d.ts +2 -0
- package/dist/esm/lib/resize-element.js +101 -0
- package/dist/esm/lib/rotate.js +8 -13
- package/dist/esm/lib/store.d.ts +9 -5
- package/dist/esm/lib/store.js +39 -9
- package/dist/esm/lib/text.d.ts +1 -0
- package/dist/esm/lib/text.js +4 -0
- package/dist/esm/lib/time.d.ts +1 -0
- package/dist/esm/lib/time.js +13 -1
- package/dist/esm/lib/view-box.js +4 -2
- package/dist/esm/lib/view-calc.d.ts +16 -3
- package/dist/esm/lib/view-calc.js +127 -3
- package/dist/esm/lib/view-content.d.ts +14 -0
- package/dist/esm/lib/view-content.js +88 -0
- package/dist/index.global.js +1614 -257
- package/dist/index.global.min.js +1 -1
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
var iDrawUtil = function(exports) {
|
|
2
|
-
"use strict";var
|
|
3
|
-
|
|
4
|
-
throw TypeError("Cannot " + msg);
|
|
5
|
-
};
|
|
6
|
-
var __privateGet = (obj, member, getter) => {
|
|
7
|
-
__accessCheck(obj, member, "read from private field");
|
|
8
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
9
|
-
};
|
|
10
|
-
var __privateAdd = (obj, member, value) => {
|
|
11
|
-
if (member.has(obj))
|
|
12
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
13
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
14
|
-
};
|
|
15
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
16
|
-
__accessCheck(obj, member, "write to private field");
|
|
17
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
18
|
-
return value;
|
|
2
|
+
"use strict";var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
19
4
|
};
|
|
5
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
6
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
7
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
8
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
9
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
20
10
|
|
|
21
|
-
var _ctx, _opts;
|
|
11
|
+
var _ctx, _opts, _listeners, _temp, _backUpDefaultStorage, _static, _Store_instances, createTempStorage_fn;
|
|
22
12
|
function compose(middleware) {
|
|
23
13
|
return function(context, next) {
|
|
24
14
|
return dispatch(0);
|
|
@@ -27,8 +17,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
27
17
|
if (i === middleware.length && next) {
|
|
28
18
|
fn = next;
|
|
29
19
|
}
|
|
30
|
-
if (!fn)
|
|
31
|
-
return Promise.resolve();
|
|
20
|
+
if (!fn) return Promise.resolve();
|
|
32
21
|
try {
|
|
33
22
|
return Promise.resolve(fn(context, dispatch.bind(null, i + 1)));
|
|
34
23
|
} catch (err) {
|
|
@@ -47,7 +36,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
47
36
|
function throttle(fn, timeout) {
|
|
48
37
|
let timer = -1;
|
|
49
38
|
return function(...args) {
|
|
50
|
-
if (timer
|
|
39
|
+
if (timer >= 0) {
|
|
51
40
|
return;
|
|
52
41
|
}
|
|
53
42
|
timer = setTimeout(() => {
|
|
@@ -56,6 +45,18 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
56
45
|
}, timeout);
|
|
57
46
|
};
|
|
58
47
|
}
|
|
48
|
+
function debounce(fn, timeout) {
|
|
49
|
+
let timer = -1;
|
|
50
|
+
return function(...args) {
|
|
51
|
+
if (timer >= 0) {
|
|
52
|
+
window.clearTimeout(timer);
|
|
53
|
+
}
|
|
54
|
+
timer = setTimeout(() => {
|
|
55
|
+
fn(...args);
|
|
56
|
+
timer = -1;
|
|
57
|
+
}, timeout);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
59
60
|
function downloadImageFromCanvas(canvas, opts) {
|
|
60
61
|
const { fileName, type = "image/jpeg" } = opts;
|
|
61
62
|
const stream = canvas.toDataURL(type);
|
|
@@ -66,9 +67,12 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
66
67
|
downloadLink = null;
|
|
67
68
|
}
|
|
68
69
|
function pickFile(opts) {
|
|
69
|
-
const { success, error } = opts;
|
|
70
|
+
const { accept, success, error } = opts;
|
|
70
71
|
let input = document.createElement("input");
|
|
71
72
|
input.type = "file";
|
|
73
|
+
if (accept) {
|
|
74
|
+
input.accept = accept;
|
|
75
|
+
}
|
|
72
76
|
input.addEventListener("change", function() {
|
|
73
77
|
var _a;
|
|
74
78
|
const file = (_a = input.files) == null ? void 0 : _a[0];
|
|
@@ -139,13 +143,13 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
139
143
|
downloadLink = null;
|
|
140
144
|
}
|
|
141
145
|
function toColorHexNum(color2) {
|
|
142
|
-
return parseInt(color2.replace(
|
|
146
|
+
return parseInt(color2.replace(/^#/, "0x"));
|
|
143
147
|
}
|
|
144
148
|
function toColorHexStr(color2) {
|
|
145
149
|
return "#" + color2.toString(16);
|
|
146
150
|
}
|
|
147
151
|
function isColorStr(color2) {
|
|
148
|
-
return typeof color2 === "string" && (
|
|
152
|
+
return typeof color2 === "string" && (/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2) || /^[a-z]{1,}$/i.test(color2));
|
|
149
153
|
}
|
|
150
154
|
const colorNameMap = {
|
|
151
155
|
aliceblue: "#f0f8ff",
|
|
@@ -302,6 +306,8 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
302
306
|
let css = "transparent";
|
|
303
307
|
if (typeof color2 === "string") {
|
|
304
308
|
css = color2;
|
|
309
|
+
} else if ((color2 == null ? void 0 : color2.stops.length) === 1) {
|
|
310
|
+
css = color2.stops[0].color;
|
|
305
311
|
} else if ((color2 == null ? void 0 : color2.type) === "linear-gradient") {
|
|
306
312
|
const items = [];
|
|
307
313
|
if (typeof color2.angle === "number") {
|
|
@@ -349,13 +355,13 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
349
355
|
return hex;
|
|
350
356
|
}
|
|
351
357
|
let hexAlpha = 1;
|
|
352
|
-
const regHex1 =
|
|
353
|
-
const regHex2 =
|
|
358
|
+
const regHex1 = /^#[0-9a-f]{6,6}$/i;
|
|
359
|
+
const regHex2 = /^#[0-9a-f]{8,8}$/i;
|
|
354
360
|
let result = hex;
|
|
355
361
|
if (regHex1.test(hex)) {
|
|
356
|
-
hexAlpha = parseInt(hex.substring(5, 7).replace(
|
|
362
|
+
hexAlpha = parseInt(hex.substring(5, 7).replace(/^#/, "0x"));
|
|
357
363
|
} else if (regHex2.test(hex)) {
|
|
358
|
-
hexAlpha = parseInt(hex.substring(7, 9).replace(
|
|
364
|
+
hexAlpha = parseInt(hex.substring(7, 9).replace(/^#/, "0x"));
|
|
359
365
|
result = hex.substring(0, 7);
|
|
360
366
|
}
|
|
361
367
|
hexAlpha = hexAlpha * alpha;
|
|
@@ -422,6 +428,28 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
422
428
|
}
|
|
423
429
|
return _clone(target);
|
|
424
430
|
}
|
|
431
|
+
function deepCloneElement(element) {
|
|
432
|
+
const elem = deepClone(element);
|
|
433
|
+
const _resetUUID = (e) => {
|
|
434
|
+
e.uuid = createUUID();
|
|
435
|
+
if (e.type === "group" && e.detail.children) {
|
|
436
|
+
e.detail.children.forEach((child) => {
|
|
437
|
+
_resetUUID(child);
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
_resetUUID(elem);
|
|
442
|
+
return elem;
|
|
443
|
+
}
|
|
444
|
+
function deepCloneData(data) {
|
|
445
|
+
const { elements, ...restData } = data;
|
|
446
|
+
return {
|
|
447
|
+
...deepClone(restData),
|
|
448
|
+
...{
|
|
449
|
+
elements: elements.map((elem) => deepCloneElement(elem))
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
}
|
|
425
453
|
function is$1(target) {
|
|
426
454
|
return Object.prototype.toString.call(target).replace(/[\]|\[]{1,1}/gi, "").split(" ")[1];
|
|
427
455
|
}
|
|
@@ -458,7 +486,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
458
486
|
const assetUUID = createAssetId(html2);
|
|
459
487
|
if (!assets[assetUUID]) {
|
|
460
488
|
assets[assetUUID] = {
|
|
461
|
-
type: "
|
|
489
|
+
type: "html",
|
|
462
490
|
value: html2
|
|
463
491
|
};
|
|
464
492
|
}
|
|
@@ -479,6 +507,80 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
479
507
|
sortedData.assets = assets;
|
|
480
508
|
return sortedData;
|
|
481
509
|
}
|
|
510
|
+
function filterCompactData(data, opts) {
|
|
511
|
+
const assets = data.assets || {};
|
|
512
|
+
const sortedData = deepClone(data);
|
|
513
|
+
const loadItemMap = (opts == null ? void 0 : opts.loadItemMap) || {};
|
|
514
|
+
const _scanElements = (elems) => {
|
|
515
|
+
elems.forEach((elem) => {
|
|
516
|
+
var _a, _b, _c;
|
|
517
|
+
if (elem.type === "image" && elem.detail.src) {
|
|
518
|
+
const src = elem.detail.src;
|
|
519
|
+
if (isAssetId(src) && !assets[src] && loadItemMap[src] && typeof ((_a = loadItemMap[src]) == null ? void 0 : _a.source) === "string") {
|
|
520
|
+
assets[src] = {
|
|
521
|
+
type: "image",
|
|
522
|
+
value: loadItemMap[src].source
|
|
523
|
+
};
|
|
524
|
+
} else if (!assets[src]) {
|
|
525
|
+
const assetUUID = createAssetId(src);
|
|
526
|
+
if (!assets[assetUUID]) {
|
|
527
|
+
assets[assetUUID] = {
|
|
528
|
+
type: "image",
|
|
529
|
+
value: src
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
elem.detail.src = assetUUID;
|
|
533
|
+
}
|
|
534
|
+
} else if (elem.type === "svg") {
|
|
535
|
+
const svg2 = elem.detail.svg;
|
|
536
|
+
if (isAssetId(svg2) && !assets[svg2] && loadItemMap[svg2] && typeof ((_b = loadItemMap[svg2]) == null ? void 0 : _b.source) === "string") {
|
|
537
|
+
assets[svg2] = {
|
|
538
|
+
type: "svg",
|
|
539
|
+
value: loadItemMap[svg2].source
|
|
540
|
+
};
|
|
541
|
+
} else if (!assets[svg2]) {
|
|
542
|
+
const assetUUID = createAssetId(svg2);
|
|
543
|
+
if (!assets[assetUUID]) {
|
|
544
|
+
assets[assetUUID] = {
|
|
545
|
+
type: "svg",
|
|
546
|
+
value: svg2
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
elem.detail.svg = assetUUID;
|
|
550
|
+
}
|
|
551
|
+
} else if (elem.type === "html") {
|
|
552
|
+
const html2 = elem.detail.html;
|
|
553
|
+
if (isAssetId(html2) && !assets[html2] && loadItemMap[html2] && typeof ((_c = loadItemMap[html2]) == null ? void 0 : _c.source) === "string") {
|
|
554
|
+
assets[html2] = {
|
|
555
|
+
type: "html",
|
|
556
|
+
value: loadItemMap[html2].source
|
|
557
|
+
};
|
|
558
|
+
} else if (!assets[html2]) {
|
|
559
|
+
const assetUUID = createAssetId(html2);
|
|
560
|
+
if (!assets[assetUUID]) {
|
|
561
|
+
assets[assetUUID] = {
|
|
562
|
+
type: "html",
|
|
563
|
+
value: html2
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
elem.detail.html = assetUUID;
|
|
567
|
+
}
|
|
568
|
+
} else if (elem.type === "group" && Array.isArray(elem.detail.children)) {
|
|
569
|
+
const groupAssets = elem.detail.assets || {};
|
|
570
|
+
Object.keys(groupAssets).forEach((assetId) => {
|
|
571
|
+
if (!assets[assetId]) {
|
|
572
|
+
assets[assetId] = groupAssets[assetId];
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
delete elem.detail.assets;
|
|
576
|
+
_scanElements(elem.detail.children);
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
};
|
|
580
|
+
_scanElements(sortedData.elements);
|
|
581
|
+
sortedData.assets = assets;
|
|
582
|
+
return sortedData;
|
|
583
|
+
}
|
|
482
584
|
function parsePrototype(data) {
|
|
483
585
|
const typeStr = Object.prototype.toString.call(data) || "";
|
|
484
586
|
const result = typeStr.replace(/(\[object|\])/gi, "").trim();
|
|
@@ -501,6 +603,9 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
501
603
|
asyncFunction(data) {
|
|
502
604
|
return parsePrototype(data) === "AsyncFunction";
|
|
503
605
|
},
|
|
606
|
+
boolean(data) {
|
|
607
|
+
return parsePrototype(data) === "Boolean";
|
|
608
|
+
},
|
|
504
609
|
string(data) {
|
|
505
610
|
return parsePrototype(data) === "String";
|
|
506
611
|
},
|
|
@@ -594,6 +699,9 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
594
699
|
const image = await loadImage(dataURL);
|
|
595
700
|
return image;
|
|
596
701
|
}
|
|
702
|
+
function positiveNum(value) {
|
|
703
|
+
return typeof value === "number" && value >= 0;
|
|
704
|
+
}
|
|
597
705
|
function number(value) {
|
|
598
706
|
return typeof value === "number" && (value > 0 || value <= 0);
|
|
599
707
|
}
|
|
@@ -604,19 +712,19 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
604
712
|
return number(value);
|
|
605
713
|
}
|
|
606
714
|
function w(value) {
|
|
607
|
-
return
|
|
715
|
+
return positiveNum(value);
|
|
608
716
|
}
|
|
609
717
|
function h(value) {
|
|
610
|
-
return
|
|
718
|
+
return positiveNum(value);
|
|
611
719
|
}
|
|
612
720
|
function angle(value) {
|
|
613
721
|
return typeof value === "number" && value >= -360 && value <= 360;
|
|
614
722
|
}
|
|
615
723
|
function borderWidth(value) {
|
|
616
|
-
return
|
|
724
|
+
return positiveNum(value) || Array.isArray(value) && positiveNum(value[0]) && positiveNum(value[1]) && positiveNum(value[2]) && positiveNum(value[3]);
|
|
617
725
|
}
|
|
618
726
|
function borderRadius(value) {
|
|
619
|
-
return
|
|
727
|
+
return positiveNum(value) || Array.isArray(value) && positiveNum(value[0]) && positiveNum(value[1]) && positiveNum(value[2]) && positiveNum(value[3]);
|
|
620
728
|
}
|
|
621
729
|
function color(value) {
|
|
622
730
|
return isColorStr(value);
|
|
@@ -670,6 +778,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
670
778
|
return /^(-?\d+(?:\.\d+)?)$/.test(`${value}`);
|
|
671
779
|
}
|
|
672
780
|
const is = {
|
|
781
|
+
positiveNum,
|
|
673
782
|
x,
|
|
674
783
|
y,
|
|
675
784
|
w,
|
|
@@ -806,14 +915,18 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
806
915
|
svgDesc,
|
|
807
916
|
htmlDesc
|
|
808
917
|
};
|
|
918
|
+
const defaultFontSize = 12;
|
|
919
|
+
const defaultFontWeight = "400";
|
|
920
|
+
const defaultFontFamily = `-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'`;
|
|
809
921
|
class Context2D {
|
|
810
922
|
// private _width: number = 0;
|
|
811
923
|
// private _height: number = 0;
|
|
812
924
|
constructor(ctx, opts) {
|
|
813
|
-
__privateAdd(this, _ctx
|
|
814
|
-
__privateAdd(this, _opts
|
|
925
|
+
__privateAdd(this, _ctx);
|
|
926
|
+
__privateAdd(this, _opts);
|
|
815
927
|
__privateSet(this, _ctx, ctx);
|
|
816
928
|
__privateSet(this, _opts, { ...{ devicePixelRatio: 1, offscreenCanvas: null }, ...opts });
|
|
929
|
+
this.$resetFont();
|
|
817
930
|
}
|
|
818
931
|
$undoPixelRatio(num) {
|
|
819
932
|
return num / __privateGet(this, _opts).devicePixelRatio;
|
|
@@ -824,6 +937,9 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
824
937
|
$getContext() {
|
|
825
938
|
return __privateGet(this, _ctx);
|
|
826
939
|
}
|
|
940
|
+
$setContext(ctx) {
|
|
941
|
+
__privateSet(this, _ctx, ctx);
|
|
942
|
+
}
|
|
827
943
|
$setFont(opts) {
|
|
828
944
|
const strList = [];
|
|
829
945
|
if (opts.fontWeight) {
|
|
@@ -833,6 +949,13 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
833
949
|
strList.push(`${opts.fontFamily || "sans-serif"}`);
|
|
834
950
|
__privateGet(this, _ctx).font = `${strList.join(" ")}`;
|
|
835
951
|
}
|
|
952
|
+
$resetFont() {
|
|
953
|
+
this.$setFont({
|
|
954
|
+
fontSize: defaultFontSize,
|
|
955
|
+
fontFamily: defaultFontFamily,
|
|
956
|
+
fontWeight: defaultFontWeight
|
|
957
|
+
});
|
|
958
|
+
}
|
|
836
959
|
$getOffscreenCanvas() {
|
|
837
960
|
return __privateGet(this, _opts).offscreenCanvas;
|
|
838
961
|
}
|
|
@@ -940,16 +1063,33 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
940
1063
|
return __privateGet(this, _ctx).fill(...args);
|
|
941
1064
|
}
|
|
942
1065
|
arc(x2, y2, radius, startAngle, endAngle, anticlockwise) {
|
|
943
|
-
return __privateGet(this, _ctx).arc(
|
|
1066
|
+
return __privateGet(this, _ctx).arc(
|
|
1067
|
+
this.$doPixelRatio(x2),
|
|
1068
|
+
this.$doPixelRatio(y2),
|
|
1069
|
+
this.$doPixelRatio(radius),
|
|
1070
|
+
startAngle,
|
|
1071
|
+
endAngle,
|
|
1072
|
+
anticlockwise
|
|
1073
|
+
);
|
|
944
1074
|
}
|
|
945
1075
|
rect(x2, y2, w2, h2) {
|
|
946
1076
|
return __privateGet(this, _ctx).rect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
|
|
947
1077
|
}
|
|
948
1078
|
fillRect(x2, y2, w2, h2) {
|
|
949
|
-
return __privateGet(this, _ctx).fillRect(
|
|
1079
|
+
return __privateGet(this, _ctx).fillRect(
|
|
1080
|
+
this.$doPixelRatio(x2),
|
|
1081
|
+
this.$doPixelRatio(y2),
|
|
1082
|
+
this.$doPixelRatio(w2),
|
|
1083
|
+
this.$doPixelRatio(h2)
|
|
1084
|
+
);
|
|
950
1085
|
}
|
|
951
1086
|
clearRect(x2, y2, w2, h2) {
|
|
952
|
-
return __privateGet(this, _ctx).clearRect(
|
|
1087
|
+
return __privateGet(this, _ctx).clearRect(
|
|
1088
|
+
this.$doPixelRatio(x2),
|
|
1089
|
+
this.$doPixelRatio(y2),
|
|
1090
|
+
this.$doPixelRatio(w2),
|
|
1091
|
+
this.$doPixelRatio(h2)
|
|
1092
|
+
);
|
|
953
1093
|
}
|
|
954
1094
|
beginPath() {
|
|
955
1095
|
return __privateGet(this, _ctx).beginPath();
|
|
@@ -964,7 +1104,31 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
964
1104
|
return __privateGet(this, _ctx).moveTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
965
1105
|
}
|
|
966
1106
|
arcTo(x1, y1, x2, y2, radius) {
|
|
967
|
-
return __privateGet(this, _ctx).arcTo(
|
|
1107
|
+
return __privateGet(this, _ctx).arcTo(
|
|
1108
|
+
this.$doPixelRatio(x1),
|
|
1109
|
+
this.$doPixelRatio(y1),
|
|
1110
|
+
this.$doPixelRatio(x2),
|
|
1111
|
+
this.$doPixelRatio(y2),
|
|
1112
|
+
this.$doPixelRatio(radius)
|
|
1113
|
+
);
|
|
1114
|
+
}
|
|
1115
|
+
bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x2, y2) {
|
|
1116
|
+
return __privateGet(this, _ctx).bezierCurveTo(
|
|
1117
|
+
this.$doPixelRatio(cp1x),
|
|
1118
|
+
this.$doPixelRatio(cp1y),
|
|
1119
|
+
this.$doPixelRatio(cp2x),
|
|
1120
|
+
this.$doPixelRatio(cp2y),
|
|
1121
|
+
this.$doPixelRatio(x2),
|
|
1122
|
+
this.$doPixelRatio(y2)
|
|
1123
|
+
);
|
|
1124
|
+
}
|
|
1125
|
+
quadraticCurveTo(cpx, cpy, x2, y2) {
|
|
1126
|
+
return __privateGet(this, _ctx).quadraticCurveTo(
|
|
1127
|
+
this.$doPixelRatio(cpx),
|
|
1128
|
+
this.$doPixelRatio(cpy),
|
|
1129
|
+
this.$doPixelRatio(x2),
|
|
1130
|
+
this.$doPixelRatio(y2)
|
|
1131
|
+
);
|
|
968
1132
|
}
|
|
969
1133
|
getLineDash() {
|
|
970
1134
|
return __privateGet(this, _ctx).getLineDash();
|
|
@@ -1005,7 +1169,13 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1005
1169
|
this.$doPixelRatio(dh)
|
|
1006
1170
|
);
|
|
1007
1171
|
} else {
|
|
1008
|
-
return __privateGet(this, _ctx).drawImage(
|
|
1172
|
+
return __privateGet(this, _ctx).drawImage(
|
|
1173
|
+
image,
|
|
1174
|
+
this.$doPixelRatio(dx),
|
|
1175
|
+
this.$doPixelRatio(dy),
|
|
1176
|
+
this.$doPixelRatio(dw),
|
|
1177
|
+
this.$doPixelRatio(dh)
|
|
1178
|
+
);
|
|
1009
1179
|
}
|
|
1010
1180
|
}
|
|
1011
1181
|
createPattern(image, repetition) {
|
|
@@ -1065,7 +1235,12 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1065
1235
|
return __privateGet(this, _ctx).getTransform();
|
|
1066
1236
|
}
|
|
1067
1237
|
createLinearGradient(x0, y0, x1, y1) {
|
|
1068
|
-
return __privateGet(this, _ctx).createLinearGradient(
|
|
1238
|
+
return __privateGet(this, _ctx).createLinearGradient(
|
|
1239
|
+
this.$doPixelRatio(x0),
|
|
1240
|
+
this.$doPixelRatio(y0),
|
|
1241
|
+
this.$doPixelRatio(x1),
|
|
1242
|
+
this.$doPixelRatio(y1)
|
|
1243
|
+
);
|
|
1069
1244
|
}
|
|
1070
1245
|
createRadialGradient(x0, y0, r0, x1, y1, r1) {
|
|
1071
1246
|
return __privateGet(this, _ctx).createRadialGradient(
|
|
@@ -1107,77 +1282,55 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1107
1282
|
return context2d;
|
|
1108
1283
|
}
|
|
1109
1284
|
function createBoardContent(canvas, opts) {
|
|
1110
|
-
const { width, height, devicePixelRatio
|
|
1285
|
+
const { width, height, devicePixelRatio } = opts;
|
|
1111
1286
|
const ctxOpts = {
|
|
1112
1287
|
width,
|
|
1113
1288
|
height,
|
|
1114
1289
|
devicePixelRatio
|
|
1115
1290
|
};
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
const ctx = canvas.getContext("2d");
|
|
1142
|
-
const viewContext = createContext2D(ctxOpts);
|
|
1143
|
-
const helperContext = createContext2D(ctxOpts);
|
|
1144
|
-
const underContext = createContext2D(ctxOpts);
|
|
1145
|
-
const boardContext = createContext2D({ ctx, ...ctxOpts });
|
|
1146
|
-
const drawView = () => {
|
|
1147
|
-
boardContext.clearRect(0, 0, width, height);
|
|
1148
|
-
boardContext.drawImage(underContext.canvas, 0, 0, width, height);
|
|
1149
|
-
boardContext.drawImage(viewContext.canvas, 0, 0, width, height);
|
|
1150
|
-
boardContext.drawImage(helperContext.canvas, 0, 0, width, height);
|
|
1151
|
-
underContext.clearRect(0, 0, width, height);
|
|
1152
|
-
viewContext.clearRect(0, 0, width, height);
|
|
1153
|
-
helperContext.clearRect(0, 0, width, height);
|
|
1154
|
-
};
|
|
1155
|
-
const content = {
|
|
1156
|
-
underContext,
|
|
1157
|
-
viewContext,
|
|
1158
|
-
helperContext,
|
|
1159
|
-
boardContext,
|
|
1160
|
-
drawView
|
|
1161
|
-
};
|
|
1162
|
-
return content;
|
|
1163
|
-
}
|
|
1291
|
+
const ctx = canvas.getContext("2d");
|
|
1292
|
+
const viewContext = createOffscreenContext2D(ctxOpts);
|
|
1293
|
+
const overlayContext = createOffscreenContext2D(ctxOpts);
|
|
1294
|
+
const underlayContext = createOffscreenContext2D(ctxOpts);
|
|
1295
|
+
const boardContext = createContext2D({ ctx, ...ctxOpts });
|
|
1296
|
+
const tempContext = createOffscreenContext2D(ctxOpts);
|
|
1297
|
+
const drawView = () => {
|
|
1298
|
+
const { width: w2, height: h2 } = viewContext.$getSize();
|
|
1299
|
+
boardContext.clearRect(0, 0, w2, h2);
|
|
1300
|
+
boardContext.drawImage(underlayContext.canvas, 0, 0, w2, h2);
|
|
1301
|
+
boardContext.drawImage(viewContext.canvas, 0, 0, w2, h2);
|
|
1302
|
+
boardContext.drawImage(overlayContext.canvas, 0, 0, w2, h2);
|
|
1303
|
+
underlayContext.clearRect(0, 0, w2, h2);
|
|
1304
|
+
viewContext.clearRect(0, 0, w2, h2);
|
|
1305
|
+
overlayContext.clearRect(0, 0, w2, h2);
|
|
1306
|
+
};
|
|
1307
|
+
const content = {
|
|
1308
|
+
underlayContext,
|
|
1309
|
+
viewContext,
|
|
1310
|
+
overlayContext,
|
|
1311
|
+
boardContext,
|
|
1312
|
+
tempContext,
|
|
1313
|
+
drawView
|
|
1314
|
+
};
|
|
1315
|
+
return content;
|
|
1164
1316
|
}
|
|
1165
1317
|
class EventEmitter {
|
|
1166
1318
|
constructor() {
|
|
1167
|
-
this
|
|
1319
|
+
__privateAdd(this, _listeners);
|
|
1320
|
+
__privateSet(this, _listeners, /* @__PURE__ */ new Map());
|
|
1168
1321
|
}
|
|
1169
1322
|
on(eventKey, callback) {
|
|
1170
|
-
if (this
|
|
1171
|
-
const callbacks = this
|
|
1323
|
+
if (__privateGet(this, _listeners).has(eventKey)) {
|
|
1324
|
+
const callbacks = __privateGet(this, _listeners).get(eventKey) || [];
|
|
1172
1325
|
callbacks == null ? void 0 : callbacks.push(callback);
|
|
1173
|
-
this
|
|
1326
|
+
__privateGet(this, _listeners).set(eventKey, callbacks);
|
|
1174
1327
|
} else {
|
|
1175
|
-
this
|
|
1328
|
+
__privateGet(this, _listeners).set(eventKey, [callback]);
|
|
1176
1329
|
}
|
|
1177
1330
|
}
|
|
1178
1331
|
off(eventKey, callback) {
|
|
1179
|
-
if (this
|
|
1180
|
-
const callbacks = this
|
|
1332
|
+
if (__privateGet(this, _listeners).has(eventKey)) {
|
|
1333
|
+
const callbacks = __privateGet(this, _listeners).get(eventKey);
|
|
1181
1334
|
if (Array.isArray(callbacks)) {
|
|
1182
1335
|
for (let i = 0; i < (callbacks == null ? void 0 : callbacks.length); i++) {
|
|
1183
1336
|
if (callbacks[i] === callback) {
|
|
@@ -1186,11 +1339,11 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1186
1339
|
}
|
|
1187
1340
|
}
|
|
1188
1341
|
}
|
|
1189
|
-
this
|
|
1342
|
+
__privateGet(this, _listeners).set(eventKey, callbacks || []);
|
|
1190
1343
|
}
|
|
1191
1344
|
}
|
|
1192
1345
|
trigger(eventKey, e) {
|
|
1193
|
-
const callbacks = this
|
|
1346
|
+
const callbacks = __privateGet(this, _listeners).get(eventKey);
|
|
1194
1347
|
if (Array.isArray(callbacks)) {
|
|
1195
1348
|
callbacks.forEach((cb) => {
|
|
1196
1349
|
cb(e);
|
|
@@ -1201,15 +1354,22 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1201
1354
|
}
|
|
1202
1355
|
}
|
|
1203
1356
|
has(name) {
|
|
1204
|
-
if (this
|
|
1205
|
-
const list = this
|
|
1357
|
+
if (__privateGet(this, _listeners).has(name)) {
|
|
1358
|
+
const list = __privateGet(this, _listeners).get(name);
|
|
1206
1359
|
if (Array.isArray(list) && list.length > 0) {
|
|
1207
1360
|
return true;
|
|
1208
1361
|
}
|
|
1209
1362
|
}
|
|
1210
1363
|
return false;
|
|
1211
1364
|
}
|
|
1365
|
+
destroy() {
|
|
1366
|
+
this.clear();
|
|
1367
|
+
}
|
|
1368
|
+
clear() {
|
|
1369
|
+
__privateGet(this, _listeners).clear();
|
|
1370
|
+
}
|
|
1212
1371
|
}
|
|
1372
|
+
_listeners = new WeakMap();
|
|
1213
1373
|
function calcDistance(start, end) {
|
|
1214
1374
|
const distance = (start.x - end.x) * (start.x - end.x) + (start.y - end.y) * (start.y - end.y);
|
|
1215
1375
|
return distance === 0 ? distance : Math.sqrt(distance);
|
|
@@ -1242,25 +1402,47 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1242
1402
|
}
|
|
1243
1403
|
class Store {
|
|
1244
1404
|
constructor(opts) {
|
|
1245
|
-
this
|
|
1246
|
-
this
|
|
1405
|
+
__privateAdd(this, _Store_instances);
|
|
1406
|
+
__privateAdd(this, _temp);
|
|
1407
|
+
__privateAdd(this, _backUpDefaultStorage);
|
|
1408
|
+
__privateAdd(this, _static);
|
|
1409
|
+
__privateSet(this, _backUpDefaultStorage, deepClone(opts.defaultStorage));
|
|
1410
|
+
__privateSet(this, _temp, __privateMethod(this, _Store_instances, createTempStorage_fn).call(this));
|
|
1411
|
+
__privateSet(this, _static, opts.defaultStatic || {});
|
|
1247
1412
|
}
|
|
1248
1413
|
set(name, value) {
|
|
1249
|
-
this
|
|
1414
|
+
__privateGet(this, _temp)[name] = value;
|
|
1250
1415
|
}
|
|
1251
1416
|
get(name) {
|
|
1252
|
-
return this
|
|
1417
|
+
return __privateGet(this, _temp)[name];
|
|
1253
1418
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1419
|
+
setStatic(name, value) {
|
|
1420
|
+
__privateGet(this, _static)[name] = value;
|
|
1421
|
+
}
|
|
1422
|
+
getStatic(name) {
|
|
1423
|
+
return __privateGet(this, _static)[name];
|
|
1424
|
+
}
|
|
1425
|
+
getSnapshot(opts) {
|
|
1426
|
+
if ((opts == null ? void 0 : opts.deepClone) === true) {
|
|
1427
|
+
return deepClone(__privateGet(this, _temp));
|
|
1428
|
+
}
|
|
1429
|
+
return { ...__privateGet(this, _temp) };
|
|
1256
1430
|
}
|
|
1257
1431
|
clear() {
|
|
1258
|
-
this
|
|
1432
|
+
__privateSet(this, _temp, __privateMethod(this, _Store_instances, createTempStorage_fn).call(this));
|
|
1259
1433
|
}
|
|
1260
|
-
|
|
1261
|
-
|
|
1434
|
+
destroy() {
|
|
1435
|
+
__privateSet(this, _temp, null);
|
|
1436
|
+
__privateSet(this, _static, null);
|
|
1262
1437
|
}
|
|
1263
1438
|
}
|
|
1439
|
+
_temp = new WeakMap();
|
|
1440
|
+
_backUpDefaultStorage = new WeakMap();
|
|
1441
|
+
_static = new WeakMap();
|
|
1442
|
+
_Store_instances = new WeakSet();
|
|
1443
|
+
createTempStorage_fn = function() {
|
|
1444
|
+
return deepClone(__privateGet(this, _backUpDefaultStorage));
|
|
1445
|
+
};
|
|
1264
1446
|
function getViewScaleInfoFromSnapshot(snapshot) {
|
|
1265
1447
|
const { activeStore } = snapshot;
|
|
1266
1448
|
const sacelInfo = {
|
|
@@ -1329,6 +1511,15 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1329
1511
|
};
|
|
1330
1512
|
return calcElementCenter(elemSize);
|
|
1331
1513
|
}
|
|
1514
|
+
function calcRadian(center, start, end) {
|
|
1515
|
+
const startRadian = calcLineRadian(center, start);
|
|
1516
|
+
const endRadian = calcLineRadian(center, end);
|
|
1517
|
+
if (endRadian !== null && startRadian !== null) {
|
|
1518
|
+
return endRadian - startRadian;
|
|
1519
|
+
} else {
|
|
1520
|
+
return 0;
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1332
1523
|
function calcLineRadian(center, p) {
|
|
1333
1524
|
const x2 = p.x - center.x;
|
|
1334
1525
|
const y2 = p.y - center.y;
|
|
@@ -1409,7 +1600,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1409
1600
|
let resultY = point.y;
|
|
1410
1601
|
groupQueue.forEach((group) => {
|
|
1411
1602
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = group;
|
|
1412
|
-
const center = calcElementCenter({ x: x2, y: y2, w: w2, h: h2
|
|
1603
|
+
const center = calcElementCenter({ x: x2, y: y2, w: w2, h: h2 });
|
|
1413
1604
|
const temp = rotatePoint(center, { x: resultX, y: resultY }, parseAngleToRadian(angle2));
|
|
1414
1605
|
resultX = temp.x;
|
|
1415
1606
|
resultY = temp.y;
|
|
@@ -1450,12 +1641,14 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1450
1641
|
];
|
|
1451
1642
|
}
|
|
1452
1643
|
function limitAngle(angle2) {
|
|
1453
|
-
if (!(angle2 > 0 || angle2 < 0) || angle2 === 0) {
|
|
1644
|
+
if (!(angle2 > 0 || angle2 < 0) || angle2 === 0 || angle2 === 360) {
|
|
1454
1645
|
return 0;
|
|
1455
1646
|
}
|
|
1456
1647
|
let num = angle2 % 360;
|
|
1457
1648
|
if (num < 0) {
|
|
1458
1649
|
num += 360;
|
|
1650
|
+
} else if (angle2 === 360) {
|
|
1651
|
+
num = 0;
|
|
1459
1652
|
}
|
|
1460
1653
|
return num;
|
|
1461
1654
|
}
|
|
@@ -1708,6 +1901,24 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1708
1901
|
_scan(uuid, elements);
|
|
1709
1902
|
return groupQueue;
|
|
1710
1903
|
}
|
|
1904
|
+
function getGroupQueueByElementPosition(elements, position) {
|
|
1905
|
+
var _a;
|
|
1906
|
+
const groupQueue = [];
|
|
1907
|
+
let currentElements = elements;
|
|
1908
|
+
if (position.length > 1) {
|
|
1909
|
+
for (let i = 0; i < position.length - 1; i++) {
|
|
1910
|
+
const index = position[i];
|
|
1911
|
+
const group = currentElements[index];
|
|
1912
|
+
if ((group == null ? void 0 : group.type) === "group" && Array.isArray((_a = group == null ? void 0 : group.detail) == null ? void 0 : _a.children)) {
|
|
1913
|
+
groupQueue.push(group);
|
|
1914
|
+
currentElements = group.detail.children;
|
|
1915
|
+
} else {
|
|
1916
|
+
return null;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
return groupQueue;
|
|
1921
|
+
}
|
|
1711
1922
|
function getElementSize(elem) {
|
|
1712
1923
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = elem;
|
|
1713
1924
|
const size = { x: x2, y: y2, w: w2, h: h2, angle: angle2 };
|
|
@@ -1843,16 +2054,120 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1843
2054
|
_loop(elements);
|
|
1844
2055
|
return result;
|
|
1845
2056
|
}
|
|
2057
|
+
function getElementPositionMapFromList(uuids, elements) {
|
|
2058
|
+
const currentPosition = [];
|
|
2059
|
+
const positionMap = {};
|
|
2060
|
+
let over = false;
|
|
2061
|
+
const _loop = (list) => {
|
|
2062
|
+
var _a;
|
|
2063
|
+
for (let i = 0; i < list.length; i++) {
|
|
2064
|
+
if (over === true) {
|
|
2065
|
+
break;
|
|
2066
|
+
}
|
|
2067
|
+
currentPosition.push(i);
|
|
2068
|
+
const elem = list[i];
|
|
2069
|
+
if (uuids.includes(elem.uuid)) {
|
|
2070
|
+
positionMap[elem.uuid] = [...currentPosition];
|
|
2071
|
+
if (Object.keys(positionMap).length === uuids.length) {
|
|
2072
|
+
over = true;
|
|
2073
|
+
break;
|
|
2074
|
+
}
|
|
2075
|
+
} else if (elem.type === "group") {
|
|
2076
|
+
_loop(((_a = elem == null ? void 0 : elem.detail) == null ? void 0 : _a.children) || []);
|
|
2077
|
+
}
|
|
2078
|
+
if (over) {
|
|
2079
|
+
break;
|
|
2080
|
+
}
|
|
2081
|
+
currentPosition.pop();
|
|
2082
|
+
}
|
|
2083
|
+
};
|
|
2084
|
+
_loop(elements);
|
|
2085
|
+
return positionMap;
|
|
2086
|
+
}
|
|
2087
|
+
function isSameElementSize(elem1, elem2) {
|
|
2088
|
+
return elem1.x === elem2.x && elem1.y === elem2.y && elem1.h === elem2.h && elem1.w === elem2.w && limitAngle(elem1.angle || 0) === limitAngle(elem2.angle || 0);
|
|
2089
|
+
}
|
|
1846
2090
|
function checkRectIntersect(rect1, rect2) {
|
|
1847
|
-
const
|
|
1848
|
-
const
|
|
1849
|
-
const
|
|
1850
|
-
const
|
|
1851
|
-
const
|
|
1852
|
-
const
|
|
1853
|
-
const
|
|
1854
|
-
const
|
|
1855
|
-
return
|
|
2091
|
+
const rect1MinX = rect1.x;
|
|
2092
|
+
const rect1MinY = rect1.y;
|
|
2093
|
+
const rect1MaxX = rect1.x + rect1.w;
|
|
2094
|
+
const rect1MaxY = rect1.y + rect1.h;
|
|
2095
|
+
const rect2MinX = rect2.x;
|
|
2096
|
+
const rect2MinY = rect2.y;
|
|
2097
|
+
const rect2MaxX = rect2.x + rect2.w;
|
|
2098
|
+
const rect2MaxY = rect2.y + rect2.h;
|
|
2099
|
+
return rect1MinX <= rect2MaxX && rect1MaxX >= rect2MinX && rect1MinY <= rect2MaxY && rect1MaxY >= rect2MinY;
|
|
2100
|
+
}
|
|
2101
|
+
function getElementVertexes(elemSize) {
|
|
2102
|
+
const { x: x2, y: y2, h: h2, w: w2 } = elemSize;
|
|
2103
|
+
return [
|
|
2104
|
+
{ x: x2, y: y2 },
|
|
2105
|
+
{ x: x2 + w2, y: y2 },
|
|
2106
|
+
{ x: x2 + w2, y: y2 + h2 },
|
|
2107
|
+
{ x: x2, y: y2 + h2 }
|
|
2108
|
+
];
|
|
2109
|
+
}
|
|
2110
|
+
function calcElementVertexes(elemSize) {
|
|
2111
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemSize;
|
|
2112
|
+
if (angle2 === 0) {
|
|
2113
|
+
return getElementVertexes(elemSize);
|
|
2114
|
+
}
|
|
2115
|
+
return getElementRotateVertexes(elemSize, calcElementCenter({ x: x2, y: y2, w: w2, h: h2 }), angle2);
|
|
2116
|
+
}
|
|
2117
|
+
function calcElementQueueVertexesQueueInGroup(groupQueue) {
|
|
2118
|
+
const vesList = [];
|
|
2119
|
+
let totalX = 0;
|
|
2120
|
+
let totalY = 0;
|
|
2121
|
+
const rotateActionList = [];
|
|
2122
|
+
const elemQueue = [...groupQueue];
|
|
2123
|
+
for (let i = 0; i < elemQueue.length; i++) {
|
|
2124
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemQueue[i];
|
|
2125
|
+
totalX += x2;
|
|
2126
|
+
totalY += y2;
|
|
2127
|
+
let ves;
|
|
2128
|
+
if (i === 0) {
|
|
2129
|
+
const elemSize = { x: totalX, y: totalY, w: w2, h: h2 };
|
|
2130
|
+
ves = calcElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2131
|
+
rotateActionList.push({
|
|
2132
|
+
center: calcElementCenter(elemSize),
|
|
2133
|
+
angle: angle2,
|
|
2134
|
+
radian: parseAngleToRadian(angle2)
|
|
2135
|
+
});
|
|
2136
|
+
} else {
|
|
2137
|
+
const elemSize = { x: totalX, y: totalY, w: w2, h: h2 };
|
|
2138
|
+
ves = getElementVertexes(elemSize);
|
|
2139
|
+
for (let aIdx = 0; aIdx < rotateActionList.length; aIdx++) {
|
|
2140
|
+
const { center, radian } = rotateActionList[aIdx];
|
|
2141
|
+
ves = rotateVertexes(center, ves, radian);
|
|
2142
|
+
}
|
|
2143
|
+
const vesCenter = calcElementCenterFromVertexes(ves);
|
|
2144
|
+
if (angle2 > 0 || angle2 < 0) {
|
|
2145
|
+
const radian = parseAngleToRadian(angle2);
|
|
2146
|
+
ves = rotateVertexes(vesCenter, ves, radian);
|
|
2147
|
+
}
|
|
2148
|
+
rotateActionList.push({
|
|
2149
|
+
center: vesCenter,
|
|
2150
|
+
angle: angle2,
|
|
2151
|
+
radian: parseAngleToRadian(angle2)
|
|
2152
|
+
});
|
|
2153
|
+
}
|
|
2154
|
+
vesList.push(ves);
|
|
2155
|
+
}
|
|
2156
|
+
return vesList;
|
|
2157
|
+
}
|
|
2158
|
+
function calcElementVertexesQueueInGroup(targetElem, opts) {
|
|
2159
|
+
const { groupQueue } = opts;
|
|
2160
|
+
if (!(groupQueue.length > 0)) {
|
|
2161
|
+
return [calcElementVertexes(targetElem)];
|
|
2162
|
+
}
|
|
2163
|
+
const elemQueue = [...groupQueue, ...[targetElem]];
|
|
2164
|
+
const vesList = calcElementQueueVertexesQueueInGroup(elemQueue);
|
|
2165
|
+
return vesList;
|
|
2166
|
+
}
|
|
2167
|
+
function calcElementVertexesInGroup(targetElem, opts) {
|
|
2168
|
+
const vesList = calcElementVertexesQueueInGroup(targetElem, opts);
|
|
2169
|
+
const ves = vesList.pop();
|
|
2170
|
+
return ves || null;
|
|
1856
2171
|
}
|
|
1857
2172
|
function calcViewScaleInfo(info, opts) {
|
|
1858
2173
|
const { scale, offsetX, offsetY } = info;
|
|
@@ -1940,9 +2255,9 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1940
2255
|
];
|
|
1941
2256
|
}
|
|
1942
2257
|
function isViewPointInElement(p, opts) {
|
|
1943
|
-
const { context2d: ctx, element: elem, viewScaleInfo
|
|
2258
|
+
const { context2d: ctx, element: elem, viewScaleInfo } = opts;
|
|
1944
2259
|
const { angle: angle2 = 0 } = elem;
|
|
1945
|
-
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo
|
|
2260
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo });
|
|
1946
2261
|
const vertexes = rotateElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
1947
2262
|
if (vertexes.length >= 2) {
|
|
1948
2263
|
ctx.beginPath();
|
|
@@ -1957,6 +2272,25 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1957
2272
|
}
|
|
1958
2273
|
return false;
|
|
1959
2274
|
}
|
|
2275
|
+
function isViewPointInElementSize(p, elemSize, opts) {
|
|
2276
|
+
const vertexes = calcElementVertexes(elemSize);
|
|
2277
|
+
return isViewPointInVertexes(p, vertexes, opts);
|
|
2278
|
+
}
|
|
2279
|
+
function isViewPointInVertexes(p, vertexes, opts) {
|
|
2280
|
+
const xList = [vertexes[0].x, vertexes[1].x, vertexes[2].x, vertexes[3].x];
|
|
2281
|
+
const yList = [vertexes[0].y, vertexes[1].y, vertexes[2].y, vertexes[3].y];
|
|
2282
|
+
const mixX = Math.min(...xList);
|
|
2283
|
+
const maxX = Math.max(...xList);
|
|
2284
|
+
const mixY = Math.min(...yList);
|
|
2285
|
+
const maxY = Math.max(...yList);
|
|
2286
|
+
if (p.x > mixX && p.x < maxX && p.y > mixY && p.y < maxY) {
|
|
2287
|
+
return true;
|
|
2288
|
+
}
|
|
2289
|
+
if ((opts == null ? void 0 : opts.includeBorder) === true && (p.x === mixX || p.x === maxX || p.y === mixY || p.y === maxY)) {
|
|
2290
|
+
return true;
|
|
2291
|
+
}
|
|
2292
|
+
return false;
|
|
2293
|
+
}
|
|
1960
2294
|
function getViewPointAtElement(p, opts) {
|
|
1961
2295
|
var _a, _b, _c;
|
|
1962
2296
|
const { context2d: ctx, data, viewScaleInfo, viewSizeInfo, groupQueue } = opts;
|
|
@@ -1990,7 +2324,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1990
2324
|
h: child.h,
|
|
1991
2325
|
angle: totalAngle + (child.angle || 0)
|
|
1992
2326
|
};
|
|
1993
|
-
if (isViewPointInElement(p, { context2d: ctx, element: elemSize, viewScaleInfo
|
|
2327
|
+
if (isViewPointInElement(p, { context2d: ctx, element: elemSize, viewScaleInfo })) {
|
|
1994
2328
|
result.element = child;
|
|
1995
2329
|
if (gIdx < groupQueue.length - 1 || child.type !== "group") {
|
|
1996
2330
|
result.groupQueueIndex = gIdx;
|
|
@@ -2015,7 +2349,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2015
2349
|
if (((_c = elem == null ? void 0 : elem.operations) == null ? void 0 : _c.invisible) === true) {
|
|
2016
2350
|
continue;
|
|
2017
2351
|
}
|
|
2018
|
-
if (isViewPointInElement(p, { context2d: ctx, element: elem, viewScaleInfo
|
|
2352
|
+
if (isViewPointInElement(p, { context2d: ctx, element: elem, viewScaleInfo })) {
|
|
2019
2353
|
result.index = i;
|
|
2020
2354
|
result.element = elem;
|
|
2021
2355
|
break;
|
|
@@ -2027,7 +2361,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2027
2361
|
const { viewSizeInfo, viewScaleInfo } = opts;
|
|
2028
2362
|
const { width, height } = viewSizeInfo;
|
|
2029
2363
|
const { angle: angle2 } = elem;
|
|
2030
|
-
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo
|
|
2364
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo });
|
|
2031
2365
|
const ves = rotateElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2032
2366
|
const viewSize = { x: 0, y: 0, w: width, h: height };
|
|
2033
2367
|
const elemStartX = Math.min(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
|
|
@@ -2037,76 +2371,148 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2037
2371
|
const elemSize = { x: elemStartX, y: elemStartY, w: elemEndX - elemStartX, h: elemEndY - elemStartY };
|
|
2038
2372
|
return checkRectIntersect(viewSize, elemSize);
|
|
2039
2373
|
}
|
|
2040
|
-
function
|
|
2041
|
-
const {
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
];
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
const
|
|
2051
|
-
|
|
2052
|
-
|
|
2374
|
+
function calcElementOriginRectInfo(elemSize, opts) {
|
|
2375
|
+
const { groupQueue } = opts;
|
|
2376
|
+
const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
|
|
2377
|
+
const top = getCenterFromTwoPoints(vertexes[0], vertexes[1]);
|
|
2378
|
+
const right = getCenterFromTwoPoints(vertexes[1], vertexes[2]);
|
|
2379
|
+
const bottom = getCenterFromTwoPoints(vertexes[2], vertexes[3]);
|
|
2380
|
+
const left = getCenterFromTwoPoints(vertexes[3], vertexes[0]);
|
|
2381
|
+
const topLeft = vertexes[0];
|
|
2382
|
+
const topRight = vertexes[1];
|
|
2383
|
+
const bottomRight = vertexes[2];
|
|
2384
|
+
const bottomLeft = vertexes[3];
|
|
2385
|
+
const maxX = Math.max(topLeft.x, topRight.x, bottomRight.x, bottomLeft.x);
|
|
2386
|
+
const maxY = Math.max(topLeft.y, topRight.y, bottomRight.y, bottomLeft.y);
|
|
2387
|
+
const minX = Math.min(topLeft.x, topRight.x, bottomRight.x, bottomLeft.x);
|
|
2388
|
+
const minY = Math.min(topLeft.y, topRight.y, bottomRight.y, bottomLeft.y);
|
|
2389
|
+
const center = {
|
|
2390
|
+
x: (maxX + minX) / 2,
|
|
2391
|
+
y: (maxY + minY) / 2
|
|
2392
|
+
};
|
|
2393
|
+
const rectInfo = {
|
|
2394
|
+
center,
|
|
2395
|
+
topLeft,
|
|
2396
|
+
topRight,
|
|
2397
|
+
bottomLeft,
|
|
2398
|
+
bottomRight,
|
|
2399
|
+
top,
|
|
2400
|
+
right,
|
|
2401
|
+
left,
|
|
2402
|
+
bottom
|
|
2403
|
+
};
|
|
2404
|
+
return rectInfo;
|
|
2405
|
+
}
|
|
2406
|
+
function originRectInfoToRangeRectInfo(originRectInfo) {
|
|
2407
|
+
const rangeMaxX = Math.max(
|
|
2408
|
+
originRectInfo.topLeft.x,
|
|
2409
|
+
originRectInfo.topRight.x,
|
|
2410
|
+
originRectInfo.bottomRight.x,
|
|
2411
|
+
originRectInfo.bottomLeft.x
|
|
2412
|
+
);
|
|
2413
|
+
const rangeMaxY = Math.max(
|
|
2414
|
+
originRectInfo.topLeft.y,
|
|
2415
|
+
originRectInfo.topRight.y,
|
|
2416
|
+
originRectInfo.bottomRight.y,
|
|
2417
|
+
originRectInfo.bottomLeft.y
|
|
2418
|
+
);
|
|
2419
|
+
const rangeMinX = Math.min(
|
|
2420
|
+
originRectInfo.topLeft.x,
|
|
2421
|
+
originRectInfo.topRight.x,
|
|
2422
|
+
originRectInfo.bottomRight.x,
|
|
2423
|
+
originRectInfo.bottomLeft.x
|
|
2424
|
+
);
|
|
2425
|
+
const rangeMinY = Math.min(
|
|
2426
|
+
originRectInfo.topLeft.y,
|
|
2427
|
+
originRectInfo.topRight.y,
|
|
2428
|
+
originRectInfo.bottomRight.y,
|
|
2429
|
+
originRectInfo.bottomLeft.y
|
|
2430
|
+
);
|
|
2431
|
+
const rangeCenter = { x: originRectInfo.center.x, y: originRectInfo.center.y };
|
|
2432
|
+
const rangeTopLeft = { x: rangeMinX, y: rangeMinY };
|
|
2433
|
+
const rangeTopRight = { x: rangeMaxX, y: rangeMinY };
|
|
2434
|
+
const rangeBottomRight = { x: rangeMaxX, y: rangeMaxY };
|
|
2435
|
+
const rangeBottomLeft = { x: rangeMinX, y: rangeMaxY };
|
|
2436
|
+
const rangeTop = getCenterFromTwoPoints(rangeTopLeft, rangeTopRight);
|
|
2437
|
+
const rangeBottom = getCenterFromTwoPoints(rangeBottomLeft, rangeBottomRight);
|
|
2438
|
+
const rangeLeft = getCenterFromTwoPoints(rangeTopLeft, rangeBottomLeft);
|
|
2439
|
+
const rangeRight = getCenterFromTwoPoints(rangeTopRight, rangeBottomRight);
|
|
2440
|
+
const rangeRectInfo = {
|
|
2441
|
+
center: rangeCenter,
|
|
2442
|
+
topLeft: rangeTopLeft,
|
|
2443
|
+
topRight: rangeTopRight,
|
|
2444
|
+
bottomLeft: rangeBottomLeft,
|
|
2445
|
+
bottomRight: rangeBottomRight,
|
|
2446
|
+
top: rangeTop,
|
|
2447
|
+
right: rangeRight,
|
|
2448
|
+
left: rangeLeft,
|
|
2449
|
+
bottom: rangeBottom
|
|
2450
|
+
};
|
|
2451
|
+
return rangeRectInfo;
|
|
2452
|
+
}
|
|
2453
|
+
function calcElementViewRectInfo(elemSize, opts) {
|
|
2454
|
+
const { groupQueue, viewScaleInfo, range } = opts;
|
|
2455
|
+
const originRectInfo = calcElementOriginRectInfo(elemSize, { groupQueue });
|
|
2456
|
+
const { center, top, bottom, left, right, topLeft, topRight, bottomLeft, bottomRight } = originRectInfo;
|
|
2457
|
+
const viewRectInfo = {
|
|
2458
|
+
center: calcViewPointSize(center, { viewScaleInfo }),
|
|
2459
|
+
topLeft: calcViewPointSize(topLeft, { viewScaleInfo }),
|
|
2460
|
+
topRight: calcViewPointSize(topRight, { viewScaleInfo }),
|
|
2461
|
+
bottomLeft: calcViewPointSize(bottomLeft, { viewScaleInfo }),
|
|
2462
|
+
bottomRight: calcViewPointSize(bottomRight, { viewScaleInfo }),
|
|
2463
|
+
top: calcViewPointSize(top, { viewScaleInfo }),
|
|
2464
|
+
right: calcViewPointSize(right, { viewScaleInfo }),
|
|
2465
|
+
left: calcViewPointSize(left, { viewScaleInfo }),
|
|
2466
|
+
bottom: calcViewPointSize(bottom, { viewScaleInfo })
|
|
2467
|
+
};
|
|
2468
|
+
if (range === true) {
|
|
2469
|
+
const viewMaxX = Math.max(
|
|
2470
|
+
viewRectInfo.topLeft.x,
|
|
2471
|
+
viewRectInfo.topRight.x,
|
|
2472
|
+
viewRectInfo.bottomRight.x,
|
|
2473
|
+
viewRectInfo.bottomLeft.x
|
|
2474
|
+
);
|
|
2475
|
+
const viewMaxY = Math.max(
|
|
2476
|
+
viewRectInfo.topLeft.y,
|
|
2477
|
+
viewRectInfo.topRight.y,
|
|
2478
|
+
viewRectInfo.bottomRight.y,
|
|
2479
|
+
viewRectInfo.bottomLeft.y
|
|
2480
|
+
);
|
|
2481
|
+
const viewMinX = Math.min(
|
|
2482
|
+
viewRectInfo.topLeft.x,
|
|
2483
|
+
viewRectInfo.topRight.x,
|
|
2484
|
+
viewRectInfo.bottomRight.x,
|
|
2485
|
+
viewRectInfo.bottomLeft.x
|
|
2486
|
+
);
|
|
2487
|
+
const viewMinY = Math.min(
|
|
2488
|
+
viewRectInfo.topLeft.y,
|
|
2489
|
+
viewRectInfo.topRight.y,
|
|
2490
|
+
viewRectInfo.bottomRight.y,
|
|
2491
|
+
viewRectInfo.bottomLeft.y
|
|
2492
|
+
);
|
|
2493
|
+
const rangeCenter = { x: viewRectInfo.center.x, y: viewRectInfo.center.y };
|
|
2494
|
+
const rangeTopLeft = { x: viewMinX, y: viewMinY };
|
|
2495
|
+
const rangeTopRight = { x: viewMaxX, y: viewMinY };
|
|
2496
|
+
const rangeBottomRight = { x: viewMaxX, y: viewMaxY };
|
|
2497
|
+
const rangeBottomLeft = { x: viewMinX, y: viewMaxY };
|
|
2498
|
+
const rangeTop = getCenterFromTwoPoints(rangeTopLeft, rangeTopRight);
|
|
2499
|
+
const rangeBottom = getCenterFromTwoPoints(rangeBottomLeft, rangeBottomRight);
|
|
2500
|
+
const rangeLeft = getCenterFromTwoPoints(rangeTopLeft, rangeBottomLeft);
|
|
2501
|
+
const rangeRight = getCenterFromTwoPoints(rangeTopRight, rangeBottomRight);
|
|
2502
|
+
const rangeRectInfo = {
|
|
2503
|
+
center: rangeCenter,
|
|
2504
|
+
topLeft: rangeTopLeft,
|
|
2505
|
+
topRight: rangeTopRight,
|
|
2506
|
+
bottomLeft: rangeBottomLeft,
|
|
2507
|
+
bottomRight: rangeBottomRight,
|
|
2508
|
+
top: rangeTop,
|
|
2509
|
+
right: rangeRight,
|
|
2510
|
+
left: rangeLeft,
|
|
2511
|
+
bottom: rangeBottom
|
|
2512
|
+
};
|
|
2513
|
+
return rangeRectInfo;
|
|
2053
2514
|
}
|
|
2054
|
-
return
|
|
2055
|
-
}
|
|
2056
|
-
function calcElementQueueVertexesQueueInGroup(groupQueue) {
|
|
2057
|
-
const vesList = [];
|
|
2058
|
-
let totalX = 0;
|
|
2059
|
-
let totalY = 0;
|
|
2060
|
-
const rotateActionList = [];
|
|
2061
|
-
const elemQueue = [...groupQueue];
|
|
2062
|
-
for (let i = 0; i < elemQueue.length; i++) {
|
|
2063
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemQueue[i];
|
|
2064
|
-
totalX += x2;
|
|
2065
|
-
totalY += y2;
|
|
2066
|
-
let ves;
|
|
2067
|
-
if (i === 0) {
|
|
2068
|
-
const elemSize = { x: totalX, y: totalY, w: w2, h: h2, angle: angle2 };
|
|
2069
|
-
ves = calcElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2070
|
-
rotateActionList.push({
|
|
2071
|
-
center: calcElementCenter(elemSize),
|
|
2072
|
-
angle: angle2,
|
|
2073
|
-
radian: parseAngleToRadian(angle2)
|
|
2074
|
-
});
|
|
2075
|
-
} else {
|
|
2076
|
-
const elemSize = { x: totalX, y: totalY, w: w2, h: h2, angle: angle2 };
|
|
2077
|
-
ves = getElementVertexes(elemSize);
|
|
2078
|
-
for (let aIdx = 0; aIdx < rotateActionList.length; aIdx++) {
|
|
2079
|
-
const { center, radian } = rotateActionList[aIdx];
|
|
2080
|
-
ves = rotateVertexes(center, ves, radian);
|
|
2081
|
-
}
|
|
2082
|
-
const vesCenter = calcElementCenterFromVertexes(ves);
|
|
2083
|
-
if (angle2 > 0 || angle2 < 0) {
|
|
2084
|
-
const radian = parseAngleToRadian(angle2);
|
|
2085
|
-
ves = rotateVertexes(vesCenter, ves, radian);
|
|
2086
|
-
}
|
|
2087
|
-
rotateActionList.push({
|
|
2088
|
-
center: vesCenter,
|
|
2089
|
-
angle: angle2,
|
|
2090
|
-
radian: parseAngleToRadian(angle2)
|
|
2091
|
-
});
|
|
2092
|
-
}
|
|
2093
|
-
vesList.push(ves);
|
|
2094
|
-
}
|
|
2095
|
-
return vesList;
|
|
2096
|
-
}
|
|
2097
|
-
function calcElementVertexesQueueInGroup(targetElem, opts) {
|
|
2098
|
-
const { groupQueue } = opts;
|
|
2099
|
-
if (!(groupQueue.length > 0)) {
|
|
2100
|
-
return [calcElementVertexes(targetElem)];
|
|
2101
|
-
}
|
|
2102
|
-
const elemQueue = [...groupQueue, ...[targetElem]];
|
|
2103
|
-
const vesList = calcElementQueueVertexesQueueInGroup(elemQueue);
|
|
2104
|
-
return vesList;
|
|
2105
|
-
}
|
|
2106
|
-
function calcElementVertexesInGroup(targetElem, opts) {
|
|
2107
|
-
const vesList = calcElementVertexesQueueInGroup(targetElem, opts);
|
|
2108
|
-
const ves = vesList.pop();
|
|
2109
|
-
return ves || null;
|
|
2515
|
+
return viewRectInfo;
|
|
2110
2516
|
}
|
|
2111
2517
|
function createControllerElementSizeFromCenter(center, opts) {
|
|
2112
2518
|
const { x: x2, y: y2 } = center;
|
|
@@ -2120,9 +2526,11 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2120
2526
|
};
|
|
2121
2527
|
}
|
|
2122
2528
|
function calcElementSizeController(elemSize, opts) {
|
|
2123
|
-
const { groupQueue, controllerSize, viewScaleInfo } = opts;
|
|
2529
|
+
const { groupQueue, controllerSize, viewScaleInfo, rotateControllerSize, rotateControllerPosition } = opts;
|
|
2124
2530
|
const ctrlSize = (controllerSize && controllerSize > 0 ? controllerSize : 8) / viewScaleInfo.scale;
|
|
2125
2531
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemSize;
|
|
2532
|
+
const rotateCtrlSize = rotateControllerSize;
|
|
2533
|
+
const rotateCtrlPos = rotateControllerPosition;
|
|
2126
2534
|
const ctrlGroupQueue = [
|
|
2127
2535
|
...[
|
|
2128
2536
|
{
|
|
@@ -2143,6 +2551,16 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2143
2551
|
totalAngle += angle22;
|
|
2144
2552
|
});
|
|
2145
2553
|
const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
|
|
2554
|
+
const rotateElemVertexes = calcElementVertexesInGroup(
|
|
2555
|
+
{
|
|
2556
|
+
x: x2,
|
|
2557
|
+
y: y2 - (rotateCtrlPos + rotateCtrlSize / 2) / viewScaleInfo.scale,
|
|
2558
|
+
h: h2 + (rotateCtrlPos * 2 + rotateCtrlSize) / viewScaleInfo.scale,
|
|
2559
|
+
w: w2,
|
|
2560
|
+
angle: angle2
|
|
2561
|
+
},
|
|
2562
|
+
{ groupQueue: [...groupQueue] }
|
|
2563
|
+
);
|
|
2146
2564
|
const topCenter = getCenterFromTwoPoints(vertexes[0], vertexes[1]);
|
|
2147
2565
|
const rightCenter = getCenterFromTwoPoints(vertexes[1], vertexes[2]);
|
|
2148
2566
|
const bottomCenter = getCenterFromTwoPoints(vertexes[2], vertexes[3]);
|
|
@@ -2151,6 +2569,10 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2151
2569
|
const topRightCenter = vertexes[1];
|
|
2152
2570
|
const bottomRightCenter = vertexes[2];
|
|
2153
2571
|
const bottomLeftCenter = vertexes[3];
|
|
2572
|
+
const topMiddleSize = createControllerElementSizeFromCenter(topCenter, { size: ctrlSize, angle: totalAngle });
|
|
2573
|
+
const rightMiddleSize = createControllerElementSizeFromCenter(rightCenter, { size: ctrlSize, angle: totalAngle });
|
|
2574
|
+
const bottomMiddleSize = createControllerElementSizeFromCenter(bottomCenter, { size: ctrlSize, angle: totalAngle });
|
|
2575
|
+
const leftMiddleSize = createControllerElementSizeFromCenter(leftCenter, { size: ctrlSize, angle: totalAngle });
|
|
2154
2576
|
const topLeftSize = createControllerElementSizeFromCenter(topLeftCenter, { size: ctrlSize, angle: totalAngle });
|
|
2155
2577
|
const topRightSize = createControllerElementSizeFromCenter(topRightCenter, { size: ctrlSize, angle: totalAngle });
|
|
2156
2578
|
const bottomLeftSize = createControllerElementSizeFromCenter(bottomLeftCenter, { size: ctrlSize, angle: totalAngle });
|
|
@@ -2163,47 +2585,207 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2163
2585
|
const rightVertexes = [topRightVertexes[3], topRightVertexes[2], bottomRightVertexes[1], bottomRightVertexes[0]];
|
|
2164
2586
|
const bottomVertexes = [bottomLeftVertexes[1], bottomRightVertexes[0], bottomRightVertexes[3], bottomLeftVertexes[2]];
|
|
2165
2587
|
const leftVertexes = [topLeftVertexes[3], topLeftVertexes[2], bottomLeftVertexes[1], bottomLeftVertexes[0]];
|
|
2588
|
+
const topMiddleVertexes = calcElementVertexes(topMiddleSize);
|
|
2589
|
+
const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
|
|
2590
|
+
const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
|
|
2591
|
+
const leftMiddleVertexes = calcElementVertexes(leftMiddleSize);
|
|
2592
|
+
const rotateCenter = getCenterFromTwoPoints(rotateElemVertexes[0], rotateElemVertexes[1]);
|
|
2593
|
+
const tempRotateSizeRepairRatio = 1.1;
|
|
2594
|
+
const rotateSize = createControllerElementSizeFromCenter(rotateCenter, {
|
|
2595
|
+
size: rotateControllerSize * tempRotateSizeRepairRatio / viewScaleInfo.scale,
|
|
2596
|
+
angle: totalAngle
|
|
2597
|
+
});
|
|
2598
|
+
const rotateVertexes2 = calcElementVertexes(rotateSize);
|
|
2166
2599
|
const sizeController = {
|
|
2600
|
+
originalElementCenter: calcElementCenter(elemSize),
|
|
2601
|
+
originalElementSize: { ...elemSize },
|
|
2167
2602
|
elementWrapper: vertexes,
|
|
2168
2603
|
left: {
|
|
2169
2604
|
type: "left",
|
|
2170
2605
|
vertexes: leftVertexes,
|
|
2171
|
-
center: leftCenter
|
|
2606
|
+
center: leftCenter,
|
|
2607
|
+
size: ctrlSize
|
|
2608
|
+
},
|
|
2609
|
+
right: {
|
|
2610
|
+
type: "right",
|
|
2611
|
+
vertexes: rightVertexes,
|
|
2612
|
+
center: rightCenter,
|
|
2613
|
+
size: ctrlSize
|
|
2614
|
+
},
|
|
2615
|
+
top: {
|
|
2616
|
+
type: "top",
|
|
2617
|
+
vertexes: topVertexes,
|
|
2618
|
+
center: topCenter,
|
|
2619
|
+
size: ctrlSize
|
|
2620
|
+
},
|
|
2621
|
+
bottom: {
|
|
2622
|
+
type: "bottom",
|
|
2623
|
+
vertexes: bottomVertexes,
|
|
2624
|
+
center: bottomCenter,
|
|
2625
|
+
size: ctrlSize
|
|
2626
|
+
},
|
|
2627
|
+
topLeft: {
|
|
2628
|
+
type: "top-left",
|
|
2629
|
+
vertexes: topLeftVertexes,
|
|
2630
|
+
center: topLeftCenter,
|
|
2631
|
+
size: ctrlSize
|
|
2632
|
+
},
|
|
2633
|
+
topRight: {
|
|
2634
|
+
type: "top-right",
|
|
2635
|
+
vertexes: topRightVertexes,
|
|
2636
|
+
center: topRightCenter,
|
|
2637
|
+
size: ctrlSize
|
|
2638
|
+
},
|
|
2639
|
+
bottomLeft: {
|
|
2640
|
+
type: "bottom-left",
|
|
2641
|
+
vertexes: bottomLeftVertexes,
|
|
2642
|
+
center: bottomLeftCenter,
|
|
2643
|
+
size: ctrlSize
|
|
2644
|
+
},
|
|
2645
|
+
bottomRight: {
|
|
2646
|
+
type: "bottom-right",
|
|
2647
|
+
vertexes: bottomRightVertexes,
|
|
2648
|
+
center: bottomRightCenter,
|
|
2649
|
+
size: ctrlSize
|
|
2650
|
+
},
|
|
2651
|
+
leftMiddle: {
|
|
2652
|
+
type: "left-middle",
|
|
2653
|
+
vertexes: leftMiddleVertexes,
|
|
2654
|
+
center: leftCenter,
|
|
2655
|
+
size: ctrlSize
|
|
2656
|
+
},
|
|
2657
|
+
rightMiddle: {
|
|
2658
|
+
type: "right-middle",
|
|
2659
|
+
vertexes: rightMiddleVertexes,
|
|
2660
|
+
center: rightCenter,
|
|
2661
|
+
size: ctrlSize
|
|
2662
|
+
},
|
|
2663
|
+
topMiddle: {
|
|
2664
|
+
type: "top-middle",
|
|
2665
|
+
vertexes: topMiddleVertexes,
|
|
2666
|
+
center: topCenter,
|
|
2667
|
+
size: ctrlSize
|
|
2668
|
+
},
|
|
2669
|
+
bottomMiddle: {
|
|
2670
|
+
type: "bottom-middle",
|
|
2671
|
+
vertexes: bottomMiddleVertexes,
|
|
2672
|
+
center: bottomCenter,
|
|
2673
|
+
size: ctrlSize
|
|
2674
|
+
},
|
|
2675
|
+
rotate: {
|
|
2676
|
+
type: "rotate",
|
|
2677
|
+
vertexes: rotateVertexes2,
|
|
2678
|
+
center: rotateCenter,
|
|
2679
|
+
size: rotateControllerSize
|
|
2680
|
+
}
|
|
2681
|
+
};
|
|
2682
|
+
return sizeController;
|
|
2683
|
+
}
|
|
2684
|
+
function calcLayoutSizeController(layoutSize, opts) {
|
|
2685
|
+
const { controllerSize, viewScaleInfo } = opts;
|
|
2686
|
+
const ctrlSize = controllerSize && controllerSize > 0 ? controllerSize : 8;
|
|
2687
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(layoutSize, { viewScaleInfo });
|
|
2688
|
+
const center = calcElementCenter({ x: x2, y: y2, w: w2, h: h2 });
|
|
2689
|
+
const topCenter = { x: center.x, y: y2 };
|
|
2690
|
+
const rightCenter = { x: x2 + w2, y: center.y };
|
|
2691
|
+
const bottomCenter = { x: center.x, y: y2 + h2 };
|
|
2692
|
+
const leftCenter = { x: x2, y: center.y };
|
|
2693
|
+
const topLeftCenter = { x: x2, y: y2 };
|
|
2694
|
+
const topRightCenter = { x: x2 + w2, y: y2 };
|
|
2695
|
+
const bottomRightCenter = { x: x2 + w2, y: y2 + h2 };
|
|
2696
|
+
const bottomLeftCenter = { x: x2, y: y2 + h2 };
|
|
2697
|
+
const topMiddleSize = createControllerElementSizeFromCenter(topCenter, { size: ctrlSize, angle: 0 });
|
|
2698
|
+
const rightMiddleSize = createControllerElementSizeFromCenter(rightCenter, { size: ctrlSize, angle: 0 });
|
|
2699
|
+
const bottomMiddleSize = createControllerElementSizeFromCenter(bottomCenter, { size: ctrlSize, angle: 0 });
|
|
2700
|
+
const leftMiddleSize = createControllerElementSizeFromCenter(leftCenter, { size: ctrlSize, angle: 0 });
|
|
2701
|
+
const topLeftSize = createControllerElementSizeFromCenter(topLeftCenter, { size: ctrlSize, angle: 0 });
|
|
2702
|
+
const topRightSize = createControllerElementSizeFromCenter(topRightCenter, { size: ctrlSize, angle: 0 });
|
|
2703
|
+
const bottomLeftSize = createControllerElementSizeFromCenter(bottomLeftCenter, { size: ctrlSize, angle: 0 });
|
|
2704
|
+
const bottomRightSize = createControllerElementSizeFromCenter(bottomRightCenter, { size: ctrlSize, angle: 0 });
|
|
2705
|
+
const topLeftVertexes = calcElementVertexes(topLeftSize);
|
|
2706
|
+
const topRightVertexes = calcElementVertexes(topRightSize);
|
|
2707
|
+
const bottomLeftVertexes = calcElementVertexes(bottomLeftSize);
|
|
2708
|
+
const bottomRightVertexes = calcElementVertexes(bottomRightSize);
|
|
2709
|
+
const topVertexes = [topLeftVertexes[1], topRightVertexes[0], topRightVertexes[3], topLeftVertexes[2]];
|
|
2710
|
+
const rightVertexes = [topRightVertexes[3], topRightVertexes[2], bottomRightVertexes[1], bottomRightVertexes[0]];
|
|
2711
|
+
const bottomVertexes = [bottomLeftVertexes[1], bottomRightVertexes[0], bottomRightVertexes[3], bottomLeftVertexes[2]];
|
|
2712
|
+
const leftVertexes = [topLeftVertexes[3], topLeftVertexes[2], bottomLeftVertexes[1], bottomLeftVertexes[0]];
|
|
2713
|
+
const topMiddleVertexes = calcElementVertexes(topMiddleSize);
|
|
2714
|
+
const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
|
|
2715
|
+
const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
|
|
2716
|
+
const leftMiddleVertexes = calcElementVertexes(leftMiddleSize);
|
|
2717
|
+
const sizeController = {
|
|
2718
|
+
left: {
|
|
2719
|
+
type: "left",
|
|
2720
|
+
vertexes: leftVertexes,
|
|
2721
|
+
center: leftCenter,
|
|
2722
|
+
size: ctrlSize
|
|
2172
2723
|
},
|
|
2173
2724
|
right: {
|
|
2174
2725
|
type: "right",
|
|
2175
2726
|
vertexes: rightVertexes,
|
|
2176
|
-
center: rightCenter
|
|
2727
|
+
center: rightCenter,
|
|
2728
|
+
size: ctrlSize
|
|
2177
2729
|
},
|
|
2178
2730
|
top: {
|
|
2179
2731
|
type: "top",
|
|
2180
2732
|
vertexes: topVertexes,
|
|
2181
|
-
center: topCenter
|
|
2733
|
+
center: topCenter,
|
|
2734
|
+
size: ctrlSize
|
|
2182
2735
|
},
|
|
2183
2736
|
bottom: {
|
|
2184
2737
|
type: "bottom",
|
|
2185
2738
|
vertexes: bottomVertexes,
|
|
2186
|
-
center: bottomCenter
|
|
2739
|
+
center: bottomCenter,
|
|
2740
|
+
size: ctrlSize
|
|
2187
2741
|
},
|
|
2188
2742
|
topLeft: {
|
|
2189
2743
|
type: "top-left",
|
|
2190
2744
|
vertexes: topLeftVertexes,
|
|
2191
|
-
center: topLeftCenter
|
|
2745
|
+
center: topLeftCenter,
|
|
2746
|
+
size: ctrlSize
|
|
2192
2747
|
},
|
|
2193
2748
|
topRight: {
|
|
2194
2749
|
type: "top-right",
|
|
2195
2750
|
vertexes: topRightVertexes,
|
|
2196
|
-
center: topRightCenter
|
|
2751
|
+
center: topRightCenter,
|
|
2752
|
+
size: ctrlSize
|
|
2197
2753
|
},
|
|
2198
2754
|
bottomLeft: {
|
|
2199
2755
|
type: "bottom-left",
|
|
2200
2756
|
vertexes: bottomLeftVertexes,
|
|
2201
|
-
center: bottomLeftCenter
|
|
2757
|
+
center: bottomLeftCenter,
|
|
2758
|
+
size: ctrlSize
|
|
2202
2759
|
},
|
|
2203
2760
|
bottomRight: {
|
|
2204
2761
|
type: "bottom-right",
|
|
2205
2762
|
vertexes: bottomRightVertexes,
|
|
2206
|
-
center: bottomRightCenter
|
|
2763
|
+
center: bottomRightCenter,
|
|
2764
|
+
size: ctrlSize
|
|
2765
|
+
},
|
|
2766
|
+
leftMiddle: {
|
|
2767
|
+
type: "left-middle",
|
|
2768
|
+
vertexes: leftMiddleVertexes,
|
|
2769
|
+
center: leftCenter,
|
|
2770
|
+
size: ctrlSize
|
|
2771
|
+
},
|
|
2772
|
+
rightMiddle: {
|
|
2773
|
+
type: "right-middle",
|
|
2774
|
+
vertexes: rightMiddleVertexes,
|
|
2775
|
+
center: rightCenter,
|
|
2776
|
+
size: ctrlSize
|
|
2777
|
+
},
|
|
2778
|
+
topMiddle: {
|
|
2779
|
+
type: "top-middle",
|
|
2780
|
+
vertexes: topMiddleVertexes,
|
|
2781
|
+
center: topCenter,
|
|
2782
|
+
size: ctrlSize
|
|
2783
|
+
},
|
|
2784
|
+
bottomMiddle: {
|
|
2785
|
+
type: "bottom-middle",
|
|
2786
|
+
vertexes: bottomMiddleVertexes,
|
|
2787
|
+
center: bottomCenter,
|
|
2788
|
+
size: ctrlSize
|
|
2207
2789
|
}
|
|
2208
2790
|
};
|
|
2209
2791
|
return sizeController;
|
|
@@ -2290,7 +2872,6 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2290
2872
|
const arr = [];
|
|
2291
2873
|
let current;
|
|
2292
2874
|
let level = -1;
|
|
2293
|
-
let inComponent = false;
|
|
2294
2875
|
html2.replace(elemRegExp, (element, index) => {
|
|
2295
2876
|
const isOpen = element.charAt(1) !== "/";
|
|
2296
2877
|
const isComment = element.startsWith("<!--");
|
|
@@ -2310,7 +2891,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2310
2891
|
if (isOpen) {
|
|
2311
2892
|
level++;
|
|
2312
2893
|
current = parseElement(element);
|
|
2313
|
-
if (!current.isVoid &&
|
|
2894
|
+
if (!current.isVoid && true && nextChar && nextChar !== "<") {
|
|
2314
2895
|
const content = html2.slice(start, html2.indexOf("<", start));
|
|
2315
2896
|
if (content.trim()) {
|
|
2316
2897
|
current.children.push({
|
|
@@ -2441,6 +3022,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2441
3022
|
}
|
|
2442
3023
|
return radian;
|
|
2443
3024
|
}
|
|
3025
|
+
const defaultText = "Text Element";
|
|
2444
3026
|
function getDefaultElementDetailConfig() {
|
|
2445
3027
|
const config = {
|
|
2446
3028
|
boxSizing: "border-box",
|
|
@@ -2457,9 +3039,11 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2457
3039
|
textAlign: "left",
|
|
2458
3040
|
verticalAlign: "top",
|
|
2459
3041
|
fontSize: 16,
|
|
2460
|
-
lineHeight: 20,
|
|
3042
|
+
// lineHeight: 20,
|
|
2461
3043
|
fontFamily: "sans-serif",
|
|
2462
3044
|
fontWeight: 400,
|
|
3045
|
+
minInlineSize: "auto",
|
|
3046
|
+
wordBreak: "break-all",
|
|
2463
3047
|
overflow: "hidden"
|
|
2464
3048
|
};
|
|
2465
3049
|
return config;
|
|
@@ -2470,24 +3054,22 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2470
3054
|
};
|
|
2471
3055
|
return detail;
|
|
2472
3056
|
}
|
|
2473
|
-
function getDefaultElementCircleDetail(
|
|
3057
|
+
function getDefaultElementCircleDetail() {
|
|
2474
3058
|
const detail = {
|
|
2475
3059
|
background: "#D9D9D9",
|
|
2476
3060
|
radius: 0
|
|
2477
3061
|
};
|
|
2478
3062
|
return detail;
|
|
2479
3063
|
}
|
|
2480
|
-
function getDefaultElementTextDetail(
|
|
2481
|
-
var _a;
|
|
3064
|
+
function getDefaultElementTextDetail(elementSize) {
|
|
2482
3065
|
const detailConfig = getDefaultElementDetailConfig();
|
|
2483
|
-
const scale = ((_a = opts == null ? void 0 : opts.viewScaleInfo) == null ? void 0 : _a.scale) || 1;
|
|
2484
3066
|
const detail = {
|
|
2485
|
-
text:
|
|
3067
|
+
text: defaultText,
|
|
2486
3068
|
color: detailConfig.color,
|
|
2487
3069
|
fontFamily: detailConfig.fontFamily,
|
|
2488
3070
|
fontWeight: detailConfig.fontWeight,
|
|
2489
|
-
lineHeight:
|
|
2490
|
-
fontSize:
|
|
3071
|
+
lineHeight: elementSize.w / defaultText.length,
|
|
3072
|
+
fontSize: elementSize.w / defaultText.length,
|
|
2491
3073
|
textAlign: "center",
|
|
2492
3074
|
verticalAlign: "middle"
|
|
2493
3075
|
};
|
|
@@ -2505,7 +3087,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2505
3087
|
};
|
|
2506
3088
|
return detail;
|
|
2507
3089
|
}
|
|
2508
|
-
function getDefaultElementGroupDetail(
|
|
3090
|
+
function getDefaultElementGroupDetail() {
|
|
2509
3091
|
const detail = {
|
|
2510
3092
|
children: [],
|
|
2511
3093
|
background: "#D9D9D9",
|
|
@@ -2518,8 +3100,10 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2518
3100
|
const { viewScaleInfo } = opts;
|
|
2519
3101
|
const { scale } = viewScaleInfo;
|
|
2520
3102
|
let { borderRadius: borderRadius2 } = viewElem.detail;
|
|
3103
|
+
const { borderDash } = viewElem.detail;
|
|
3104
|
+
const hasBorderDash = Array.isArray(borderDash) && borderDash.length > 0;
|
|
2521
3105
|
const { boxSizing = defaultElemConfig.boxSizing, borderWidth: borderWidth2 } = viewElem.detail;
|
|
2522
|
-
if (
|
|
3106
|
+
if (Array.isArray(borderWidth2)) {
|
|
2523
3107
|
borderRadius2 = 0;
|
|
2524
3108
|
}
|
|
2525
3109
|
let { x: x2, y: y2, w: w2, h: h2 } = viewElem;
|
|
@@ -2534,7 +3118,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2534
3118
|
if (typeof borderWidth2 === "number") {
|
|
2535
3119
|
bw = (borderWidth2 || 0) * scale;
|
|
2536
3120
|
}
|
|
2537
|
-
if (boxSizing === "border-box") {
|
|
3121
|
+
if (boxSizing === "border-box" && !hasBorderDash) {
|
|
2538
3122
|
x2 = viewElem.x + bw / 2;
|
|
2539
3123
|
y2 = viewElem.y + bw / 2;
|
|
2540
3124
|
w2 = viewElem.w - bw;
|
|
@@ -2563,9 +3147,100 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2563
3147
|
radiusList
|
|
2564
3148
|
};
|
|
2565
3149
|
}
|
|
3150
|
+
const doNum = (n) => {
|
|
3151
|
+
return formatNumber(n, { decimalPlaces: 4 });
|
|
3152
|
+
};
|
|
3153
|
+
function resizeElementBaseDetail(elem, opts) {
|
|
3154
|
+
const { detail } = elem;
|
|
3155
|
+
const { xRatio, yRatio, maxRatio } = opts;
|
|
3156
|
+
const middleRatio = (xRatio + yRatio) / 2;
|
|
3157
|
+
const { borderWidth: borderWidth2, borderRadius: borderRadius2, borderDash, shadowOffsetX, shadowOffsetY, shadowBlur } = detail;
|
|
3158
|
+
if (typeof borderWidth2 === "number") {
|
|
3159
|
+
detail.borderWidth = doNum(borderWidth2 * middleRatio);
|
|
3160
|
+
} else if (Array.isArray(detail.borderWidth)) {
|
|
3161
|
+
const bw = borderWidth2;
|
|
3162
|
+
detail.borderWidth = [doNum(bw[0] * yRatio), doNum(bw[1] * xRatio), doNum(bw[2] * yRatio), doNum(bw[3] * xRatio)];
|
|
3163
|
+
}
|
|
3164
|
+
if (typeof borderRadius2 === "number") {
|
|
3165
|
+
detail.borderRadius = doNum(borderRadius2 * middleRatio);
|
|
3166
|
+
} else if (Array.isArray(detail.borderRadius)) {
|
|
3167
|
+
const br = borderRadius2;
|
|
3168
|
+
detail.borderRadius = [br[0] * xRatio, br[1] * xRatio, br[2] * yRatio, br[3] * yRatio];
|
|
3169
|
+
}
|
|
3170
|
+
if (Array.isArray(borderDash)) {
|
|
3171
|
+
borderDash.forEach((dash, i) => {
|
|
3172
|
+
detail.borderDash[i] = doNum(dash * maxRatio);
|
|
3173
|
+
});
|
|
3174
|
+
}
|
|
3175
|
+
if (typeof shadowOffsetX === "number") {
|
|
3176
|
+
detail.shadowOffsetX = doNum(shadowOffsetX * maxRatio);
|
|
3177
|
+
}
|
|
3178
|
+
if (typeof shadowOffsetY === "number") {
|
|
3179
|
+
detail.shadowOffsetX = doNum(shadowOffsetY * maxRatio);
|
|
3180
|
+
}
|
|
3181
|
+
if (typeof shadowBlur === "number") {
|
|
3182
|
+
detail.shadowOffsetX = doNum(shadowBlur * maxRatio);
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
function resizeElementBase(elem, opts) {
|
|
3186
|
+
const { xRatio, yRatio } = opts;
|
|
3187
|
+
const { x: x2, y: y2, w: w2, h: h2 } = elem;
|
|
3188
|
+
elem.x = doNum(x2 * xRatio);
|
|
3189
|
+
elem.y = doNum(y2 * yRatio);
|
|
3190
|
+
elem.w = doNum(w2 * xRatio);
|
|
3191
|
+
elem.h = doNum(h2 * yRatio);
|
|
3192
|
+
resizeElementBaseDetail(elem, opts);
|
|
3193
|
+
}
|
|
3194
|
+
function resizeTextElementDetail(elem, opts) {
|
|
3195
|
+
const { minRatio, maxRatio } = opts;
|
|
3196
|
+
const { fontSize: fontSize2, lineHeight: lineHeight2 } = elem.detail;
|
|
3197
|
+
const ratio = (minRatio + maxRatio) / 2;
|
|
3198
|
+
if (fontSize2 && fontSize2 > 0) {
|
|
3199
|
+
elem.detail.fontSize = doNum(fontSize2 * ratio);
|
|
3200
|
+
}
|
|
3201
|
+
if (lineHeight2 && lineHeight2 > 0) {
|
|
3202
|
+
elem.detail.lineHeight = doNum(lineHeight2 * ratio);
|
|
3203
|
+
}
|
|
3204
|
+
}
|
|
3205
|
+
function resizeElement(elem, opts) {
|
|
3206
|
+
const { type } = elem;
|
|
3207
|
+
resizeElementBase(elem, opts);
|
|
3208
|
+
if (type === "circle") ;
|
|
3209
|
+
else if (type === "text") {
|
|
3210
|
+
resizeTextElementDetail(elem, opts);
|
|
3211
|
+
} else if (type === "image") ;
|
|
3212
|
+
else if (type === "svg") ;
|
|
3213
|
+
else if (type === "html") ;
|
|
3214
|
+
else if (type === "path") ;
|
|
3215
|
+
else if (type === "group" && Array.isArray(elem.detail.children)) {
|
|
3216
|
+
elem.detail.children.forEach((child) => {
|
|
3217
|
+
resizeElement(child, opts);
|
|
3218
|
+
});
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
function deepResizeGroupElement(elem, size) {
|
|
3222
|
+
const resizeW = size.w && size.w > 0 ? size.w : elem.w;
|
|
3223
|
+
const resizeH = size.h && size.h > 0 ? size.h : elem.h;
|
|
3224
|
+
const xRatio = resizeW / elem.w;
|
|
3225
|
+
const yRatio = resizeH / elem.h;
|
|
3226
|
+
if (xRatio === yRatio && xRatio === 1) {
|
|
3227
|
+
return elem;
|
|
3228
|
+
}
|
|
3229
|
+
const minRatio = Math.min(xRatio, yRatio);
|
|
3230
|
+
const maxRatio = Math.max(xRatio, yRatio);
|
|
3231
|
+
elem.w = resizeW;
|
|
3232
|
+
elem.h = resizeH;
|
|
3233
|
+
const opts = { xRatio, yRatio, minRatio, maxRatio };
|
|
3234
|
+
if (elem.type === "group" && Array.isArray(elem.detail.children)) {
|
|
3235
|
+
elem.detail.children.forEach((child) => {
|
|
3236
|
+
resizeElement(child, opts);
|
|
3237
|
+
});
|
|
3238
|
+
}
|
|
3239
|
+
resizeElementBaseDetail(elem, opts);
|
|
3240
|
+
return elem;
|
|
3241
|
+
}
|
|
2566
3242
|
const defaultViewWidth = 200;
|
|
2567
3243
|
const defaultViewHeight = 200;
|
|
2568
|
-
const defaultDetail = getDefaultElementDetailConfig();
|
|
2569
3244
|
function createElementSize(type, opts) {
|
|
2570
3245
|
let x2 = 0;
|
|
2571
3246
|
let y2 = 0;
|
|
@@ -2575,26 +3250,23 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2575
3250
|
const { viewScaleInfo, viewSizeInfo } = opts;
|
|
2576
3251
|
const { scale, offsetLeft, offsetTop } = viewScaleInfo;
|
|
2577
3252
|
const { width, height } = viewSizeInfo;
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
3253
|
+
const limitViewWidth = width / 4;
|
|
3254
|
+
const limitViewHeight = height / 4;
|
|
3255
|
+
if (defaultViewWidth >= limitViewWidth) {
|
|
3256
|
+
w2 = limitViewWidth / scale;
|
|
2582
3257
|
} else {
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
if (["circle", "svg", "image"].includes(type)) {
|
|
2596
|
-
w2 = h2 = Math.max(w2, h2);
|
|
2597
|
-
}
|
|
3258
|
+
w2 = defaultViewWidth / scale;
|
|
3259
|
+
}
|
|
3260
|
+
if (defaultViewHeight >= limitViewHeight) {
|
|
3261
|
+
h2 = limitViewHeight / scale;
|
|
3262
|
+
} else {
|
|
3263
|
+
h2 = defaultViewHeight / scale;
|
|
3264
|
+
}
|
|
3265
|
+
if (["circle", "svg", "image"].includes(type)) {
|
|
3266
|
+
w2 = h2 = Math.max(w2, h2);
|
|
3267
|
+
} else if (type === "text") {
|
|
3268
|
+
const fontSize2 = w2 / defaultText.length;
|
|
3269
|
+
h2 = fontSize2 * 2;
|
|
2598
3270
|
}
|
|
2599
3271
|
x2 = (0 - offsetLeft + width / 2 - w2 * scale / 2) / scale;
|
|
2600
3272
|
y2 = (0 - offsetTop + height / 2 - h2 * scale / 2) / scale;
|
|
@@ -2608,16 +3280,14 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2608
3280
|
return elemSize;
|
|
2609
3281
|
}
|
|
2610
3282
|
function createElement(type, baseElem, opts) {
|
|
2611
|
-
const
|
|
3283
|
+
const elementSize = createElementSize(type, opts);
|
|
2612
3284
|
let detail = {};
|
|
2613
3285
|
if (type === "rect") {
|
|
2614
3286
|
detail = getDefaultElementRectDetail();
|
|
2615
3287
|
} else if (type === "circle") {
|
|
2616
|
-
detail = getDefaultElementCircleDetail(
|
|
2617
|
-
radius: elemSize.w
|
|
2618
|
-
});
|
|
3288
|
+
detail = getDefaultElementCircleDetail();
|
|
2619
3289
|
} else if (type === "text") {
|
|
2620
|
-
detail = getDefaultElementTextDetail(
|
|
3290
|
+
detail = getDefaultElementTextDetail(elementSize);
|
|
2621
3291
|
} else if (type === "svg") {
|
|
2622
3292
|
detail = getDefaultElementSVGDetail();
|
|
2623
3293
|
} else if (type === "image") {
|
|
@@ -2626,7 +3296,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2626
3296
|
detail = getDefaultElementGroupDetail();
|
|
2627
3297
|
}
|
|
2628
3298
|
const elem = {
|
|
2629
|
-
...
|
|
3299
|
+
...elementSize,
|
|
2630
3300
|
...baseElem,
|
|
2631
3301
|
uuid: createUUID(),
|
|
2632
3302
|
type,
|
|
@@ -2690,15 +3360,16 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2690
3360
|
return deleteElementInListByPosition(position, list);
|
|
2691
3361
|
}
|
|
2692
3362
|
function moveElementPosition(elements, opts) {
|
|
2693
|
-
const
|
|
3363
|
+
const from = [...opts.from];
|
|
3364
|
+
const to = [...opts.to];
|
|
2694
3365
|
if (from.length === 0 || to.length === 0) {
|
|
2695
|
-
return elements;
|
|
3366
|
+
return { elements, from, to };
|
|
2696
3367
|
}
|
|
2697
3368
|
if (from.length <= to.length) {
|
|
2698
3369
|
for (let i = 0; i < from.length; i++) {
|
|
2699
3370
|
if (to[i] === from[i]) {
|
|
2700
3371
|
if (i === from.length - 1) {
|
|
2701
|
-
return elements;
|
|
3372
|
+
return { elements, from, to };
|
|
2702
3373
|
}
|
|
2703
3374
|
continue;
|
|
2704
3375
|
}
|
|
@@ -2708,18 +3379,59 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2708
3379
|
if (target) {
|
|
2709
3380
|
const insterResult = insertElementToListByPosition(target, to, elements);
|
|
2710
3381
|
if (!insterResult) {
|
|
2711
|
-
return elements;
|
|
3382
|
+
return { elements, from, to };
|
|
2712
3383
|
}
|
|
2713
3384
|
let trimDeletePosIndex = -1;
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
3385
|
+
let isEffectToIndex = false;
|
|
3386
|
+
if (from.length >= 1 && to.length >= 1) {
|
|
3387
|
+
if (from.length <= to.length) {
|
|
3388
|
+
if (from.length === 1) {
|
|
3389
|
+
if (from[0] < to[0]) {
|
|
3390
|
+
isEffectToIndex = true;
|
|
3391
|
+
}
|
|
3392
|
+
} else {
|
|
3393
|
+
for (let i = 0; i < from.length; i++) {
|
|
3394
|
+
if (from[i] === to[i]) {
|
|
3395
|
+
if (from.length === from.length - 1) {
|
|
3396
|
+
isEffectToIndex = true;
|
|
3397
|
+
break;
|
|
3398
|
+
}
|
|
3399
|
+
} else {
|
|
3400
|
+
break;
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
2717
3404
|
}
|
|
2718
|
-
if (
|
|
2719
|
-
|
|
3405
|
+
if (from.length >= to.length) {
|
|
3406
|
+
if (to.length === 1) {
|
|
3407
|
+
if (to[0] < from[0]) {
|
|
3408
|
+
isEffectToIndex = true;
|
|
3409
|
+
}
|
|
3410
|
+
} else {
|
|
3411
|
+
for (let i = 0; i < to.length; i++) {
|
|
3412
|
+
if (i === to.length - 1 && to[i] < from[i]) {
|
|
3413
|
+
isEffectToIndex = true;
|
|
3414
|
+
}
|
|
3415
|
+
if (from[i] === to[i]) {
|
|
3416
|
+
continue;
|
|
3417
|
+
} else {
|
|
3418
|
+
break;
|
|
3419
|
+
}
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
2720
3422
|
}
|
|
2721
|
-
|
|
2722
|
-
|
|
3423
|
+
}
|
|
3424
|
+
if (isEffectToIndex === true) {
|
|
3425
|
+
for (let i = 0; i < from.length; i++) {
|
|
3426
|
+
if (!(to[i] >= 0)) {
|
|
3427
|
+
break;
|
|
3428
|
+
}
|
|
3429
|
+
if (to[i] === from[i]) {
|
|
3430
|
+
continue;
|
|
3431
|
+
}
|
|
3432
|
+
if (to[i] < from[i] && i == to.length - 1) {
|
|
3433
|
+
trimDeletePosIndex = i;
|
|
3434
|
+
}
|
|
2723
3435
|
}
|
|
2724
3436
|
}
|
|
2725
3437
|
if (trimDeletePosIndex >= 0) {
|
|
@@ -2729,7 +3441,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2729
3441
|
}
|
|
2730
3442
|
deleteElementInListByPosition(from, elements);
|
|
2731
3443
|
}
|
|
2732
|
-
return elements;
|
|
3444
|
+
return { elements, from, to };
|
|
2733
3445
|
}
|
|
2734
3446
|
function mergeElement(originElem, updateContent) {
|
|
2735
3447
|
var _a;
|
|
@@ -2762,20 +3474,637 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2762
3474
|
return originElem;
|
|
2763
3475
|
}
|
|
2764
3476
|
function updateElementInList(uuid, updateContent, elements) {
|
|
2765
|
-
var _a;
|
|
3477
|
+
var _a, _b;
|
|
2766
3478
|
let targetElement = null;
|
|
2767
3479
|
for (let i = 0; i < elements.length; i++) {
|
|
2768
3480
|
const elem = elements[i];
|
|
2769
3481
|
if (elem.uuid === uuid) {
|
|
3482
|
+
if (elem.type === "group" && ((_a = elem.operations) == null ? void 0 : _a.deepResize) === true) {
|
|
3483
|
+
if (updateContent.w && updateContent.w > 0 || updateContent.h && updateContent.h > 0) {
|
|
3484
|
+
deepResizeGroupElement(elem, {
|
|
3485
|
+
w: updateContent.w,
|
|
3486
|
+
h: updateContent.h
|
|
3487
|
+
});
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
2770
3490
|
mergeElement(elem, updateContent);
|
|
2771
3491
|
targetElement = elem;
|
|
2772
3492
|
break;
|
|
2773
3493
|
} else if (elem.type === "group") {
|
|
2774
|
-
targetElement = updateElementInList(uuid, updateContent, ((
|
|
3494
|
+
targetElement = updateElementInList(uuid, updateContent, ((_b = elem == null ? void 0 : elem.detail) == null ? void 0 : _b.children) || []);
|
|
2775
3495
|
}
|
|
2776
3496
|
}
|
|
2777
3497
|
return targetElement;
|
|
2778
3498
|
}
|
|
3499
|
+
function updateElementInListByPosition(position, updateContent, elements) {
|
|
3500
|
+
var _a;
|
|
3501
|
+
const elem = findElementFromListByPosition(position, elements);
|
|
3502
|
+
if (elem) {
|
|
3503
|
+
if (elem.type === "group" && ((_a = elem.operations) == null ? void 0 : _a.deepResize) === true) {
|
|
3504
|
+
if (updateContent.w && updateContent.w > 0 || updateContent.h && updateContent.h > 0) {
|
|
3505
|
+
deepResizeGroupElement(elem, {
|
|
3506
|
+
w: updateContent.w,
|
|
3507
|
+
h: updateContent.h
|
|
3508
|
+
});
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
mergeElement(elem, updateContent);
|
|
3512
|
+
}
|
|
3513
|
+
return elem;
|
|
3514
|
+
}
|
|
3515
|
+
function calcViewCenterContent(data, opts) {
|
|
3516
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3517
|
+
let offsetX = 0;
|
|
3518
|
+
let offsetY = 0;
|
|
3519
|
+
let scale = 1;
|
|
3520
|
+
let contentX = ((_b = (_a = data == null ? void 0 : data.elements) == null ? void 0 : _a[0]) == null ? void 0 : _b.x) || 0;
|
|
3521
|
+
let contentY = ((_d = (_c = data == null ? void 0 : data.elements) == null ? void 0 : _c[0]) == null ? void 0 : _d.y) || 0;
|
|
3522
|
+
let contentW = ((_f = (_e = data == null ? void 0 : data.elements) == null ? void 0 : _e[0]) == null ? void 0 : _f.w) || 0;
|
|
3523
|
+
let contentH = ((_h = (_g = data == null ? void 0 : data.elements) == null ? void 0 : _g[0]) == null ? void 0 : _h.h) || 0;
|
|
3524
|
+
const { width, height } = opts.viewSizeInfo;
|
|
3525
|
+
if (data.layout && ((_j = (_i = data.layout) == null ? void 0 : _i.detail) == null ? void 0 : _j.overflow) === "hidden") {
|
|
3526
|
+
contentX = 0;
|
|
3527
|
+
contentY = 0;
|
|
3528
|
+
contentW = data.layout.w || 0;
|
|
3529
|
+
contentH = data.layout.h || 0;
|
|
3530
|
+
} else {
|
|
3531
|
+
data.elements.forEach((elem) => {
|
|
3532
|
+
const elemSize = {
|
|
3533
|
+
x: elem.x,
|
|
3534
|
+
y: elem.y,
|
|
3535
|
+
w: elem.w,
|
|
3536
|
+
h: elem.h,
|
|
3537
|
+
angle: elem.angle
|
|
3538
|
+
};
|
|
3539
|
+
if (elemSize.angle && (elemSize.angle > 0 || elemSize.angle < 0)) {
|
|
3540
|
+
const ves = rotateElementVertexes(elemSize);
|
|
3541
|
+
if (ves.length === 4) {
|
|
3542
|
+
const xList = [ves[0].x, ves[1].x, ves[2].x, ves[3].x];
|
|
3543
|
+
const yList = [ves[0].y, ves[1].y, ves[2].y, ves[3].y];
|
|
3544
|
+
elemSize.x = Math.min(...xList);
|
|
3545
|
+
elemSize.y = Math.min(...yList);
|
|
3546
|
+
elemSize.w = Math.abs(Math.max(...xList) - Math.min(...xList));
|
|
3547
|
+
elemSize.h = Math.abs(Math.max(...yList) - Math.min(...yList));
|
|
3548
|
+
}
|
|
3549
|
+
}
|
|
3550
|
+
const areaStartX = Math.min(elemSize.x, contentX);
|
|
3551
|
+
const areaStartY = Math.min(elemSize.y, contentY);
|
|
3552
|
+
const areaEndX = Math.max(elemSize.x + elemSize.w, contentX + contentW);
|
|
3553
|
+
const areaEndY = Math.max(elemSize.y + elemSize.h, contentY + contentH);
|
|
3554
|
+
contentX = areaStartX;
|
|
3555
|
+
contentY = areaStartY;
|
|
3556
|
+
contentW = Math.abs(areaEndX - areaStartX);
|
|
3557
|
+
contentH = Math.abs(areaEndY - areaStartY);
|
|
3558
|
+
});
|
|
3559
|
+
}
|
|
3560
|
+
if (data.layout) {
|
|
3561
|
+
const { x: x2, y: y2, w: w2, h: h2 } = data.layout;
|
|
3562
|
+
if (is.x(x2) && is.y(y2) && is.w(w2) && is.h(h2)) {
|
|
3563
|
+
contentX = Math.min(contentX, x2);
|
|
3564
|
+
contentY = Math.min(contentY, y2);
|
|
3565
|
+
contentW = Math.max(contentW, w2);
|
|
3566
|
+
contentH = Math.max(contentH, h2);
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
if (contentW > 0 && contentH > 0) {
|
|
3570
|
+
const scaleW = formatNumber(width / contentW, { decimalPlaces: 4 });
|
|
3571
|
+
const scaleH = formatNumber(height / contentH, { decimalPlaces: 4 });
|
|
3572
|
+
scale = Math.min(scaleW, scaleH, 1);
|
|
3573
|
+
offsetX = (contentW * scale - width) / 2 / scale + contentX;
|
|
3574
|
+
offsetY = (contentH * scale - height) / 2 / scale + contentY;
|
|
3575
|
+
}
|
|
3576
|
+
const result = {
|
|
3577
|
+
offsetX: formatNumber(offsetX, { decimalPlaces: 0 }),
|
|
3578
|
+
offsetY: formatNumber(offsetY, { decimalPlaces: 0 }),
|
|
3579
|
+
scale
|
|
3580
|
+
};
|
|
3581
|
+
return result;
|
|
3582
|
+
}
|
|
3583
|
+
function calcViewCenter(opts) {
|
|
3584
|
+
let x2 = 0;
|
|
3585
|
+
let y2 = 0;
|
|
3586
|
+
if (opts) {
|
|
3587
|
+
const { viewScaleInfo, viewSizeInfo } = opts;
|
|
3588
|
+
const { offsetLeft, offsetTop, scale } = viewScaleInfo;
|
|
3589
|
+
const { width, height } = viewSizeInfo;
|
|
3590
|
+
x2 = 0 - offsetLeft + width / scale / 2;
|
|
3591
|
+
y2 = 0 - offsetTop + height / scale / 2;
|
|
3592
|
+
}
|
|
3593
|
+
const p = {
|
|
3594
|
+
x: x2,
|
|
3595
|
+
y: y2
|
|
3596
|
+
};
|
|
3597
|
+
return p;
|
|
3598
|
+
}
|
|
3599
|
+
function modifyElement(data, options) {
|
|
3600
|
+
const { type } = options;
|
|
3601
|
+
const content = { ...options.content };
|
|
3602
|
+
if (type === "addElement") {
|
|
3603
|
+
const opts = options;
|
|
3604
|
+
const { element, position } = opts.content;
|
|
3605
|
+
if ((position == null ? void 0 : position.length) > 0) {
|
|
3606
|
+
insertElementToListByPosition(element, [...position], data.elements);
|
|
3607
|
+
} else {
|
|
3608
|
+
data.elements.push(element);
|
|
3609
|
+
}
|
|
3610
|
+
} else if (type === "deleteElement") {
|
|
3611
|
+
const opts = options;
|
|
3612
|
+
const { position } = opts.content;
|
|
3613
|
+
deleteElementInListByPosition(position, data.elements);
|
|
3614
|
+
} else if (type === "moveElement") {
|
|
3615
|
+
const opts = options;
|
|
3616
|
+
const { from, to } = opts.content;
|
|
3617
|
+
const movedResult = moveElementPosition(data.elements, { from, to });
|
|
3618
|
+
content.from = movedResult.from;
|
|
3619
|
+
content.to = movedResult.to;
|
|
3620
|
+
data.elements = movedResult.elements;
|
|
3621
|
+
} else if (type === "updateElement") {
|
|
3622
|
+
const opts = options;
|
|
3623
|
+
const { position, afterModifiedElement } = opts.content;
|
|
3624
|
+
updateElementInListByPosition(position, afterModifiedElement, data.elements);
|
|
3625
|
+
}
|
|
3626
|
+
return { data, content };
|
|
3627
|
+
}
|
|
3628
|
+
function _get(source, path, defaultValue = void 0) {
|
|
3629
|
+
const keyList = path.split(".");
|
|
3630
|
+
const result = keyList.reduce((obj, key) => {
|
|
3631
|
+
return Object(obj)[key];
|
|
3632
|
+
}, source);
|
|
3633
|
+
return result === void 0 ? defaultValue : result;
|
|
3634
|
+
}
|
|
3635
|
+
function _set(obj, path, value) {
|
|
3636
|
+
const keys = path.split(".");
|
|
3637
|
+
if (typeof obj !== "object") return obj;
|
|
3638
|
+
keys.reduce((o, k, i, _) => {
|
|
3639
|
+
if (i === _.length - 1) {
|
|
3640
|
+
o[k] = value;
|
|
3641
|
+
return null;
|
|
3642
|
+
} else if (k in o) {
|
|
3643
|
+
return o[k];
|
|
3644
|
+
} else {
|
|
3645
|
+
o[k] = /^[0-9]{1,}$/.test(_[i + 1]) ? [] : {};
|
|
3646
|
+
return o[k];
|
|
3647
|
+
}
|
|
3648
|
+
}, obj);
|
|
3649
|
+
return obj;
|
|
3650
|
+
}
|
|
3651
|
+
function getModifiedElement(target, originElement) {
|
|
3652
|
+
const modifiedElement = {};
|
|
3653
|
+
const pathList = [];
|
|
3654
|
+
const _walk = (t) => {
|
|
3655
|
+
if (istype.json(t)) {
|
|
3656
|
+
const keys = Object.keys(t);
|
|
3657
|
+
keys.forEach((key) => {
|
|
3658
|
+
pathList.push(key);
|
|
3659
|
+
if (istype.json(t[key]) || istype.array(t[key])) {
|
|
3660
|
+
_walk(t[key]);
|
|
3661
|
+
} else {
|
|
3662
|
+
const pathStr = pathList.join(".");
|
|
3663
|
+
if (pathStr !== "uuid") {
|
|
3664
|
+
const value = _get(originElement, pathStr);
|
|
3665
|
+
_set(modifiedElement, pathList.join("."), value);
|
|
3666
|
+
}
|
|
3667
|
+
}
|
|
3668
|
+
pathList.pop();
|
|
3669
|
+
});
|
|
3670
|
+
} else if (istype.array(t)) {
|
|
3671
|
+
t.forEach((index) => {
|
|
3672
|
+
pathList.push(index);
|
|
3673
|
+
if (istype.json(t[index]) || istype.array(t[index])) {
|
|
3674
|
+
_walk(t[index]);
|
|
3675
|
+
} else {
|
|
3676
|
+
const value = _get(originElement, pathList.join("."));
|
|
3677
|
+
_set(modifiedElement, pathList.join("."), value);
|
|
3678
|
+
}
|
|
3679
|
+
pathList.pop();
|
|
3680
|
+
});
|
|
3681
|
+
}
|
|
3682
|
+
};
|
|
3683
|
+
_walk(target);
|
|
3684
|
+
return modifiedElement;
|
|
3685
|
+
}
|
|
3686
|
+
const baseFontFamilyList = ["-apple-system", '"system-ui"', ' "Segoe UI"', " Roboto", '"Helvetica Neue"', "Arial", '"Noto Sans"', " sans-serif"];
|
|
3687
|
+
function enhanceFontFamliy(fontFamily2) {
|
|
3688
|
+
return [fontFamily2, ...baseFontFamilyList].join(", ");
|
|
3689
|
+
}
|
|
3690
|
+
function flatElementSize(elemSize, opts) {
|
|
3691
|
+
const { groupQueue } = opts;
|
|
3692
|
+
let { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemSize;
|
|
3693
|
+
let totalAngle = 0;
|
|
3694
|
+
groupQueue.forEach((group) => {
|
|
3695
|
+
x2 += group.x;
|
|
3696
|
+
y2 += group.y;
|
|
3697
|
+
totalAngle += group.angle || 0;
|
|
3698
|
+
});
|
|
3699
|
+
totalAngle = limitAngle(totalAngle);
|
|
3700
|
+
if (totalAngle === 0) {
|
|
3701
|
+
return {
|
|
3702
|
+
x: x2,
|
|
3703
|
+
y: y2,
|
|
3704
|
+
w: w2,
|
|
3705
|
+
h: h2,
|
|
3706
|
+
angle: angle2
|
|
3707
|
+
};
|
|
3708
|
+
}
|
|
3709
|
+
totalAngle += elemSize.angle || 0;
|
|
3710
|
+
totalAngle = limitAngle(totalAngle);
|
|
3711
|
+
const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
|
|
3712
|
+
const center = calcElementCenterFromVertexes(vertexes);
|
|
3713
|
+
const start = rotatePoint(center, vertexes[0], parseAngleToRadian(0 - totalAngle));
|
|
3714
|
+
x2 = start.x;
|
|
3715
|
+
y2 = start.y;
|
|
3716
|
+
return {
|
|
3717
|
+
x: x2,
|
|
3718
|
+
y: y2,
|
|
3719
|
+
w: w2,
|
|
3720
|
+
h: h2,
|
|
3721
|
+
angle: totalAngle
|
|
3722
|
+
};
|
|
3723
|
+
}
|
|
3724
|
+
function isValidElement(elem) {
|
|
3725
|
+
var _a;
|
|
3726
|
+
if (["rect", "circle"].includes(elem.type)) {
|
|
3727
|
+
const detail = elem.detail;
|
|
3728
|
+
if (!detail.background && !detail.borderWidth) {
|
|
3729
|
+
return false;
|
|
3730
|
+
}
|
|
3731
|
+
if (detail.background === "transparent" && !detail.borderWidth) {
|
|
3732
|
+
return false;
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3735
|
+
if (["group"].includes(elem.type)) {
|
|
3736
|
+
const detail = elem.detail || {};
|
|
3737
|
+
const { children } = detail;
|
|
3738
|
+
if (!(children.length > 0) && !detail.background && !detail.borderWidth) {
|
|
3739
|
+
return false;
|
|
3740
|
+
}
|
|
3741
|
+
if (!(children.length > 0) && detail.background === "transparent" && !detail.borderWidth) {
|
|
3742
|
+
return false;
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
if (elem.type === "text") {
|
|
3746
|
+
if (!elem.detail.text) {
|
|
3747
|
+
return false;
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
if (elem.type === "image") {
|
|
3751
|
+
if (!elem.detail.src) {
|
|
3752
|
+
return false;
|
|
3753
|
+
}
|
|
3754
|
+
}
|
|
3755
|
+
if (elem.type === "html") {
|
|
3756
|
+
if (!elem.detail.html) {
|
|
3757
|
+
return false;
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
if (elem.type === "svg") {
|
|
3761
|
+
if (!elem.detail.svg) {
|
|
3762
|
+
return false;
|
|
3763
|
+
}
|
|
3764
|
+
}
|
|
3765
|
+
if (elem.type === "path") {
|
|
3766
|
+
const detail = elem.detail;
|
|
3767
|
+
if (!(((_a = detail == null ? void 0 : detail.commands) == null ? void 0 : _a.length) > 0)) {
|
|
3768
|
+
return false;
|
|
3769
|
+
}
|
|
3770
|
+
}
|
|
3771
|
+
return true;
|
|
3772
|
+
}
|
|
3773
|
+
function flatElementList(list) {
|
|
3774
|
+
const elemeList = [];
|
|
3775
|
+
const currentGroupQueue = [];
|
|
3776
|
+
const _resetElemSize = (elem) => {
|
|
3777
|
+
if (!isValidElement(elem)) {
|
|
3778
|
+
return;
|
|
3779
|
+
}
|
|
3780
|
+
const newSize = flatElementSize(elem, { groupQueue: currentGroupQueue });
|
|
3781
|
+
const resizeElem = {
|
|
3782
|
+
...elem,
|
|
3783
|
+
...newSize
|
|
3784
|
+
};
|
|
3785
|
+
elemeList.push(resizeElem);
|
|
3786
|
+
};
|
|
3787
|
+
const _walk = (elem) => {
|
|
3788
|
+
var _a;
|
|
3789
|
+
if (((_a = elem == null ? void 0 : elem.operations) == null ? void 0 : _a.invisible) === true) {
|
|
3790
|
+
return;
|
|
3791
|
+
}
|
|
3792
|
+
if (elem.type === "group") {
|
|
3793
|
+
const { detail } = elem;
|
|
3794
|
+
const { children, ...restDetail } = detail;
|
|
3795
|
+
_resetElemSize({ ...elem, ...{ detail: { ...restDetail, children: [] } } });
|
|
3796
|
+
currentGroupQueue.push(elem);
|
|
3797
|
+
children.forEach((child) => {
|
|
3798
|
+
_walk(child);
|
|
3799
|
+
});
|
|
3800
|
+
currentGroupQueue.pop();
|
|
3801
|
+
} else {
|
|
3802
|
+
_resetElemSize(elem);
|
|
3803
|
+
}
|
|
3804
|
+
};
|
|
3805
|
+
for (let i = 0; i < list.length; i++) {
|
|
3806
|
+
const elem = list[i];
|
|
3807
|
+
_walk(elem);
|
|
3808
|
+
}
|
|
3809
|
+
return elemeList;
|
|
3810
|
+
}
|
|
3811
|
+
function groupElementsByPosition(list, positions) {
|
|
3812
|
+
if (positions.length > 1) {
|
|
3813
|
+
let isValidPositions = true;
|
|
3814
|
+
let lastIndexs = [];
|
|
3815
|
+
for (let i = 1; i < positions.length; i++) {
|
|
3816
|
+
const prevPosition = positions[i - 1];
|
|
3817
|
+
const position = positions[i];
|
|
3818
|
+
if (!(prevPosition.length > 0 && position.length > 0)) {
|
|
3819
|
+
isValidPositions = false;
|
|
3820
|
+
break;
|
|
3821
|
+
}
|
|
3822
|
+
if (prevPosition.length !== position.length) {
|
|
3823
|
+
isValidPositions = false;
|
|
3824
|
+
break;
|
|
3825
|
+
}
|
|
3826
|
+
const temp1 = [...prevPosition];
|
|
3827
|
+
const temp2 = [...position];
|
|
3828
|
+
const lastIndex1 = temp1.pop();
|
|
3829
|
+
const lastIndex2 = temp2.pop();
|
|
3830
|
+
if (i === 1 && typeof lastIndex1 === "number" && lastIndex1 >= 0) {
|
|
3831
|
+
lastIndexs.push(lastIndex1);
|
|
3832
|
+
}
|
|
3833
|
+
if (typeof lastIndex2 === "number" && lastIndex2 >= 0) {
|
|
3834
|
+
lastIndexs.push(lastIndex2);
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3837
|
+
if (isValidPositions !== true) {
|
|
3838
|
+
console.error("[idraw]: The grouped elements are not siblings!");
|
|
3839
|
+
return list;
|
|
3840
|
+
}
|
|
3841
|
+
lastIndexs.sort((a, b) => a - b);
|
|
3842
|
+
const groupParentPosition = [...positions[0]].splice(0, positions[0].length - 1);
|
|
3843
|
+
const groupChildren = [];
|
|
3844
|
+
const groupPosition = [...groupParentPosition, lastIndexs[0]];
|
|
3845
|
+
for (let i = 0; i < lastIndexs.length; i++) {
|
|
3846
|
+
const position = [...groupParentPosition, lastIndexs[i]];
|
|
3847
|
+
const elem = findElementFromListByPosition(position, list);
|
|
3848
|
+
if (elem) {
|
|
3849
|
+
groupChildren.push(elem);
|
|
3850
|
+
}
|
|
3851
|
+
}
|
|
3852
|
+
const groupSize = calcElementListSize(groupChildren);
|
|
3853
|
+
for (let i = 0; i < groupChildren.length; i++) {
|
|
3854
|
+
const elem = groupChildren[i];
|
|
3855
|
+
if (elem) {
|
|
3856
|
+
elem.x -= groupSize.x;
|
|
3857
|
+
elem.y -= groupSize.y;
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
for (let i = lastIndexs.length - 1; i >= 0; i--) {
|
|
3861
|
+
const position = [...groupParentPosition, lastIndexs[i]];
|
|
3862
|
+
deleteElementInListByPosition(position, list);
|
|
3863
|
+
}
|
|
3864
|
+
const group = {
|
|
3865
|
+
name: "Group",
|
|
3866
|
+
uuid: createUUID(),
|
|
3867
|
+
type: "group",
|
|
3868
|
+
...groupSize,
|
|
3869
|
+
detail: {
|
|
3870
|
+
children: groupChildren
|
|
3871
|
+
}
|
|
3872
|
+
};
|
|
3873
|
+
insertElementToListByPosition(group, groupPosition, list);
|
|
3874
|
+
}
|
|
3875
|
+
return list;
|
|
3876
|
+
}
|
|
3877
|
+
function ungroupElementsByPosition(list, position) {
|
|
3878
|
+
var _a;
|
|
3879
|
+
const elem = findElementFromListByPosition(position, list);
|
|
3880
|
+
if (!(elem && (elem == null ? void 0 : elem.type) === "group" && Array.isArray((_a = elem == null ? void 0 : elem.detail) == null ? void 0 : _a.children))) {
|
|
3881
|
+
console.error("[idraw]: The ungrouped element is not a group element!");
|
|
3882
|
+
}
|
|
3883
|
+
const groupParentPosition = [...position].splice(0, position.length - 1);
|
|
3884
|
+
const groupLastIndex = position[position.length - 1];
|
|
3885
|
+
const { x: x2, y: y2 } = elem;
|
|
3886
|
+
deleteElementInListByPosition(position, list);
|
|
3887
|
+
elem.detail.children.forEach((child, i) => {
|
|
3888
|
+
child.x += x2;
|
|
3889
|
+
child.y += y2;
|
|
3890
|
+
const elemPosition = [...groupParentPosition, groupLastIndex + i];
|
|
3891
|
+
insertElementToListByPosition(child, elemPosition, list);
|
|
3892
|
+
});
|
|
3893
|
+
return list;
|
|
3894
|
+
}
|
|
3895
|
+
function calcPointMoveElementInGroup(start, end, groupQueue) {
|
|
3896
|
+
let moveX = end.x - start.x;
|
|
3897
|
+
let moveY = end.y - start.y;
|
|
3898
|
+
const pointGroupQueue = [];
|
|
3899
|
+
groupQueue.forEach((group) => {
|
|
3900
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = group;
|
|
3901
|
+
pointGroupQueue.push({
|
|
3902
|
+
x: x2,
|
|
3903
|
+
y: y2,
|
|
3904
|
+
w: w2,
|
|
3905
|
+
h: h2,
|
|
3906
|
+
angle: 0 - angle2
|
|
3907
|
+
});
|
|
3908
|
+
});
|
|
3909
|
+
if ((groupQueue == null ? void 0 : groupQueue.length) > 0) {
|
|
3910
|
+
const startInGroup = rotatePointInGroup(start, pointGroupQueue);
|
|
3911
|
+
const endInGroup = rotatePointInGroup(end, pointGroupQueue);
|
|
3912
|
+
moveX = endInGroup.x - startInGroup.x;
|
|
3913
|
+
moveY = endInGroup.y - startInGroup.y;
|
|
3914
|
+
}
|
|
3915
|
+
return {
|
|
3916
|
+
moveX,
|
|
3917
|
+
moveY
|
|
3918
|
+
};
|
|
3919
|
+
}
|
|
3920
|
+
function merge(target, source) {
|
|
3921
|
+
const result = target;
|
|
3922
|
+
for (const key in source) {
|
|
3923
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
3924
|
+
if (typeof source[key] === "object" && source[key] !== null && typeof result[key] === "object" && result[key] !== null) {
|
|
3925
|
+
result[key] = merge(result[key], source[key]);
|
|
3926
|
+
} else {
|
|
3927
|
+
result[key] = source[key];
|
|
3928
|
+
}
|
|
3929
|
+
}
|
|
3930
|
+
}
|
|
3931
|
+
return target;
|
|
3932
|
+
}
|
|
3933
|
+
function omit(obj, keys) {
|
|
3934
|
+
const result = { ...obj };
|
|
3935
|
+
for (const key of keys) {
|
|
3936
|
+
delete result[key];
|
|
3937
|
+
}
|
|
3938
|
+
return result;
|
|
3939
|
+
}
|
|
3940
|
+
function elementToBoxInfo(elem) {
|
|
3941
|
+
const { x: x2, y: y2, w: w2, h: h2, detail } = elem;
|
|
3942
|
+
const { borderWidth: borderWidth2, borderRadius: borderRadius2, boxSizing } = detail;
|
|
3943
|
+
let btw = 0;
|
|
3944
|
+
let brw = 0;
|
|
3945
|
+
let bbw = 0;
|
|
3946
|
+
let blw = 0;
|
|
3947
|
+
let btlr = 0;
|
|
3948
|
+
let btrr = 0;
|
|
3949
|
+
let bblr = 0;
|
|
3950
|
+
let bbrr = 0;
|
|
3951
|
+
if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
|
|
3952
|
+
btw = borderWidth2;
|
|
3953
|
+
brw = borderWidth2;
|
|
3954
|
+
bbw = borderWidth2;
|
|
3955
|
+
blw = borderWidth2;
|
|
3956
|
+
} else if (Array.isArray(borderWidth2)) {
|
|
3957
|
+
btw = is.positiveNum(borderWidth2[0]) ? borderWidth2[0] : 0;
|
|
3958
|
+
brw = is.positiveNum(borderWidth2[1]) ? borderWidth2[0] : 0;
|
|
3959
|
+
bbw = is.positiveNum(borderWidth2[2]) ? borderWidth2[0] : 0;
|
|
3960
|
+
blw = is.positiveNum(borderWidth2[3]) ? borderWidth2[0] : 0;
|
|
3961
|
+
}
|
|
3962
|
+
if (typeof borderRadius2 === "number" && borderRadius2 > 0) {
|
|
3963
|
+
btlr = borderRadius2;
|
|
3964
|
+
btrr = borderRadius2;
|
|
3965
|
+
bblr = borderRadius2;
|
|
3966
|
+
bbrr = borderRadius2;
|
|
3967
|
+
} else if (Array.isArray(borderRadius2)) {
|
|
3968
|
+
btlr = is.positiveNum(borderRadius2[0]) ? borderRadius2[0] : 0;
|
|
3969
|
+
btrr = is.positiveNum(borderRadius2[0]) ? borderRadius2[0] : 0;
|
|
3970
|
+
bblr = is.positiveNum(borderRadius2[0]) ? borderRadius2[0] : 0;
|
|
3971
|
+
bbrr = is.positiveNum(borderRadius2[0]) ? borderRadius2[0] : 0;
|
|
3972
|
+
}
|
|
3973
|
+
const p0 = { x: x2, y: y2 };
|
|
3974
|
+
const p1 = { x: x2 + w2, y: y2 };
|
|
3975
|
+
const p2 = { x: x2 + w2, y: y2 + h2 };
|
|
3976
|
+
const p3 = { x: x2, y: y2 + h2 };
|
|
3977
|
+
const p0s = { x: x2, y: y2 + btlr };
|
|
3978
|
+
const p0e = { x: x2 + btlr, y: y2 };
|
|
3979
|
+
const p1s = { x: x2 + w2 - btrr, y: y2 };
|
|
3980
|
+
const p1e = { x: x2 + w2, y: y2 + btrr };
|
|
3981
|
+
const p2s = { x: x2 + w2, y: y2 + h2 - bbrr };
|
|
3982
|
+
const p2e = { x: x2 + w2 - bbrr, y: y2 + h2 };
|
|
3983
|
+
const p3s = { x: x2 + bblr, y: y2 + h2 };
|
|
3984
|
+
const p3e = { x: x2, y: y2 + h2 - bblr };
|
|
3985
|
+
let op0 = { ...p0 };
|
|
3986
|
+
let op1 = { ...p1 };
|
|
3987
|
+
let op2 = { ...p2 };
|
|
3988
|
+
let op3 = { ...p3 };
|
|
3989
|
+
let op0s = { ...p0s };
|
|
3990
|
+
let op0e = { ...p0e };
|
|
3991
|
+
let op1s = { ...p1s };
|
|
3992
|
+
let op1e = { ...p1e };
|
|
3993
|
+
let op2s = { ...p2s };
|
|
3994
|
+
let op2e = { ...p2e };
|
|
3995
|
+
let op3s = { ...p3s };
|
|
3996
|
+
let op3e = { ...p3e };
|
|
3997
|
+
let ip0 = { ...p0 };
|
|
3998
|
+
let ip1 = { ...p1 };
|
|
3999
|
+
let ip2 = { ...p2 };
|
|
4000
|
+
let ip3 = { ...p3 };
|
|
4001
|
+
let ip0s = { ...p0s };
|
|
4002
|
+
let ip0e = { ...p0e };
|
|
4003
|
+
let ip1s = { ...p1s };
|
|
4004
|
+
let ip1e = { ...p1e };
|
|
4005
|
+
let ip2s = { ...p2s };
|
|
4006
|
+
let ip2e = { ...p2e };
|
|
4007
|
+
let ip3s = { ...p3s };
|
|
4008
|
+
let ip3e = { ...p3e };
|
|
4009
|
+
if (boxSizing === "border-box") {
|
|
4010
|
+
ip0 = { x: ip0.x + blw, y: ip0.y + btw };
|
|
4011
|
+
ip1 = { x: ip1.x - brw, y: ip1.y + btw };
|
|
4012
|
+
ip2 = { x: ip2.x - brw, y: ip2.y - bbw };
|
|
4013
|
+
ip3 = { x: ip3.x + blw, y: ip3.y - bbw };
|
|
4014
|
+
ip0s = { x: ip0s.x + blw, y: ip0s.y + btw };
|
|
4015
|
+
ip0e = { x: ip0e.x + blw, y: ip0e.y + btw };
|
|
4016
|
+
ip1s = { x: ip1s.x - brw, y: ip1s.y + btw };
|
|
4017
|
+
ip1e = { x: ip1e.x - brw, y: ip1e.y + btw };
|
|
4018
|
+
ip2s = { x: ip2s.x - brw, y: ip2s.y - bbw };
|
|
4019
|
+
ip2e = { x: ip2e.x - brw, y: ip2e.y - bbw };
|
|
4020
|
+
ip3s = { x: ip3s.x + blw, y: ip3s.y - bbw };
|
|
4021
|
+
ip3e = { x: ip3e.x + blw, y: ip3e.y - bbw };
|
|
4022
|
+
} else if (boxSizing === "content-box") {
|
|
4023
|
+
op0 = { x: op0.x - blw, y: op0.y - btw };
|
|
4024
|
+
op1 = { x: op1.x + brw, y: op1.y - btw };
|
|
4025
|
+
op2 = { x: op2.x + brw, y: op2.y + bbw };
|
|
4026
|
+
op3 = { x: op3.x - blw, y: op3.y + bbw };
|
|
4027
|
+
op0s = { x: op0s.x - blw, y: op0s.y - btw };
|
|
4028
|
+
op0e = { x: op0e.x - blw, y: op0e.y - btw };
|
|
4029
|
+
op1s = { x: op1s.x + brw, y: op1s.y - btw };
|
|
4030
|
+
op1e = { x: op1e.x + brw, y: op1e.y - btw };
|
|
4031
|
+
op2s = { x: op2s.x + brw, y: op2s.y + bbw };
|
|
4032
|
+
op2e = { x: op2e.x + brw, y: op2e.y + bbw };
|
|
4033
|
+
op3s = { x: op3s.x - blw, y: op3s.y + bbw };
|
|
4034
|
+
op3e = { x: op3e.x - blw, y: op3e.y + bbw };
|
|
4035
|
+
} else {
|
|
4036
|
+
ip0 = { x: ip0.x + blw / 2, y: ip0.y + btw / 2 };
|
|
4037
|
+
ip1 = { x: ip1.x - brw / 2, y: ip1.y + btw / 2 };
|
|
4038
|
+
ip2 = { x: ip2.x - brw / 2, y: ip2.y - bbw / 2 };
|
|
4039
|
+
ip3 = { x: ip3.x + blw / 2, y: ip3.y - bbw / 2 };
|
|
4040
|
+
ip0s = { x: ip0s.x + blw / 2, y: ip0s.y + btw / 2 };
|
|
4041
|
+
ip0e = { x: ip0e.x + blw / 2, y: ip0e.y + btw / 2 };
|
|
4042
|
+
ip1s = { x: ip1s.x - brw / 2, y: ip1s.y + btw / 2 };
|
|
4043
|
+
ip1e = { x: ip1e.x - brw / 2, y: ip1e.y + btw / 2 };
|
|
4044
|
+
ip2s = { x: ip2s.x - brw / 2, y: ip2s.y - bbw / 2 };
|
|
4045
|
+
ip2e = { x: ip2e.x - brw / 2, y: ip2e.y - bbw / 2 };
|
|
4046
|
+
ip3s = { x: ip3s.x + blw / 2, y: ip3s.y - bbw / 2 };
|
|
4047
|
+
ip3e = { x: ip3e.x + blw / 2, y: ip3e.y - bbw / 2 };
|
|
4048
|
+
op0 = { x: op0.x - blw / 2, y: op0.y - btw / 2 };
|
|
4049
|
+
op1 = { x: op1.x + brw / 2, y: op1.y - btw / 2 };
|
|
4050
|
+
op2 = { x: op2.x + brw / 2, y: op2.y + bbw / 2 };
|
|
4051
|
+
op3 = { x: op3.x - blw / 2, y: op3.y + bbw / 2 };
|
|
4052
|
+
op0s = { x: op0s.x - blw / 2, y: op0s.y - btw / 2 };
|
|
4053
|
+
op0e = { x: op0e.x - blw / 2, y: op0e.y - btw / 2 };
|
|
4054
|
+
op1s = { x: op1s.x + brw / 2, y: op1s.y - btw / 2 };
|
|
4055
|
+
op1e = { x: op1e.x + brw / 2, y: op1e.y - btw / 2 };
|
|
4056
|
+
op2s = { x: op2s.x + brw / 2, y: op2s.y + bbw / 2 };
|
|
4057
|
+
op2e = { x: op2e.x + brw / 2, y: op2e.y + bbw / 2 };
|
|
4058
|
+
op3s = { x: op3s.x - blw / 2, y: op3s.y + bbw / 2 };
|
|
4059
|
+
op3e = { x: op3e.x - blw / 2, y: op3e.y + bbw / 2 };
|
|
4060
|
+
}
|
|
4061
|
+
return {
|
|
4062
|
+
btw,
|
|
4063
|
+
brw,
|
|
4064
|
+
bbw,
|
|
4065
|
+
blw,
|
|
4066
|
+
btlr,
|
|
4067
|
+
btrr,
|
|
4068
|
+
bblr,
|
|
4069
|
+
bbrr,
|
|
4070
|
+
p0,
|
|
4071
|
+
p1,
|
|
4072
|
+
p2,
|
|
4073
|
+
p3,
|
|
4074
|
+
p0s,
|
|
4075
|
+
p0e,
|
|
4076
|
+
p1s,
|
|
4077
|
+
p1e,
|
|
4078
|
+
p2s,
|
|
4079
|
+
p2e,
|
|
4080
|
+
p3s,
|
|
4081
|
+
p3e,
|
|
4082
|
+
op0,
|
|
4083
|
+
op1,
|
|
4084
|
+
op2,
|
|
4085
|
+
op3,
|
|
4086
|
+
op0s,
|
|
4087
|
+
op0e,
|
|
4088
|
+
op1s,
|
|
4089
|
+
op1e,
|
|
4090
|
+
op2s,
|
|
4091
|
+
op2e,
|
|
4092
|
+
op3s,
|
|
4093
|
+
op3e,
|
|
4094
|
+
ip0,
|
|
4095
|
+
ip1,
|
|
4096
|
+
ip2,
|
|
4097
|
+
ip3,
|
|
4098
|
+
ip0s,
|
|
4099
|
+
ip0e,
|
|
4100
|
+
ip1s,
|
|
4101
|
+
ip1e,
|
|
4102
|
+
ip2s,
|
|
4103
|
+
ip2e,
|
|
4104
|
+
ip3s,
|
|
4105
|
+
ip3e
|
|
4106
|
+
};
|
|
4107
|
+
}
|
|
2779
4108
|
exports.Context2D = Context2D;
|
|
2780
4109
|
exports.EventEmitter = EventEmitter;
|
|
2781
4110
|
exports.Store = Store;
|
|
@@ -2783,14 +4112,21 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2783
4112
|
exports.calcElementCenter = calcElementCenter;
|
|
2784
4113
|
exports.calcElementCenterFromVertexes = calcElementCenterFromVertexes;
|
|
2785
4114
|
exports.calcElementListSize = calcElementListSize;
|
|
4115
|
+
exports.calcElementOriginRectInfo = calcElementOriginRectInfo;
|
|
2786
4116
|
exports.calcElementQueueVertexesQueueInGroup = calcElementQueueVertexesQueueInGroup;
|
|
2787
4117
|
exports.calcElementSizeController = calcElementSizeController;
|
|
2788
4118
|
exports.calcElementVertexesInGroup = calcElementVertexesInGroup;
|
|
2789
4119
|
exports.calcElementVertexesQueueInGroup = calcElementVertexesQueueInGroup;
|
|
4120
|
+
exports.calcElementViewRectInfo = calcElementViewRectInfo;
|
|
2790
4121
|
exports.calcElementsContextSize = calcElementsContextSize;
|
|
2791
4122
|
exports.calcElementsViewInfo = calcElementsViewInfo;
|
|
4123
|
+
exports.calcLayoutSizeController = calcLayoutSizeController;
|
|
4124
|
+
exports.calcPointMoveElementInGroup = calcPointMoveElementInGroup;
|
|
4125
|
+
exports.calcRadian = calcRadian;
|
|
2792
4126
|
exports.calcSpeed = calcSpeed;
|
|
2793
4127
|
exports.calcViewBoxSize = calcViewBoxSize;
|
|
4128
|
+
exports.calcViewCenter = calcViewCenter;
|
|
4129
|
+
exports.calcViewCenterContent = calcViewCenterContent;
|
|
2794
4130
|
exports.calcViewElementSize = calcViewElementSize;
|
|
2795
4131
|
exports.calcViewPointSize = calcViewPointSize;
|
|
2796
4132
|
exports.calcViewScaleInfo = calcViewScaleInfo;
|
|
@@ -2808,20 +4144,28 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2808
4144
|
exports.createElement = createElement;
|
|
2809
4145
|
exports.createOffscreenContext2D = createOffscreenContext2D;
|
|
2810
4146
|
exports.createUUID = createUUID;
|
|
4147
|
+
exports.debounce = debounce;
|
|
2811
4148
|
exports.deepClone = deepClone;
|
|
4149
|
+
exports.deepCloneData = deepCloneData;
|
|
4150
|
+
exports.deepCloneElement = deepCloneElement;
|
|
4151
|
+
exports.deepResizeGroupElement = deepResizeGroupElement;
|
|
2812
4152
|
exports.delay = delay;
|
|
2813
4153
|
exports.deleteElementInList = deleteElementInList;
|
|
2814
4154
|
exports.deleteElementInListByPosition = deleteElementInListByPosition;
|
|
2815
4155
|
exports.downloadFileFromText = downloadFileFromText;
|
|
2816
4156
|
exports.downloadImageFromCanvas = downloadImageFromCanvas;
|
|
4157
|
+
exports.elementToBoxInfo = elementToBoxInfo;
|
|
4158
|
+
exports.enhanceFontFamliy = enhanceFontFamliy;
|
|
2817
4159
|
exports.equalPoint = equalPoint;
|
|
2818
4160
|
exports.equalTouchPoint = equalTouchPoint;
|
|
4161
|
+
exports.filterCompactData = filterCompactData;
|
|
2819
4162
|
exports.filterElementAsset = filterElementAsset;
|
|
2820
4163
|
exports.findElementFromList = findElementFromList;
|
|
2821
4164
|
exports.findElementFromListByPosition = findElementFromListByPosition;
|
|
2822
4165
|
exports.findElementQueueFromListByPosition = findElementQueueFromListByPosition;
|
|
2823
4166
|
exports.findElementsFromList = findElementsFromList;
|
|
2824
4167
|
exports.findElementsFromListByPositions = findElementsFromListByPositions;
|
|
4168
|
+
exports.flatElementList = flatElementList;
|
|
2825
4169
|
exports.formatNumber = formatNumber;
|
|
2826
4170
|
exports.generateHTML = generateHTML;
|
|
2827
4171
|
exports.generateSVGPath = generateSVGPath;
|
|
@@ -2830,21 +4174,28 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2830
4174
|
exports.getDefaultElementRectDetail = getDefaultElementRectDetail;
|
|
2831
4175
|
exports.getElemenetsAssetIds = getElemenetsAssetIds;
|
|
2832
4176
|
exports.getElementPositionFromList = getElementPositionFromList;
|
|
4177
|
+
exports.getElementPositionMapFromList = getElementPositionMapFromList;
|
|
2833
4178
|
exports.getElementRotateVertexes = getElementRotateVertexes;
|
|
2834
4179
|
exports.getElementSize = getElementSize;
|
|
2835
4180
|
exports.getElementVertexes = getElementVertexes;
|
|
4181
|
+
exports.getGroupQueueByElementPosition = getGroupQueueByElementPosition;
|
|
2836
4182
|
exports.getGroupQueueFromList = getGroupQueueFromList;
|
|
4183
|
+
exports.getModifiedElement = getModifiedElement;
|
|
2837
4184
|
exports.getSelectedElementUUIDs = getSelectedElementUUIDs;
|
|
2838
4185
|
exports.getViewPointAtElement = getViewPointAtElement;
|
|
2839
4186
|
exports.getViewScaleInfoFromSnapshot = getViewScaleInfoFromSnapshot;
|
|
2840
4187
|
exports.getViewSizeInfoFromSnapshot = getViewSizeInfoFromSnapshot;
|
|
4188
|
+
exports.groupElementsByPosition = groupElementsByPosition;
|
|
2841
4189
|
exports.insertElementToListByPosition = insertElementToListByPosition;
|
|
2842
4190
|
exports.is = is;
|
|
2843
4191
|
exports.isAssetId = isAssetId;
|
|
2844
4192
|
exports.isColorStr = isColorStr;
|
|
2845
4193
|
exports.isElementInView = isElementInView;
|
|
2846
4194
|
exports.isResourceElement = isResourceElement;
|
|
4195
|
+
exports.isSameElementSize = isSameElementSize;
|
|
2847
4196
|
exports.isViewPointInElement = isViewPointInElement;
|
|
4197
|
+
exports.isViewPointInElementSize = isViewPointInElementSize;
|
|
4198
|
+
exports.isViewPointInVertexes = isViewPointInVertexes;
|
|
2848
4199
|
exports.istype = istype;
|
|
2849
4200
|
exports.limitAngle = limitAngle;
|
|
2850
4201
|
exports.loadHTML = loadHTML;
|
|
@@ -2852,9 +4203,13 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2852
4203
|
exports.loadSVG = loadSVG;
|
|
2853
4204
|
exports.matrixToAngle = matrixToAngle;
|
|
2854
4205
|
exports.matrixToRadian = matrixToRadian;
|
|
4206
|
+
exports.merge = merge;
|
|
2855
4207
|
exports.mergeElementAsset = mergeElementAsset;
|
|
2856
4208
|
exports.mergeHexColorAlpha = mergeHexColorAlpha;
|
|
4209
|
+
exports.modifyElement = modifyElement;
|
|
2857
4210
|
exports.moveElementPosition = moveElementPosition;
|
|
4211
|
+
exports.omit = omit;
|
|
4212
|
+
exports.originRectInfoToRangeRectInfo = originRectInfoToRangeRectInfo;
|
|
2858
4213
|
exports.parseAngleToRadian = parseAngleToRadian;
|
|
2859
4214
|
exports.parseFileToBase64 = parseFileToBase64;
|
|
2860
4215
|
exports.parseFileToText = parseFileToText;
|
|
@@ -2872,7 +4227,9 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2872
4227
|
exports.throttle = throttle;
|
|
2873
4228
|
exports.toColorHexNum = toColorHexNum;
|
|
2874
4229
|
exports.toColorHexStr = toColorHexStr;
|
|
4230
|
+
exports.ungroupElementsByPosition = ungroupElementsByPosition;
|
|
2875
4231
|
exports.updateElementInList = updateElementInList;
|
|
4232
|
+
exports.updateElementInListByPosition = updateElementInListByPosition;
|
|
2876
4233
|
exports.vaildPoint = vaildPoint;
|
|
2877
4234
|
exports.vaildTouchPoint = vaildTouchPoint;
|
|
2878
4235
|
exports.validateElements = validateElements;
|