@idraw/util 0.4.0-beta.3 → 0.4.0-beta.31
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 +14 -8
- package/dist/esm/index.js +14 -8
- package/dist/esm/lib/canvas.d.ts +6 -1
- package/dist/esm/lib/canvas.js +42 -19
- package/dist/esm/lib/config.d.ts +5 -10
- package/dist/esm/lib/config.js +9 -9
- package/dist/esm/lib/context2d.d.ts +2 -0
- package/dist/esm/lib/context2d.js +14 -0
- package/dist/esm/lib/controller.d.ts +5 -1
- package/dist/esm/lib/controller.js +142 -0
- package/dist/esm/lib/data.d.ts +6 -2
- package/dist/esm/lib/data.js +95 -2
- package/dist/esm/lib/element.d.ts +1 -0
- package/dist/esm/lib/element.js +19 -0
- package/dist/esm/lib/event.d.ts +4 -2
- package/dist/esm/lib/event.js +31 -11
- package/dist/esm/lib/file.d.ts +7 -2
- package/dist/esm/lib/file.js +26 -7
- package/dist/esm/lib/flat.d.ts +2 -0
- package/dist/esm/lib/flat.js +132 -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/istype.d.ts +1 -0
- package/dist/esm/lib/istype.js +3 -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/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/store.d.ts +6 -5
- package/dist/esm/lib/store.js +30 -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 -3
- package/dist/esm/lib/view-calc.d.ts +20 -3
- package/dist/esm/lib/view-calc.js +171 -3
- package/dist/esm/lib/view-content.d.ts +14 -0
- package/dist/esm/lib/view-content.js +88 -0
- package/dist/esm/lib/view-visible.d.ts +21 -0
- package/dist/esm/lib/view-visible.js +93 -0
- package/dist/index.global.js +1272 -176
- package/dist/index.global.min.js +1 -1
- package/package.json +1 -1
package/dist/index.global.js
CHANGED
|
@@ -17,8 +17,12 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
17
17
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
18
18
|
return value;
|
|
19
19
|
};
|
|
20
|
+
var __privateMethod = (obj, member, method) => {
|
|
21
|
+
__accessCheck(obj, member, "access private method");
|
|
22
|
+
return method;
|
|
23
|
+
};
|
|
20
24
|
|
|
21
|
-
var _ctx, _opts;
|
|
25
|
+
var _ctx, _opts, _listeners, _temp, _backUpDefaultStorage, _createTempStorage, createTempStorage_fn;
|
|
22
26
|
function compose(middleware) {
|
|
23
27
|
return function(context, next) {
|
|
24
28
|
return dispatch(0);
|
|
@@ -47,7 +51,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
47
51
|
function throttle(fn, timeout) {
|
|
48
52
|
let timer = -1;
|
|
49
53
|
return function(...args) {
|
|
50
|
-
if (timer
|
|
54
|
+
if (timer >= 0) {
|
|
51
55
|
return;
|
|
52
56
|
}
|
|
53
57
|
timer = setTimeout(() => {
|
|
@@ -56,20 +60,34 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
56
60
|
}, timeout);
|
|
57
61
|
};
|
|
58
62
|
}
|
|
63
|
+
function debounce(fn, timeout) {
|
|
64
|
+
let timer = -1;
|
|
65
|
+
return function(...args) {
|
|
66
|
+
if (timer >= 0) {
|
|
67
|
+
window.clearTimeout(timer);
|
|
68
|
+
}
|
|
69
|
+
timer = setTimeout(() => {
|
|
70
|
+
fn(...args);
|
|
71
|
+
timer = -1;
|
|
72
|
+
}, timeout);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
59
75
|
function downloadImageFromCanvas(canvas, opts) {
|
|
60
|
-
const {
|
|
76
|
+
const { fileName, type = "image/jpeg" } = opts;
|
|
61
77
|
const stream = canvas.toDataURL(type);
|
|
62
|
-
|
|
78
|
+
let downloadLink = document.createElement("a");
|
|
63
79
|
downloadLink.href = stream;
|
|
64
|
-
downloadLink.download =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
downloadLink.dispatchEvent(downloadClickEvent);
|
|
80
|
+
downloadLink.download = fileName;
|
|
81
|
+
downloadLink.click();
|
|
82
|
+
downloadLink = null;
|
|
68
83
|
}
|
|
69
84
|
function pickFile(opts) {
|
|
70
|
-
const { success, error } = opts;
|
|
85
|
+
const { accept, success, error } = opts;
|
|
71
86
|
let input = document.createElement("input");
|
|
72
87
|
input.type = "file";
|
|
88
|
+
if (accept) {
|
|
89
|
+
input.accept = accept;
|
|
90
|
+
}
|
|
73
91
|
input.addEventListener("change", function() {
|
|
74
92
|
var _a;
|
|
75
93
|
const file = (_a = input.files) == null ? void 0 : _a[0];
|
|
@@ -122,6 +140,23 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
122
140
|
reader.readAsText(file);
|
|
123
141
|
});
|
|
124
142
|
}
|
|
143
|
+
function parseTextToBlobURL(text2) {
|
|
144
|
+
const bytes = new TextEncoder().encode(text2);
|
|
145
|
+
const blob = new Blob([bytes], {
|
|
146
|
+
type: "text/plain;charset=utf-8"
|
|
147
|
+
});
|
|
148
|
+
const blobURL = window.URL.createObjectURL(blob);
|
|
149
|
+
return blobURL;
|
|
150
|
+
}
|
|
151
|
+
function downloadFileFromText(text2, opts) {
|
|
152
|
+
const { fileName } = opts;
|
|
153
|
+
const blobURL = parseTextToBlobURL(text2);
|
|
154
|
+
let downloadLink = document.createElement("a");
|
|
155
|
+
downloadLink.href = blobURL;
|
|
156
|
+
downloadLink.download = fileName;
|
|
157
|
+
downloadLink.click();
|
|
158
|
+
downloadLink = null;
|
|
159
|
+
}
|
|
125
160
|
function toColorHexNum(color2) {
|
|
126
161
|
return parseInt(color2.replace(/^\#/, "0x"));
|
|
127
162
|
}
|
|
@@ -406,6 +441,19 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
406
441
|
}
|
|
407
442
|
return _clone(target);
|
|
408
443
|
}
|
|
444
|
+
function deepCloneElement(element) {
|
|
445
|
+
const elem = deepClone(element);
|
|
446
|
+
const _resetUUID = (e) => {
|
|
447
|
+
e.uuid = createUUID();
|
|
448
|
+
if (e.type === "group" && e.detail.children) {
|
|
449
|
+
e.detail.children.forEach((child) => {
|
|
450
|
+
_resetUUID(child);
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
_resetUUID(elem);
|
|
455
|
+
return elem;
|
|
456
|
+
}
|
|
409
457
|
function is$1(target) {
|
|
410
458
|
return Object.prototype.toString.call(target).replace(/[\]|\[]{1,1}/gi, "").split(" ")[1];
|
|
411
459
|
}
|
|
@@ -442,7 +490,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
442
490
|
const assetUUID = createAssetId(html2);
|
|
443
491
|
if (!assets[assetUUID]) {
|
|
444
492
|
assets[assetUUID] = {
|
|
445
|
-
type: "
|
|
493
|
+
type: "html",
|
|
446
494
|
value: html2
|
|
447
495
|
};
|
|
448
496
|
}
|
|
@@ -463,6 +511,80 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
463
511
|
sortedData.assets = assets;
|
|
464
512
|
return sortedData;
|
|
465
513
|
}
|
|
514
|
+
function filterCompactData(data, opts) {
|
|
515
|
+
const assets = data.assets || {};
|
|
516
|
+
const sortedData = deepClone(data);
|
|
517
|
+
const loadItemMap = (opts == null ? void 0 : opts.loadItemMap) || {};
|
|
518
|
+
const _scanElements = (elems) => {
|
|
519
|
+
elems.forEach((elem) => {
|
|
520
|
+
var _a, _b, _c;
|
|
521
|
+
if (elem.type === "image" && elem.detail.src) {
|
|
522
|
+
const src = elem.detail.src;
|
|
523
|
+
if (isAssetId(src) && !assets[src] && loadItemMap[src] && typeof ((_a = loadItemMap[src]) == null ? void 0 : _a.source) === "string") {
|
|
524
|
+
assets[src] = {
|
|
525
|
+
type: "image",
|
|
526
|
+
value: loadItemMap[src].source
|
|
527
|
+
};
|
|
528
|
+
} else if (!assets[src]) {
|
|
529
|
+
const assetUUID = createAssetId(src);
|
|
530
|
+
if (!assets[assetUUID]) {
|
|
531
|
+
assets[assetUUID] = {
|
|
532
|
+
type: "image",
|
|
533
|
+
value: src
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
elem.detail.src = assetUUID;
|
|
537
|
+
}
|
|
538
|
+
} else if (elem.type === "svg") {
|
|
539
|
+
const svg2 = elem.detail.svg;
|
|
540
|
+
if (isAssetId(svg2) && !assets[svg2] && loadItemMap[svg2] && typeof ((_b = loadItemMap[svg2]) == null ? void 0 : _b.source) === "string") {
|
|
541
|
+
assets[svg2] = {
|
|
542
|
+
type: "svg",
|
|
543
|
+
value: loadItemMap[svg2].source
|
|
544
|
+
};
|
|
545
|
+
} else if (!assets[svg2]) {
|
|
546
|
+
const assetUUID = createAssetId(svg2);
|
|
547
|
+
if (!assets[assetUUID]) {
|
|
548
|
+
assets[assetUUID] = {
|
|
549
|
+
type: "svg",
|
|
550
|
+
value: svg2
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
elem.detail.svg = assetUUID;
|
|
554
|
+
}
|
|
555
|
+
} else if (elem.type === "html") {
|
|
556
|
+
const html2 = elem.detail.html;
|
|
557
|
+
if (isAssetId(html2) && !assets[html2] && loadItemMap[html2] && typeof ((_c = loadItemMap[html2]) == null ? void 0 : _c.source) === "string") {
|
|
558
|
+
assets[html2] = {
|
|
559
|
+
type: "html",
|
|
560
|
+
value: loadItemMap[html2].source
|
|
561
|
+
};
|
|
562
|
+
} else if (!assets[html2]) {
|
|
563
|
+
const assetUUID = createAssetId(html2);
|
|
564
|
+
if (!assets[assetUUID]) {
|
|
565
|
+
assets[assetUUID] = {
|
|
566
|
+
type: "html",
|
|
567
|
+
value: html2
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
elem.detail.html = assetUUID;
|
|
571
|
+
}
|
|
572
|
+
} else if (elem.type === "group" && Array.isArray(elem.detail.children)) {
|
|
573
|
+
const groupAssets = elem.detail.assets || {};
|
|
574
|
+
Object.keys(groupAssets).forEach((assetId) => {
|
|
575
|
+
if (!assets[assetId]) {
|
|
576
|
+
assets[assetId] = groupAssets[assetId];
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
delete elem.detail.assets;
|
|
580
|
+
_scanElements(elem.detail.children);
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
};
|
|
584
|
+
_scanElements(sortedData.elements);
|
|
585
|
+
sortedData.assets = assets;
|
|
586
|
+
return sortedData;
|
|
587
|
+
}
|
|
466
588
|
function parsePrototype(data) {
|
|
467
589
|
const typeStr = Object.prototype.toString.call(data) || "";
|
|
468
590
|
const result = typeStr.replace(/(\[object|\])/gi, "").trim();
|
|
@@ -485,6 +607,9 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
485
607
|
asyncFunction(data) {
|
|
486
608
|
return parsePrototype(data) === "AsyncFunction";
|
|
487
609
|
},
|
|
610
|
+
boolean(data) {
|
|
611
|
+
return parsePrototype(data) === "Boolean";
|
|
612
|
+
},
|
|
488
613
|
string(data) {
|
|
489
614
|
return parsePrototype(data) === "String";
|
|
490
615
|
},
|
|
@@ -790,6 +915,9 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
790
915
|
svgDesc,
|
|
791
916
|
htmlDesc
|
|
792
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'`;
|
|
793
921
|
class Context2D {
|
|
794
922
|
// private _width: number = 0;
|
|
795
923
|
// private _height: number = 0;
|
|
@@ -798,6 +926,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
798
926
|
__privateAdd(this, _opts, void 0);
|
|
799
927
|
__privateSet(this, _ctx, ctx);
|
|
800
928
|
__privateSet(this, _opts, { ...{ devicePixelRatio: 1, offscreenCanvas: null }, ...opts });
|
|
929
|
+
this.$resetFont();
|
|
801
930
|
}
|
|
802
931
|
$undoPixelRatio(num) {
|
|
803
932
|
return num / __privateGet(this, _opts).devicePixelRatio;
|
|
@@ -808,6 +937,9 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
808
937
|
$getContext() {
|
|
809
938
|
return __privateGet(this, _ctx);
|
|
810
939
|
}
|
|
940
|
+
$setContext(ctx) {
|
|
941
|
+
__privateSet(this, _ctx, ctx);
|
|
942
|
+
}
|
|
811
943
|
$setFont(opts) {
|
|
812
944
|
const strList = [];
|
|
813
945
|
if (opts.fontWeight) {
|
|
@@ -817,6 +949,13 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
817
949
|
strList.push(`${opts.fontFamily || "sans-serif"}`);
|
|
818
950
|
__privateGet(this, _ctx).font = `${strList.join(" ")}`;
|
|
819
951
|
}
|
|
952
|
+
$resetFont() {
|
|
953
|
+
this.$setFont({
|
|
954
|
+
fontSize: defaultFontSize,
|
|
955
|
+
fontFamily: defaultFontFamily,
|
|
956
|
+
fontWeight: defaultFontWeight
|
|
957
|
+
});
|
|
958
|
+
}
|
|
820
959
|
$getOffscreenCanvas() {
|
|
821
960
|
return __privateGet(this, _opts).offscreenCanvas;
|
|
822
961
|
}
|
|
@@ -1091,55 +1230,78 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1091
1230
|
return context2d;
|
|
1092
1231
|
}
|
|
1093
1232
|
function createBoardContent(canvas, opts) {
|
|
1094
|
-
const { width, height, devicePixelRatio, offscreen } = opts;
|
|
1233
|
+
const { width, height, devicePixelRatio, offscreen, createCustomContext2D } = opts;
|
|
1095
1234
|
const ctxOpts = {
|
|
1096
1235
|
width,
|
|
1097
1236
|
height,
|
|
1098
1237
|
devicePixelRatio
|
|
1099
1238
|
};
|
|
1239
|
+
const ctx = canvas.getContext("2d");
|
|
1240
|
+
if (createCustomContext2D) {
|
|
1241
|
+
const viewContext = createCustomContext2D(ctxOpts);
|
|
1242
|
+
const overlayContext = createCustomContext2D(ctxOpts);
|
|
1243
|
+
const underlayContext = createCustomContext2D(ctxOpts);
|
|
1244
|
+
const boardContext = createContext2D({ ctx, ...ctxOpts });
|
|
1245
|
+
const drawView = () => {
|
|
1246
|
+
const { width: w2, height: h2 } = viewContext.$getSize();
|
|
1247
|
+
boardContext.clearRect(0, 0, w2, h2);
|
|
1248
|
+
boardContext.drawImage(underlayContext.canvas, 0, 0, w2, h2);
|
|
1249
|
+
boardContext.drawImage(viewContext.canvas, 0, 0, w2, h2);
|
|
1250
|
+
boardContext.drawImage(overlayContext.canvas, 0, 0, w2, h2);
|
|
1251
|
+
underlayContext.clearRect(0, 0, w2, h2);
|
|
1252
|
+
viewContext.clearRect(0, 0, w2, h2);
|
|
1253
|
+
overlayContext.clearRect(0, 0, w2, h2);
|
|
1254
|
+
};
|
|
1255
|
+
const content = {
|
|
1256
|
+
underlayContext,
|
|
1257
|
+
viewContext,
|
|
1258
|
+
overlayContext,
|
|
1259
|
+
boardContext,
|
|
1260
|
+
drawView
|
|
1261
|
+
};
|
|
1262
|
+
return content;
|
|
1263
|
+
}
|
|
1100
1264
|
if (offscreen === true) {
|
|
1101
|
-
const ctx = canvas.getContext("2d");
|
|
1102
1265
|
const viewContext = createOffscreenContext2D(ctxOpts);
|
|
1103
|
-
const
|
|
1104
|
-
const
|
|
1266
|
+
const overlayContext = createOffscreenContext2D(ctxOpts);
|
|
1267
|
+
const underlayContext = createOffscreenContext2D(ctxOpts);
|
|
1105
1268
|
const boardContext = createContext2D({ ctx, ...ctxOpts });
|
|
1106
1269
|
const drawView = () => {
|
|
1107
1270
|
const { width: w2, height: h2 } = viewContext.$getSize();
|
|
1108
1271
|
boardContext.clearRect(0, 0, w2, h2);
|
|
1109
|
-
boardContext.drawImage(
|
|
1272
|
+
boardContext.drawImage(underlayContext.canvas, 0, 0, w2, h2);
|
|
1110
1273
|
boardContext.drawImage(viewContext.canvas, 0, 0, w2, h2);
|
|
1111
|
-
boardContext.drawImage(
|
|
1112
|
-
|
|
1274
|
+
boardContext.drawImage(overlayContext.canvas, 0, 0, w2, h2);
|
|
1275
|
+
underlayContext.clearRect(0, 0, w2, h2);
|
|
1113
1276
|
viewContext.clearRect(0, 0, w2, h2);
|
|
1114
|
-
|
|
1277
|
+
overlayContext.clearRect(0, 0, w2, h2);
|
|
1115
1278
|
};
|
|
1116
1279
|
const content = {
|
|
1117
|
-
|
|
1280
|
+
underlayContext,
|
|
1118
1281
|
viewContext,
|
|
1119
|
-
|
|
1282
|
+
overlayContext,
|
|
1120
1283
|
boardContext,
|
|
1121
1284
|
drawView
|
|
1122
1285
|
};
|
|
1123
1286
|
return content;
|
|
1124
1287
|
} else {
|
|
1125
|
-
const ctx = canvas.getContext("2d");
|
|
1126
1288
|
const viewContext = createContext2D(ctxOpts);
|
|
1127
|
-
const
|
|
1128
|
-
const
|
|
1289
|
+
const overlayContext = createContext2D(ctxOpts);
|
|
1290
|
+
const underlayContext = createContext2D(ctxOpts);
|
|
1129
1291
|
const boardContext = createContext2D({ ctx, ...ctxOpts });
|
|
1130
1292
|
const drawView = () => {
|
|
1131
1293
|
boardContext.clearRect(0, 0, width, height);
|
|
1132
|
-
boardContext.drawImage(
|
|
1294
|
+
boardContext.drawImage(underlayContext.canvas, 0, 0, width, height);
|
|
1133
1295
|
boardContext.drawImage(viewContext.canvas, 0, 0, width, height);
|
|
1134
|
-
boardContext.drawImage(
|
|
1135
|
-
|
|
1296
|
+
boardContext.drawImage(overlayContext.canvas, 0, 0, width, height);
|
|
1297
|
+
underlayContext.clearRect(0, 0, width, height);
|
|
1136
1298
|
viewContext.clearRect(0, 0, width, height);
|
|
1137
|
-
|
|
1299
|
+
overlayContext.clearRect(0, 0, width, height);
|
|
1138
1300
|
};
|
|
1139
1301
|
const content = {
|
|
1140
|
-
|
|
1302
|
+
underlayContext,
|
|
1141
1303
|
viewContext,
|
|
1142
|
-
|
|
1304
|
+
overlayContext,
|
|
1143
1305
|
boardContext,
|
|
1144
1306
|
drawView
|
|
1145
1307
|
};
|
|
@@ -1148,20 +1310,21 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1148
1310
|
}
|
|
1149
1311
|
class EventEmitter {
|
|
1150
1312
|
constructor() {
|
|
1151
|
-
this
|
|
1313
|
+
__privateAdd(this, _listeners, void 0);
|
|
1314
|
+
__privateSet(this, _listeners, /* @__PURE__ */ new Map());
|
|
1152
1315
|
}
|
|
1153
1316
|
on(eventKey, callback) {
|
|
1154
|
-
if (this
|
|
1155
|
-
const callbacks = this
|
|
1317
|
+
if (__privateGet(this, _listeners).has(eventKey)) {
|
|
1318
|
+
const callbacks = __privateGet(this, _listeners).get(eventKey) || [];
|
|
1156
1319
|
callbacks == null ? void 0 : callbacks.push(callback);
|
|
1157
|
-
this
|
|
1320
|
+
__privateGet(this, _listeners).set(eventKey, callbacks);
|
|
1158
1321
|
} else {
|
|
1159
|
-
this
|
|
1322
|
+
__privateGet(this, _listeners).set(eventKey, [callback]);
|
|
1160
1323
|
}
|
|
1161
1324
|
}
|
|
1162
1325
|
off(eventKey, callback) {
|
|
1163
|
-
if (this
|
|
1164
|
-
const callbacks = this
|
|
1326
|
+
if (__privateGet(this, _listeners).has(eventKey)) {
|
|
1327
|
+
const callbacks = __privateGet(this, _listeners).get(eventKey);
|
|
1165
1328
|
if (Array.isArray(callbacks)) {
|
|
1166
1329
|
for (let i = 0; i < (callbacks == null ? void 0 : callbacks.length); i++) {
|
|
1167
1330
|
if (callbacks[i] === callback) {
|
|
@@ -1170,11 +1333,11 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1170
1333
|
}
|
|
1171
1334
|
}
|
|
1172
1335
|
}
|
|
1173
|
-
this
|
|
1336
|
+
__privateGet(this, _listeners).set(eventKey, callbacks || []);
|
|
1174
1337
|
}
|
|
1175
1338
|
}
|
|
1176
1339
|
trigger(eventKey, e) {
|
|
1177
|
-
const callbacks = this
|
|
1340
|
+
const callbacks = __privateGet(this, _listeners).get(eventKey);
|
|
1178
1341
|
if (Array.isArray(callbacks)) {
|
|
1179
1342
|
callbacks.forEach((cb) => {
|
|
1180
1343
|
cb(e);
|
|
@@ -1185,15 +1348,22 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1185
1348
|
}
|
|
1186
1349
|
}
|
|
1187
1350
|
has(name) {
|
|
1188
|
-
if (this
|
|
1189
|
-
const list = this
|
|
1351
|
+
if (__privateGet(this, _listeners).has(name)) {
|
|
1352
|
+
const list = __privateGet(this, _listeners).get(name);
|
|
1190
1353
|
if (Array.isArray(list) && list.length > 0) {
|
|
1191
1354
|
return true;
|
|
1192
1355
|
}
|
|
1193
1356
|
}
|
|
1194
1357
|
return false;
|
|
1195
1358
|
}
|
|
1359
|
+
destroy() {
|
|
1360
|
+
this.clear();
|
|
1361
|
+
}
|
|
1362
|
+
clear() {
|
|
1363
|
+
__privateGet(this, _listeners).clear();
|
|
1364
|
+
}
|
|
1196
1365
|
}
|
|
1366
|
+
_listeners = new WeakMap();
|
|
1197
1367
|
function calcDistance(start, end) {
|
|
1198
1368
|
const distance = (start.x - end.x) * (start.x - end.x) + (start.y - end.y) * (start.y - end.y);
|
|
1199
1369
|
return distance === 0 ? distance : Math.sqrt(distance);
|
|
@@ -1226,25 +1396,37 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1226
1396
|
}
|
|
1227
1397
|
class Store {
|
|
1228
1398
|
constructor(opts) {
|
|
1229
|
-
this
|
|
1230
|
-
this
|
|
1399
|
+
__privateAdd(this, _createTempStorage);
|
|
1400
|
+
__privateAdd(this, _temp, void 0);
|
|
1401
|
+
__privateAdd(this, _backUpDefaultStorage, void 0);
|
|
1402
|
+
__privateSet(this, _backUpDefaultStorage, deepClone(opts.defaultStorage));
|
|
1403
|
+
__privateSet(this, _temp, __privateMethod(this, _createTempStorage, createTempStorage_fn).call(this));
|
|
1231
1404
|
}
|
|
1232
1405
|
set(name, value) {
|
|
1233
|
-
this
|
|
1406
|
+
__privateGet(this, _temp)[name] = value;
|
|
1234
1407
|
}
|
|
1235
1408
|
get(name) {
|
|
1236
|
-
return this
|
|
1409
|
+
return __privateGet(this, _temp)[name];
|
|
1237
1410
|
}
|
|
1238
|
-
getSnapshot() {
|
|
1239
|
-
|
|
1411
|
+
getSnapshot(opts) {
|
|
1412
|
+
if ((opts == null ? void 0 : opts.deepClone) === true) {
|
|
1413
|
+
return deepClone(__privateGet(this, _temp));
|
|
1414
|
+
}
|
|
1415
|
+
return { ...__privateGet(this, _temp) };
|
|
1240
1416
|
}
|
|
1241
1417
|
clear() {
|
|
1242
|
-
this
|
|
1418
|
+
__privateSet(this, _temp, __privateMethod(this, _createTempStorage, createTempStorage_fn).call(this));
|
|
1243
1419
|
}
|
|
1244
|
-
|
|
1245
|
-
|
|
1420
|
+
destroy() {
|
|
1421
|
+
__privateSet(this, _temp, null);
|
|
1246
1422
|
}
|
|
1247
1423
|
}
|
|
1424
|
+
_temp = new WeakMap();
|
|
1425
|
+
_backUpDefaultStorage = new WeakMap();
|
|
1426
|
+
_createTempStorage = new WeakSet();
|
|
1427
|
+
createTempStorage_fn = function() {
|
|
1428
|
+
return deepClone(__privateGet(this, _backUpDefaultStorage));
|
|
1429
|
+
};
|
|
1248
1430
|
function getViewScaleInfoFromSnapshot(snapshot) {
|
|
1249
1431
|
const { activeStore } = snapshot;
|
|
1250
1432
|
const sacelInfo = {
|
|
@@ -1313,6 +1495,21 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1313
1495
|
};
|
|
1314
1496
|
return calcElementCenter(elemSize);
|
|
1315
1497
|
}
|
|
1498
|
+
function calcRadian(center, start, end) {
|
|
1499
|
+
const startAngle = calcLineRadian(center, start);
|
|
1500
|
+
const endAngle = calcLineRadian(center, end);
|
|
1501
|
+
if (endAngle !== null && startAngle !== null) {
|
|
1502
|
+
if (startAngle > Math.PI * 3 / 2 && endAngle < Math.PI / 2) {
|
|
1503
|
+
return endAngle + (Math.PI * 2 - startAngle);
|
|
1504
|
+
} else if (endAngle > Math.PI * 3 / 2 && startAngle < Math.PI / 2) {
|
|
1505
|
+
return startAngle + (Math.PI * 2 - endAngle);
|
|
1506
|
+
} else {
|
|
1507
|
+
return endAngle - startAngle;
|
|
1508
|
+
}
|
|
1509
|
+
} else {
|
|
1510
|
+
return 0;
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1316
1513
|
function calcLineRadian(center, p) {
|
|
1317
1514
|
const x2 = p.x - center.x;
|
|
1318
1515
|
const y2 = p.y - center.y;
|
|
@@ -1692,6 +1889,24 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1692
1889
|
_scan(uuid, elements);
|
|
1693
1890
|
return groupQueue;
|
|
1694
1891
|
}
|
|
1892
|
+
function getGroupQueueByElementPosition(elements, position) {
|
|
1893
|
+
var _a;
|
|
1894
|
+
const groupQueue = [];
|
|
1895
|
+
let currentElements = elements;
|
|
1896
|
+
if (position.length > 1) {
|
|
1897
|
+
for (let i = 0; i < position.length - 1; i++) {
|
|
1898
|
+
const index = position[i];
|
|
1899
|
+
const group = currentElements[index];
|
|
1900
|
+
if ((group == null ? void 0 : group.type) === "group" && Array.isArray((_a = group == null ? void 0 : group.detail) == null ? void 0 : _a.children)) {
|
|
1901
|
+
groupQueue.push(group);
|
|
1902
|
+
currentElements = group.detail.children;
|
|
1903
|
+
} else {
|
|
1904
|
+
return null;
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
return groupQueue;
|
|
1909
|
+
}
|
|
1695
1910
|
function getElementSize(elem) {
|
|
1696
1911
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = elem;
|
|
1697
1912
|
const size = { x: x2, y: y2, w: w2, h: h2, angle: angle2 };
|
|
@@ -1828,15 +2043,86 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1828
2043
|
return result;
|
|
1829
2044
|
}
|
|
1830
2045
|
function checkRectIntersect(rect1, rect2) {
|
|
1831
|
-
const
|
|
1832
|
-
const
|
|
1833
|
-
const
|
|
1834
|
-
const
|
|
1835
|
-
const
|
|
1836
|
-
const
|
|
1837
|
-
const
|
|
1838
|
-
const
|
|
1839
|
-
return
|
|
2046
|
+
const rect1MinX = rect1.x;
|
|
2047
|
+
const rect1MinY = rect1.y;
|
|
2048
|
+
const rect1MaxX = rect1.x + rect1.w;
|
|
2049
|
+
const rect1MaxY = rect1.y + rect1.h;
|
|
2050
|
+
const rect2MinX = rect2.x;
|
|
2051
|
+
const rect2MinY = rect2.y;
|
|
2052
|
+
const rect2MaxX = rect2.x + rect2.w;
|
|
2053
|
+
const rect2MaxY = rect2.y + rect2.h;
|
|
2054
|
+
return rect1MinX <= rect2MaxX && rect1MaxX >= rect2MinX && rect1MinY <= rect2MaxY && rect1MaxY >= rect2MinY;
|
|
2055
|
+
}
|
|
2056
|
+
function getElementVertexes(elemSize) {
|
|
2057
|
+
const { x: x2, y: y2, h: h2, w: w2 } = elemSize;
|
|
2058
|
+
return [
|
|
2059
|
+
{ x: x2, y: y2 },
|
|
2060
|
+
{ x: x2 + w2, y: y2 },
|
|
2061
|
+
{ x: x2 + w2, y: y2 + h2 },
|
|
2062
|
+
{ x: x2, y: y2 + h2 }
|
|
2063
|
+
];
|
|
2064
|
+
}
|
|
2065
|
+
function calcElementVertexes(elemSize) {
|
|
2066
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemSize;
|
|
2067
|
+
if (angle2 === 0) {
|
|
2068
|
+
return getElementVertexes(elemSize);
|
|
2069
|
+
}
|
|
2070
|
+
return getElementRotateVertexes(elemSize, calcElementCenter({ x: x2, y: y2, w: w2, h: h2, angle: angle2 }), angle2);
|
|
2071
|
+
}
|
|
2072
|
+
function calcElementQueueVertexesQueueInGroup(groupQueue) {
|
|
2073
|
+
const vesList = [];
|
|
2074
|
+
let totalX = 0;
|
|
2075
|
+
let totalY = 0;
|
|
2076
|
+
const rotateActionList = [];
|
|
2077
|
+
const elemQueue = [...groupQueue];
|
|
2078
|
+
for (let i = 0; i < elemQueue.length; i++) {
|
|
2079
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemQueue[i];
|
|
2080
|
+
totalX += x2;
|
|
2081
|
+
totalY += y2;
|
|
2082
|
+
let ves;
|
|
2083
|
+
if (i === 0) {
|
|
2084
|
+
const elemSize = { x: totalX, y: totalY, w: w2, h: h2, angle: angle2 };
|
|
2085
|
+
ves = calcElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2086
|
+
rotateActionList.push({
|
|
2087
|
+
center: calcElementCenter(elemSize),
|
|
2088
|
+
angle: angle2,
|
|
2089
|
+
radian: parseAngleToRadian(angle2)
|
|
2090
|
+
});
|
|
2091
|
+
} else {
|
|
2092
|
+
const elemSize = { x: totalX, y: totalY, w: w2, h: h2, angle: angle2 };
|
|
2093
|
+
ves = getElementVertexes(elemSize);
|
|
2094
|
+
for (let aIdx = 0; aIdx < rotateActionList.length; aIdx++) {
|
|
2095
|
+
const { center, radian } = rotateActionList[aIdx];
|
|
2096
|
+
ves = rotateVertexes(center, ves, radian);
|
|
2097
|
+
}
|
|
2098
|
+
const vesCenter = calcElementCenterFromVertexes(ves);
|
|
2099
|
+
if (angle2 > 0 || angle2 < 0) {
|
|
2100
|
+
const radian = parseAngleToRadian(angle2);
|
|
2101
|
+
ves = rotateVertexes(vesCenter, ves, radian);
|
|
2102
|
+
}
|
|
2103
|
+
rotateActionList.push({
|
|
2104
|
+
center: vesCenter,
|
|
2105
|
+
angle: angle2,
|
|
2106
|
+
radian: parseAngleToRadian(angle2)
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2109
|
+
vesList.push(ves);
|
|
2110
|
+
}
|
|
2111
|
+
return vesList;
|
|
2112
|
+
}
|
|
2113
|
+
function calcElementVertexesQueueInGroup(targetElem, opts) {
|
|
2114
|
+
const { groupQueue } = opts;
|
|
2115
|
+
if (!(groupQueue.length > 0)) {
|
|
2116
|
+
return [calcElementVertexes(targetElem)];
|
|
2117
|
+
}
|
|
2118
|
+
const elemQueue = [...groupQueue, ...[targetElem]];
|
|
2119
|
+
const vesList = calcElementQueueVertexesQueueInGroup(elemQueue);
|
|
2120
|
+
return vesList;
|
|
2121
|
+
}
|
|
2122
|
+
function calcElementVertexesInGroup(targetElem, opts) {
|
|
2123
|
+
const vesList = calcElementVertexesQueueInGroup(targetElem, opts);
|
|
2124
|
+
const ves = vesList.pop();
|
|
2125
|
+
return ves || null;
|
|
1840
2126
|
}
|
|
1841
2127
|
function calcViewScaleInfo(info, opts) {
|
|
1842
2128
|
const { scale, offsetX, offsetY } = info;
|
|
@@ -1924,9 +2210,9 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1924
2210
|
];
|
|
1925
2211
|
}
|
|
1926
2212
|
function isViewPointInElement(p, opts) {
|
|
1927
|
-
const { context2d: ctx, element: elem, viewScaleInfo
|
|
2213
|
+
const { context2d: ctx, element: elem, viewScaleInfo } = opts;
|
|
1928
2214
|
const { angle: angle2 = 0 } = elem;
|
|
1929
|
-
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo
|
|
2215
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo });
|
|
1930
2216
|
const vertexes = rotateElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
1931
2217
|
if (vertexes.length >= 2) {
|
|
1932
2218
|
ctx.beginPath();
|
|
@@ -1941,6 +2227,25 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1941
2227
|
}
|
|
1942
2228
|
return false;
|
|
1943
2229
|
}
|
|
2230
|
+
function isViewPointInElementSize(p, elemSize, opts) {
|
|
2231
|
+
const vertexes = calcElementVertexes(elemSize);
|
|
2232
|
+
return isViewPointInVertexes(p, vertexes, opts);
|
|
2233
|
+
}
|
|
2234
|
+
function isViewPointInVertexes(p, vertexes, opts) {
|
|
2235
|
+
const xList = [vertexes[0].x, vertexes[1].x, vertexes[2].x, vertexes[3].x];
|
|
2236
|
+
const yList = [vertexes[0].y, vertexes[1].y, vertexes[2].y, vertexes[3].y];
|
|
2237
|
+
const mixX = Math.min(...xList);
|
|
2238
|
+
const maxX = Math.max(...xList);
|
|
2239
|
+
const mixY = Math.min(...yList);
|
|
2240
|
+
const maxY = Math.max(...yList);
|
|
2241
|
+
if (p.x > mixX && p.x < maxX && p.y > mixY && p.y < maxY) {
|
|
2242
|
+
return true;
|
|
2243
|
+
}
|
|
2244
|
+
if ((opts == null ? void 0 : opts.includeBorder) === true && (p.x === mixX || p.x === maxX || p.y === mixY || p.y === maxY)) {
|
|
2245
|
+
return true;
|
|
2246
|
+
}
|
|
2247
|
+
return false;
|
|
2248
|
+
}
|
|
1944
2249
|
function getViewPointAtElement(p, opts) {
|
|
1945
2250
|
var _a, _b, _c;
|
|
1946
2251
|
const { context2d: ctx, data, viewScaleInfo, viewSizeInfo, groupQueue } = opts;
|
|
@@ -2011,7 +2316,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2011
2316
|
const { viewSizeInfo, viewScaleInfo } = opts;
|
|
2012
2317
|
const { width, height } = viewSizeInfo;
|
|
2013
2318
|
const { angle: angle2 } = elem;
|
|
2014
|
-
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo
|
|
2319
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo });
|
|
2015
2320
|
const ves = rotateElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2016
2321
|
const viewSize = { x: 0, y: 0, w: width, h: height };
|
|
2017
2322
|
const elemStartX = Math.min(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
|
|
@@ -2021,76 +2326,244 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2021
2326
|
const elemSize = { x: elemStartX, y: elemStartY, w: elemEndX - elemStartX, h: elemEndY - elemStartY };
|
|
2022
2327
|
return checkRectIntersect(viewSize, elemSize);
|
|
2023
2328
|
}
|
|
2024
|
-
function
|
|
2025
|
-
const {
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
];
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
const
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2329
|
+
function calcElementOriginRectInfo(elemSize, opts) {
|
|
2330
|
+
const { groupQueue } = opts;
|
|
2331
|
+
const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
|
|
2332
|
+
const top = getCenterFromTwoPoints(vertexes[0], vertexes[1]);
|
|
2333
|
+
const right = getCenterFromTwoPoints(vertexes[1], vertexes[2]);
|
|
2334
|
+
const bottom = getCenterFromTwoPoints(vertexes[2], vertexes[3]);
|
|
2335
|
+
const left = getCenterFromTwoPoints(vertexes[3], vertexes[0]);
|
|
2336
|
+
const topLeft = vertexes[0];
|
|
2337
|
+
const topRight = vertexes[1];
|
|
2338
|
+
const bottomRight = vertexes[2];
|
|
2339
|
+
const bottomLeft = vertexes[3];
|
|
2340
|
+
const maxX = Math.max(topLeft.x, topRight.x, bottomRight.x, bottomLeft.x);
|
|
2341
|
+
const maxY = Math.max(topLeft.y, topRight.y, bottomRight.y, bottomLeft.y);
|
|
2342
|
+
const minX = Math.min(topLeft.x, topRight.x, bottomRight.x, bottomLeft.x);
|
|
2343
|
+
const minY = Math.min(topLeft.y, topRight.y, bottomRight.y, bottomLeft.y);
|
|
2344
|
+
const center = {
|
|
2345
|
+
x: (maxX + minX) / 2,
|
|
2346
|
+
y: (maxY + minY) / 2
|
|
2347
|
+
};
|
|
2348
|
+
const rectInfo = {
|
|
2349
|
+
center,
|
|
2350
|
+
topLeft,
|
|
2351
|
+
topRight,
|
|
2352
|
+
bottomLeft,
|
|
2353
|
+
bottomRight,
|
|
2354
|
+
top,
|
|
2355
|
+
right,
|
|
2356
|
+
left,
|
|
2357
|
+
bottom
|
|
2358
|
+
};
|
|
2359
|
+
return rectInfo;
|
|
2360
|
+
}
|
|
2361
|
+
function originRectInfoToRangeRectInfo(originRectInfo) {
|
|
2362
|
+
const rangeMaxX = Math.max(originRectInfo.topLeft.x, originRectInfo.topRight.x, originRectInfo.bottomRight.x, originRectInfo.bottomLeft.x);
|
|
2363
|
+
const rangeMaxY = Math.max(originRectInfo.topLeft.y, originRectInfo.topRight.y, originRectInfo.bottomRight.y, originRectInfo.bottomLeft.y);
|
|
2364
|
+
const rangeMinX = Math.min(originRectInfo.topLeft.x, originRectInfo.topRight.x, originRectInfo.bottomRight.x, originRectInfo.bottomLeft.x);
|
|
2365
|
+
const rangeMinY = Math.min(originRectInfo.topLeft.y, originRectInfo.topRight.y, originRectInfo.bottomRight.y, originRectInfo.bottomLeft.y);
|
|
2366
|
+
const rangeCenter = { x: originRectInfo.center.x, y: originRectInfo.center.y };
|
|
2367
|
+
const rangeTopLeft = { x: rangeMinX, y: rangeMinY };
|
|
2368
|
+
const rangeTopRight = { x: rangeMaxX, y: rangeMinY };
|
|
2369
|
+
const rangeBottomRight = { x: rangeMaxX, y: rangeMaxY };
|
|
2370
|
+
const rangeBottomLeft = { x: rangeMinX, y: rangeMaxY };
|
|
2371
|
+
const rangeTop = getCenterFromTwoPoints(rangeTopLeft, rangeTopRight);
|
|
2372
|
+
const rangeBottom = getCenterFromTwoPoints(rangeBottomLeft, rangeBottomRight);
|
|
2373
|
+
const rangeLeft = getCenterFromTwoPoints(rangeTopLeft, rangeBottomLeft);
|
|
2374
|
+
const rangeRight = getCenterFromTwoPoints(rangeTopRight, rangeBottomRight);
|
|
2375
|
+
const rangeRectInfo = {
|
|
2376
|
+
center: rangeCenter,
|
|
2377
|
+
topLeft: rangeTopLeft,
|
|
2378
|
+
topRight: rangeTopRight,
|
|
2379
|
+
bottomLeft: rangeBottomLeft,
|
|
2380
|
+
bottomRight: rangeBottomRight,
|
|
2381
|
+
top: rangeTop,
|
|
2382
|
+
right: rangeRight,
|
|
2383
|
+
left: rangeLeft,
|
|
2384
|
+
bottom: rangeBottom
|
|
2385
|
+
};
|
|
2386
|
+
return rangeRectInfo;
|
|
2387
|
+
}
|
|
2388
|
+
function calcElementViewRectInfo(elemSize, opts) {
|
|
2389
|
+
const { groupQueue, viewScaleInfo, range } = opts;
|
|
2390
|
+
const originRectInfo = calcElementOriginRectInfo(elemSize, { groupQueue });
|
|
2391
|
+
const { center, top, bottom, left, right, topLeft, topRight, bottomLeft, bottomRight } = originRectInfo;
|
|
2392
|
+
const viewRectInfo = {
|
|
2393
|
+
center: calcViewPointSize(center, { viewScaleInfo }),
|
|
2394
|
+
topLeft: calcViewPointSize(topLeft, { viewScaleInfo }),
|
|
2395
|
+
topRight: calcViewPointSize(topRight, { viewScaleInfo }),
|
|
2396
|
+
bottomLeft: calcViewPointSize(bottomLeft, { viewScaleInfo }),
|
|
2397
|
+
bottomRight: calcViewPointSize(bottomRight, { viewScaleInfo }),
|
|
2398
|
+
top: calcViewPointSize(top, { viewScaleInfo }),
|
|
2399
|
+
right: calcViewPointSize(right, { viewScaleInfo }),
|
|
2400
|
+
left: calcViewPointSize(left, { viewScaleInfo }),
|
|
2401
|
+
bottom: calcViewPointSize(bottom, { viewScaleInfo })
|
|
2402
|
+
};
|
|
2403
|
+
if (range === true) {
|
|
2404
|
+
const viewMaxX = Math.max(viewRectInfo.topLeft.x, viewRectInfo.topRight.x, viewRectInfo.bottomRight.x, viewRectInfo.bottomLeft.x);
|
|
2405
|
+
const viewMaxY = Math.max(viewRectInfo.topLeft.y, viewRectInfo.topRight.y, viewRectInfo.bottomRight.y, viewRectInfo.bottomLeft.y);
|
|
2406
|
+
const viewMinX = Math.min(viewRectInfo.topLeft.x, viewRectInfo.topRight.x, viewRectInfo.bottomRight.x, viewRectInfo.bottomLeft.x);
|
|
2407
|
+
const viewMinY = Math.min(viewRectInfo.topLeft.y, viewRectInfo.topRight.y, viewRectInfo.bottomRight.y, viewRectInfo.bottomLeft.y);
|
|
2408
|
+
const rangeCenter = { x: viewRectInfo.center.x, y: viewRectInfo.center.y };
|
|
2409
|
+
const rangeTopLeft = { x: viewMinX, y: viewMinY };
|
|
2410
|
+
const rangeTopRight = { x: viewMaxX, y: viewMinY };
|
|
2411
|
+
const rangeBottomRight = { x: viewMaxX, y: viewMaxY };
|
|
2412
|
+
const rangeBottomLeft = { x: viewMinX, y: viewMaxY };
|
|
2413
|
+
const rangeTop = getCenterFromTwoPoints(rangeTopLeft, rangeTopRight);
|
|
2414
|
+
const rangeBottom = getCenterFromTwoPoints(rangeBottomLeft, rangeBottomRight);
|
|
2415
|
+
const rangeLeft = getCenterFromTwoPoints(rangeTopLeft, rangeBottomLeft);
|
|
2416
|
+
const rangeRight = getCenterFromTwoPoints(rangeTopRight, rangeBottomRight);
|
|
2417
|
+
const rangeRectInfo = {
|
|
2418
|
+
center: rangeCenter,
|
|
2419
|
+
topLeft: rangeTopLeft,
|
|
2420
|
+
topRight: rangeTopRight,
|
|
2421
|
+
bottomLeft: rangeBottomLeft,
|
|
2422
|
+
bottomRight: rangeBottomRight,
|
|
2423
|
+
top: rangeTop,
|
|
2424
|
+
right: rangeRight,
|
|
2425
|
+
left: rangeLeft,
|
|
2426
|
+
bottom: rangeBottom
|
|
2427
|
+
};
|
|
2428
|
+
return rangeRectInfo;
|
|
2429
|
+
}
|
|
2430
|
+
return viewRectInfo;
|
|
2431
|
+
}
|
|
2432
|
+
function calcElementViewRectInfoMap(elemSize, opts) {
|
|
2433
|
+
const { groupQueue, viewScaleInfo } = opts;
|
|
2434
|
+
const originRectInfo = calcElementOriginRectInfo(elemSize, { groupQueue });
|
|
2435
|
+
const { center, top, bottom, left, right, topLeft, topRight, bottomLeft, bottomRight } = originRectInfo;
|
|
2436
|
+
const viewRectInfo = {
|
|
2437
|
+
center: calcViewPointSize(center, { viewScaleInfo }),
|
|
2438
|
+
topLeft: calcViewPointSize(topLeft, { viewScaleInfo }),
|
|
2439
|
+
topRight: calcViewPointSize(topRight, { viewScaleInfo }),
|
|
2440
|
+
bottomLeft: calcViewPointSize(bottomLeft, { viewScaleInfo }),
|
|
2441
|
+
bottomRight: calcViewPointSize(bottomRight, { viewScaleInfo }),
|
|
2442
|
+
top: calcViewPointSize(top, { viewScaleInfo }),
|
|
2443
|
+
right: calcViewPointSize(right, { viewScaleInfo }),
|
|
2444
|
+
left: calcViewPointSize(left, { viewScaleInfo }),
|
|
2445
|
+
bottom: calcViewPointSize(bottom, { viewScaleInfo })
|
|
2446
|
+
};
|
|
2447
|
+
const viewMaxX = Math.max(viewRectInfo.topLeft.x, viewRectInfo.topRight.x, viewRectInfo.bottomRight.x, viewRectInfo.bottomLeft.x);
|
|
2448
|
+
const viewMaxY = Math.max(viewRectInfo.topLeft.y, viewRectInfo.topRight.y, viewRectInfo.bottomRight.y, viewRectInfo.bottomLeft.y);
|
|
2449
|
+
const viewMinX = Math.min(viewRectInfo.topLeft.x, viewRectInfo.topRight.x, viewRectInfo.bottomRight.x, viewRectInfo.bottomLeft.x);
|
|
2450
|
+
const viewMinY = Math.min(viewRectInfo.topLeft.y, viewRectInfo.topRight.y, viewRectInfo.bottomRight.y, viewRectInfo.bottomLeft.y);
|
|
2451
|
+
const rangeCenter = { x: viewRectInfo.center.x, y: viewRectInfo.center.y };
|
|
2452
|
+
const rangeTopLeft = { x: viewMinX, y: viewMinY };
|
|
2453
|
+
const rangeTopRight = { x: viewMaxX, y: viewMinY };
|
|
2454
|
+
const rangeBottomRight = { x: viewMaxX, y: viewMaxY };
|
|
2455
|
+
const rangeBottomLeft = { x: viewMinX, y: viewMaxY };
|
|
2456
|
+
const rangeTop = getCenterFromTwoPoints(rangeTopLeft, rangeTopRight);
|
|
2457
|
+
const rangeBottom = getCenterFromTwoPoints(rangeBottomLeft, rangeBottomRight);
|
|
2458
|
+
const rangeLeft = getCenterFromTwoPoints(rangeTopLeft, rangeBottomLeft);
|
|
2459
|
+
const rangeRight = getCenterFromTwoPoints(rangeTopRight, rangeBottomRight);
|
|
2460
|
+
const rangeRectInfo = {
|
|
2461
|
+
center: rangeCenter,
|
|
2462
|
+
topLeft: rangeTopLeft,
|
|
2463
|
+
topRight: rangeTopRight,
|
|
2464
|
+
bottomLeft: rangeBottomLeft,
|
|
2465
|
+
bottomRight: rangeBottomRight,
|
|
2466
|
+
top: rangeTop,
|
|
2467
|
+
right: rangeRight,
|
|
2468
|
+
left: rangeLeft,
|
|
2469
|
+
bottom: rangeBottom
|
|
2470
|
+
};
|
|
2471
|
+
return {
|
|
2472
|
+
originRectInfo,
|
|
2473
|
+
// viewRectInfo,
|
|
2474
|
+
rangeRectInfo
|
|
2475
|
+
};
|
|
2039
2476
|
}
|
|
2040
|
-
function
|
|
2041
|
-
const
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
} else {
|
|
2060
|
-
const elemSize = { x: totalX, y: totalY, w: w2, h: h2, angle: angle2 };
|
|
2061
|
-
ves = getElementVertexes(elemSize);
|
|
2062
|
-
for (let aIdx = 0; aIdx < rotateActionList.length; aIdx++) {
|
|
2063
|
-
const { center, radian } = rotateActionList[aIdx];
|
|
2064
|
-
ves = rotateVertexes(center, ves, radian);
|
|
2065
|
-
}
|
|
2066
|
-
const vesCenter = calcElementCenterFromVertexes(ves);
|
|
2067
|
-
if (angle2 > 0 || angle2 < 0) {
|
|
2068
|
-
const radian = parseAngleToRadian(angle2);
|
|
2069
|
-
ves = rotateVertexes(vesCenter, ves, radian);
|
|
2477
|
+
function sortElementsViewVisiableInfoMap(elements, opts) {
|
|
2478
|
+
const visibleInfoMap = {};
|
|
2479
|
+
const currentPosition = [];
|
|
2480
|
+
const _walk = (elem) => {
|
|
2481
|
+
const baseInfo = {
|
|
2482
|
+
isVisibleInView: true,
|
|
2483
|
+
isGroup: elem.type === "group",
|
|
2484
|
+
position: [...currentPosition]
|
|
2485
|
+
};
|
|
2486
|
+
let originRectInfo = null;
|
|
2487
|
+
const groupQueue = getGroupQueueByElementPosition(elements, currentPosition);
|
|
2488
|
+
originRectInfo = calcElementOriginRectInfo(elem, {
|
|
2489
|
+
groupQueue: groupQueue || []
|
|
2490
|
+
});
|
|
2491
|
+
visibleInfoMap[elem.uuid] = {
|
|
2492
|
+
...baseInfo,
|
|
2493
|
+
...{
|
|
2494
|
+
originRectInfo,
|
|
2495
|
+
rangeRectInfo: is.angle(elem.angle) ? originRectInfoToRangeRectInfo(originRectInfo) : originRectInfo
|
|
2070
2496
|
}
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2497
|
+
};
|
|
2498
|
+
if (elem.type === "group") {
|
|
2499
|
+
elem.detail.children.forEach((ele, i) => {
|
|
2500
|
+
currentPosition.push(i);
|
|
2501
|
+
_walk(ele);
|
|
2502
|
+
currentPosition.pop();
|
|
2075
2503
|
});
|
|
2076
2504
|
}
|
|
2077
|
-
|
|
2505
|
+
};
|
|
2506
|
+
elements.forEach((elem, index) => {
|
|
2507
|
+
currentPosition.push(index);
|
|
2508
|
+
_walk(elem);
|
|
2509
|
+
currentPosition.pop();
|
|
2510
|
+
});
|
|
2511
|
+
return updateViewVisibleInfoMapStatus(visibleInfoMap, opts);
|
|
2512
|
+
}
|
|
2513
|
+
function isRangeRectInfoCollide(info1, info2) {
|
|
2514
|
+
const rect1MinX = Math.min(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
|
|
2515
|
+
const rect1MaxX = Math.max(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
|
|
2516
|
+
const rect1MinY = Math.min(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
|
|
2517
|
+
const rect1MaxY = Math.max(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
|
|
2518
|
+
const rect2MinX = Math.min(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x);
|
|
2519
|
+
const rect2MaxX = Math.max(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x);
|
|
2520
|
+
const rect2MinY = Math.min(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y);
|
|
2521
|
+
const rect2MaxY = Math.max(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y);
|
|
2522
|
+
if (rect1MinX <= rect2MaxX && rect1MaxX >= rect2MinX && rect1MinY <= rect2MaxY && rect1MaxY >= rect2MinY || rect2MaxX <= rect1MaxY && rect2MaxX >= rect1MaxY && rect2MaxX <= rect1MaxY && rect2MaxX >= rect1MaxY) {
|
|
2523
|
+
return true;
|
|
2078
2524
|
}
|
|
2079
|
-
return
|
|
2525
|
+
return false;
|
|
2080
2526
|
}
|
|
2081
|
-
function
|
|
2082
|
-
const
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2527
|
+
function updateViewVisibleInfoMapStatus(viewVisibleInfoMap, opts) {
|
|
2528
|
+
const canvasRectInfo = calcVisibleOriginCanvasRectInfo(opts);
|
|
2529
|
+
let visibleCount = 0;
|
|
2530
|
+
let invisibleCount = 0;
|
|
2531
|
+
Object.keys(viewVisibleInfoMap).forEach((uuid) => {
|
|
2532
|
+
const info = viewVisibleInfoMap[uuid];
|
|
2533
|
+
info.isVisibleInView = isRangeRectInfoCollide(info.rangeRectInfo, canvasRectInfo);
|
|
2534
|
+
info.isVisibleInView ? visibleCount++ : invisibleCount++;
|
|
2535
|
+
});
|
|
2536
|
+
return { viewVisibleInfoMap, visibleCount, invisibleCount };
|
|
2089
2537
|
}
|
|
2090
|
-
function
|
|
2091
|
-
const
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2538
|
+
function calcVisibleOriginCanvasRectInfo(opts) {
|
|
2539
|
+
const { viewScaleInfo, viewSizeInfo } = opts;
|
|
2540
|
+
const { scale, offsetTop, offsetLeft } = viewScaleInfo;
|
|
2541
|
+
const { width, height } = viewSizeInfo;
|
|
2542
|
+
const x2 = 0 - offsetLeft / scale;
|
|
2543
|
+
const y2 = 0 - offsetTop / scale;
|
|
2544
|
+
const w2 = width / scale;
|
|
2545
|
+
const h2 = height / scale;
|
|
2546
|
+
const center = calcElementCenter({ x: x2, y: y2, w: w2, h: h2 });
|
|
2547
|
+
const topLeft = { x: x2, y: y2 };
|
|
2548
|
+
const topRight = { x: x2 + w2, y: y2 };
|
|
2549
|
+
const bottomLeft = { x: x2, y: y2 + h2 };
|
|
2550
|
+
const bottomRight = { x: x2 + w2, y: y2 + h2 };
|
|
2551
|
+
const left = { x: x2, y: center.y };
|
|
2552
|
+
const top = { x: center.x, y: y2 };
|
|
2553
|
+
const right = { x: x2 + w2, y: center.y };
|
|
2554
|
+
const bottom = { x: center.x, y: y2 + h2 };
|
|
2555
|
+
const rectInfo = {
|
|
2556
|
+
center,
|
|
2557
|
+
topLeft,
|
|
2558
|
+
topRight,
|
|
2559
|
+
bottomLeft,
|
|
2560
|
+
bottomRight,
|
|
2561
|
+
left,
|
|
2562
|
+
top,
|
|
2563
|
+
right,
|
|
2564
|
+
bottom
|
|
2565
|
+
};
|
|
2566
|
+
return rectInfo;
|
|
2094
2567
|
}
|
|
2095
2568
|
function createControllerElementSizeFromCenter(center, opts) {
|
|
2096
2569
|
const { x: x2, y: y2 } = center;
|
|
@@ -2127,6 +2600,16 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2127
2600
|
totalAngle += angle22;
|
|
2128
2601
|
});
|
|
2129
2602
|
const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
|
|
2603
|
+
const rotateElemVertexes = calcElementVertexesInGroup(
|
|
2604
|
+
{
|
|
2605
|
+
x: x2 - ctrlSize * 2,
|
|
2606
|
+
y: y2 - ctrlSize * 2,
|
|
2607
|
+
h: h2 + ctrlSize * 4,
|
|
2608
|
+
w: w2 + ctrlSize * 4,
|
|
2609
|
+
angle: angle2
|
|
2610
|
+
},
|
|
2611
|
+
{ groupQueue: [...groupQueue] }
|
|
2612
|
+
);
|
|
2130
2613
|
const topCenter = getCenterFromTwoPoints(vertexes[0], vertexes[1]);
|
|
2131
2614
|
const rightCenter = getCenterFromTwoPoints(vertexes[1], vertexes[2]);
|
|
2132
2615
|
const bottomCenter = getCenterFromTwoPoints(vertexes[2], vertexes[3]);
|
|
@@ -2135,6 +2618,10 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2135
2618
|
const topRightCenter = vertexes[1];
|
|
2136
2619
|
const bottomRightCenter = vertexes[2];
|
|
2137
2620
|
const bottomLeftCenter = vertexes[3];
|
|
2621
|
+
const topMiddleSize = createControllerElementSizeFromCenter(topCenter, { size: ctrlSize, angle: totalAngle });
|
|
2622
|
+
const rightMiddleSize = createControllerElementSizeFromCenter(rightCenter, { size: ctrlSize, angle: totalAngle });
|
|
2623
|
+
const bottomMiddleSize = createControllerElementSizeFromCenter(bottomCenter, { size: ctrlSize, angle: totalAngle });
|
|
2624
|
+
const leftMiddleSize = createControllerElementSizeFromCenter(leftCenter, { size: ctrlSize, angle: totalAngle });
|
|
2138
2625
|
const topLeftSize = createControllerElementSizeFromCenter(topLeftCenter, { size: ctrlSize, angle: totalAngle });
|
|
2139
2626
|
const topRightSize = createControllerElementSizeFromCenter(topRightCenter, { size: ctrlSize, angle: totalAngle });
|
|
2140
2627
|
const bottomLeftSize = createControllerElementSizeFromCenter(bottomLeftCenter, { size: ctrlSize, angle: totalAngle });
|
|
@@ -2147,6 +2634,13 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2147
2634
|
const rightVertexes = [topRightVertexes[3], topRightVertexes[2], bottomRightVertexes[1], bottomRightVertexes[0]];
|
|
2148
2635
|
const bottomVertexes = [bottomLeftVertexes[1], bottomRightVertexes[0], bottomRightVertexes[3], bottomLeftVertexes[2]];
|
|
2149
2636
|
const leftVertexes = [topLeftVertexes[3], topLeftVertexes[2], bottomLeftVertexes[1], bottomLeftVertexes[0]];
|
|
2637
|
+
const topMiddleVertexes = calcElementVertexes(topMiddleSize);
|
|
2638
|
+
const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
|
|
2639
|
+
const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
|
|
2640
|
+
const leftMiddleVertexes = calcElementVertexes(leftMiddleSize);
|
|
2641
|
+
const rotateCenter = getCenterFromTwoPoints(rotateElemVertexes[0], rotateElemVertexes[1]);
|
|
2642
|
+
const rotateSize = createControllerElementSizeFromCenter(rotateCenter, { size: ctrlSize, angle: totalAngle });
|
|
2643
|
+
const rotateVertexes2 = calcElementVertexes(rotateSize);
|
|
2150
2644
|
const sizeController = {
|
|
2151
2645
|
elementWrapper: vertexes,
|
|
2152
2646
|
left: {
|
|
@@ -2188,6 +2682,128 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2188
2682
|
type: "bottom-right",
|
|
2189
2683
|
vertexes: bottomRightVertexes,
|
|
2190
2684
|
center: bottomRightCenter
|
|
2685
|
+
},
|
|
2686
|
+
leftMiddle: {
|
|
2687
|
+
type: "left-middle",
|
|
2688
|
+
vertexes: leftMiddleVertexes,
|
|
2689
|
+
center: leftCenter
|
|
2690
|
+
},
|
|
2691
|
+
rightMiddle: {
|
|
2692
|
+
type: "right-middle",
|
|
2693
|
+
vertexes: rightMiddleVertexes,
|
|
2694
|
+
center: rightCenter
|
|
2695
|
+
},
|
|
2696
|
+
topMiddle: {
|
|
2697
|
+
type: "top-middle",
|
|
2698
|
+
vertexes: topMiddleVertexes,
|
|
2699
|
+
center: topCenter
|
|
2700
|
+
},
|
|
2701
|
+
bottomMiddle: {
|
|
2702
|
+
type: "bottom-middle",
|
|
2703
|
+
vertexes: bottomMiddleVertexes,
|
|
2704
|
+
center: bottomCenter
|
|
2705
|
+
},
|
|
2706
|
+
rotate: {
|
|
2707
|
+
type: "rotate",
|
|
2708
|
+
vertexes: rotateVertexes2,
|
|
2709
|
+
center: rotateCenter
|
|
2710
|
+
}
|
|
2711
|
+
};
|
|
2712
|
+
return sizeController;
|
|
2713
|
+
}
|
|
2714
|
+
function calcLayoutSizeController(layoutSize, opts) {
|
|
2715
|
+
const { controllerSize, viewScaleInfo } = opts;
|
|
2716
|
+
const ctrlSize = controllerSize && controllerSize > 0 ? controllerSize : 8;
|
|
2717
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(layoutSize, { viewScaleInfo });
|
|
2718
|
+
const center = calcElementCenter({ x: x2, y: y2, w: w2, h: h2 });
|
|
2719
|
+
const topCenter = { x: center.x, y: y2 };
|
|
2720
|
+
const rightCenter = { x: x2 + w2, y: center.y };
|
|
2721
|
+
const bottomCenter = { x: center.x, y: y2 + h2 };
|
|
2722
|
+
const leftCenter = { x: x2, y: center.y };
|
|
2723
|
+
const topLeftCenter = { x: x2, y: y2 };
|
|
2724
|
+
const topRightCenter = { x: x2 + w2, y: y2 };
|
|
2725
|
+
const bottomRightCenter = { x: x2 + w2, y: y2 + h2 };
|
|
2726
|
+
const bottomLeftCenter = { x: x2, y: y2 + h2 };
|
|
2727
|
+
const topMiddleSize = createControllerElementSizeFromCenter(topCenter, { size: ctrlSize, angle: 0 });
|
|
2728
|
+
const rightMiddleSize = createControllerElementSizeFromCenter(rightCenter, { size: ctrlSize, angle: 0 });
|
|
2729
|
+
const bottomMiddleSize = createControllerElementSizeFromCenter(bottomCenter, { size: ctrlSize, angle: 0 });
|
|
2730
|
+
const leftMiddleSize = createControllerElementSizeFromCenter(leftCenter, { size: ctrlSize, angle: 0 });
|
|
2731
|
+
const topLeftSize = createControllerElementSizeFromCenter(topLeftCenter, { size: ctrlSize, angle: 0 });
|
|
2732
|
+
const topRightSize = createControllerElementSizeFromCenter(topRightCenter, { size: ctrlSize, angle: 0 });
|
|
2733
|
+
const bottomLeftSize = createControllerElementSizeFromCenter(bottomLeftCenter, { size: ctrlSize, angle: 0 });
|
|
2734
|
+
const bottomRightSize = createControllerElementSizeFromCenter(bottomRightCenter, { size: ctrlSize, angle: 0 });
|
|
2735
|
+
const topLeftVertexes = calcElementVertexes(topLeftSize);
|
|
2736
|
+
const topRightVertexes = calcElementVertexes(topRightSize);
|
|
2737
|
+
const bottomLeftVertexes = calcElementVertexes(bottomLeftSize);
|
|
2738
|
+
const bottomRightVertexes = calcElementVertexes(bottomRightSize);
|
|
2739
|
+
const topVertexes = [topLeftVertexes[1], topRightVertexes[0], topRightVertexes[3], topLeftVertexes[2]];
|
|
2740
|
+
const rightVertexes = [topRightVertexes[3], topRightVertexes[2], bottomRightVertexes[1], bottomRightVertexes[0]];
|
|
2741
|
+
const bottomVertexes = [bottomLeftVertexes[1], bottomRightVertexes[0], bottomRightVertexes[3], bottomLeftVertexes[2]];
|
|
2742
|
+
const leftVertexes = [topLeftVertexes[3], topLeftVertexes[2], bottomLeftVertexes[1], bottomLeftVertexes[0]];
|
|
2743
|
+
const topMiddleVertexes = calcElementVertexes(topMiddleSize);
|
|
2744
|
+
const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
|
|
2745
|
+
const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
|
|
2746
|
+
const leftMiddleVertexes = calcElementVertexes(leftMiddleSize);
|
|
2747
|
+
const sizeController = {
|
|
2748
|
+
left: {
|
|
2749
|
+
type: "left",
|
|
2750
|
+
vertexes: leftVertexes,
|
|
2751
|
+
center: leftCenter
|
|
2752
|
+
},
|
|
2753
|
+
right: {
|
|
2754
|
+
type: "right",
|
|
2755
|
+
vertexes: rightVertexes,
|
|
2756
|
+
center: rightCenter
|
|
2757
|
+
},
|
|
2758
|
+
top: {
|
|
2759
|
+
type: "top",
|
|
2760
|
+
vertexes: topVertexes,
|
|
2761
|
+
center: topCenter
|
|
2762
|
+
},
|
|
2763
|
+
bottom: {
|
|
2764
|
+
type: "bottom",
|
|
2765
|
+
vertexes: bottomVertexes,
|
|
2766
|
+
center: bottomCenter
|
|
2767
|
+
},
|
|
2768
|
+
topLeft: {
|
|
2769
|
+
type: "top-left",
|
|
2770
|
+
vertexes: topLeftVertexes,
|
|
2771
|
+
center: topLeftCenter
|
|
2772
|
+
},
|
|
2773
|
+
topRight: {
|
|
2774
|
+
type: "top-right",
|
|
2775
|
+
vertexes: topRightVertexes,
|
|
2776
|
+
center: topRightCenter
|
|
2777
|
+
},
|
|
2778
|
+
bottomLeft: {
|
|
2779
|
+
type: "bottom-left",
|
|
2780
|
+
vertexes: bottomLeftVertexes,
|
|
2781
|
+
center: bottomLeftCenter
|
|
2782
|
+
},
|
|
2783
|
+
bottomRight: {
|
|
2784
|
+
type: "bottom-right",
|
|
2785
|
+
vertexes: bottomRightVertexes,
|
|
2786
|
+
center: bottomRightCenter
|
|
2787
|
+
},
|
|
2788
|
+
leftMiddle: {
|
|
2789
|
+
type: "left-middle",
|
|
2790
|
+
vertexes: leftMiddleVertexes,
|
|
2791
|
+
center: leftCenter
|
|
2792
|
+
},
|
|
2793
|
+
rightMiddle: {
|
|
2794
|
+
type: "right-middle",
|
|
2795
|
+
vertexes: rightMiddleVertexes,
|
|
2796
|
+
center: rightCenter
|
|
2797
|
+
},
|
|
2798
|
+
topMiddle: {
|
|
2799
|
+
type: "top-middle",
|
|
2800
|
+
vertexes: topMiddleVertexes,
|
|
2801
|
+
center: topCenter
|
|
2802
|
+
},
|
|
2803
|
+
bottomMiddle: {
|
|
2804
|
+
type: "bottom-middle",
|
|
2805
|
+
vertexes: bottomMiddleVertexes,
|
|
2806
|
+
center: bottomCenter
|
|
2191
2807
|
}
|
|
2192
2808
|
};
|
|
2193
2809
|
return sizeController;
|
|
@@ -2425,6 +3041,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2425
3041
|
}
|
|
2426
3042
|
return radian;
|
|
2427
3043
|
}
|
|
3044
|
+
const defaultText = "Text Element";
|
|
2428
3045
|
function getDefaultElementDetailConfig() {
|
|
2429
3046
|
const config = {
|
|
2430
3047
|
boxSizing: "border-box",
|
|
@@ -2441,9 +3058,11 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2441
3058
|
textAlign: "left",
|
|
2442
3059
|
verticalAlign: "top",
|
|
2443
3060
|
fontSize: 16,
|
|
2444
|
-
lineHeight: 20,
|
|
3061
|
+
// lineHeight: 20,
|
|
2445
3062
|
fontFamily: "sans-serif",
|
|
2446
3063
|
fontWeight: 400,
|
|
3064
|
+
minInlineSize: "auto",
|
|
3065
|
+
wordBreak: "break-all",
|
|
2447
3066
|
overflow: "hidden"
|
|
2448
3067
|
};
|
|
2449
3068
|
return config;
|
|
@@ -2454,24 +3073,22 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2454
3073
|
};
|
|
2455
3074
|
return detail;
|
|
2456
3075
|
}
|
|
2457
|
-
function getDefaultElementCircleDetail(
|
|
3076
|
+
function getDefaultElementCircleDetail() {
|
|
2458
3077
|
const detail = {
|
|
2459
3078
|
background: "#D9D9D9",
|
|
2460
3079
|
radius: 0
|
|
2461
3080
|
};
|
|
2462
3081
|
return detail;
|
|
2463
3082
|
}
|
|
2464
|
-
function getDefaultElementTextDetail(
|
|
2465
|
-
var _a;
|
|
3083
|
+
function getDefaultElementTextDetail(elementSize) {
|
|
2466
3084
|
const detailConfig = getDefaultElementDetailConfig();
|
|
2467
|
-
const scale = ((_a = opts == null ? void 0 : opts.viewScaleInfo) == null ? void 0 : _a.scale) || 1;
|
|
2468
3085
|
const detail = {
|
|
2469
|
-
text:
|
|
3086
|
+
text: defaultText,
|
|
2470
3087
|
color: detailConfig.color,
|
|
2471
3088
|
fontFamily: detailConfig.fontFamily,
|
|
2472
3089
|
fontWeight: detailConfig.fontWeight,
|
|
2473
|
-
lineHeight:
|
|
2474
|
-
fontSize:
|
|
3090
|
+
lineHeight: elementSize.w / defaultText.length,
|
|
3091
|
+
fontSize: elementSize.w / defaultText.length,
|
|
2475
3092
|
textAlign: "center",
|
|
2476
3093
|
verticalAlign: "middle"
|
|
2477
3094
|
};
|
|
@@ -2489,7 +3106,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2489
3106
|
};
|
|
2490
3107
|
return detail;
|
|
2491
3108
|
}
|
|
2492
|
-
function getDefaultElementGroupDetail(
|
|
3109
|
+
function getDefaultElementGroupDetail() {
|
|
2493
3110
|
const detail = {
|
|
2494
3111
|
children: [],
|
|
2495
3112
|
background: "#D9D9D9",
|
|
@@ -2501,9 +3118,10 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2501
3118
|
function calcViewBoxSize(viewElem, opts) {
|
|
2502
3119
|
const { viewScaleInfo } = opts;
|
|
2503
3120
|
const { scale } = viewScaleInfo;
|
|
2504
|
-
let { borderRadius: borderRadius2 } = viewElem.detail;
|
|
3121
|
+
let { borderRadius: borderRadius2, borderDash } = viewElem.detail;
|
|
3122
|
+
const hasBorderDash = Array.isArray(borderDash) && borderDash.length > 0;
|
|
2505
3123
|
const { boxSizing = defaultElemConfig.boxSizing, borderWidth: borderWidth2 } = viewElem.detail;
|
|
2506
|
-
if (
|
|
3124
|
+
if (Array.isArray(borderWidth2)) {
|
|
2507
3125
|
borderRadius2 = 0;
|
|
2508
3126
|
}
|
|
2509
3127
|
let { x: x2, y: y2, w: w2, h: h2 } = viewElem;
|
|
@@ -2518,7 +3136,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2518
3136
|
if (typeof borderWidth2 === "number") {
|
|
2519
3137
|
bw = (borderWidth2 || 0) * scale;
|
|
2520
3138
|
}
|
|
2521
|
-
if (boxSizing === "border-box") {
|
|
3139
|
+
if (boxSizing === "border-box" && !hasBorderDash) {
|
|
2522
3140
|
x2 = viewElem.x + bw / 2;
|
|
2523
3141
|
y2 = viewElem.y + bw / 2;
|
|
2524
3142
|
w2 = viewElem.w - bw;
|
|
@@ -2547,9 +3165,105 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2547
3165
|
radiusList
|
|
2548
3166
|
};
|
|
2549
3167
|
}
|
|
3168
|
+
const doNum = (n) => {
|
|
3169
|
+
return formatNumber(n, { decimalPlaces: 4 });
|
|
3170
|
+
};
|
|
3171
|
+
function resizeElementBaseDetail(elem, opts) {
|
|
3172
|
+
const { detail } = elem;
|
|
3173
|
+
const { xRatio, yRatio, maxRatio } = opts;
|
|
3174
|
+
const middleRatio = (xRatio + yRatio) / 2;
|
|
3175
|
+
const { borderWidth: borderWidth2, borderRadius: borderRadius2, borderDash, shadowOffsetX, shadowOffsetY, shadowBlur } = detail;
|
|
3176
|
+
if (typeof borderWidth2 === "number") {
|
|
3177
|
+
detail.borderWidth = doNum(borderWidth2 * middleRatio);
|
|
3178
|
+
} else if (Array.isArray(detail.borderWidth)) {
|
|
3179
|
+
const bw = borderWidth2;
|
|
3180
|
+
detail.borderWidth = [doNum(bw[0] * yRatio), doNum(bw[1] * xRatio), doNum(bw[2] * yRatio), doNum(bw[3] * xRatio)];
|
|
3181
|
+
}
|
|
3182
|
+
if (typeof borderRadius2 === "number") {
|
|
3183
|
+
detail.borderRadius = doNum(borderRadius2 * middleRatio);
|
|
3184
|
+
} else if (Array.isArray(detail.borderRadius)) {
|
|
3185
|
+
const br = borderRadius2;
|
|
3186
|
+
detail.borderRadius = [br[0] * xRatio, br[1] * xRatio, br[2] * yRatio, br[3] * yRatio];
|
|
3187
|
+
}
|
|
3188
|
+
if (Array.isArray(borderDash)) {
|
|
3189
|
+
borderDash.forEach((dash, i) => {
|
|
3190
|
+
detail.borderDash[i] = doNum(dash * maxRatio);
|
|
3191
|
+
});
|
|
3192
|
+
}
|
|
3193
|
+
if (typeof shadowOffsetX === "number") {
|
|
3194
|
+
detail.shadowOffsetX = doNum(shadowOffsetX * maxRatio);
|
|
3195
|
+
}
|
|
3196
|
+
if (typeof shadowOffsetY === "number") {
|
|
3197
|
+
detail.shadowOffsetX = doNum(shadowOffsetY * maxRatio);
|
|
3198
|
+
}
|
|
3199
|
+
if (typeof shadowBlur === "number") {
|
|
3200
|
+
detail.shadowOffsetX = doNum(shadowBlur * maxRatio);
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
function resizeElementBase(elem, opts) {
|
|
3204
|
+
const { xRatio, yRatio } = opts;
|
|
3205
|
+
const { x: x2, y: y2, w: w2, h: h2 } = elem;
|
|
3206
|
+
elem.x = doNum(x2 * xRatio);
|
|
3207
|
+
elem.y = doNum(y2 * yRatio);
|
|
3208
|
+
elem.w = doNum(w2 * xRatio);
|
|
3209
|
+
elem.h = doNum(h2 * yRatio);
|
|
3210
|
+
resizeElementBaseDetail(elem, opts);
|
|
3211
|
+
}
|
|
3212
|
+
function resizeTextElementDetail(elem, opts) {
|
|
3213
|
+
const { minRatio, maxRatio } = opts;
|
|
3214
|
+
const { fontSize: fontSize2, lineHeight: lineHeight2 } = elem.detail;
|
|
3215
|
+
const ratio = (minRatio + maxRatio) / 2;
|
|
3216
|
+
if (fontSize2 && fontSize2 > 0) {
|
|
3217
|
+
elem.detail.fontSize = doNum(fontSize2 * ratio);
|
|
3218
|
+
}
|
|
3219
|
+
if (lineHeight2 && lineHeight2 > 0) {
|
|
3220
|
+
elem.detail.lineHeight = doNum(lineHeight2 * ratio);
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
function resizeElement(elem, opts) {
|
|
3224
|
+
const { type } = elem;
|
|
3225
|
+
resizeElementBase(elem, opts);
|
|
3226
|
+
if (type === "circle")
|
|
3227
|
+
;
|
|
3228
|
+
else if (type === "text") {
|
|
3229
|
+
resizeTextElementDetail(elem, opts);
|
|
3230
|
+
} else if (type === "image")
|
|
3231
|
+
;
|
|
3232
|
+
else if (type === "svg")
|
|
3233
|
+
;
|
|
3234
|
+
else if (type === "html")
|
|
3235
|
+
;
|
|
3236
|
+
else if (type === "path")
|
|
3237
|
+
;
|
|
3238
|
+
else if (type === "group" && Array.isArray(elem.detail.children)) {
|
|
3239
|
+
elem.detail.children.forEach((child) => {
|
|
3240
|
+
resizeElement(child, opts);
|
|
3241
|
+
});
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
function deepResizeGroupElement(elem, size) {
|
|
3245
|
+
const resizeW = size.w && size.w > 0 ? size.w : elem.w;
|
|
3246
|
+
const resizeH = size.h && size.h > 0 ? size.h : elem.h;
|
|
3247
|
+
const xRatio = resizeW / elem.w;
|
|
3248
|
+
const yRatio = resizeH / elem.h;
|
|
3249
|
+
if (xRatio === yRatio && xRatio === 1) {
|
|
3250
|
+
return elem;
|
|
3251
|
+
}
|
|
3252
|
+
const minRatio = Math.min(xRatio, yRatio);
|
|
3253
|
+
const maxRatio = Math.max(xRatio, yRatio);
|
|
3254
|
+
elem.w = resizeW;
|
|
3255
|
+
elem.h = resizeH;
|
|
3256
|
+
const opts = { xRatio, yRatio, minRatio, maxRatio };
|
|
3257
|
+
if (elem.type === "group" && Array.isArray(elem.detail.children)) {
|
|
3258
|
+
elem.detail.children.forEach((child) => {
|
|
3259
|
+
resizeElement(child, opts);
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
3262
|
+
resizeElementBaseDetail(elem, opts);
|
|
3263
|
+
return elem;
|
|
3264
|
+
}
|
|
2550
3265
|
const defaultViewWidth = 200;
|
|
2551
3266
|
const defaultViewHeight = 200;
|
|
2552
|
-
const defaultDetail = getDefaultElementDetailConfig();
|
|
2553
3267
|
function createElementSize(type, opts) {
|
|
2554
3268
|
let x2 = 0;
|
|
2555
3269
|
let y2 = 0;
|
|
@@ -2559,26 +3273,23 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2559
3273
|
const { viewScaleInfo, viewSizeInfo } = opts;
|
|
2560
3274
|
const { scale, offsetLeft, offsetTop } = viewScaleInfo;
|
|
2561
3275
|
const { width, height } = viewSizeInfo;
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
3276
|
+
const limitViewWidth = width / 4;
|
|
3277
|
+
const limitViewHeight = height / 4;
|
|
3278
|
+
if (defaultViewWidth >= limitViewWidth) {
|
|
3279
|
+
w2 = limitViewWidth / scale;
|
|
2566
3280
|
} else {
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
if (["circle", "svg", "image"].includes(type)) {
|
|
2580
|
-
w2 = h2 = Math.max(w2, h2);
|
|
2581
|
-
}
|
|
3281
|
+
w2 = defaultViewWidth / scale;
|
|
3282
|
+
}
|
|
3283
|
+
if (defaultViewHeight >= limitViewHeight) {
|
|
3284
|
+
h2 = limitViewHeight / scale;
|
|
3285
|
+
} else {
|
|
3286
|
+
h2 = defaultViewHeight / scale;
|
|
3287
|
+
}
|
|
3288
|
+
if (["circle", "svg", "image"].includes(type)) {
|
|
3289
|
+
w2 = h2 = Math.max(w2, h2);
|
|
3290
|
+
} else if (type === "text") {
|
|
3291
|
+
const fontSize2 = w2 / defaultText.length;
|
|
3292
|
+
h2 = fontSize2 * 2;
|
|
2582
3293
|
}
|
|
2583
3294
|
x2 = (0 - offsetLeft + width / 2 - w2 * scale / 2) / scale;
|
|
2584
3295
|
y2 = (0 - offsetTop + height / 2 - h2 * scale / 2) / scale;
|
|
@@ -2592,16 +3303,14 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2592
3303
|
return elemSize;
|
|
2593
3304
|
}
|
|
2594
3305
|
function createElement(type, baseElem, opts) {
|
|
2595
|
-
const
|
|
3306
|
+
const elementSize = createElementSize(type, opts);
|
|
2596
3307
|
let detail = {};
|
|
2597
3308
|
if (type === "rect") {
|
|
2598
3309
|
detail = getDefaultElementRectDetail();
|
|
2599
3310
|
} else if (type === "circle") {
|
|
2600
|
-
detail = getDefaultElementCircleDetail(
|
|
2601
|
-
radius: elemSize.w
|
|
2602
|
-
});
|
|
3311
|
+
detail = getDefaultElementCircleDetail();
|
|
2603
3312
|
} else if (type === "text") {
|
|
2604
|
-
detail = getDefaultElementTextDetail(
|
|
3313
|
+
detail = getDefaultElementTextDetail(elementSize);
|
|
2605
3314
|
} else if (type === "svg") {
|
|
2606
3315
|
detail = getDefaultElementSVGDetail();
|
|
2607
3316
|
} else if (type === "image") {
|
|
@@ -2610,7 +3319,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2610
3319
|
detail = getDefaultElementGroupDetail();
|
|
2611
3320
|
}
|
|
2612
3321
|
const elem = {
|
|
2613
|
-
...
|
|
3322
|
+
...elementSize,
|
|
2614
3323
|
...baseElem,
|
|
2615
3324
|
uuid: createUUID(),
|
|
2616
3325
|
type,
|
|
@@ -2674,15 +3383,16 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2674
3383
|
return deleteElementInListByPosition(position, list);
|
|
2675
3384
|
}
|
|
2676
3385
|
function moveElementPosition(elements, opts) {
|
|
2677
|
-
const
|
|
3386
|
+
const from = [...opts.from];
|
|
3387
|
+
const to = [...opts.to];
|
|
2678
3388
|
if (from.length === 0 || to.length === 0) {
|
|
2679
|
-
return elements;
|
|
3389
|
+
return { elements, from, to };
|
|
2680
3390
|
}
|
|
2681
3391
|
if (from.length <= to.length) {
|
|
2682
3392
|
for (let i = 0; i < from.length; i++) {
|
|
2683
3393
|
if (to[i] === from[i]) {
|
|
2684
3394
|
if (i === from.length - 1) {
|
|
2685
|
-
return elements;
|
|
3395
|
+
return { elements, from, to };
|
|
2686
3396
|
}
|
|
2687
3397
|
continue;
|
|
2688
3398
|
}
|
|
@@ -2692,18 +3402,59 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2692
3402
|
if (target) {
|
|
2693
3403
|
const insterResult = insertElementToListByPosition(target, to, elements);
|
|
2694
3404
|
if (!insterResult) {
|
|
2695
|
-
return elements;
|
|
3405
|
+
return { elements, from, to };
|
|
2696
3406
|
}
|
|
2697
3407
|
let trimDeletePosIndex = -1;
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
3408
|
+
let isEffectToIndex = false;
|
|
3409
|
+
if (from.length >= 1 && to.length >= 1) {
|
|
3410
|
+
if (from.length <= to.length) {
|
|
3411
|
+
if (from.length === 1) {
|
|
3412
|
+
if (from[0] < to[0]) {
|
|
3413
|
+
isEffectToIndex = true;
|
|
3414
|
+
}
|
|
3415
|
+
} else {
|
|
3416
|
+
for (let i = 0; i < from.length; i++) {
|
|
3417
|
+
if (from[i] === to[i]) {
|
|
3418
|
+
if (from.length === from.length - 1) {
|
|
3419
|
+
isEffectToIndex = true;
|
|
3420
|
+
break;
|
|
3421
|
+
}
|
|
3422
|
+
} else {
|
|
3423
|
+
break;
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
2701
3427
|
}
|
|
2702
|
-
if (
|
|
2703
|
-
|
|
3428
|
+
if (from.length >= to.length) {
|
|
3429
|
+
if (to.length === 1) {
|
|
3430
|
+
if (to[0] < from[0]) {
|
|
3431
|
+
isEffectToIndex = true;
|
|
3432
|
+
}
|
|
3433
|
+
} else {
|
|
3434
|
+
for (let i = 0; i < to.length; i++) {
|
|
3435
|
+
if (i === to.length - 1 && to[i] < from[i]) {
|
|
3436
|
+
isEffectToIndex = true;
|
|
3437
|
+
}
|
|
3438
|
+
if (from[i] === to[i]) {
|
|
3439
|
+
continue;
|
|
3440
|
+
} else {
|
|
3441
|
+
break;
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
2704
3445
|
}
|
|
2705
|
-
|
|
2706
|
-
|
|
3446
|
+
}
|
|
3447
|
+
if (isEffectToIndex === true) {
|
|
3448
|
+
for (let i = 0; i < from.length; i++) {
|
|
3449
|
+
if (!(to[i] >= 0)) {
|
|
3450
|
+
break;
|
|
3451
|
+
}
|
|
3452
|
+
if (to[i] === from[i]) {
|
|
3453
|
+
continue;
|
|
3454
|
+
}
|
|
3455
|
+
if (to[i] < from[i] && i == to.length - 1) {
|
|
3456
|
+
trimDeletePosIndex = i;
|
|
3457
|
+
}
|
|
2707
3458
|
}
|
|
2708
3459
|
}
|
|
2709
3460
|
if (trimDeletePosIndex >= 0) {
|
|
@@ -2713,7 +3464,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2713
3464
|
}
|
|
2714
3465
|
deleteElementInListByPosition(from, elements);
|
|
2715
3466
|
}
|
|
2716
|
-
return elements;
|
|
3467
|
+
return { elements, from, to };
|
|
2717
3468
|
}
|
|
2718
3469
|
function mergeElement(originElem, updateContent) {
|
|
2719
3470
|
var _a;
|
|
@@ -2746,20 +3497,341 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2746
3497
|
return originElem;
|
|
2747
3498
|
}
|
|
2748
3499
|
function updateElementInList(uuid, updateContent, elements) {
|
|
2749
|
-
var _a;
|
|
3500
|
+
var _a, _b;
|
|
2750
3501
|
let targetElement = null;
|
|
2751
3502
|
for (let i = 0; i < elements.length; i++) {
|
|
2752
3503
|
const elem = elements[i];
|
|
2753
3504
|
if (elem.uuid === uuid) {
|
|
3505
|
+
if (elem.type === "group" && ((_a = elem.operations) == null ? void 0 : _a.deepResize) === true) {
|
|
3506
|
+
if (updateContent.w && updateContent.w > 0 || updateContent.h && updateContent.h > 0) {
|
|
3507
|
+
deepResizeGroupElement(elem, {
|
|
3508
|
+
w: updateContent.w,
|
|
3509
|
+
h: updateContent.h
|
|
3510
|
+
});
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
2754
3513
|
mergeElement(elem, updateContent);
|
|
2755
3514
|
targetElement = elem;
|
|
2756
3515
|
break;
|
|
2757
3516
|
} else if (elem.type === "group") {
|
|
2758
|
-
targetElement = updateElementInList(uuid, updateContent, ((
|
|
3517
|
+
targetElement = updateElementInList(uuid, updateContent, ((_b = elem == null ? void 0 : elem.detail) == null ? void 0 : _b.children) || []);
|
|
2759
3518
|
}
|
|
2760
3519
|
}
|
|
2761
3520
|
return targetElement;
|
|
2762
3521
|
}
|
|
3522
|
+
function updateElementInListByPosition(position, updateContent, elements) {
|
|
3523
|
+
var _a;
|
|
3524
|
+
const elem = findElementFromListByPosition(position, elements);
|
|
3525
|
+
if (elem) {
|
|
3526
|
+
if (elem.type === "group" && ((_a = elem.operations) == null ? void 0 : _a.deepResize) === true) {
|
|
3527
|
+
if (updateContent.w && updateContent.w > 0 || updateContent.h && updateContent.h > 0) {
|
|
3528
|
+
deepResizeGroupElement(elem, {
|
|
3529
|
+
w: updateContent.w,
|
|
3530
|
+
h: updateContent.h
|
|
3531
|
+
});
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
mergeElement(elem, updateContent);
|
|
3535
|
+
}
|
|
3536
|
+
return elem;
|
|
3537
|
+
}
|
|
3538
|
+
function calcViewCenterContent(data, opts) {
|
|
3539
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3540
|
+
let offsetX = 0;
|
|
3541
|
+
let offsetY = 0;
|
|
3542
|
+
let scale = 1;
|
|
3543
|
+
let contentX = ((_b = (_a = data == null ? void 0 : data.elements) == null ? void 0 : _a[0]) == null ? void 0 : _b.x) || 0;
|
|
3544
|
+
let contentY = ((_d = (_c = data == null ? void 0 : data.elements) == null ? void 0 : _c[0]) == null ? void 0 : _d.y) || 0;
|
|
3545
|
+
let contentW = ((_f = (_e = data == null ? void 0 : data.elements) == null ? void 0 : _e[0]) == null ? void 0 : _f.w) || 0;
|
|
3546
|
+
let contentH = ((_h = (_g = data == null ? void 0 : data.elements) == null ? void 0 : _g[0]) == null ? void 0 : _h.h) || 0;
|
|
3547
|
+
const { width, height } = opts.viewSizeInfo;
|
|
3548
|
+
if (data.layout && ((_j = (_i = data.layout) == null ? void 0 : _i.detail) == null ? void 0 : _j.overflow) === "hidden") {
|
|
3549
|
+
contentX = 0;
|
|
3550
|
+
contentY = 0;
|
|
3551
|
+
contentW = data.layout.w || 0;
|
|
3552
|
+
contentH = data.layout.h || 0;
|
|
3553
|
+
} else {
|
|
3554
|
+
data.elements.forEach((elem) => {
|
|
3555
|
+
const elemSize = {
|
|
3556
|
+
x: elem.x,
|
|
3557
|
+
y: elem.y,
|
|
3558
|
+
w: elem.w,
|
|
3559
|
+
h: elem.h,
|
|
3560
|
+
angle: elem.angle
|
|
3561
|
+
};
|
|
3562
|
+
if (elemSize.angle && (elemSize.angle > 0 || elemSize.angle < 0)) {
|
|
3563
|
+
const ves = rotateElementVertexes(elemSize);
|
|
3564
|
+
if (ves.length === 4) {
|
|
3565
|
+
const xList = [ves[0].x, ves[1].x, ves[2].x, ves[3].x];
|
|
3566
|
+
const yList = [ves[0].y, ves[1].y, ves[2].y, ves[3].y];
|
|
3567
|
+
elemSize.x = Math.min(...xList);
|
|
3568
|
+
elemSize.y = Math.min(...yList);
|
|
3569
|
+
elemSize.w = Math.abs(Math.max(...xList) - Math.min(...xList));
|
|
3570
|
+
elemSize.h = Math.abs(Math.max(...yList) - Math.min(...yList));
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
const areaStartX = Math.min(elemSize.x, contentX);
|
|
3574
|
+
const areaStartY = Math.min(elemSize.y, contentY);
|
|
3575
|
+
const areaEndX = Math.max(elemSize.x + elemSize.w, contentX + contentW);
|
|
3576
|
+
const areaEndY = Math.max(elemSize.y + elemSize.h, contentY + contentH);
|
|
3577
|
+
contentX = areaStartX;
|
|
3578
|
+
contentY = areaStartY;
|
|
3579
|
+
contentW = Math.abs(areaEndX - areaStartX);
|
|
3580
|
+
contentH = Math.abs(areaEndY - areaStartY);
|
|
3581
|
+
});
|
|
3582
|
+
}
|
|
3583
|
+
if (data.layout) {
|
|
3584
|
+
const { x: x2, y: y2, w: w2, h: h2 } = data.layout;
|
|
3585
|
+
if (is.x(x2) && is.y(y2) && is.w(w2) && is.h(h2)) {
|
|
3586
|
+
contentX = Math.min(contentX, x2);
|
|
3587
|
+
contentY = Math.min(contentY, y2);
|
|
3588
|
+
contentW = Math.max(contentW, w2);
|
|
3589
|
+
contentH = Math.max(contentH, h2);
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
if (contentW > 0 && contentH > 0) {
|
|
3593
|
+
const scaleW = formatNumber(width / contentW, { decimalPlaces: 4 });
|
|
3594
|
+
const scaleH = formatNumber(height / contentH, { decimalPlaces: 4 });
|
|
3595
|
+
scale = Math.min(scaleW, scaleH, 1);
|
|
3596
|
+
offsetX = (contentW * scale - width) / 2 / scale + contentX;
|
|
3597
|
+
offsetY = (contentH * scale - height) / 2 / scale + contentY;
|
|
3598
|
+
}
|
|
3599
|
+
const result = {
|
|
3600
|
+
offsetX: formatNumber(offsetX, { decimalPlaces: 0 }),
|
|
3601
|
+
offsetY: formatNumber(offsetY, { decimalPlaces: 0 }),
|
|
3602
|
+
scale
|
|
3603
|
+
};
|
|
3604
|
+
return result;
|
|
3605
|
+
}
|
|
3606
|
+
function calcViewCenter(opts) {
|
|
3607
|
+
let x2 = 0;
|
|
3608
|
+
let y2 = 0;
|
|
3609
|
+
if (opts) {
|
|
3610
|
+
const { viewScaleInfo, viewSizeInfo } = opts;
|
|
3611
|
+
const { offsetLeft, offsetTop, scale } = viewScaleInfo;
|
|
3612
|
+
const { width, height } = viewSizeInfo;
|
|
3613
|
+
x2 = 0 - offsetLeft + width / scale / 2;
|
|
3614
|
+
y2 = 0 - offsetTop + height / scale / 2;
|
|
3615
|
+
}
|
|
3616
|
+
const p = {
|
|
3617
|
+
x: x2,
|
|
3618
|
+
y: y2
|
|
3619
|
+
};
|
|
3620
|
+
return p;
|
|
3621
|
+
}
|
|
3622
|
+
function modifyElement(data, options) {
|
|
3623
|
+
const { type } = options;
|
|
3624
|
+
const content = { ...options.content };
|
|
3625
|
+
if (type === "addElement") {
|
|
3626
|
+
const opts = options;
|
|
3627
|
+
const { element, position } = opts.content;
|
|
3628
|
+
if ((position == null ? void 0 : position.length) > 0) {
|
|
3629
|
+
insertElementToListByPosition(element, [...position], data.elements);
|
|
3630
|
+
} else {
|
|
3631
|
+
data.elements.push(element);
|
|
3632
|
+
}
|
|
3633
|
+
} else if (type === "deleteElement") {
|
|
3634
|
+
const opts = options;
|
|
3635
|
+
const { position } = opts.content;
|
|
3636
|
+
deleteElementInListByPosition(position, data.elements);
|
|
3637
|
+
} else if (type === "moveElement") {
|
|
3638
|
+
const opts = options;
|
|
3639
|
+
const { from, to } = opts.content;
|
|
3640
|
+
const movedResult = moveElementPosition(data.elements, { from, to });
|
|
3641
|
+
content.from = movedResult.from;
|
|
3642
|
+
content.to = movedResult.to;
|
|
3643
|
+
data.elements = movedResult.elements;
|
|
3644
|
+
} else if (type === "updateElement") {
|
|
3645
|
+
const opts = options;
|
|
3646
|
+
const { position, afterModifiedElement } = opts.content;
|
|
3647
|
+
updateElementInListByPosition(position, afterModifiedElement, data.elements);
|
|
3648
|
+
}
|
|
3649
|
+
return { data, content };
|
|
3650
|
+
}
|
|
3651
|
+
function _get(source, path, defaultValue = void 0) {
|
|
3652
|
+
const keyList = path.split(".");
|
|
3653
|
+
const result = keyList.reduce((obj, key) => {
|
|
3654
|
+
return Object(obj)[key];
|
|
3655
|
+
}, source);
|
|
3656
|
+
return result === void 0 ? defaultValue : result;
|
|
3657
|
+
}
|
|
3658
|
+
function _set(obj, path, value) {
|
|
3659
|
+
const keys = path.split(".");
|
|
3660
|
+
if (typeof obj !== "object")
|
|
3661
|
+
return obj;
|
|
3662
|
+
keys.reduce((o, k, i, _) => {
|
|
3663
|
+
if (i === _.length - 1) {
|
|
3664
|
+
o[k] = value;
|
|
3665
|
+
return null;
|
|
3666
|
+
} else if (k in o) {
|
|
3667
|
+
return o[k];
|
|
3668
|
+
} else {
|
|
3669
|
+
o[k] = /^[0-9]{1,}$/.test(_[i + 1]) ? [] : {};
|
|
3670
|
+
return o[k];
|
|
3671
|
+
}
|
|
3672
|
+
}, obj);
|
|
3673
|
+
return obj;
|
|
3674
|
+
}
|
|
3675
|
+
function getModifiedElement(target, originElement) {
|
|
3676
|
+
const modifiedElement = {};
|
|
3677
|
+
const pathList = [];
|
|
3678
|
+
const _walk = (t) => {
|
|
3679
|
+
if (istype.json(t)) {
|
|
3680
|
+
const keys = Object.keys(t);
|
|
3681
|
+
keys.forEach((key) => {
|
|
3682
|
+
pathList.push(key);
|
|
3683
|
+
if (istype.json(t[key]) || istype.array(t[key])) {
|
|
3684
|
+
_walk(t[key]);
|
|
3685
|
+
} else {
|
|
3686
|
+
const pathStr = pathList.join(".");
|
|
3687
|
+
if (pathStr !== "uuid") {
|
|
3688
|
+
const value = _get(originElement, pathStr);
|
|
3689
|
+
_set(modifiedElement, pathList.join("."), value);
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
pathList.pop();
|
|
3693
|
+
});
|
|
3694
|
+
} else if (istype.array(t)) {
|
|
3695
|
+
t.forEach((index) => {
|
|
3696
|
+
pathList.push(index);
|
|
3697
|
+
if (istype.json(t[index]) || istype.array(t[index])) {
|
|
3698
|
+
_walk(t[index]);
|
|
3699
|
+
} else {
|
|
3700
|
+
const value = _get(originElement, pathList.join("."));
|
|
3701
|
+
_set(modifiedElement, pathList.join("."), value);
|
|
3702
|
+
}
|
|
3703
|
+
pathList.pop();
|
|
3704
|
+
});
|
|
3705
|
+
}
|
|
3706
|
+
};
|
|
3707
|
+
_walk(target);
|
|
3708
|
+
return modifiedElement;
|
|
3709
|
+
}
|
|
3710
|
+
const baseFontFamilyList = ["-apple-system", '"system-ui"', ' "Segoe UI"', " Roboto", '"Helvetica Neue"', "Arial", '"Noto Sans"', " sans-serif"];
|
|
3711
|
+
function enhanceFontFamliy(fontFamily2) {
|
|
3712
|
+
return [fontFamily2, ...baseFontFamilyList].join(", ");
|
|
3713
|
+
}
|
|
3714
|
+
function flatElementSize(elemSize, opts) {
|
|
3715
|
+
const { groupQueue } = opts;
|
|
3716
|
+
let { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemSize;
|
|
3717
|
+
let totalAngle = 0;
|
|
3718
|
+
groupQueue.forEach((group) => {
|
|
3719
|
+
x2 += group.x;
|
|
3720
|
+
y2 += group.y;
|
|
3721
|
+
totalAngle += group.angle || 0;
|
|
3722
|
+
});
|
|
3723
|
+
totalAngle = limitAngle(totalAngle);
|
|
3724
|
+
if (totalAngle === 0) {
|
|
3725
|
+
return {
|
|
3726
|
+
x: x2,
|
|
3727
|
+
y: y2,
|
|
3728
|
+
w: w2,
|
|
3729
|
+
h: h2,
|
|
3730
|
+
angle: angle2
|
|
3731
|
+
};
|
|
3732
|
+
}
|
|
3733
|
+
totalAngle += elemSize.angle || 0;
|
|
3734
|
+
totalAngle = limitAngle(totalAngle);
|
|
3735
|
+
const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
|
|
3736
|
+
const center = calcElementCenterFromVertexes(vertexes);
|
|
3737
|
+
const start = rotatePoint(center, vertexes[0], parseAngleToRadian(0 - totalAngle));
|
|
3738
|
+
x2 = start.x;
|
|
3739
|
+
y2 = start.y;
|
|
3740
|
+
return {
|
|
3741
|
+
x: x2,
|
|
3742
|
+
y: y2,
|
|
3743
|
+
w: w2,
|
|
3744
|
+
h: h2,
|
|
3745
|
+
angle: totalAngle
|
|
3746
|
+
};
|
|
3747
|
+
}
|
|
3748
|
+
function isValidElement(elem) {
|
|
3749
|
+
var _a;
|
|
3750
|
+
if (["rect", "circle"].includes(elem.type)) {
|
|
3751
|
+
const detail = elem.detail;
|
|
3752
|
+
if (!detail.background && !detail.borderWidth) {
|
|
3753
|
+
return false;
|
|
3754
|
+
}
|
|
3755
|
+
if (detail.background === "transparent" && !detail.borderWidth) {
|
|
3756
|
+
return false;
|
|
3757
|
+
}
|
|
3758
|
+
}
|
|
3759
|
+
if (["group"].includes(elem.type)) {
|
|
3760
|
+
const detail = elem.detail || {};
|
|
3761
|
+
const { children } = detail;
|
|
3762
|
+
if (!(children.length > 0) && !detail.background && !detail.borderWidth) {
|
|
3763
|
+
return false;
|
|
3764
|
+
}
|
|
3765
|
+
if (!(children.length > 0) && detail.background === "transparent" && !detail.borderWidth) {
|
|
3766
|
+
return false;
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
if (elem.type === "text") {
|
|
3770
|
+
if (!elem.detail.text) {
|
|
3771
|
+
return false;
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
if (elem.type === "image") {
|
|
3775
|
+
if (!elem.detail.src) {
|
|
3776
|
+
return false;
|
|
3777
|
+
}
|
|
3778
|
+
}
|
|
3779
|
+
if (elem.type === "html") {
|
|
3780
|
+
if (!elem.detail.html) {
|
|
3781
|
+
return false;
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
if (elem.type === "svg") {
|
|
3785
|
+
if (!elem.detail.svg) {
|
|
3786
|
+
return false;
|
|
3787
|
+
}
|
|
3788
|
+
}
|
|
3789
|
+
if (elem.type === "path") {
|
|
3790
|
+
const detail = elem.detail;
|
|
3791
|
+
if (!(((_a = detail == null ? void 0 : detail.commands) == null ? void 0 : _a.length) > 0)) {
|
|
3792
|
+
return false;
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
return true;
|
|
3796
|
+
}
|
|
3797
|
+
function flatElementList(list) {
|
|
3798
|
+
const elemeList = [];
|
|
3799
|
+
const currentGroupQueue = [];
|
|
3800
|
+
const _resetElemSize = (elem) => {
|
|
3801
|
+
if (!isValidElement(elem)) {
|
|
3802
|
+
return;
|
|
3803
|
+
}
|
|
3804
|
+
const newSize = flatElementSize(elem, { groupQueue: currentGroupQueue });
|
|
3805
|
+
const resizeElem = {
|
|
3806
|
+
...elem,
|
|
3807
|
+
...newSize
|
|
3808
|
+
};
|
|
3809
|
+
elemeList.push(resizeElem);
|
|
3810
|
+
};
|
|
3811
|
+
const _walk = (elem) => {
|
|
3812
|
+
var _a;
|
|
3813
|
+
if (((_a = elem == null ? void 0 : elem.operations) == null ? void 0 : _a.invisible) === true) {
|
|
3814
|
+
return;
|
|
3815
|
+
}
|
|
3816
|
+
if (elem.type === "group") {
|
|
3817
|
+
const { detail } = elem;
|
|
3818
|
+
const { children, ...restDetail } = detail;
|
|
3819
|
+
_resetElemSize({ ...elem, ...{ detail: { ...restDetail, children: [] } } });
|
|
3820
|
+
currentGroupQueue.push(elem);
|
|
3821
|
+
children.forEach((child) => {
|
|
3822
|
+
_walk(child);
|
|
3823
|
+
});
|
|
3824
|
+
currentGroupQueue.pop();
|
|
3825
|
+
} else {
|
|
3826
|
+
_resetElemSize(elem);
|
|
3827
|
+
}
|
|
3828
|
+
};
|
|
3829
|
+
for (let i = 0; i < list.length; i++) {
|
|
3830
|
+
const elem = list[i];
|
|
3831
|
+
_walk(elem);
|
|
3832
|
+
}
|
|
3833
|
+
return elemeList;
|
|
3834
|
+
}
|
|
2763
3835
|
exports.Context2D = Context2D;
|
|
2764
3836
|
exports.EventEmitter = EventEmitter;
|
|
2765
3837
|
exports.Store = Store;
|
|
@@ -2767,18 +3839,26 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2767
3839
|
exports.calcElementCenter = calcElementCenter;
|
|
2768
3840
|
exports.calcElementCenterFromVertexes = calcElementCenterFromVertexes;
|
|
2769
3841
|
exports.calcElementListSize = calcElementListSize;
|
|
3842
|
+
exports.calcElementOriginRectInfo = calcElementOriginRectInfo;
|
|
2770
3843
|
exports.calcElementQueueVertexesQueueInGroup = calcElementQueueVertexesQueueInGroup;
|
|
2771
3844
|
exports.calcElementSizeController = calcElementSizeController;
|
|
2772
3845
|
exports.calcElementVertexesInGroup = calcElementVertexesInGroup;
|
|
2773
3846
|
exports.calcElementVertexesQueueInGroup = calcElementVertexesQueueInGroup;
|
|
3847
|
+
exports.calcElementViewRectInfo = calcElementViewRectInfo;
|
|
3848
|
+
exports.calcElementViewRectInfoMap = calcElementViewRectInfoMap;
|
|
2774
3849
|
exports.calcElementsContextSize = calcElementsContextSize;
|
|
2775
3850
|
exports.calcElementsViewInfo = calcElementsViewInfo;
|
|
3851
|
+
exports.calcLayoutSizeController = calcLayoutSizeController;
|
|
3852
|
+
exports.calcRadian = calcRadian;
|
|
2776
3853
|
exports.calcSpeed = calcSpeed;
|
|
2777
3854
|
exports.calcViewBoxSize = calcViewBoxSize;
|
|
3855
|
+
exports.calcViewCenter = calcViewCenter;
|
|
3856
|
+
exports.calcViewCenterContent = calcViewCenterContent;
|
|
2778
3857
|
exports.calcViewElementSize = calcViewElementSize;
|
|
2779
3858
|
exports.calcViewPointSize = calcViewPointSize;
|
|
2780
3859
|
exports.calcViewScaleInfo = calcViewScaleInfo;
|
|
2781
3860
|
exports.calcViewVertexes = calcViewVertexes;
|
|
3861
|
+
exports.calcVisibleOriginCanvasRectInfo = calcVisibleOriginCanvasRectInfo;
|
|
2782
3862
|
exports.check = check;
|
|
2783
3863
|
exports.checkRectIntersect = checkRectIntersect;
|
|
2784
3864
|
exports.colorNameToHex = colorNameToHex;
|
|
@@ -2792,19 +3872,26 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2792
3872
|
exports.createElement = createElement;
|
|
2793
3873
|
exports.createOffscreenContext2D = createOffscreenContext2D;
|
|
2794
3874
|
exports.createUUID = createUUID;
|
|
3875
|
+
exports.debounce = debounce;
|
|
2795
3876
|
exports.deepClone = deepClone;
|
|
3877
|
+
exports.deepCloneElement = deepCloneElement;
|
|
3878
|
+
exports.deepResizeGroupElement = deepResizeGroupElement;
|
|
2796
3879
|
exports.delay = delay;
|
|
2797
3880
|
exports.deleteElementInList = deleteElementInList;
|
|
2798
3881
|
exports.deleteElementInListByPosition = deleteElementInListByPosition;
|
|
3882
|
+
exports.downloadFileFromText = downloadFileFromText;
|
|
2799
3883
|
exports.downloadImageFromCanvas = downloadImageFromCanvas;
|
|
3884
|
+
exports.enhanceFontFamliy = enhanceFontFamliy;
|
|
2800
3885
|
exports.equalPoint = equalPoint;
|
|
2801
3886
|
exports.equalTouchPoint = equalTouchPoint;
|
|
3887
|
+
exports.filterCompactData = filterCompactData;
|
|
2802
3888
|
exports.filterElementAsset = filterElementAsset;
|
|
2803
3889
|
exports.findElementFromList = findElementFromList;
|
|
2804
3890
|
exports.findElementFromListByPosition = findElementFromListByPosition;
|
|
2805
3891
|
exports.findElementQueueFromListByPosition = findElementQueueFromListByPosition;
|
|
2806
3892
|
exports.findElementsFromList = findElementsFromList;
|
|
2807
3893
|
exports.findElementsFromListByPositions = findElementsFromListByPositions;
|
|
3894
|
+
exports.flatElementList = flatElementList;
|
|
2808
3895
|
exports.formatNumber = formatNumber;
|
|
2809
3896
|
exports.generateHTML = generateHTML;
|
|
2810
3897
|
exports.generateSVGPath = generateSVGPath;
|
|
@@ -2816,7 +3903,9 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2816
3903
|
exports.getElementRotateVertexes = getElementRotateVertexes;
|
|
2817
3904
|
exports.getElementSize = getElementSize;
|
|
2818
3905
|
exports.getElementVertexes = getElementVertexes;
|
|
3906
|
+
exports.getGroupQueueByElementPosition = getGroupQueueByElementPosition;
|
|
2819
3907
|
exports.getGroupQueueFromList = getGroupQueueFromList;
|
|
3908
|
+
exports.getModifiedElement = getModifiedElement;
|
|
2820
3909
|
exports.getSelectedElementUUIDs = getSelectedElementUUIDs;
|
|
2821
3910
|
exports.getViewPointAtElement = getViewPointAtElement;
|
|
2822
3911
|
exports.getViewScaleInfoFromSnapshot = getViewScaleInfoFromSnapshot;
|
|
@@ -2828,6 +3917,8 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2828
3917
|
exports.isElementInView = isElementInView;
|
|
2829
3918
|
exports.isResourceElement = isResourceElement;
|
|
2830
3919
|
exports.isViewPointInElement = isViewPointInElement;
|
|
3920
|
+
exports.isViewPointInElementSize = isViewPointInElementSize;
|
|
3921
|
+
exports.isViewPointInVertexes = isViewPointInVertexes;
|
|
2831
3922
|
exports.istype = istype;
|
|
2832
3923
|
exports.limitAngle = limitAngle;
|
|
2833
3924
|
exports.loadHTML = loadHTML;
|
|
@@ -2837,7 +3928,9 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2837
3928
|
exports.matrixToRadian = matrixToRadian;
|
|
2838
3929
|
exports.mergeElementAsset = mergeElementAsset;
|
|
2839
3930
|
exports.mergeHexColorAlpha = mergeHexColorAlpha;
|
|
3931
|
+
exports.modifyElement = modifyElement;
|
|
2840
3932
|
exports.moveElementPosition = moveElementPosition;
|
|
3933
|
+
exports.originRectInfoToRangeRectInfo = originRectInfoToRangeRectInfo;
|
|
2841
3934
|
exports.parseAngleToRadian = parseAngleToRadian;
|
|
2842
3935
|
exports.parseFileToBase64 = parseFileToBase64;
|
|
2843
3936
|
exports.parseFileToText = parseFileToText;
|
|
@@ -2852,10 +3945,13 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
2852
3945
|
exports.rotatePointInGroup = rotatePointInGroup;
|
|
2853
3946
|
exports.rotateVertexes = rotateVertexes;
|
|
2854
3947
|
exports.sortDataAsserts = sortDataAsserts;
|
|
3948
|
+
exports.sortElementsViewVisiableInfoMap = sortElementsViewVisiableInfoMap;
|
|
2855
3949
|
exports.throttle = throttle;
|
|
2856
3950
|
exports.toColorHexNum = toColorHexNum;
|
|
2857
3951
|
exports.toColorHexStr = toColorHexStr;
|
|
2858
3952
|
exports.updateElementInList = updateElementInList;
|
|
3953
|
+
exports.updateElementInListByPosition = updateElementInListByPosition;
|
|
3954
|
+
exports.updateViewVisibleInfoMapStatus = updateViewVisibleInfoMapStatus;
|
|
2859
3955
|
exports.vaildPoint = vaildPoint;
|
|
2860
3956
|
exports.vaildTouchPoint = vaildTouchPoint;
|
|
2861
3957
|
exports.validateElements = validateElements;
|