@aivex/ui 1.2.0-dev.25 → 1.2.0-dev.26
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/components/ShapeEditor/ShapeEditor.d.ts +1 -1
- package/dist/components/ShapeEditor/_model/props.d.ts +6 -0
- package/dist/components/ShapeEditor/_state/createInteractionController.d.ts +2 -0
- package/dist/shape-editor.cjs +1 -1
- package/dist/shape-editor.cjs.map +1 -1
- package/dist/shape-editor.js +812 -805
- package/dist/shape-editor.js.map +1 -1
- package/package.json +1 -1
package/dist/shape-editor.js
CHANGED
|
@@ -6,9 +6,9 @@ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
|
6
6
|
import { memo as b, useCallback as x, useEffect as S, useId as C, useImperativeHandle as w, useLayoutEffect as T, useMemo as E, useReducer as D, useRef as O, useState as k } from "react";
|
|
7
7
|
import A from "konva";
|
|
8
8
|
import "pixi.js/unsafe-eval";
|
|
9
|
-
import { Application as j, ColorMatrixFilter as M, Container as N, Graphics as P, Polygon as
|
|
9
|
+
import { Application as j, ColorMatrixFilter as M, Container as N, Graphics as P, Polygon as ee, Rectangle as te, Sprite as ne, Texture as F } from "pixi.js";
|
|
10
10
|
//#region src/components/ShapeEditor/_model/geometry.ts
|
|
11
|
-
var
|
|
11
|
+
var I = {
|
|
12
12
|
POINT: "POINT",
|
|
13
13
|
RECTANGLE: "RECTANGLE",
|
|
14
14
|
ROTATED_RECTANGLE: "ROTATED_RECTANGLE",
|
|
@@ -16,22 +16,22 @@ var L = {
|
|
|
16
16
|
ELLIPSE: "ELLIPSE",
|
|
17
17
|
LINE: "LINE"
|
|
18
18
|
};
|
|
19
|
-
function ne(e) {
|
|
20
|
-
return e.interaction?.visible !== !1;
|
|
21
|
-
}
|
|
22
19
|
function re(e) {
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
function R(e) {
|
|
26
|
-
return re(e) && e.interaction?.selectable !== !1;
|
|
20
|
+
return e.interaction?.visible !== !1;
|
|
27
21
|
}
|
|
28
22
|
function ie(e) {
|
|
29
|
-
return
|
|
23
|
+
return re(e) && e.interaction?.hitTestDisabled !== !0;
|
|
30
24
|
}
|
|
31
|
-
function
|
|
32
|
-
return ie(e) && e.interaction?.
|
|
25
|
+
function L(e) {
|
|
26
|
+
return ie(e) && e.interaction?.selectable !== !1;
|
|
33
27
|
}
|
|
34
28
|
function ae(e) {
|
|
29
|
+
return L(e) && !e.readOnly && e.interaction?.editable !== !1;
|
|
30
|
+
}
|
|
31
|
+
function R(e) {
|
|
32
|
+
return ae(e) && e.interaction?.draggable !== !1;
|
|
33
|
+
}
|
|
34
|
+
function z(e) {
|
|
35
35
|
return e.map((e, t) => ({
|
|
36
36
|
shape: e,
|
|
37
37
|
index: t
|
|
@@ -238,7 +238,7 @@ function Te(e, t, n, r) {
|
|
|
238
238
|
let i = (e, t, n) => Math.sign((t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x)), a = i(e, t, n), o = i(e, t, r), s = i(n, r, e), c = i(n, r, t);
|
|
239
239
|
return a !== o && s !== c && !(a === 0 && o === 0);
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function Ee(e, t = 256) {
|
|
242
242
|
let n = e.length;
|
|
243
243
|
if (n < 4 || n > t) return !1;
|
|
244
244
|
for (let t = 0; t < n; t++) {
|
|
@@ -247,7 +247,7 @@ function U(e, t = 256) {
|
|
|
247
247
|
}
|
|
248
248
|
return !1;
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function U(e, t, n, r) {
|
|
251
251
|
let i = t.x - e.x, a = t.y - e.y, o = r.x - n.x, s = r.y - n.y, c = i * s - a * o;
|
|
252
252
|
if (!c) return null;
|
|
253
253
|
let l = ((n.x - e.x) * s - (n.y - e.y) * o) / c, u = ((n.x - e.x) * a - (n.y - e.y) * i) / c, d = 1e-9;
|
|
@@ -258,13 +258,13 @@ function Ee(e, t, n, r) {
|
|
|
258
258
|
}
|
|
259
259
|
function De(e, t = 256) {
|
|
260
260
|
let n = e.length;
|
|
261
|
-
if (n < 4 || n > t || !
|
|
261
|
+
if (n < 4 || n > t || !Ee(e, t)) return [e];
|
|
262
262
|
let r = Array.from({ length: n }, () => []), i = 0;
|
|
263
263
|
for (let t = 0; t < n; t++) {
|
|
264
264
|
let a = e[t], o = e[(t + 1) % n];
|
|
265
265
|
for (let s = t + 2; s < n; s++) {
|
|
266
266
|
if (t === 0 && s === n - 1) continue;
|
|
267
|
-
let c =
|
|
267
|
+
let c = U(a, o, e[s], e[(s + 1) % n]);
|
|
268
268
|
c && (r[t].push({
|
|
269
269
|
t: c.ti,
|
|
270
270
|
id: i
|
|
@@ -428,9 +428,9 @@ var G = {
|
|
|
428
428
|
keepZoomOnImageChange: !1,
|
|
429
429
|
wheelZoom: !0,
|
|
430
430
|
zoomSensitivity: 1
|
|
431
|
-
}, Ae = "var(--editor-overlay-inverse-scale, 1)",
|
|
431
|
+
}, Ae = "var(--editor-overlay-inverse-scale, 1)", je = "#377be2", K = "#e23c3c";
|
|
432
432
|
function Me({ point: e }) {
|
|
433
|
-
let t = e.positive ?
|
|
433
|
+
let t = e.positive ? je : K;
|
|
434
434
|
return /* @__PURE__ */ v("div", {
|
|
435
435
|
style: {
|
|
436
436
|
position: "absolute",
|
|
@@ -707,11 +707,11 @@ var Ge = b(function({ shape: e, strokeSize: t, register: n }) {
|
|
|
707
707
|
strokeWidth: a.strokeWidth,
|
|
708
708
|
strokeDasharray: a.dash?.join(" "),
|
|
709
709
|
opacity: a.opacity,
|
|
710
|
-
fill: a.fillVisible && r !==
|
|
710
|
+
fill: a.fillVisible && r !== I.LINE ? a.color : "none",
|
|
711
711
|
fillOpacity: a.fillAlpha,
|
|
712
712
|
vectorEffect: "non-scaling-stroke"
|
|
713
713
|
};
|
|
714
|
-
if (r ===
|
|
714
|
+
if (r === I.POINT) return /* @__PURE__ */ v("circle", {
|
|
715
715
|
ref: o,
|
|
716
716
|
cx: i[0].x,
|
|
717
717
|
cy: i[0].y,
|
|
@@ -719,9 +719,9 @@ var Ge = b(function({ shape: e, strokeSize: t, register: n }) {
|
|
|
719
719
|
fill: a.color,
|
|
720
720
|
opacity: a.opacity
|
|
721
721
|
});
|
|
722
|
-
if (r ===
|
|
722
|
+
if (r === I.RECTANGLE || r === I.ELLIPSE) {
|
|
723
723
|
let e = V(i);
|
|
724
|
-
return r ===
|
|
724
|
+
return r === I.ELLIPSE ? /* @__PURE__ */ v("ellipse", {
|
|
725
725
|
cx: (e.minX + e.maxX) / 2,
|
|
726
726
|
cy: (e.minY + e.maxY) / 2,
|
|
727
727
|
rx: (e.maxX - e.minX) / 2,
|
|
@@ -736,7 +736,7 @@ var Ge = b(function({ shape: e, strokeSize: t, register: n }) {
|
|
|
736
736
|
});
|
|
737
737
|
}
|
|
738
738
|
let c = i.map((e) => `${e.x},${e.y}`).join(" ");
|
|
739
|
-
return r ===
|
|
739
|
+
return r === I.LINE ? /* @__PURE__ */ v("polyline", {
|
|
740
740
|
points: c,
|
|
741
741
|
...s
|
|
742
742
|
}) : /* @__PURE__ */ v("polygon", {
|
|
@@ -976,14 +976,14 @@ var Xe = {
|
|
|
976
976
|
"top-left": "aivex:top-2 aivex:left-2",
|
|
977
977
|
"top-right": "aivex:top-2 aivex:right-2"
|
|
978
978
|
}, Ze = b(function({ image: e, imageUrl: t, imageVisible: n = !0, loading: r = !1, maskDataUrl: a, region: o, roiMaskId: l, shapes: p, view: m, viewDefaults: h, onChangeView: g, nav: _, registerShape: b, rectRef: x, zoomLabelRef: S, onZoom100: C, open: w, onToggleOpen: T, position: E = "bottom-left", showSettings: D = !0, settingsOpen: O, onToggleSettings: k, onCloseSettings: A, labels: j = W.minimap, settingsLabels: M }) {
|
|
979
|
-
let { offX: N, offY: P, dispW:
|
|
979
|
+
let { offX: N, offY: P, dispW: ee, dispH: te, zoomCentered: ne } = _, F = E.startsWith("top"), I = {
|
|
980
980
|
position: "absolute",
|
|
981
981
|
left: N,
|
|
982
982
|
top: P,
|
|
983
|
-
width:
|
|
984
|
-
height:
|
|
985
|
-
},
|
|
986
|
-
className: `aivex:overflow-hidden aivex:rounded-sm aivex:transition-all aivex:duration-200 aivex:ease-in-out ${w ? `${
|
|
983
|
+
width: ee,
|
|
984
|
+
height: te
|
|
985
|
+
}, ie = /* @__PURE__ */ v("div", {
|
|
986
|
+
className: `aivex:overflow-hidden aivex:rounded-sm aivex:transition-all aivex:duration-200 aivex:ease-in-out ${w ? `${F ? "aivex:mt-md" : "aivex:mb-md"} aivex:opacity-100` : "aivex:opacity-0"}`,
|
|
987
987
|
style: { maxHeight: w ? 204 : 0 },
|
|
988
988
|
children: /* @__PURE__ */ v("div", {
|
|
989
989
|
style: {
|
|
@@ -1010,14 +1010,14 @@ var Xe = {
|
|
|
1010
1010
|
alt: "",
|
|
1011
1011
|
crossOrigin: "anonymous",
|
|
1012
1012
|
draggable: !1,
|
|
1013
|
-
style:
|
|
1013
|
+
style: I
|
|
1014
1014
|
}),
|
|
1015
1015
|
a && m.showGuide && /* @__PURE__ */ v("img", {
|
|
1016
1016
|
src: a,
|
|
1017
1017
|
alt: "",
|
|
1018
1018
|
draggable: !1,
|
|
1019
1019
|
style: {
|
|
1020
|
-
...
|
|
1020
|
+
...I,
|
|
1021
1021
|
opacity: .55,
|
|
1022
1022
|
imageRendering: "pixelated",
|
|
1023
1023
|
pointerEvents: "none"
|
|
@@ -1027,8 +1027,8 @@ var Xe = {
|
|
|
1027
1027
|
image: e,
|
|
1028
1028
|
region: o,
|
|
1029
1029
|
maskId: l,
|
|
1030
|
-
width:
|
|
1031
|
-
height:
|
|
1030
|
+
width: ee,
|
|
1031
|
+
height: te,
|
|
1032
1032
|
strokeWidth: 1,
|
|
1033
1033
|
strokeDasharray: "4 4",
|
|
1034
1034
|
style: {
|
|
@@ -1040,8 +1040,8 @@ var Xe = {
|
|
|
1040
1040
|
}),
|
|
1041
1041
|
/* @__PURE__ */ v("svg", {
|
|
1042
1042
|
viewBox: `0 0 ${e.w} ${e.h}`,
|
|
1043
|
-
width:
|
|
1044
|
-
height:
|
|
1043
|
+
width: ee,
|
|
1044
|
+
height: te,
|
|
1045
1045
|
style: {
|
|
1046
1046
|
position: "absolute",
|
|
1047
1047
|
left: N,
|
|
@@ -1049,7 +1049,7 @@ var Xe = {
|
|
|
1049
1049
|
pointerEvents: "none"
|
|
1050
1050
|
},
|
|
1051
1051
|
"aria-hidden": !0,
|
|
1052
|
-
children:
|
|
1052
|
+
children: z(p).filter(re).map((e) => /* @__PURE__ */ v(Ge, {
|
|
1053
1053
|
shape: e,
|
|
1054
1054
|
strokeSize: m.strokeSize,
|
|
1055
1055
|
register: b
|
|
@@ -1068,14 +1068,14 @@ var Xe = {
|
|
|
1068
1068
|
]
|
|
1069
1069
|
})
|
|
1070
1070
|
})
|
|
1071
|
-
}),
|
|
1071
|
+
}), L = /* @__PURE__ */ y("div", {
|
|
1072
1072
|
className: "aivex:relative aivex:flex aivex:items-center aivex:gap-xs",
|
|
1073
1073
|
children: [
|
|
1074
1074
|
/* @__PURE__ */ v(u, {
|
|
1075
1075
|
variant: "ghost",
|
|
1076
1076
|
size: "icon-md",
|
|
1077
1077
|
"aria-label": j.zoomOut,
|
|
1078
|
-
onClick: () =>
|
|
1078
|
+
onClick: () => ne(1 / 1.2),
|
|
1079
1079
|
disabled: r,
|
|
1080
1080
|
children: /* @__PURE__ */ v(f, { size: 20 })
|
|
1081
1081
|
}),
|
|
@@ -1095,7 +1095,7 @@ var Xe = {
|
|
|
1095
1095
|
variant: "ghost",
|
|
1096
1096
|
size: "icon-md",
|
|
1097
1097
|
"aria-label": j.zoomIn,
|
|
1098
|
-
onClick: () =>
|
|
1098
|
+
onClick: () => ne(1.2),
|
|
1099
1099
|
disabled: r,
|
|
1100
1100
|
children: /* @__PURE__ */ v(i, { size: 20 })
|
|
1101
1101
|
}),
|
|
@@ -1115,7 +1115,7 @@ var Xe = {
|
|
|
1115
1115
|
onChange: g,
|
|
1116
1116
|
onClose: A,
|
|
1117
1117
|
labels: M,
|
|
1118
|
-
openDown:
|
|
1118
|
+
openDown: F,
|
|
1119
1119
|
alignEnd: E.endsWith("right")
|
|
1120
1120
|
})]
|
|
1121
1121
|
}),
|
|
@@ -1127,14 +1127,14 @@ var Xe = {
|
|
|
1127
1127
|
onClick: T,
|
|
1128
1128
|
children: w ? /* @__PURE__ */ v(c, {
|
|
1129
1129
|
size: 20,
|
|
1130
|
-
className:
|
|
1130
|
+
className: F ? "aivex:rotate-180" : void 0
|
|
1131
1131
|
}) : /* @__PURE__ */ v(s, { size: 20 })
|
|
1132
1132
|
})
|
|
1133
1133
|
]
|
|
1134
1134
|
});
|
|
1135
1135
|
return /* @__PURE__ */ y("div", {
|
|
1136
1136
|
className: `aivex:absolute ${Xe[E]} aivex:w-[220px] aivex:rounded-[12px] aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:p-md aivex:shadow-[0_4px_12px_rgba(13,13,18,0.24)]`,
|
|
1137
|
-
children: [
|
|
1137
|
+
children: [F ? L : ie, F ? ie : L]
|
|
1138
1138
|
});
|
|
1139
1139
|
}), Qe = "var(--editor-overlay-inverse-scale, 1)", $e = 6, et = {
|
|
1140
1140
|
fontFamily: "Pretendard, sans-serif",
|
|
@@ -1186,7 +1186,7 @@ function ot({ color: e, striped: t }) {
|
|
|
1186
1186
|
}
|
|
1187
1187
|
function st({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i }) {
|
|
1188
1188
|
return /* @__PURE__ */ v(_, { children: e.map((e) => {
|
|
1189
|
-
let a = tt(e.points), o = e.type ===
|
|
1189
|
+
let a = tt(e.points), o = e.type === I.POINT, s = o ? void 0 : t?.(e), c = e.style?.color ?? "#00e5ff", l = !!e.style?.dashed || !!e.style?.dash, u = it(e, e.points), d = r ? r(u) : at(u);
|
|
1190
1190
|
return /* @__PURE__ */ y("div", {
|
|
1191
1191
|
ref: (t) => i(e.id, t),
|
|
1192
1192
|
style: {
|
|
@@ -1231,16 +1231,16 @@ function st({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1231
1231
|
}
|
|
1232
1232
|
//#endregion
|
|
1233
1233
|
//#region src/components/ShapeEditor/_model/clipboard.ts
|
|
1234
|
-
var ct = "AIVEX_SHAPE_EDITOR:", lt = 1, ut = new Set(Object.values(
|
|
1235
|
-
function
|
|
1234
|
+
var ct = "AIVEX_SHAPE_EDITOR:", lt = 1, ut = new Set(Object.values(I)), dt = null, q = "unavailable", ft = 0;
|
|
1235
|
+
function pt(e) {
|
|
1236
1236
|
if (!e || typeof e != "object") return !1;
|
|
1237
1237
|
let t = e;
|
|
1238
1238
|
return Number.isFinite(t.x) && Number.isFinite(t.y);
|
|
1239
1239
|
}
|
|
1240
|
-
function
|
|
1240
|
+
function J(e) {
|
|
1241
1241
|
if (!e || typeof e != "object") return !1;
|
|
1242
1242
|
let t = e;
|
|
1243
|
-
return typeof t.type == "string" && ut.has(t.type) && Array.isArray(t.points) && t.points.length > 0 && t.points.every(
|
|
1243
|
+
return typeof t.type == "string" && ut.has(t.type) && Array.isArray(t.points) && t.points.length > 0 && t.points.every(pt);
|
|
1244
1244
|
}
|
|
1245
1245
|
function mt(e, t, n) {
|
|
1246
1246
|
return {
|
|
@@ -1263,43 +1263,43 @@ function _t(e) {
|
|
|
1263
1263
|
if (!e.startsWith(ct)) return null;
|
|
1264
1264
|
try {
|
|
1265
1265
|
let t = JSON.parse(e.slice(19));
|
|
1266
|
-
return t.kind !== "aivex-shape-editor" || t.version !== lt || !Array.isArray(t.shapes) || t.shapes.length === 0 || !t.shapes.every(
|
|
1266
|
+
return t.kind !== "aivex-shape-editor" || t.version !== lt || !Array.isArray(t.shapes) || t.shapes.length === 0 || !t.shapes.every(J) || t.scope !== void 0 && typeof t.scope != "string" || t.documentId !== void 0 && typeof t.documentId != "string" ? null : t;
|
|
1267
1267
|
} catch {
|
|
1268
1268
|
return null;
|
|
1269
1269
|
}
|
|
1270
1270
|
}
|
|
1271
1271
|
function vt(e) {
|
|
1272
|
-
|
|
1272
|
+
dt = e;
|
|
1273
1273
|
let t = ++ft;
|
|
1274
1274
|
if (typeof navigator > "u" || !navigator.clipboard?.writeText) {
|
|
1275
|
-
|
|
1275
|
+
q = "unavailable";
|
|
1276
1276
|
return;
|
|
1277
1277
|
}
|
|
1278
1278
|
let n;
|
|
1279
1279
|
try {
|
|
1280
1280
|
n = gt(e);
|
|
1281
1281
|
} catch {
|
|
1282
|
-
|
|
1282
|
+
q = "unavailable";
|
|
1283
1283
|
return;
|
|
1284
1284
|
}
|
|
1285
|
-
|
|
1286
|
-
t === ft && (
|
|
1285
|
+
q = "pending", navigator.clipboard.writeText(n).then(() => {
|
|
1286
|
+
t === ft && (q = "written");
|
|
1287
1287
|
}, () => {
|
|
1288
|
-
t === ft && (
|
|
1288
|
+
t === ft && (q = "unavailable");
|
|
1289
1289
|
});
|
|
1290
1290
|
}
|
|
1291
1291
|
function yt(e, t) {
|
|
1292
1292
|
return !!e && e.scope === t;
|
|
1293
1293
|
}
|
|
1294
|
-
function
|
|
1295
|
-
return yt(
|
|
1294
|
+
function bt(e) {
|
|
1295
|
+
return yt(dt, e) || typeof navigator < "u" && typeof navigator.clipboard?.readText == "function";
|
|
1296
1296
|
}
|
|
1297
|
-
async function
|
|
1298
|
-
let t = yt(
|
|
1299
|
-
if (t &&
|
|
1297
|
+
async function Y(e) {
|
|
1298
|
+
let t = yt(dt, e) ? dt : null;
|
|
1299
|
+
if (t && q !== "written") return t;
|
|
1300
1300
|
if (typeof navigator < "u" && navigator.clipboard?.readText) try {
|
|
1301
1301
|
let t = _t(await navigator.clipboard.readText());
|
|
1302
|
-
return t?.scope === e ? (
|
|
1302
|
+
return t?.scope === e ? (dt = t, t) : null;
|
|
1303
1303
|
} catch {}
|
|
1304
1304
|
return t;
|
|
1305
1305
|
}
|
|
@@ -1311,7 +1311,7 @@ function xt(e, t, n) {
|
|
|
1311
1311
|
}
|
|
1312
1312
|
//#endregion
|
|
1313
1313
|
//#region src/components/ShapeEditor/_model/cursors.ts
|
|
1314
|
-
var
|
|
1314
|
+
var St = new Set([
|
|
1315
1315
|
G.RECTANGLE,
|
|
1316
1316
|
G.ROTATED_RECTANGLE,
|
|
1317
1317
|
G.CIRCLE,
|
|
@@ -1322,7 +1322,7 @@ var X = new Set([
|
|
|
1322
1322
|
G.ASSISTANT_POLYGON,
|
|
1323
1323
|
G.ASSISTANT_RECT,
|
|
1324
1324
|
G.ASSISTANT_POINT
|
|
1325
|
-
]),
|
|
1325
|
+
]), X = {
|
|
1326
1326
|
tl: -135,
|
|
1327
1327
|
t: -90,
|
|
1328
1328
|
tr: -45,
|
|
@@ -1338,11 +1338,11 @@ var X = new Set([
|
|
|
1338
1338
|
"nesw-resize"
|
|
1339
1339
|
];
|
|
1340
1340
|
function wt(e, t = 0) {
|
|
1341
|
-
let n = ((
|
|
1341
|
+
let n = ((X[e] + t * 180 / Math.PI) % 180 + 180) % 180;
|
|
1342
1342
|
return Ct[Math.round(n / 45) % 4];
|
|
1343
1343
|
}
|
|
1344
1344
|
function Tt({ tool: e, externalToolCursor: t, isSpacePressed: n, isPolygonDrawing: r }) {
|
|
1345
|
-
return n ? "grab" : t || (e === G.SELECT ? "default" :
|
|
1345
|
+
return n ? "grab" : t || (e === G.SELECT ? "default" : St.has(e) ? r ? "default" : "crosshair" : "default");
|
|
1346
1346
|
}
|
|
1347
1347
|
function Et({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode: r, rendererCursorHint: i, isPolygonDrawing: a }) {
|
|
1348
1348
|
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e === G.SELECT && i ? i : Tt({
|
|
@@ -1565,7 +1565,7 @@ var Rt = {
|
|
|
1565
1565
|
occludedOutline: [],
|
|
1566
1566
|
outlineStyles: l
|
|
1567
1567
|
};
|
|
1568
|
-
},
|
|
1568
|
+
}, Ht = .3, Z = .05;
|
|
1569
1569
|
function Ut(e) {
|
|
1570
1570
|
return 1 - (1 - e) ** 3;
|
|
1571
1571
|
}
|
|
@@ -1579,7 +1579,7 @@ function Wt(e) {
|
|
|
1579
1579
|
}
|
|
1580
1580
|
function Gt(e, t) {
|
|
1581
1581
|
if (!t.length) return null;
|
|
1582
|
-
if (e ===
|
|
1582
|
+
if (e === I.POINT) {
|
|
1583
1583
|
let e = t[0];
|
|
1584
1584
|
return {
|
|
1585
1585
|
x: e.x - 8,
|
|
@@ -1608,7 +1608,7 @@ function Kt(e) {
|
|
|
1608
1608
|
}]))) : null;
|
|
1609
1609
|
}
|
|
1610
1610
|
function qt(e, t, n, r = {}) {
|
|
1611
|
-
let { containerRatio: i =
|
|
1611
|
+
let { containerRatio: i = Ht, minScale: a = Z, maxScale: o = 20 } = r;
|
|
1612
1612
|
if (!t || !n || e.width <= 0 || e.height <= 0) return null;
|
|
1613
1613
|
let s = Math.min(t * i / e.width, n * i / e.height), c = Math.max(a, Math.min(o, s)), l = e.x + e.width / 2, u = e.y + e.height / 2;
|
|
1614
1614
|
return {
|
|
@@ -1619,7 +1619,7 @@ function qt(e, t, n, r = {}) {
|
|
|
1619
1619
|
}
|
|
1620
1620
|
function Jt(e, t, n, r = 80) {
|
|
1621
1621
|
if (!t || !n) return null;
|
|
1622
|
-
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(
|
|
1622
|
+
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(Z, Math.min(20, Math.min((t - r) / i, (n - r) / a))), s = (e.minX + e.maxX) / 2, c = (e.minY + e.maxY) / 2;
|
|
1623
1623
|
return {
|
|
1624
1624
|
scale: o,
|
|
1625
1625
|
x: t / 2 - s * o,
|
|
@@ -1640,10 +1640,10 @@ function Yt(e, t, n, r = 300) {
|
|
|
1640
1640
|
//#endregion
|
|
1641
1641
|
//#region src/components/ShapeEditor/_state/createInteractionController.ts
|
|
1642
1642
|
function Xt(e) {
|
|
1643
|
-
let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, shiftRef: a, docRef: o, selRef: s, draftRef: c, readOnlyRef: l, disableMarqueeRef: u, lockedRef: d, onLockedInteraction: f,
|
|
1643
|
+
let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, shiftRef: a, docRef: o, selRef: s, draftRef: c, readOnlyRef: l, disableMarqueeRef: u, lockedRef: d, onLockedInteraction: f, onDrawAttemptWithoutDraft: p, createRef: m, selectRef: h, enterEditRef: g, editingIdRef: _, drawSessionRef: v, assistantRef: y, setCursorHint: b, setInteractionMode: x, syncMinimap: S, onTransformPreview: C, onDrawPreview: w } = e, T = () => v.current, E = () => y.current, D = null, O = null, k = null, A = null, j = null, M = null, N = "", P = null, ee = null, te = (e) => e === G.RECTANGLE || e === G.ROTATED_RECTANGLE || e === G.CIRCLE, ne = (e) => e === G.ASSISTANT_POLYGON || e === G.ASSISTANT_RECT, F = (e) => e === G.POLYGON, re = (e) => te(e) || ne(e) || F(e) || e === G.PATH || e === G.BRUSH || e === G.POINT, ie = (e, t) => {
|
|
1644
1644
|
let n = !1;
|
|
1645
|
-
|
|
1646
|
-
},
|
|
1645
|
+
O && !te(t) && !ne(t) && (O = null, e.clearPreview(), w(null), n = !0), (k === "path" && t !== G.PATH || k === "scalar" && t !== G.BRUSH) && (k = null, n = !0), A && !F(t) && (A = null, n = !0), j && t !== G.SELECT && (j = null, M = null, e.clearMarquee(), n = !0), P && t !== G.POINT && (P = null, n = !0), n && x("idle");
|
|
1646
|
+
}, ae = () => r.current.get(n.current), oe = (e, t, n, r) => ({
|
|
1647
1647
|
point: t,
|
|
1648
1648
|
targetId: r,
|
|
1649
1649
|
event: n,
|
|
@@ -1651,66 +1651,70 @@ function Xt(e) {
|
|
|
1651
1651
|
viewport: e.viewport
|
|
1652
1652
|
});
|
|
1653
1653
|
return {
|
|
1654
|
-
onCursorHint:
|
|
1655
|
-
onInteractionModeChange:
|
|
1654
|
+
onCursorHint: b,
|
|
1655
|
+
onInteractionModeChange: x,
|
|
1656
1656
|
onPointerDown: (e, r, u) => {
|
|
1657
|
-
let
|
|
1658
|
-
if (!
|
|
1659
|
-
let
|
|
1660
|
-
if (
|
|
1661
|
-
|
|
1657
|
+
let m = t.current;
|
|
1658
|
+
if (!m) return;
|
|
1659
|
+
let v = n.current;
|
|
1660
|
+
if (P = null, ie(m, v), u.button === 1 || i.current) {
|
|
1661
|
+
x("panning"), b(null), D = {
|
|
1662
1662
|
px: u.global.x,
|
|
1663
1663
|
py: u.global.y
|
|
1664
1664
|
};
|
|
1665
1665
|
return;
|
|
1666
1666
|
}
|
|
1667
|
-
if (u.button === 2 && !(
|
|
1667
|
+
if (u.button === 2 && !(v === G.ASSISTANT_POINT && u.altKey)) {
|
|
1668
1668
|
if (r && !s.current.includes(r)) {
|
|
1669
1669
|
let e = o.current.getShapes().find((e) => e.id === r);
|
|
1670
|
-
e &&
|
|
1670
|
+
e && L(e) && h.current([r]);
|
|
1671
1671
|
}
|
|
1672
1672
|
return;
|
|
1673
1673
|
}
|
|
1674
|
-
let
|
|
1675
|
-
if (
|
|
1676
|
-
|
|
1674
|
+
let y = ae();
|
|
1675
|
+
if (y) {
|
|
1676
|
+
T().reset(), h.current([]), y.onPointerDown?.(oe(m, e, u, r));
|
|
1677
1677
|
return;
|
|
1678
1678
|
}
|
|
1679
1679
|
if (d.current) {
|
|
1680
1680
|
f();
|
|
1681
1681
|
return;
|
|
1682
1682
|
}
|
|
1683
|
-
if (
|
|
1684
|
-
|
|
1683
|
+
if (re(v) && !c.current) {
|
|
1684
|
+
p();
|
|
1685
1685
|
return;
|
|
1686
1686
|
}
|
|
1687
|
-
if (
|
|
1688
|
-
|
|
1687
|
+
if (v === G.ASSISTANT_POINT) {
|
|
1688
|
+
u.altKey ? E().addPoint(e, u.button !== 2) : E().newPolygon(e);
|
|
1689
1689
|
return;
|
|
1690
1690
|
}
|
|
1691
|
-
if (
|
|
1692
|
-
|
|
1693
|
-
|
|
1691
|
+
if (ne(v) && c.current) {
|
|
1692
|
+
O = e, x("drawing");
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
if (v === G.SELECT && u.altKey) {
|
|
1696
|
+
let t = z(o.current.getShapes()).filter((t) => {
|
|
1697
|
+
if (!L(t)) return !1;
|
|
1694
1698
|
let n = V(t.points);
|
|
1695
1699
|
return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
|
|
1696
1700
|
});
|
|
1697
1701
|
if (t.length) {
|
|
1698
1702
|
let e = [...t].reverse(), n = [e[(e.findIndex((e) => s.current.includes(e.id)) + 1) % e.length].id];
|
|
1699
|
-
|
|
1703
|
+
h.current(n);
|
|
1700
1704
|
return;
|
|
1701
1705
|
}
|
|
1702
1706
|
}
|
|
1703
|
-
if (r &&
|
|
1707
|
+
if (r && v === G.SELECT) {
|
|
1704
1708
|
let t = o.current.getShapes().find((e) => e.id === r);
|
|
1705
|
-
if (!t || !
|
|
1706
|
-
let n = typeof performance < "u" ? performance.now() : 0, i = !!
|
|
1707
|
-
|
|
1709
|
+
if (!t || !L(t)) return;
|
|
1710
|
+
let n = typeof performance < "u" ? performance.now() : 0, i = !!ee && ee.id === r && n - ee.t < 300;
|
|
1711
|
+
ee = {
|
|
1708
1712
|
id: r,
|
|
1709
1713
|
t: n
|
|
1710
1714
|
};
|
|
1711
|
-
let c = (t.type ===
|
|
1715
|
+
let c = (t.type === I.POLYGON || t.type === I.LINE) && !l.current && t.interaction?.editable !== !1 && !t.readOnly;
|
|
1712
1716
|
if (i && c) {
|
|
1713
|
-
|
|
1717
|
+
h.current([r]), g.current(r);
|
|
1714
1718
|
return;
|
|
1715
1719
|
}
|
|
1716
1720
|
let u = s.current;
|
|
@@ -1718,176 +1722,176 @@ function Xt(e) {
|
|
|
1718
1722
|
let e = new Set(u);
|
|
1719
1723
|
e.has(r) ? e.delete(r) : e.add(r), u = [...e];
|
|
1720
1724
|
} else u.includes(r) || (u = [r]);
|
|
1721
|
-
|
|
1725
|
+
h.current(u), !l.current && R(t) && m.beginMove(e, u);
|
|
1722
1726
|
return;
|
|
1723
1727
|
}
|
|
1724
|
-
if (
|
|
1725
|
-
|
|
1728
|
+
if (te(v) && c.current) {
|
|
1729
|
+
O = e, x("drawing");
|
|
1726
1730
|
return;
|
|
1727
1731
|
}
|
|
1728
|
-
if (
|
|
1729
|
-
if (!
|
|
1730
|
-
let t =
|
|
1732
|
+
if (F(v) && c.current) {
|
|
1733
|
+
if (!T().getDraftPointsSnapshot().length && s.current.length && h.current([]), T().tryClosePolygon(e, 12 / m.viewport.scale)) return;
|
|
1734
|
+
let t = T().hitDraftPoint(e);
|
|
1731
1735
|
if (t >= 0) {
|
|
1732
1736
|
if (u.altKey) {
|
|
1733
|
-
|
|
1737
|
+
T().removeDraftPoint(t);
|
|
1734
1738
|
return;
|
|
1735
1739
|
}
|
|
1736
|
-
let n =
|
|
1740
|
+
let n = T().selectDraftPointForDrag(t, u.shiftKey || u.ctrlKey || u.metaKey);
|
|
1737
1741
|
if (!n) return;
|
|
1738
|
-
|
|
1742
|
+
A = {
|
|
1739
1743
|
start: e,
|
|
1740
1744
|
base: n.base,
|
|
1741
1745
|
indices: n.indices,
|
|
1742
1746
|
moved: !1
|
|
1743
|
-
},
|
|
1747
|
+
}, x("vertexDragging");
|
|
1744
1748
|
return;
|
|
1745
1749
|
}
|
|
1746
|
-
|
|
1750
|
+
T().appendPolygonPoint(e);
|
|
1747
1751
|
return;
|
|
1748
1752
|
}
|
|
1749
|
-
if (
|
|
1750
|
-
s.current.length &&
|
|
1753
|
+
if (v === G.PATH && c.current) {
|
|
1754
|
+
s.current.length && h.current([]), k = "path", x("drawing"), T().beginStroke(e);
|
|
1751
1755
|
return;
|
|
1752
1756
|
}
|
|
1753
|
-
if (
|
|
1754
|
-
|
|
1757
|
+
if (v === G.BRUSH && c.current && !l.current) {
|
|
1758
|
+
k = "scalar", x("drawing"), T().beginStroke(e);
|
|
1755
1759
|
return;
|
|
1756
1760
|
}
|
|
1757
|
-
if (
|
|
1758
|
-
|
|
1761
|
+
if (v === G.POINT && c.current && u.button === 0) {
|
|
1762
|
+
P = {
|
|
1759
1763
|
pointerId: u.pointerId,
|
|
1760
1764
|
global: u.global,
|
|
1761
1765
|
cancelled: !1
|
|
1762
1766
|
};
|
|
1763
1767
|
return;
|
|
1764
1768
|
}
|
|
1765
|
-
if (
|
|
1766
|
-
if (
|
|
1767
|
-
let t = o.current.getShapes().filter((e) => s.current.includes(e.id) &&
|
|
1769
|
+
if (v === G.SELECT) {
|
|
1770
|
+
if (M = _.current ? a.current ? m.getVertexSelection() : [] : null, !a.current && !l.current && s.current.length >= 2) {
|
|
1771
|
+
let t = o.current.getShapes().filter((e) => s.current.includes(e.id) && R(e));
|
|
1768
1772
|
if (t.length) {
|
|
1769
1773
|
let n = V(t.flatMap((e) => e.points));
|
|
1770
1774
|
if (e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY) {
|
|
1771
|
-
|
|
1775
|
+
m.beginMove(e, s.current);
|
|
1772
1776
|
return;
|
|
1773
1777
|
}
|
|
1774
1778
|
}
|
|
1775
1779
|
}
|
|
1776
|
-
|
|
1780
|
+
j = e, N = "", x("marquee"), b(null);
|
|
1777
1781
|
}
|
|
1778
1782
|
},
|
|
1779
1783
|
onPointerMove: (e, r) => {
|
|
1780
1784
|
let i = t.current;
|
|
1781
1785
|
if (!i) return;
|
|
1782
|
-
if (
|
|
1786
|
+
if (P && P.pointerId === r.pointerId && Math.hypot(r.global.x - P.global.x, r.global.y - P.global.y) > 4 && (P.cancelled = !0), D) {
|
|
1783
1787
|
i.applyViewport({
|
|
1784
1788
|
scale: i.viewport.scale,
|
|
1785
|
-
x: i.viewport.x + (r.global.x -
|
|
1786
|
-
y: i.viewport.y + (r.global.y -
|
|
1787
|
-
}),
|
|
1789
|
+
x: i.viewport.x + (r.global.x - D.px),
|
|
1790
|
+
y: i.viewport.y + (r.global.y - D.py)
|
|
1791
|
+
}), D.px = r.global.x, D.py = r.global.y;
|
|
1788
1792
|
return;
|
|
1789
1793
|
}
|
|
1790
1794
|
let s = n.current;
|
|
1791
|
-
|
|
1792
|
-
let l =
|
|
1795
|
+
ie(i, s);
|
|
1796
|
+
let l = ae();
|
|
1793
1797
|
if (l) {
|
|
1794
|
-
l.onPointerMove?.(
|
|
1798
|
+
l.onPointerMove?.(oe(i, e, r));
|
|
1795
1799
|
return;
|
|
1796
1800
|
}
|
|
1797
|
-
if (
|
|
1798
|
-
let t = e.x -
|
|
1799
|
-
|
|
1801
|
+
if (A) {
|
|
1802
|
+
let t = e.x - A.start.x, n = e.y - A.start.y;
|
|
1803
|
+
A.moved = A.moved || Math.hypot(t, n) > .5, T().moveDraftPoints(A.base, A.indices, t, n);
|
|
1800
1804
|
return;
|
|
1801
1805
|
}
|
|
1802
|
-
if (
|
|
1803
|
-
let t = a.current ? ce(
|
|
1804
|
-
i.previewBox(s === G.CIRCLE ? "ellipse" : "rect",
|
|
1806
|
+
if (O && (te(s) || ne(s))) {
|
|
1807
|
+
let t = a.current ? ce(O, e) : e;
|
|
1808
|
+
i.previewBox(s === G.CIRCLE ? "ellipse" : "rect", O, t, {
|
|
1805
1809
|
...c.current,
|
|
1806
1810
|
color: c.current?.color ?? "#00e5ff"
|
|
1807
|
-
}),
|
|
1808
|
-
type: s === G.CIRCLE ?
|
|
1809
|
-
points: [
|
|
1811
|
+
}), te(s) && w({
|
|
1812
|
+
type: s === G.CIRCLE ? I.ELLIPSE : I.RECTANGLE,
|
|
1813
|
+
points: [O, t]
|
|
1810
1814
|
});
|
|
1811
1815
|
return;
|
|
1812
1816
|
}
|
|
1813
|
-
if (
|
|
1814
|
-
|
|
1817
|
+
if (k) {
|
|
1818
|
+
T().appendStrokePoint(e, 2 / i.viewport.scale);
|
|
1815
1819
|
return;
|
|
1816
1820
|
}
|
|
1817
|
-
if (
|
|
1818
|
-
|
|
1821
|
+
if (F(s) && T().hasDraftPoints()) {
|
|
1822
|
+
T().setDraftCursor(e);
|
|
1819
1823
|
return;
|
|
1820
1824
|
}
|
|
1821
|
-
if (
|
|
1825
|
+
if (j) {
|
|
1822
1826
|
if (u?.current) return;
|
|
1823
1827
|
let t = {
|
|
1824
|
-
minX: Math.min(
|
|
1825
|
-
minY: Math.min(
|
|
1826
|
-
maxX: Math.max(
|
|
1827
|
-
maxY: Math.max(
|
|
1828
|
+
minX: Math.min(j.x, e.x),
|
|
1829
|
+
minY: Math.min(j.y, e.y),
|
|
1830
|
+
maxX: Math.max(j.x, e.x),
|
|
1831
|
+
maxY: Math.max(j.y, e.y)
|
|
1828
1832
|
};
|
|
1829
|
-
if (i.previewMarquee(
|
|
1830
|
-
let e = (o.current.getShapes().find((e) => e.id ===
|
|
1831
|
-
r !==
|
|
1833
|
+
if (i.previewMarquee(j, e), M) {
|
|
1834
|
+
let e = (o.current.getShapes().find((e) => e.id === _.current)?.points ?? []).flatMap((e, n) => e.x >= t.minX && e.x <= t.maxX && e.y >= t.minY && e.y <= t.maxY ? [n] : []), n = [...new Set([...M, ...e])].sort((e, t) => e - t), r = n.join(",");
|
|
1835
|
+
r !== N && (N = r, i.setVertexSelection(n));
|
|
1832
1836
|
return;
|
|
1833
1837
|
}
|
|
1834
1838
|
let n = i.shapesIntersecting(t), r = n.join(",");
|
|
1835
|
-
r !==
|
|
1839
|
+
r !== N && (N = r, h.current(n));
|
|
1836
1840
|
}
|
|
1837
1841
|
},
|
|
1838
1842
|
onPointerUp: (e, r) => {
|
|
1839
1843
|
let i = t.current;
|
|
1840
1844
|
if (!i) return;
|
|
1841
|
-
let o =
|
|
1842
|
-
if (
|
|
1843
|
-
|
|
1845
|
+
let o = P;
|
|
1846
|
+
if (P = null, D) {
|
|
1847
|
+
D = null, x("idle");
|
|
1844
1848
|
return;
|
|
1845
1849
|
}
|
|
1846
1850
|
let l = n.current;
|
|
1847
|
-
if (
|
|
1848
|
-
|
|
1851
|
+
if (ie(i, l), A) {
|
|
1852
|
+
T().commitDraftPointDrag(A.moved), A = null, x("idle");
|
|
1849
1853
|
return;
|
|
1850
1854
|
}
|
|
1851
|
-
let u =
|
|
1855
|
+
let u = ae();
|
|
1852
1856
|
if (u) {
|
|
1853
|
-
u.onPointerUp?.(
|
|
1857
|
+
u.onPointerUp?.(oe(i, e, r));
|
|
1854
1858
|
return;
|
|
1855
1859
|
}
|
|
1856
1860
|
let d = o ? Math.hypot(r.global.x - o.global.x, r.global.y - o.global.y) : Infinity;
|
|
1857
1861
|
if (l === G.POINT && c.current && o && !o.cancelled && o.pointerId === r.pointerId && r.insideCanvas && d <= 4) {
|
|
1858
|
-
|
|
1862
|
+
m.current(I.POINT, [e]);
|
|
1859
1863
|
return;
|
|
1860
1864
|
}
|
|
1861
|
-
if (
|
|
1862
|
-
let e =
|
|
1863
|
-
|
|
1865
|
+
if (k) {
|
|
1866
|
+
let e = k;
|
|
1867
|
+
k = null, x("idle"), e === "path" ? T().completeFreehandStroke() : T().finishScalarStroke();
|
|
1864
1868
|
return;
|
|
1865
1869
|
}
|
|
1866
|
-
if (
|
|
1867
|
-
let t =
|
|
1868
|
-
|
|
1870
|
+
if (O && ne(l)) {
|
|
1871
|
+
let t = O;
|
|
1872
|
+
O = null, x("idle"), i.clearPreview();
|
|
1869
1873
|
let n = {
|
|
1870
1874
|
x: Math.min(t.x, e.x),
|
|
1871
1875
|
y: Math.min(t.y, e.y),
|
|
1872
1876
|
width: Math.abs(e.x - t.x),
|
|
1873
1877
|
height: Math.abs(e.y - t.y)
|
|
1874
1878
|
};
|
|
1875
|
-
n.width > 2 && n.height > 2 &&
|
|
1879
|
+
n.width > 2 && n.height > 2 && E().beginBox(n, l === G.ASSISTANT_RECT ? "rect" : "polygon");
|
|
1876
1880
|
return;
|
|
1877
1881
|
}
|
|
1878
|
-
if (
|
|
1879
|
-
let t = a.current ? ce(
|
|
1880
|
-
|
|
1882
|
+
if (O && te(l)) {
|
|
1883
|
+
let t = a.current ? ce(O, e) : e, n = O;
|
|
1884
|
+
O = null, x("idle"), i.clearPreview(), w(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (l === G.ROTATED_RECTANGLE ? m.current(I.ROTATED_RECTANGLE, ue([n, t])) : l === G.CIRCLE ? m.current(I.POLYGON, de(n, t)) : m.current(I.RECTANGLE, [n, t]));
|
|
1881
1885
|
return;
|
|
1882
1886
|
}
|
|
1883
|
-
if (
|
|
1884
|
-
let t = Math.abs(e.x -
|
|
1885
|
-
if (
|
|
1886
|
-
!t && s.current.length &&
|
|
1887
|
+
if (j) {
|
|
1888
|
+
let t = Math.abs(e.x - j.x) > 3 || Math.abs(e.y - j.y) > 3, n = M !== null;
|
|
1889
|
+
if (j = null, M = null, i.clearMarquee(), x("idle"), n && t) return;
|
|
1890
|
+
!t && s.current.length && h.current([]);
|
|
1887
1891
|
}
|
|
1888
1892
|
},
|
|
1889
|
-
onViewportChange:
|
|
1890
|
-
onTransformPreview:
|
|
1893
|
+
onViewportChange: S,
|
|
1894
|
+
onTransformPreview: C,
|
|
1891
1895
|
onTransformCommit: (e) => {
|
|
1892
1896
|
let t = o.current.getShapes(), n = e.map((e) => {
|
|
1893
1897
|
let n = t.find((t) => t.id === e.id);
|
|
@@ -1912,7 +1916,7 @@ function Zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
1912
1916
|
return e.map((e) => {
|
|
1913
1917
|
if (t === "rect" && a) return {
|
|
1914
1918
|
id: oe(),
|
|
1915
|
-
type:
|
|
1919
|
+
type: I.ROTATED_RECTANGLE,
|
|
1916
1920
|
points: pe(e),
|
|
1917
1921
|
style: r,
|
|
1918
1922
|
meta: n
|
|
@@ -1921,7 +1925,7 @@ function Zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
1921
1925
|
let t = V(e);
|
|
1922
1926
|
return {
|
|
1923
1927
|
id: oe(),
|
|
1924
|
-
type:
|
|
1928
|
+
type: I.RECTANGLE,
|
|
1925
1929
|
points: [{
|
|
1926
1930
|
x: t.minX,
|
|
1927
1931
|
y: t.minY
|
|
@@ -1935,7 +1939,7 @@ function Zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
1935
1939
|
}
|
|
1936
1940
|
return {
|
|
1937
1941
|
id: oe(),
|
|
1938
|
-
type:
|
|
1942
|
+
type: I.POLYGON,
|
|
1939
1943
|
points: e,
|
|
1940
1944
|
style: r,
|
|
1941
1945
|
meta: n
|
|
@@ -2188,11 +2192,11 @@ function un(e, t) {
|
|
|
2188
2192
|
}
|
|
2189
2193
|
function dn(e) {
|
|
2190
2194
|
switch (e.type) {
|
|
2191
|
-
case
|
|
2192
|
-
case
|
|
2193
|
-
case
|
|
2194
|
-
case
|
|
2195
|
-
case
|
|
2195
|
+
case I.RECTANGLE: return e.points.length < 2 ? null : ue(e.points);
|
|
2196
|
+
case I.POLYGON:
|
|
2197
|
+
case I.ROTATED_RECTANGLE:
|
|
2198
|
+
case I.ELLIPSE: return e.points.length >= 3 ? e.points : null;
|
|
2199
|
+
case I.POINT: {
|
|
2196
2200
|
let t = e.points[0];
|
|
2197
2201
|
return t ? de({
|
|
2198
2202
|
x: t.x - 6,
|
|
@@ -2307,18 +2311,18 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2307
2311
|
let _ = O(null), v = O([]), y = O(null), b = O(/* @__PURE__ */ new Set()), S = O([[]]), C = O(0), w = O(null), T = O([]), E = O([]), D = O([]), k = O([[]]), A = O(0), j = O("draw"), M = () => j.current === "erase" ? "erase" : "add", N = () => D.current.length > 0 || T.current.length > 0 || e.current === G.BRUSH && v.current.length > 0, P = () => {
|
|
2308
2312
|
let t = e.current;
|
|
2309
2313
|
return t === G.BRUSH && N() ? "brush" : t === G.POLYGON && v.current.length > 0 ? "polygon" : t === G.PATH && v.current.length > 0 ? "path" : "none";
|
|
2310
|
-
},
|
|
2314
|
+
}, ee = () => v.current.length > 0 || A.current > 0, te = () => v.current.length === 0 && A.current < k.current.length - 1, ne = () => C.current > 0, F = () => C.current < S.current.length - 1, re = () => {
|
|
2311
2315
|
let t = e.current;
|
|
2312
|
-
return t === G.BRUSH ?
|
|
2313
|
-
},
|
|
2316
|
+
return t === G.BRUSH ? ee() : t === G.POLYGON || t === G.PATH ? ne() : !1;
|
|
2317
|
+
}, ie = () => {
|
|
2314
2318
|
let t = e.current;
|
|
2315
|
-
return t === G.BRUSH ?
|
|
2316
|
-
},
|
|
2319
|
+
return t === G.BRUSH ? te() : t === G.POLYGON || t === G.PATH ? F() : !1;
|
|
2320
|
+
}, L = () => P() !== "none", R = x(() => {
|
|
2317
2321
|
let e = P(), t = {
|
|
2318
2322
|
active: e !== "none",
|
|
2319
2323
|
kind: e,
|
|
2320
|
-
canUndo:
|
|
2321
|
-
canRedo:
|
|
2324
|
+
canUndo: re(),
|
|
2325
|
+
canRedo: ie(),
|
|
2322
2326
|
brush: e === "brush" ? {
|
|
2323
2327
|
mode: j.current,
|
|
2324
2328
|
editing: D.current.length > 0,
|
|
@@ -2326,7 +2330,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2326
2330
|
} : void 0
|
|
2327
2331
|
}, n = _.current;
|
|
2328
2332
|
n && xn(n, t) || (_.current = t, p.current?.(t));
|
|
2329
|
-
}, []),
|
|
2333
|
+
}, []), z = x(() => {
|
|
2330
2334
|
k.current = [[]], A.current = 0;
|
|
2331
2335
|
}, []), B = x(() => {
|
|
2332
2336
|
let t = c.current;
|
|
@@ -2362,7 +2366,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2362
2366
|
if (t.previewPoly(r, y.current, o, !1, s, l), n === G.POLYGON || n === G.PATH) {
|
|
2363
2367
|
let e = m.current;
|
|
2364
2368
|
e && r !== w.current && (w.current = r, e({
|
|
2365
|
-
type:
|
|
2369
|
+
type: I.POLYGON,
|
|
2366
2370
|
points: vn(r),
|
|
2367
2371
|
meta: h.current
|
|
2368
2372
|
}));
|
|
@@ -2374,20 +2378,20 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2374
2378
|
e
|
|
2375
2379
|
]), V = x((e) => {
|
|
2376
2380
|
let t = gn(e), n = k.current, r = A.current, i = n[r];
|
|
2377
|
-
i && _n(i, t) || (k.current = [...n.slice(0, r + 1), t], A.current += 1,
|
|
2378
|
-
}, [
|
|
2381
|
+
i && _n(i, t) || (k.current = [...n.slice(0, r + 1), t], A.current += 1, R());
|
|
2382
|
+
}, [R]), se = x((e) => {
|
|
2379
2383
|
let t = S.current, n = C.current, r = t[n];
|
|
2380
2384
|
r && yn(r, e) || (S.current = [...t.slice(0, n + 1), vn(e)], C.current += 1);
|
|
2381
2385
|
}, []), H = x(() => {
|
|
2382
|
-
v.current = [], T.current = [], E.current = [], D.current = [], y.current = null, b.current = /* @__PURE__ */ new Set(), S.current = [[]], C.current = 0, w.current = null,
|
|
2386
|
+
v.current = [], T.current = [], E.current = [], D.current = [], y.current = null, b.current = /* @__PURE__ */ new Set(), S.current = [[]], C.current = 0, w.current = null, z(), c.current?.clearPreview(), m.current?.(null), R();
|
|
2383
2387
|
}, [
|
|
2384
2388
|
c,
|
|
2385
|
-
|
|
2386
|
-
|
|
2389
|
+
R,
|
|
2390
|
+
z
|
|
2387
2391
|
]), ce = x((e, t) => {
|
|
2388
|
-
v.current = e, b.current = new Set(Array.from(b.current).filter((t) => t >= 0 && t < e.length)), t && se(e), B(),
|
|
2392
|
+
v.current = e, b.current = new Set(Array.from(b.current).filter((t) => t >= 0 && t < e.length)), t && se(e), B(), R();
|
|
2389
2393
|
}, [
|
|
2390
|
-
|
|
2394
|
+
R,
|
|
2391
2395
|
se,
|
|
2392
2396
|
B
|
|
2393
2397
|
]), le = x(() => vn(v.current), []), ue = x(() => v.current.length > 0, []), de = x((t, n) => {
|
|
@@ -2395,7 +2399,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2395
2399
|
let r = v.current;
|
|
2396
2400
|
if (r.length < 3) return !1;
|
|
2397
2401
|
let i = r[0];
|
|
2398
|
-
return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (g.current(
|
|
2402
|
+
return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (g.current(I.POLYGON, r), H(), !0);
|
|
2399
2403
|
}, [H, e]), fe = x((e) => {
|
|
2400
2404
|
let t = v.current;
|
|
2401
2405
|
return e < 0 || e >= t.length ? !1 : (ce(t.filter((t, n) => n !== e), !0), !0);
|
|
@@ -2403,32 +2407,32 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2403
2407
|
let n = v.current;
|
|
2404
2408
|
if (e < 0 || e >= n.length) return null;
|
|
2405
2409
|
let r = new Set(b.current);
|
|
2406
|
-
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), b.current = r, y.current = null, B(),
|
|
2410
|
+
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), b.current = r, y.current = null, B(), R(), {
|
|
2407
2411
|
base: vn(n),
|
|
2408
2412
|
indices: Array.from(r)
|
|
2409
2413
|
};
|
|
2410
|
-
}, [
|
|
2414
|
+
}, [R, B]), me = x((e) => {
|
|
2411
2415
|
b.current = /* @__PURE__ */ new Set(), y.current = e, ce([...v.current, e], !0);
|
|
2412
2416
|
}, [ce]), he = x((e) => {
|
|
2413
|
-
y.current = null, b.current = /* @__PURE__ */ new Set(), v.current = [{ ...e }], B(),
|
|
2414
|
-
}, [
|
|
2417
|
+
y.current = null, b.current = /* @__PURE__ */ new Set(), v.current = [{ ...e }], B(), R();
|
|
2418
|
+
}, [R, B]), ge = x((e, t) => {
|
|
2415
2419
|
let n = v.current[v.current.length - 1];
|
|
2416
|
-
return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (v.current = [...v.current, { ...e }], y.current = null, B(),
|
|
2417
|
-
}, [
|
|
2420
|
+
return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (v.current = [...v.current, { ...e }], y.current = null, B(), R(), !0);
|
|
2421
|
+
}, [R, B]), _e = x((e, t, n, r) => {
|
|
2418
2422
|
let i = new Set(t);
|
|
2419
2423
|
v.current = e.map((e, t) => i.has(t) ? {
|
|
2420
2424
|
x: e.x + n,
|
|
2421
2425
|
y: e.y + r
|
|
2422
|
-
} : { ...e }), y.current = null, B(),
|
|
2423
|
-
}, [
|
|
2424
|
-
e && (se(v.current), B(),
|
|
2426
|
+
} : { ...e }), y.current = null, B(), R();
|
|
2427
|
+
}, [R, B]), ve = x((e) => {
|
|
2428
|
+
e && (se(v.current), B(), R());
|
|
2425
2429
|
}, [
|
|
2426
|
-
|
|
2430
|
+
R,
|
|
2427
2431
|
se,
|
|
2428
2432
|
B
|
|
2429
2433
|
]), ye = x((e) => {
|
|
2430
2434
|
y.current = e ? { ...e } : null, B();
|
|
2431
|
-
}, [B]), be = x(() => v.current.length > 0 ? (v.current = [], B(),
|
|
2435
|
+
}, [B]), be = x(() => v.current.length > 0 ? (v.current = [], B(), R(), !0) : A.current <= 0 ? !1 : (--A.current, T.current = gn(k.current[A.current]), B(), R(), !0), [R, B]), xe = x(() => v.current.length > 0 || A.current >= k.current.length - 1 ? !1 : (A.current += 1, T.current = gn(k.current[A.current]), B(), R(), !0), [R, B]), Se = x(() => C.current <= 0 ? !1 : (--C.current, v.current = vn(S.current[C.current]), b.current = /* @__PURE__ */ new Set(), B(), R(), !0), [R, B]), Ce = x(() => C.current >= S.current.length - 1 ? !1 : (C.current += 1, v.current = vn(S.current[C.current]), b.current = /* @__PURE__ */ new Set(), B(), R(), !0), [R, B]), we = x(() => {
|
|
2432
2436
|
let t = e.current;
|
|
2433
2437
|
return t === G.BRUSH ? be() : t === G.POLYGON || t === G.PATH ? Se() : !1;
|
|
2434
2438
|
}, [
|
|
@@ -2442,12 +2446,12 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2442
2446
|
xe,
|
|
2443
2447
|
Ce,
|
|
2444
2448
|
e
|
|
2445
|
-
]),
|
|
2449
|
+
]), Ee = x(() => {
|
|
2446
2450
|
let e = t.current;
|
|
2447
2451
|
if (!e.length) return D.current.length > 0;
|
|
2448
|
-
let r = n.current.getShapes().filter((t) => e.includes(t.id) &&
|
|
2452
|
+
let r = n.current.getShapes().filter((t) => e.includes(t.id) && ae(t)), i = fn(r);
|
|
2449
2453
|
return i.length ? (D.current = r.map((e) => e.id), E.current = i, !0) : (D.current = [], E.current = [], !1);
|
|
2450
|
-
}, [n, t]),
|
|
2454
|
+
}, [n, t]), U = x(() => {
|
|
2451
2455
|
if (r.current) return !1;
|
|
2452
2456
|
let e = [...T.current];
|
|
2453
2457
|
v.current.length && e.push({
|
|
@@ -2470,7 +2474,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2470
2474
|
let r = e[n];
|
|
2471
2475
|
t.push({
|
|
2472
2476
|
...r,
|
|
2473
|
-
type:
|
|
2477
|
+
type: I.POLYGON,
|
|
2474
2478
|
points: a
|
|
2475
2479
|
}), i.push(r.id);
|
|
2476
2480
|
} else {
|
|
@@ -2478,7 +2482,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2478
2482
|
r.push({
|
|
2479
2483
|
...t,
|
|
2480
2484
|
id: n,
|
|
2481
|
-
type:
|
|
2485
|
+
type: I.POLYGON,
|
|
2482
2486
|
points: a
|
|
2483
2487
|
}), i.push(n);
|
|
2484
2488
|
}
|
|
@@ -2491,7 +2495,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2491
2495
|
if (!f) return !1;
|
|
2492
2496
|
let p = u.map((e) => ({
|
|
2493
2497
|
id: oe(),
|
|
2494
|
-
type:
|
|
2498
|
+
type: I.POLYGON,
|
|
2495
2499
|
points: e,
|
|
2496
2500
|
style: f,
|
|
2497
2501
|
meta: s
|
|
@@ -2507,40 +2511,40 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2507
2511
|
H
|
|
2508
2512
|
]), De = x(() => {
|
|
2509
2513
|
let t = e.current;
|
|
2510
|
-
if (t === G.BRUSH) return
|
|
2514
|
+
if (t === G.BRUSH) return U();
|
|
2511
2515
|
let n = v.current;
|
|
2512
|
-
return t === G.POLYGON && n.length >= 3 ? (g.current(
|
|
2516
|
+
return t === G.POLYGON && n.length >= 3 ? (g.current(I.POLYGON, n), H(), !0) : !1;
|
|
2513
2517
|
}, [
|
|
2514
|
-
|
|
2518
|
+
U,
|
|
2515
2519
|
H,
|
|
2516
2520
|
e
|
|
2517
2521
|
]), W = x(() => {
|
|
2518
2522
|
let t = v.current;
|
|
2519
2523
|
if (e.current === G.PATH && t.length >= 3) {
|
|
2520
2524
|
let e = $t(t, o.current);
|
|
2521
|
-
e.length >= 3 && g.current(
|
|
2525
|
+
e.length >= 3 && g.current(I.POLYGON, e);
|
|
2522
2526
|
}
|
|
2523
2527
|
H();
|
|
2524
2528
|
}, [H, e]), Oe = x((e) => {
|
|
2525
|
-
j.current = e,
|
|
2526
|
-
}, [
|
|
2529
|
+
j.current = e, R(), B();
|
|
2530
|
+
}, [R, B]), ke = x(() => {
|
|
2527
2531
|
if (r.current || e.current !== G.BRUSH) return !1;
|
|
2528
|
-
T.current = [], v.current = [],
|
|
2529
|
-
let t =
|
|
2530
|
-
return
|
|
2532
|
+
T.current = [], v.current = [], z();
|
|
2533
|
+
let t = Ee();
|
|
2534
|
+
return R(), B(), t;
|
|
2531
2535
|
}, [
|
|
2532
|
-
|
|
2536
|
+
R,
|
|
2533
2537
|
r,
|
|
2534
2538
|
B,
|
|
2535
|
-
|
|
2536
|
-
|
|
2539
|
+
z,
|
|
2540
|
+
Ee,
|
|
2537
2541
|
e
|
|
2538
2542
|
]), Ae = x(() => {
|
|
2539
2543
|
let e = b.current;
|
|
2540
2544
|
if (!e.size) return !1;
|
|
2541
2545
|
let t = v.current.filter((t, n) => !e.has(n));
|
|
2542
2546
|
return b.current = /* @__PURE__ */ new Set(), ce(t, !0), !0;
|
|
2543
|
-
}, [ce]),
|
|
2547
|
+
}, [ce]), je = x((e) => {
|
|
2544
2548
|
let t = c.current, n = v.current;
|
|
2545
2549
|
if (!t || !n.length) return -1;
|
|
2546
2550
|
let r = bn / (t.viewport.scale || 1);
|
|
@@ -2549,13 +2553,13 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2549
2553
|
if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
|
|
2550
2554
|
}
|
|
2551
2555
|
return -1;
|
|
2552
|
-
}, [c]),
|
|
2556
|
+
}, [c]), K = x(() => {
|
|
2553
2557
|
v.current.length >= 1 && (T.current.push({
|
|
2554
2558
|
points: vn(v.current),
|
|
2555
2559
|
mode: M()
|
|
2556
|
-
}), v.current = [], V(T.current)), B(),
|
|
2560
|
+
}), v.current = [], V(T.current)), B(), R();
|
|
2557
2561
|
}, [
|
|
2558
|
-
|
|
2562
|
+
R,
|
|
2559
2563
|
V,
|
|
2560
2564
|
B
|
|
2561
2565
|
]);
|
|
@@ -2563,22 +2567,22 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2563
2567
|
reset: H,
|
|
2564
2568
|
undoSession: we,
|
|
2565
2569
|
redoSession: Te,
|
|
2566
|
-
canUndoSession:
|
|
2567
|
-
canRedoSession:
|
|
2568
|
-
hasDraftSession:
|
|
2570
|
+
canUndoSession: re,
|
|
2571
|
+
canRedoSession: ie,
|
|
2572
|
+
hasDraftSession: L,
|
|
2569
2573
|
hasDraftPoints: ue,
|
|
2570
2574
|
commitDraftSession: De,
|
|
2571
2575
|
completeFreehandStroke: W,
|
|
2572
2576
|
setBrushScalarMode: Oe,
|
|
2573
2577
|
getBrushScalarMode: () => j.current,
|
|
2574
2578
|
hasBrushSession: N,
|
|
2575
|
-
commitBrush:
|
|
2579
|
+
commitBrush: U,
|
|
2576
2580
|
cancelBrush: x(() => {
|
|
2577
2581
|
e.current === G.BRUSH && H();
|
|
2578
2582
|
}, [H, e]),
|
|
2579
2583
|
beginBrushEditFromSelection: ke,
|
|
2580
2584
|
deleteDraftSelectedPoints: Ae,
|
|
2581
|
-
hitDraftPoint:
|
|
2585
|
+
hitDraftPoint: je,
|
|
2582
2586
|
getDraftPointsSnapshot: le,
|
|
2583
2587
|
tryClosePolygon: de,
|
|
2584
2588
|
removeDraftPoint: fe,
|
|
@@ -2589,7 +2593,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2589
2593
|
moveDraftPoints: _e,
|
|
2590
2594
|
commitDraftPointDrag: ve,
|
|
2591
2595
|
setDraftCursor: ye,
|
|
2592
|
-
finishScalarStroke:
|
|
2596
|
+
finishScalarStroke: K,
|
|
2593
2597
|
handleToolChange: x((e, t) => {
|
|
2594
2598
|
if (t) {
|
|
2595
2599
|
H(), j.current = "draw";
|
|
@@ -2599,27 +2603,27 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2599
2603
|
H(), j.current = "draw";
|
|
2600
2604
|
return;
|
|
2601
2605
|
}
|
|
2602
|
-
j.current = "draw", T.current = [], v.current = [],
|
|
2606
|
+
j.current = "draw", T.current = [], v.current = [], z(), Ee(), R(), B();
|
|
2603
2607
|
}, [
|
|
2604
|
-
|
|
2608
|
+
R,
|
|
2605
2609
|
B,
|
|
2606
2610
|
H,
|
|
2607
|
-
|
|
2608
|
-
|
|
2611
|
+
z,
|
|
2612
|
+
Ee
|
|
2609
2613
|
]),
|
|
2610
2614
|
handleBrushSelectionChange: x((t, n) => {
|
|
2611
2615
|
if (!(e.current !== G.BRUSH || n)) {
|
|
2612
2616
|
if (!t.length) {
|
|
2613
|
-
|
|
2617
|
+
R();
|
|
2614
2618
|
return;
|
|
2615
2619
|
}
|
|
2616
|
-
[...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || v.current.length || (T.current = [], v.current = [],
|
|
2620
|
+
[...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || v.current.length || (T.current = [], v.current = [], z(), Ee(), R(), B()));
|
|
2617
2621
|
}
|
|
2618
2622
|
}, [
|
|
2619
|
-
|
|
2623
|
+
R,
|
|
2620
2624
|
B,
|
|
2621
|
-
|
|
2622
|
-
|
|
2625
|
+
z,
|
|
2626
|
+
Ee,
|
|
2623
2627
|
e
|
|
2624
2628
|
])
|
|
2625
2629
|
};
|
|
@@ -3043,14 +3047,14 @@ function Jn(e, t) {
|
|
|
3043
3047
|
//#endregion
|
|
3044
3048
|
//#region src/components/ShapeEditor/_model/konva.ts
|
|
3045
3049
|
function Yn(e, t, n) {
|
|
3046
|
-
if (t ===
|
|
3050
|
+
if (t === I.POINT) {
|
|
3047
3051
|
e.setAttrs({
|
|
3048
3052
|
x: n[0].x,
|
|
3049
3053
|
y: n[0].y
|
|
3050
3054
|
});
|
|
3051
3055
|
return;
|
|
3052
3056
|
}
|
|
3053
|
-
if (t ===
|
|
3057
|
+
if (t === I.RECTANGLE) {
|
|
3054
3058
|
let [t, r] = n;
|
|
3055
3059
|
e.setAttrs({
|
|
3056
3060
|
x: Math.min(t.x, r.x),
|
|
@@ -3060,7 +3064,7 @@ function Yn(e, t, n) {
|
|
|
3060
3064
|
});
|
|
3061
3065
|
return;
|
|
3062
3066
|
}
|
|
3063
|
-
if (t ===
|
|
3067
|
+
if (t === I.ELLIPSE) {
|
|
3064
3068
|
let t = V(n);
|
|
3065
3069
|
e.setAttrs({
|
|
3066
3070
|
x: (t.minX + t.maxX) / 2,
|
|
@@ -3078,15 +3082,15 @@ function Yn(e, t, n) {
|
|
|
3078
3082
|
}
|
|
3079
3083
|
//#endregion
|
|
3080
3084
|
//#region src/components/ShapeEditor/_model/pinIcon.ts
|
|
3081
|
-
var
|
|
3085
|
+
var Xn = "M8 0C12.4183 0 16 3.58172 16 8C16 11.5323 13.71 14.5277 10.5342 15.5879L10.166 20.0068C10.0721 21.1334 9.13046 22 8 22C6.86954 22 5.92786 21.1334 5.83398 20.0068L5.46484 15.5879C2.28949 14.5275 0 11.532 0 8C0 3.58172 3.58172 0 8 0Z", Zn = "#ffffff", Q = 1.5;
|
|
3082
3086
|
function Qn(e) {
|
|
3083
|
-
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${
|
|
3087
|
+
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${Xn}" fill="${e}" stroke="${Zn}" stroke-width="${Q}"/></svg>`;
|
|
3084
3088
|
}
|
|
3085
3089
|
//#endregion
|
|
3086
3090
|
//#region src/components/ShapeEditor/_renderers/transformSession.ts
|
|
3087
3091
|
var $n = Math.PI / 12;
|
|
3088
3092
|
function er(e, t) {
|
|
3089
|
-
return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type ===
|
|
3093
|
+
return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type === I.ROTATED_RECTANGLE;
|
|
3090
3094
|
}
|
|
3091
3095
|
function tr(e, t, n) {
|
|
3092
3096
|
if (e.kind === "resize") {
|
|
@@ -3146,7 +3150,7 @@ function nr(e, t) {
|
|
|
3146
3150
|
} : er(e, t) ? be(t.shapes[0].points)[B.indexOf(t.anchor)] : se(t.anchor, t.box);
|
|
3147
3151
|
}
|
|
3148
3152
|
function rr(e, t, n) {
|
|
3149
|
-
let r = e.filter((e) => t.includes(e.id) &&
|
|
3153
|
+
let r = e.filter((e) => t.includes(e.id) && R(e)).map((e) => ({
|
|
3150
3154
|
id: e.id,
|
|
3151
3155
|
points: e.points
|
|
3152
3156
|
}));
|
|
@@ -3165,11 +3169,11 @@ function ir(e) {
|
|
|
3165
3169
|
}
|
|
3166
3170
|
function ar(e, t) {
|
|
3167
3171
|
let n = new Set(t);
|
|
3168
|
-
return e.filter((e) => n.has(e.id) &&
|
|
3172
|
+
return e.filter((e) => n.has(e.id) && ae(e));
|
|
3169
3173
|
}
|
|
3170
3174
|
function or(e, t) {
|
|
3171
3175
|
return e.filter((e) => {
|
|
3172
|
-
if (!
|
|
3176
|
+
if (!L(e)) return !1;
|
|
3173
3177
|
let n = V(e.points);
|
|
3174
3178
|
return n.minX <= t.maxX && n.maxX >= t.minX && n.minY <= t.maxY && n.maxY >= t.minY;
|
|
3175
3179
|
}).map((e) => e.id);
|
|
@@ -3186,8 +3190,8 @@ function cr(e, t) {
|
|
|
3186
3190
|
};
|
|
3187
3191
|
}
|
|
3188
3192
|
function lr(e, t, n) {
|
|
3189
|
-
if (e.type ===
|
|
3190
|
-
let r = e.type ===
|
|
3193
|
+
if (e.type === I.ROTATED_RECTANGLE) return t;
|
|
3194
|
+
let r = e.type === I.POINT ? cr(t[0], n) : V(t);
|
|
3191
3195
|
return ue([{
|
|
3192
3196
|
x: r.minX,
|
|
3193
3197
|
y: r.minY
|
|
@@ -3467,9 +3471,9 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3467
3471
|
setShapes(e, t) {
|
|
3468
3472
|
if (this.shapes = ir(e), this.selected = t, !this.activeDrag) {
|
|
3469
3473
|
this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
|
|
3470
|
-
for (let t of
|
|
3474
|
+
for (let t of z(e).filter(re)) {
|
|
3471
3475
|
let e = this.makeNode(t), n = Ue(t, { strokeWidth: this.strokeSize });
|
|
3472
|
-
if (t.style?.alternateColor && n.dash?.length && t.type !==
|
|
3476
|
+
if (t.style?.alternateColor && n.dash?.length && t.type !== I.POINT) {
|
|
3473
3477
|
let n = e.clone({
|
|
3474
3478
|
id: `${t.id}__alt`,
|
|
3475
3479
|
stroke: t.style.alternateColor,
|
|
@@ -3499,7 +3503,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3499
3503
|
t.size === this.selectedVertices.size && [...t].every((e) => this.selectedVertices.has(e)) || (this.selectedVertices = t, this.activeDrag || (this.drawTransformer(), this.layer.batchDraw()));
|
|
3500
3504
|
}
|
|
3501
3505
|
makeNode(e) {
|
|
3502
|
-
let { type: t, points: n } = e, r = Ue(e, { strokeWidth: this.strokeSize }), i =
|
|
3506
|
+
let { type: t, points: n } = e, r = Ue(e, { strokeWidth: this.strokeSize }), i = L(e), a = {
|
|
3503
3507
|
id: e.id,
|
|
3504
3508
|
stroke: r.color,
|
|
3505
3509
|
strokeWidth: r.strokeWidth,
|
|
@@ -3508,10 +3512,10 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3508
3512
|
strokeScaleEnabled: !1,
|
|
3509
3513
|
listening: i
|
|
3510
3514
|
}, o = r.fillVisible ? We(r.color, r.fillAlpha) : void 0;
|
|
3511
|
-
if (t ===
|
|
3515
|
+
if (t === I.POINT) {
|
|
3512
3516
|
let t = 1 / (this.world.scaleX() || 1), a = new A.Path({
|
|
3513
3517
|
id: e.id,
|
|
3514
|
-
data:
|
|
3518
|
+
data: Xn,
|
|
3515
3519
|
x: n[0].x,
|
|
3516
3520
|
y: n[0].y,
|
|
3517
3521
|
offsetX: 16 / 2,
|
|
@@ -3519,8 +3523,8 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3519
3523
|
scaleX: t,
|
|
3520
3524
|
scaleY: t,
|
|
3521
3525
|
fill: r.color,
|
|
3522
|
-
stroke:
|
|
3523
|
-
strokeWidth:
|
|
3526
|
+
stroke: Zn,
|
|
3527
|
+
strokeWidth: Q,
|
|
3524
3528
|
strokeScaleEnabled: !1,
|
|
3525
3529
|
shadowColor: "#000",
|
|
3526
3530
|
shadowBlur: 2,
|
|
@@ -3529,9 +3533,9 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3529
3533
|
opacity: r.opacity,
|
|
3530
3534
|
listening: i
|
|
3531
3535
|
});
|
|
3532
|
-
return this.bindCursor(a,
|
|
3536
|
+
return this.bindCursor(a, R(e) ? "grab" : "default"), a;
|
|
3533
3537
|
}
|
|
3534
|
-
if (t ===
|
|
3538
|
+
if (t === I.RECTANGLE) {
|
|
3535
3539
|
let t = V(n), r = new A.Rect({
|
|
3536
3540
|
x: t.minX,
|
|
3537
3541
|
y: t.minY,
|
|
@@ -3540,9 +3544,9 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3540
3544
|
fill: o,
|
|
3541
3545
|
...a
|
|
3542
3546
|
});
|
|
3543
|
-
return this.bindCursor(r,
|
|
3547
|
+
return this.bindCursor(r, R(e) ? "grab" : "default"), r;
|
|
3544
3548
|
}
|
|
3545
|
-
if (t ===
|
|
3549
|
+
if (t === I.ELLIPSE) {
|
|
3546
3550
|
let t = V(n), r = new A.Ellipse({
|
|
3547
3551
|
x: (t.minX + t.maxX) / 2,
|
|
3548
3552
|
y: (t.minY + t.maxY) / 2,
|
|
@@ -3551,23 +3555,23 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3551
3555
|
fill: o,
|
|
3552
3556
|
...a
|
|
3553
3557
|
});
|
|
3554
|
-
return this.bindCursor(r,
|
|
3558
|
+
return this.bindCursor(r, R(e) ? "grab" : "default"), r;
|
|
3555
3559
|
}
|
|
3556
|
-
let s = n.flatMap((e) => [e.x, e.y]), c = t !==
|
|
3560
|
+
let s = n.flatMap((e) => [e.x, e.y]), c = t !== I.LINE, l = new A.Line({
|
|
3557
3561
|
points: s,
|
|
3558
3562
|
closed: c,
|
|
3559
3563
|
fill: c ? o : void 0,
|
|
3560
3564
|
lineJoin: "round",
|
|
3561
3565
|
...a
|
|
3562
3566
|
});
|
|
3563
|
-
return this.bindCursor(l,
|
|
3567
|
+
return this.bindCursor(l, R(e) ? "grab" : "default"), l;
|
|
3564
3568
|
}
|
|
3565
3569
|
liveUpdateShape(e, t) {
|
|
3566
3570
|
let n = this.nodes.get(e), r = this.shapes.find((t) => t.id === e);
|
|
3567
3571
|
if (n && r) {
|
|
3568
3572
|
Yn(n, r.type, t);
|
|
3569
3573
|
let i = this.altNodes.get(e);
|
|
3570
|
-
i && Yn(i, r.type, t), r.type ===
|
|
3574
|
+
i && Yn(i, r.type, t), r.type === I.POINT && n instanceof A.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
|
|
3571
3575
|
}
|
|
3572
3576
|
}
|
|
3573
3577
|
pointRadius(e) {
|
|
@@ -3580,7 +3584,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3580
3584
|
let e = 1 / (this.world.scaleX() || 1);
|
|
3581
3585
|
for (let t of this.shapes) {
|
|
3582
3586
|
let n = this.nodes.get(t.id);
|
|
3583
|
-
if (t.type ===
|
|
3587
|
+
if (t.type === I.POINT) {
|
|
3584
3588
|
n?.scale({
|
|
3585
3589
|
x: e,
|
|
3586
3590
|
y: e
|
|
@@ -3594,7 +3598,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3594
3598
|
return or(this.shapes, e);
|
|
3595
3599
|
}
|
|
3596
3600
|
drawSelectionBorders() {
|
|
3597
|
-
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) &&
|
|
3601
|
+
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && L(t)) : [];
|
|
3598
3602
|
if (this.selectionBorders.length !== t.length) {
|
|
3599
3603
|
for (let e of this.selectionBorders) e.destroy();
|
|
3600
3604
|
this.selectionBorders = t.map(() => {
|
|
@@ -3615,7 +3619,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3615
3619
|
updateSelectionBordersLive(e) {
|
|
3616
3620
|
let t = new Set(this.selected), n = 0;
|
|
3617
3621
|
for (let r of this.shapes) {
|
|
3618
|
-
if (!t.has(r.id) || !
|
|
3622
|
+
if (!t.has(r.id) || !L(r)) continue;
|
|
3619
3623
|
let i = this.selectionOutlinePoints(r, e(r)), a = this.selectionBorders[n++];
|
|
3620
3624
|
a && a.points(i.flatMap((e) => [e.x, e.y]));
|
|
3621
3625
|
}
|
|
@@ -3803,8 +3807,8 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3803
3807
|
for (let e of this.midNodes) e.destroy();
|
|
3804
3808
|
if (this.ghostNode?.destroy(), this.ghostNode = null, this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
|
|
3805
3809
|
let e = ar(this.shapes, this.selected);
|
|
3806
|
-
if (!e.length || e.length === 1 && e[0].type ===
|
|
3807
|
-
let t = e.length === 1 && (e[0].type ===
|
|
3810
|
+
if (!e.length || e.length === 1 && e[0].type === I.POINT) return;
|
|
3811
|
+
let t = e.length === 1 && (e[0].type === I.POLYGON || e[0].type === I.LINE) && this.editingId === e[0].id ? e[0] : null, n = V(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === I.ROTATED_RECTANGLE ? e[0] : null, i = r ? be(r.points) : B.map((e) => se(e, n));
|
|
3808
3812
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
3809
3813
|
let a = r ? this.orientedHandleAngle(r.points) : 0;
|
|
3810
3814
|
for (let e of t ? [] : B) {
|
|
@@ -3835,7 +3839,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3835
3839
|
}), this.handleGroup.add(n), this.handleNodes.push(n);
|
|
3836
3840
|
}
|
|
3837
3841
|
if (t) {
|
|
3838
|
-
let e = t, n = e.points, r = e.type ===
|
|
3842
|
+
let e = t, n = e.points, r = e.type === I.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new A.Circle({
|
|
3839
3843
|
radius: i * .8,
|
|
3840
3844
|
fill: "#ffffff",
|
|
3841
3845
|
opacity: .6,
|
|
@@ -3919,7 +3923,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3919
3923
|
}), this.handleGroup.add(s), this.vertexNodes.push(s);
|
|
3920
3924
|
});
|
|
3921
3925
|
}
|
|
3922
|
-
if (e.length === 1 && e[0].type ===
|
|
3926
|
+
if (e.length === 1 && e[0].type === I.ROTATED_RECTANGLE) {
|
|
3923
3927
|
let t = e[0], n = ye(t.points), r = this.rotationHandleScreenPoint(t.points), i = new A.Circle({
|
|
3924
3928
|
x: r.x,
|
|
3925
3929
|
y: r.y,
|
|
@@ -3945,7 +3949,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3945
3949
|
}
|
|
3946
3950
|
beginMove(e, t) {
|
|
3947
3951
|
let n = rr(this.shapes, t, e);
|
|
3948
|
-
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type ===
|
|
3952
|
+
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === I.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
3949
3953
|
}
|
|
3950
3954
|
repositionHandles(e) {
|
|
3951
3955
|
B.forEach((t, n) => {
|
|
@@ -3990,16 +3994,16 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
|
3990
3994
|
for (let e of r) this.liveUpdateShape(e.id, e.points);
|
|
3991
3995
|
if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
|
|
3992
3996
|
n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
|
|
3993
|
-
let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type ===
|
|
3994
|
-
(t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type ===
|
|
3997
|
+
let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === I.POLYGON || e?.type === I.LINE;
|
|
3998
|
+
(t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === I.POLYGON);
|
|
3995
3999
|
} else if (t.kind === "rotate") {
|
|
3996
4000
|
this.repositionOrientedHandles(r[0].points);
|
|
3997
4001
|
let e = this.shapes.find((e) => e.id === t.id);
|
|
3998
|
-
e && (e.type ===
|
|
4002
|
+
e && (e.type === I.POLYGON || e.type === I.LINE) && this.repositionPolygonHandles(r[0].points, e.type === I.POLYGON);
|
|
3999
4003
|
} else {
|
|
4000
4004
|
i && this.repositionHandles(i);
|
|
4001
4005
|
let e = this.shapes.find((e) => e.id === t.id);
|
|
4002
|
-
this.repositionPolygonHandles(r[0].points, e?.type ===
|
|
4006
|
+
this.repositionPolygonHandles(r[0].points, e?.type === I.POLYGON);
|
|
4003
4007
|
}
|
|
4004
4008
|
this.layer.batchDraw();
|
|
4005
4009
|
}
|
|
@@ -4084,7 +4088,7 @@ var yr = class {
|
|
|
4084
4088
|
}
|
|
4085
4089
|
syncHitArea() {
|
|
4086
4090
|
let { w: e, h: t } = this.screenSize;
|
|
4087
|
-
this.app.stage.hitArea = new
|
|
4091
|
+
this.app.stage.hitArea = new te(0, 0, e, t);
|
|
4088
4092
|
}
|
|
4089
4093
|
destroy() {
|
|
4090
4094
|
this.destroyed = !0, this.clearImageTiles();
|
|
@@ -4139,9 +4143,9 @@ var yr = class {
|
|
|
4139
4143
|
let a = n?.width ?? this.imageWidth, o = n?.height ?? this.imageHeight;
|
|
4140
4144
|
this.bgLayer.scale.set(a / i.naturalWidth, o / i.naturalHeight), this.clearImageTiles();
|
|
4141
4145
|
for (let e of qn(i.naturalWidth, i.naturalHeight, this.tileSize)) {
|
|
4142
|
-
let t =
|
|
4146
|
+
let t = F.from(Jn(i, e));
|
|
4143
4147
|
t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
|
|
4144
|
-
let n = new
|
|
4148
|
+
let n = new ne(t);
|
|
4145
4149
|
n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
|
|
4146
4150
|
}
|
|
4147
4151
|
return this.applySpriteFilter(), !0;
|
|
@@ -4184,9 +4188,9 @@ var yr = class {
|
|
|
4184
4188
|
for (let e of this.guideOverlayLayer.removeChildren()) e.destroy();
|
|
4185
4189
|
for (let e of this.overlayTextures) e.destroy(!0);
|
|
4186
4190
|
if (this.overlayTextures = [], e) {
|
|
4187
|
-
let t =
|
|
4191
|
+
let t = F.from(e);
|
|
4188
4192
|
t.source.scaleMode = "nearest", this.overlayTextures.push(t);
|
|
4189
|
-
let n = new
|
|
4193
|
+
let n = new ne(t);
|
|
4190
4194
|
n.alpha = .55, this.guideOverlayLayer.addChild(n);
|
|
4191
4195
|
}
|
|
4192
4196
|
this.setRegionOverlay(t);
|
|
@@ -4293,9 +4297,9 @@ var yr = class {
|
|
|
4293
4297
|
this.shapeLayer.removeChildren();
|
|
4294
4298
|
for (let e of this.nodes.values()) e.destroy();
|
|
4295
4299
|
this.nodes.clear();
|
|
4296
|
-
for (let e of
|
|
4300
|
+
for (let e of z(this.shapes).filter(re)) {
|
|
4297
4301
|
let t = new P();
|
|
4298
|
-
this.paintShape(t, e), t.eventMode =
|
|
4302
|
+
this.paintShape(t, e), t.eventMode = L(e) ? "static" : "none", t.cursor = void 0, L(e) && R(e) && (t.on("pointerover", () => {
|
|
4299
4303
|
!this.activeDrag && this.transformEnabled && this.emitCursorHint("grab");
|
|
4300
4304
|
}), t.on("pointerout", () => {
|
|
4301
4305
|
this.activeDrag || this.emitCursorHint(null);
|
|
@@ -4307,14 +4311,14 @@ var yr = class {
|
|
|
4307
4311
|
paintShape(e, t) {
|
|
4308
4312
|
e.clear();
|
|
4309
4313
|
let n = Ue(t, { strokeWidth: this.strokeSize }), r = $(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
|
|
4310
|
-
if (t.type ===
|
|
4314
|
+
if (t.type === I.POINT) {
|
|
4311
4315
|
e.svg(Qn(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
|
|
4312
4316
|
let r = 1 / (this.world.scale.x || 1);
|
|
4313
4317
|
e.scale.set(r, r), e.alpha = a;
|
|
4314
4318
|
return;
|
|
4315
4319
|
}
|
|
4316
|
-
if (n.fillVisible && t.type !==
|
|
4317
|
-
let i = t.type ===
|
|
4320
|
+
if (n.fillVisible && t.type !== I.LINE) {
|
|
4321
|
+
let i = t.type === I.POLYGON ? De(t.points) : null;
|
|
4318
4322
|
if (i && i.length > 1) for (let t of i) e.poly(t.flatMap((e) => [e.x, e.y]), !0), e.fill({
|
|
4319
4323
|
color: r,
|
|
4320
4324
|
alpha: n.fillAlpha * a
|
|
@@ -4323,7 +4327,7 @@ var yr = class {
|
|
|
4323
4327
|
color: r,
|
|
4324
4328
|
alpha: n.fillAlpha * a
|
|
4325
4329
|
});
|
|
4326
|
-
} else t.type !==
|
|
4330
|
+
} else t.type !== I.LINE && (this.path(e, t), e.fill({
|
|
4327
4331
|
color: r,
|
|
4328
4332
|
alpha: 0
|
|
4329
4333
|
}));
|
|
@@ -4380,7 +4384,7 @@ var yr = class {
|
|
|
4380
4384
|
}, this.ensurePreview(), this.previewG.clear();
|
|
4381
4385
|
let i = {
|
|
4382
4386
|
id: "__preview__",
|
|
4383
|
-
type: e === "ellipse" ?
|
|
4387
|
+
type: e === "ellipse" ? I.ELLIPSE : I.RECTANGLE,
|
|
4384
4388
|
points: [t, n],
|
|
4385
4389
|
style: r
|
|
4386
4390
|
}, a = this.strokeW(i);
|
|
@@ -4411,7 +4415,7 @@ var yr = class {
|
|
|
4411
4415
|
}, this.ensurePreview(), this.previewG.clear(), !e.length) return;
|
|
4412
4416
|
let o = t ? [...e, t] : e, s = {
|
|
4413
4417
|
id: "__preview__",
|
|
4414
|
-
type: r ?
|
|
4418
|
+
type: r ? I.POLYGON : I.LINE,
|
|
4415
4419
|
points: o,
|
|
4416
4420
|
style: n
|
|
4417
4421
|
}, c = this.strokeW(s);
|
|
@@ -4437,7 +4441,7 @@ var yr = class {
|
|
|
4437
4441
|
previewScalarMask(e, t) {
|
|
4438
4442
|
this.lastPreview = null, this.ensurePreview(), this.previewG.clear();
|
|
4439
4443
|
let n = hn(e, t.length === 7 ? `${t}99` : t);
|
|
4440
|
-
this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture =
|
|
4444
|
+
this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture = F.from(n), this.previewMaskSprite ? (this.previewMaskSprite.texture = this.previewMaskTexture, this.previewMaskSprite.visible = !0) : (this.previewMaskSprite = new ne(this.previewMaskTexture), this.previewLayer.addChildAt(this.previewMaskSprite, 0)), this.previewMaskSprite.x = e.ox, this.previewMaskSprite.y = e.oy, this.previewMaskSprite.width = n.width / e.scale, this.previewMaskSprite.height = n.height / e.scale;
|
|
4441
4445
|
}
|
|
4442
4446
|
previewMarquee(e, t) {
|
|
4443
4447
|
this.ensurePreview(), this.marqueeG.clear();
|
|
@@ -4482,26 +4486,26 @@ var yr = class {
|
|
|
4482
4486
|
}
|
|
4483
4487
|
path(e, t) {
|
|
4484
4488
|
let { type: n, points: r } = t;
|
|
4485
|
-
if (n ===
|
|
4489
|
+
if (n === I.POINT) {
|
|
4486
4490
|
e.circle(r[0].x, r[0].y, this.pointRadius(t));
|
|
4487
4491
|
return;
|
|
4488
4492
|
}
|
|
4489
|
-
if (n ===
|
|
4493
|
+
if (n === I.RECTANGLE) {
|
|
4490
4494
|
let t = V(r);
|
|
4491
4495
|
e.rect(t.minX, t.minY, t.maxX - t.minX, t.maxY - t.minY);
|
|
4492
4496
|
return;
|
|
4493
4497
|
}
|
|
4494
|
-
if (n ===
|
|
4498
|
+
if (n === I.ELLIPSE) {
|
|
4495
4499
|
let t = V(r);
|
|
4496
4500
|
e.ellipse((t.minX + t.maxX) / 2, (t.minY + t.maxY) / 2, (t.maxX - t.minX) / 2, (t.maxY - t.minY) / 2);
|
|
4497
4501
|
return;
|
|
4498
4502
|
}
|
|
4499
4503
|
let i = r.flatMap((e) => [e.x, e.y]);
|
|
4500
|
-
e.poly(i, n !==
|
|
4504
|
+
e.poly(i, n !== I.LINE);
|
|
4501
4505
|
}
|
|
4502
4506
|
dashedStrokeShape(e, t, n, r, i, a) {
|
|
4503
4507
|
let { type: o, points: s } = t;
|
|
4504
|
-
if (o ===
|
|
4508
|
+
if (o === I.RECTANGLE) {
|
|
4505
4509
|
let t = V(s);
|
|
4506
4510
|
this.strokeDashedPolyline(e, [
|
|
4507
4511
|
{
|
|
@@ -4523,7 +4527,7 @@ var yr = class {
|
|
|
4523
4527
|
], !0, n, r, i, a);
|
|
4524
4528
|
return;
|
|
4525
4529
|
}
|
|
4526
|
-
if (o ===
|
|
4530
|
+
if (o === I.ELLIPSE) {
|
|
4527
4531
|
let t = V(s), o = (t.minX + t.maxX) / 2, c = (t.minY + t.maxY) / 2, l = (t.maxX - t.minX) / 2, u = (t.maxY - t.minY) / 2, d = Array.from({ length: 96 }, (e, t) => {
|
|
4528
4532
|
let n = t / 96 * Math.PI * 2;
|
|
4529
4533
|
return {
|
|
@@ -4534,7 +4538,7 @@ var yr = class {
|
|
|
4534
4538
|
this.strokeDashedPolyline(e, d, !0, n, r, i, a);
|
|
4535
4539
|
return;
|
|
4536
4540
|
}
|
|
4537
|
-
this.strokeDashedPolyline(e, s, o !==
|
|
4541
|
+
this.strokeDashedPolyline(e, s, o !== I.LINE, n, r, i, a);
|
|
4538
4542
|
}
|
|
4539
4543
|
strokeDashedPolyline(e, t, n, r, i, a, o) {
|
|
4540
4544
|
if (t.length < 2) return;
|
|
@@ -4575,7 +4579,7 @@ var yr = class {
|
|
|
4575
4579
|
}
|
|
4576
4580
|
drawSelectionBorders() {
|
|
4577
4581
|
this.selLayer.position.set(0, 0);
|
|
4578
|
-
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) &&
|
|
4582
|
+
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && L(t)) : [];
|
|
4579
4583
|
if (this.selectionBorderGfx.length !== t.length) {
|
|
4580
4584
|
for (let e of this.selectionBorderGfx) e.destroy();
|
|
4581
4585
|
this.selectionBorderGfx = t.map(() => {
|
|
@@ -4595,7 +4599,7 @@ var yr = class {
|
|
|
4595
4599
|
updateSelectionBordersLive(e) {
|
|
4596
4600
|
let t = new Set(this.selected), n = 1.5 / this.world.scale.x, r = 0;
|
|
4597
4601
|
for (let i of this.shapes) {
|
|
4598
|
-
if (!t.has(i.id) || !
|
|
4602
|
+
if (!t.has(i.id) || !L(i)) continue;
|
|
4599
4603
|
let a = this.selectionBorderGfx[r++];
|
|
4600
4604
|
a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4601
4605
|
width: n,
|
|
@@ -4658,8 +4662,8 @@ var yr = class {
|
|
|
4658
4662
|
for (let e of this.midNodes) e.destroy();
|
|
4659
4663
|
if (this.ghostNode?.destroy(), this.ghostNode = null, this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
|
|
4660
4664
|
let e = ar(this.shapes, this.selected);
|
|
4661
|
-
if (e.length === 0 || e.length === 1 && e[0].type ===
|
|
4662
|
-
let t = e.length === 1 && (e[0].type ===
|
|
4665
|
+
if (e.length === 0 || e.length === 1 && e[0].type === I.POINT) return;
|
|
4666
|
+
let t = e.length === 1 && (e[0].type === I.POLYGON || e[0].type === I.LINE) && this.editingId === e[0].id ? e[0] : null, n = V(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === I.ROTATED_RECTANGLE ? e[0] : null, i = r ? be(r.points) : B.map((e) => se(e, n));
|
|
4663
4667
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
4664
4668
|
let a = r ? this.orientedHandleAngle(r.points) : 0;
|
|
4665
4669
|
for (let e of t ? [] : B) {
|
|
@@ -4684,7 +4688,7 @@ var yr = class {
|
|
|
4684
4688
|
}), this.handleLayer.addChild(n), this.handleNodes.push(n);
|
|
4685
4689
|
}
|
|
4686
4690
|
if (t) {
|
|
4687
|
-
let e = t, n = e.points, r = e.type ===
|
|
4691
|
+
let e = t, n = e.points, r = e.type === I.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new P();
|
|
4688
4692
|
a.circle(0, 0, i * .8).fill({
|
|
4689
4693
|
color: 16777215,
|
|
4690
4694
|
alpha: .6
|
|
@@ -4748,7 +4752,7 @@ var yr = class {
|
|
|
4748
4752
|
}), this.handleLayer.addChild(s), this.vertexNodes.push(s);
|
|
4749
4753
|
});
|
|
4750
4754
|
}
|
|
4751
|
-
if (e.length === 1 && e[0].type ===
|
|
4755
|
+
if (e.length === 1 && e[0].type === I.ROTATED_RECTANGLE) {
|
|
4752
4756
|
let t = e[0], n = ye(t.points), r = this.rotationHandleScreenPoint(t.points), i = new P();
|
|
4753
4757
|
i.circle(0, 0, 6).fill({ color: 16777215 }).stroke({
|
|
4754
4758
|
width: 1.5,
|
|
@@ -4769,7 +4773,7 @@ var yr = class {
|
|
|
4769
4773
|
}
|
|
4770
4774
|
beginMove(e, t) {
|
|
4771
4775
|
let n = rr(this.shapes, t, e);
|
|
4772
|
-
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type ===
|
|
4776
|
+
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === I.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4773
4777
|
}
|
|
4774
4778
|
repositionHandlesForBox(e) {
|
|
4775
4779
|
B.forEach((t, n) => {
|
|
@@ -4802,7 +4806,7 @@ var yr = class {
|
|
|
4802
4806
|
}
|
|
4803
4807
|
edgeHitQuad(e, t) {
|
|
4804
4808
|
let n = Math.max(7, this.vertexHandleRadius() + 2), r = this.imgToScreen(e), i = this.imgToScreen(t), a = i.x - r.x, o = i.y - r.y, s = Math.hypot(a, o) || 1, c = -o / s * n, l = a / s * n;
|
|
4805
|
-
return new
|
|
4809
|
+
return new ee([
|
|
4806
4810
|
r.x + c,
|
|
4807
4811
|
r.y + l,
|
|
4808
4812
|
i.x + c,
|
|
@@ -4814,7 +4818,7 @@ var yr = class {
|
|
|
4814
4818
|
]);
|
|
4815
4819
|
}
|
|
4816
4820
|
resetMoveOffsets() {
|
|
4817
|
-
for (let [e, t] of this.nodes) this.shapes.find((t) => t.id === e)?.type !==
|
|
4821
|
+
for (let [e, t] of this.nodes) this.shapes.find((t) => t.id === e)?.type !== I.POINT && t.position.set(0, 0);
|
|
4818
4822
|
this.selLayer.position.set(0, 0);
|
|
4819
4823
|
}
|
|
4820
4824
|
commitTransformUpdates(e) {
|
|
@@ -4841,21 +4845,21 @@ var yr = class {
|
|
|
4841
4845
|
let n = e.x - t.start.x, r = e.y - t.start.y;
|
|
4842
4846
|
for (let e of t.shapes) {
|
|
4843
4847
|
let t = this.nodes.get(e.id);
|
|
4844
|
-
t && (this.shapes.find((t) => t.id === e.id)?.type ===
|
|
4848
|
+
t && (this.shapes.find((t) => t.id === e.id)?.type === I.POINT ? t.position.set(e.points[0].x + n, e.points[0].y + r) : t.position.set(n, r));
|
|
4845
4849
|
}
|
|
4846
4850
|
} else for (let e of r) this.liveUpdateShape(e.id, e.points);
|
|
4847
4851
|
if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
|
|
4848
4852
|
n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandlesForBox(i);
|
|
4849
|
-
let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type ===
|
|
4850
|
-
(t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type ===
|
|
4853
|
+
let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === I.POLYGON || e?.type === I.LINE;
|
|
4854
|
+
(t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === I.POLYGON);
|
|
4851
4855
|
} else if (t.kind === "rotate") {
|
|
4852
4856
|
this.repositionOrientedHandles(r[0].points);
|
|
4853
4857
|
let e = this.shapes.find((e) => e.id === t.id);
|
|
4854
|
-
e && (e.type ===
|
|
4858
|
+
e && (e.type === I.POLYGON || e.type === I.LINE) && this.repositionPolygonHandles(r[0].points, e.type === I.POLYGON);
|
|
4855
4859
|
} else {
|
|
4856
4860
|
i && this.repositionHandlesForBox(i);
|
|
4857
4861
|
let e = this.shapes.find((e) => e.id === t.id);
|
|
4858
|
-
this.repositionPolygonHandles(r[0].points, e?.type ===
|
|
4862
|
+
this.repositionPolygonHandles(r[0].points, e?.type === I.POLYGON);
|
|
4859
4863
|
}
|
|
4860
4864
|
}
|
|
4861
4865
|
endTransform() {
|
|
@@ -5131,13 +5135,13 @@ function Er({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5131
5135
|
//#region src/components/ShapeEditor/_state/useMinimapSync.ts
|
|
5132
5136
|
function Dr(e, t, n) {
|
|
5133
5137
|
if (!(!e || !n.length)) {
|
|
5134
|
-
if (t.type ===
|
|
5138
|
+
if (t.type === I.POINT) {
|
|
5135
5139
|
e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
|
|
5136
5140
|
return;
|
|
5137
5141
|
}
|
|
5138
|
-
if (t.type ===
|
|
5142
|
+
if (t.type === I.RECTANGLE || t.type === I.ELLIPSE) {
|
|
5139
5143
|
let r = V(n);
|
|
5140
|
-
if (t.type ===
|
|
5144
|
+
if (t.type === I.ELLIPSE) {
|
|
5141
5145
|
e.setAttribute("cx", String((r.minX + r.maxX) / 2)), e.setAttribute("cy", String((r.minY + r.maxY) / 2)), e.setAttribute("rx", String((r.maxX - r.minX) / 2)), e.setAttribute("ry", String((r.maxY - r.minY) / 2));
|
|
5142
5146
|
return;
|
|
5143
5147
|
}
|
|
@@ -5199,7 +5203,7 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5199
5203
|
}), []), S(() => {
|
|
5200
5204
|
s.current = 0;
|
|
5201
5205
|
}, [a]);
|
|
5202
|
-
let f = x(() => r(e.getShapes().filter((e) =>
|
|
5206
|
+
let f = x(() => r(e.getShapes().filter((e) => L(e)).map((e) => e.id)), [e, r]), p = x(() => r([]), [r]), m = x(() => e.getShapes().filter((e) => t.current.includes(e.id) && ae(e)), [e, t]), h = x(() => {
|
|
5203
5207
|
if (n || !t.current.length) return;
|
|
5204
5208
|
let i = m().map((e) => e.id);
|
|
5205
5209
|
i.length && (e.remove(i), r([]));
|
|
@@ -5216,10 +5220,10 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5216
5220
|
a,
|
|
5217
5221
|
o,
|
|
5218
5222
|
m
|
|
5219
|
-
]), _ = x(() =>
|
|
5223
|
+
]), _ = x(() => bt(o), [o]), v = x((t) => {
|
|
5220
5224
|
if (n) return;
|
|
5221
5225
|
let i = a;
|
|
5222
|
-
|
|
5226
|
+
Y(o).then((n) => {
|
|
5223
5227
|
if (!c.current || l.current || u.current !== i || d.current !== o || !n?.shapes.length) return;
|
|
5224
5228
|
let f, p, m = n.shapes.flatMap((e) => e.points);
|
|
5225
5229
|
if (t && m.length) {
|
|
@@ -5280,7 +5284,7 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5280
5284
|
m
|
|
5281
5285
|
]), w = x((r, i) => {
|
|
5282
5286
|
if (n || !t.current.length) return;
|
|
5283
|
-
let a = e.getShapes().filter((e) => t.current.includes(e.id) &&
|
|
5287
|
+
let a = e.getShapes().filter((e) => t.current.includes(e.id) && ae(e));
|
|
5284
5288
|
a.length && e.update(a.map((e) => ({
|
|
5285
5289
|
...e,
|
|
5286
5290
|
points: e.points.map((e) => ({
|
|
@@ -5292,7 +5296,7 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5292
5296
|
e,
|
|
5293
5297
|
n,
|
|
5294
5298
|
t
|
|
5295
|
-
]), T = x(() => m().filter((e) => e.type ===
|
|
5299
|
+
]), T = x(() => m().filter((e) => e.type === I.POLYGON || e.type === I.RECTANGLE || e.type === I.ROTATED_RECTANGLE || e.type === I.ELLIPSE), [m]);
|
|
5296
5300
|
return {
|
|
5297
5301
|
selectAll: f,
|
|
5298
5302
|
clearSelection: p,
|
|
@@ -5316,7 +5320,7 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5316
5320
|
if (!o.length) return;
|
|
5317
5321
|
let s = t[0], c = o.map((e) => ({
|
|
5318
5322
|
id: oe(),
|
|
5319
|
-
type:
|
|
5323
|
+
type: I.POLYGON,
|
|
5320
5324
|
points: e,
|
|
5321
5325
|
style: s.style,
|
|
5322
5326
|
meta: s.meta
|
|
@@ -5414,118 +5418,120 @@ var Mr = "__draft_preview__", Nr = new Set([
|
|
|
5414
5418
|
function Pr(e, t) {
|
|
5415
5419
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
5416
5420
|
}
|
|
5417
|
-
function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !1, selectedIds: i, activeTool: a, draftStyle: s, draftMeta: c, readOnly: l, disableMarquee: u, locked: d, onLockedInteraction: f,
|
|
5418
|
-
let
|
|
5421
|
+
function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !1, selectedIds: i, activeTool: a, draftStyle: s, draftMeta: c, readOnly: l, disableMarquee: u, locked: d, onLockedInteraction: f, onDrawAttemptWithoutDraft: p, onIdleEscape: m, overrideShapeInteraction: h, defaultViewSettings: g, viewSettings: _, onViewSettingsChange: b, showMinimap: D = !0, minimapPosition: A = "bottom-left", showViewSettings: j = !0, getContextMenuItems: M, strings: N, canMergeSelection: P, brushSize: ee = 20, zoomBound: te, zoomAnimationDuration: ne = 300, decorationShapes: F, regionMask: ie, guideMask: R, maskPalette: z, overlayMarkers: B, renderOverlayMarker: V, onOverlayMarkerClick: se, renderImageOverlay: H, getSelectionLabel: ce, hideSelectionLabelDot: le, formatSelectionInfo: ue, externalTools: de, assistant: fe, keymap: pe, handleRef: me, backend: he = "pixi", onActiveToolChange: ge, onSelectionChange: _e, onEditingChange: ve, onShapesCreated: ye, onShapesUpdated: be, onShapesDeleted: xe, onDrawSessionChange: Se, onDraftShapeChange: Ce, onViewportChange: we, onShapesTransformPreview: Te }) {
|
|
5422
|
+
let Ee = O(null), U = O(null), De = O(null), W = O(null), Ae = O(null), je = `${C()}-minimap`, [K, Me] = k(null), [Pe, Re] = k(!1), [ze, Be] = k(!1), [Ve, He] = k(null), [Ue, We] = k({
|
|
5419
5423
|
active: !1,
|
|
5420
5424
|
kind: "none",
|
|
5421
5425
|
canUndo: !1,
|
|
5422
5426
|
canRedo: !1
|
|
5423
|
-
}), [
|
|
5424
|
-
|
|
5427
|
+
}), [Ge, Ke] = k(!0), [qe, Je] = k(!1), Ye = e?.id ?? "", Xe = e?.imageUrl ?? "", Qe = e?.displayImageUrl, $e = e?.coordinateSize, et = e?.initialShapes, tt = e?.initialSelectedIds, nt = Qe ?? Xe, [ot, ct] = k("loading"), [lt, ut] = k(null), dt = x((e, t) => {
|
|
5428
|
+
ct(e), ut(e === "error" ? t ?? null : null);
|
|
5425
5429
|
}, []), q = Tn({
|
|
5426
|
-
onShapesCreated:
|
|
5427
|
-
onShapesUpdated:
|
|
5428
|
-
onShapesDeleted:
|
|
5429
|
-
}), [
|
|
5430
|
+
onShapesCreated: ye,
|
|
5431
|
+
onShapesUpdated: be,
|
|
5432
|
+
onShapesDeleted: xe
|
|
5433
|
+
}), [ft, pt] = k([]), J = i ?? ft, mt = i !== void 0, gt = E(() => new Map((de ?? []).map((e) => [e.id, e])), [de]), _t = O(gt);
|
|
5430
5434
|
T(() => {
|
|
5431
|
-
|
|
5432
|
-
}, [
|
|
5433
|
-
let
|
|
5434
|
-
|
|
5435
|
-
let
|
|
5436
|
-
let e = Object.fromEntries(Object.entries(
|
|
5435
|
+
_t.current = gt;
|
|
5436
|
+
}, [gt]);
|
|
5437
|
+
let vt = O(Ue);
|
|
5438
|
+
vt.current = Ue;
|
|
5439
|
+
let yt = E(() => {
|
|
5440
|
+
let e = Object.fromEntries(Object.entries(g ?? {}).filter(([, e]) => e !== void 0));
|
|
5437
5441
|
return {
|
|
5438
5442
|
...ke,
|
|
5439
5443
|
...e
|
|
5440
5444
|
};
|
|
5441
|
-
}, [
|
|
5442
|
-
|
|
5443
|
-
let [Y,
|
|
5445
|
+
}, [g]), bt = O(yt);
|
|
5446
|
+
bt.current = yt;
|
|
5447
|
+
let [Y, xt] = k(() => bt.current), St = x((e) => xt((t) => ({
|
|
5444
5448
|
...t,
|
|
5445
5449
|
...e
|
|
5446
|
-
})), []), X = E(() => Oe(
|
|
5450
|
+
})), []), X = E(() => Oe(N), [N]);
|
|
5447
5451
|
S(() => {
|
|
5448
|
-
|
|
5449
|
-
let t = Object.entries(
|
|
5452
|
+
_ && xt((e) => {
|
|
5453
|
+
let t = Object.entries(_).filter(([t, n]) => n !== void 0 && e[t] !== n);
|
|
5450
5454
|
return t.length ? {
|
|
5451
5455
|
...e,
|
|
5452
5456
|
...Object.fromEntries(t)
|
|
5453
5457
|
} : e;
|
|
5454
5458
|
});
|
|
5455
|
-
}, [
|
|
5456
|
-
let
|
|
5457
|
-
|
|
5458
|
-
let
|
|
5459
|
+
}, [_]);
|
|
5460
|
+
let Ct = O(b);
|
|
5461
|
+
Ct.current = b;
|
|
5462
|
+
let wt = O(!1);
|
|
5459
5463
|
S(() => {
|
|
5460
|
-
if (!
|
|
5461
|
-
|
|
5464
|
+
if (!wt.current) {
|
|
5465
|
+
wt.current = !0;
|
|
5462
5466
|
return;
|
|
5463
5467
|
}
|
|
5464
|
-
|
|
5468
|
+
Ct.current?.(Y);
|
|
5465
5469
|
}, [Y]);
|
|
5466
|
-
let
|
|
5467
|
-
|
|
5468
|
-
let
|
|
5469
|
-
|
|
5470
|
-
let
|
|
5471
|
-
|
|
5472
|
-
let
|
|
5473
|
-
|
|
5474
|
-
let
|
|
5475
|
-
|
|
5476
|
-
let
|
|
5477
|
-
|
|
5478
|
-
let
|
|
5470
|
+
let Tt = E(() => !R || !z ? null : kt(R, z), [R, z]), Dt = E(() => Tt?.toDataURL() ?? null, [Tt]), Ot = E(() => !K || !ie ? null : Vt(ie, K.w, K.h), [K, ie]), At = O(Tt);
|
|
5471
|
+
At.current = Tt;
|
|
5472
|
+
let jt = O(Ot);
|
|
5473
|
+
jt.current = Ot;
|
|
5474
|
+
let Mt = O(r);
|
|
5475
|
+
Mt.current = r;
|
|
5476
|
+
let Nt = O(K);
|
|
5477
|
+
Nt.current = K;
|
|
5478
|
+
let Pt = O($e);
|
|
5479
|
+
Pt.current = $e;
|
|
5480
|
+
let Ft = O($e?.imageSize);
|
|
5481
|
+
Ft.current = $e?.imageSize;
|
|
5482
|
+
let It = O(J);
|
|
5479
5483
|
T(() => {
|
|
5480
|
-
|
|
5484
|
+
It.current = J;
|
|
5481
5485
|
}, [J]);
|
|
5482
|
-
let
|
|
5483
|
-
|
|
5484
|
-
let
|
|
5485
|
-
|
|
5486
|
-
let
|
|
5487
|
-
|
|
5488
|
-
let
|
|
5489
|
-
|
|
5490
|
-
let
|
|
5491
|
-
|
|
5492
|
-
let Z = !!l || !!d,
|
|
5493
|
-
|
|
5494
|
-
let
|
|
5495
|
-
|
|
5496
|
-
let
|
|
5497
|
-
|
|
5498
|
-
let
|
|
5499
|
-
|
|
5500
|
-
let
|
|
5501
|
-
|
|
5502
|
-
let
|
|
5503
|
-
|
|
5504
|
-
let
|
|
5486
|
+
let Lt = O(a);
|
|
5487
|
+
Lt.current = a;
|
|
5488
|
+
let Rt = O(s);
|
|
5489
|
+
Rt.current = s;
|
|
5490
|
+
let zt = O(c);
|
|
5491
|
+
zt.current = c;
|
|
5492
|
+
let Bt = O(ee);
|
|
5493
|
+
Bt.current = ee;
|
|
5494
|
+
let Ht = O(Y.simplifyStrength);
|
|
5495
|
+
Ht.current = Y.simplifyStrength;
|
|
5496
|
+
let Z = !!l || !!d, Ut = O(Z);
|
|
5497
|
+
Ut.current = Z;
|
|
5498
|
+
let Wt = O(u);
|
|
5499
|
+
Wt.current = u;
|
|
5500
|
+
let Gt = O(d);
|
|
5501
|
+
Gt.current = d;
|
|
5502
|
+
let Kt = O(f);
|
|
5503
|
+
Kt.current = f;
|
|
5504
|
+
let qt = O(p);
|
|
5505
|
+
qt.current = p;
|
|
5506
|
+
let Jt = O(h);
|
|
5507
|
+
Jt.current = h;
|
|
5508
|
+
let Yt = O(q);
|
|
5509
|
+
Yt.current = q;
|
|
5510
|
+
let Qt = O(!1), $t = O(!1), en = O("idle"), tn = O(null), nn = x(() => {
|
|
5505
5511
|
let e = U.current;
|
|
5506
5512
|
if (!e) return;
|
|
5507
|
-
let t =
|
|
5513
|
+
let t = Lt.current, n = _t.current.get(t), r = vt.current;
|
|
5508
5514
|
e.setCursor(Et({
|
|
5509
5515
|
tool: t,
|
|
5510
5516
|
externalToolCursor: n?.cursor,
|
|
5511
|
-
isSpacePressed:
|
|
5512
|
-
interactionMode:
|
|
5513
|
-
rendererCursorHint:
|
|
5517
|
+
isSpacePressed: Qt.current,
|
|
5518
|
+
interactionMode: en.current,
|
|
5519
|
+
rendererCursorHint: tn.current,
|
|
5514
5520
|
isPolygonDrawing: r.kind === "polygon" && r.active
|
|
5515
5521
|
}));
|
|
5516
|
-
}, []),
|
|
5517
|
-
|
|
5518
|
-
}, [
|
|
5519
|
-
|
|
5520
|
-
}, [
|
|
5521
|
-
let t = /* @__PURE__ */ new Set(), n = new Map(
|
|
5522
|
+
}, []), rn = x((e) => {
|
|
5523
|
+
en.current !== e && (en.current = e, nn());
|
|
5524
|
+
}, [nn]), an = x((e) => {
|
|
5525
|
+
tn.current !== e && (tn.current = e, nn());
|
|
5526
|
+
}, [nn]), on = x((e) => {
|
|
5527
|
+
let t = /* @__PURE__ */ new Set(), n = new Map(Yt.current.getShapes().map((e) => [e.id, e]));
|
|
5522
5528
|
return e.filter((e) => {
|
|
5523
5529
|
if (t.has(e)) return !1;
|
|
5524
5530
|
t.add(e);
|
|
5525
5531
|
let r = n.get(e);
|
|
5526
5532
|
if (!r) return !1;
|
|
5527
|
-
let i =
|
|
5528
|
-
return
|
|
5533
|
+
let i = Jt.current?.(r);
|
|
5534
|
+
return L(i ? {
|
|
5529
5535
|
...r,
|
|
5530
5536
|
interaction: {
|
|
5531
5537
|
...r.interaction,
|
|
@@ -5533,175 +5539,175 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5533
5539
|
}
|
|
5534
5540
|
} : r);
|
|
5535
5541
|
});
|
|
5536
|
-
}, []),
|
|
5537
|
-
let t =
|
|
5538
|
-
Pr(
|
|
5542
|
+
}, []), sn = x((e) => {
|
|
5543
|
+
let t = on(e);
|
|
5544
|
+
Pr(It.current, t) || (mt || pt(t), U.current?.setSelection(t), _e?.(t));
|
|
5539
5545
|
}, [
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
]),
|
|
5544
|
-
|
|
5545
|
-
let [
|
|
5546
|
-
|
|
5547
|
-
let
|
|
5548
|
-
|
|
5549
|
-
if (!
|
|
5550
|
-
let e =
|
|
5551
|
-
Pr(i, e) ||
|
|
5546
|
+
on,
|
|
5547
|
+
_e,
|
|
5548
|
+
mt
|
|
5549
|
+
]), cn = O(sn);
|
|
5550
|
+
cn.current = sn;
|
|
5551
|
+
let [ln, un] = k(null), dn = x((e) => un(e), []), fn = O(dn);
|
|
5552
|
+
fn.current = dn;
|
|
5553
|
+
let pn = O(null);
|
|
5554
|
+
pn.current = ln, S(() => {
|
|
5555
|
+
if (!mt) return;
|
|
5556
|
+
let e = on(i);
|
|
5557
|
+
Pr(i, e) || _e?.(e);
|
|
5552
5558
|
}, [
|
|
5553
5559
|
i,
|
|
5554
5560
|
q.shapes,
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5561
|
+
on,
|
|
5562
|
+
_e,
|
|
5563
|
+
mt
|
|
5558
5564
|
]);
|
|
5559
|
-
let
|
|
5560
|
-
|
|
5561
|
-
let { registerMinimapShape:
|
|
5565
|
+
let mn = O(we);
|
|
5566
|
+
mn.current = we;
|
|
5567
|
+
let { registerMinimapShape: hn, applyMinimapPreview: gn, syncMinimap: _n } = Or({
|
|
5562
5568
|
engineRef: U,
|
|
5563
|
-
docRef:
|
|
5564
|
-
overlayRef:
|
|
5565
|
-
zoomLabelRef:
|
|
5566
|
-
minimapRectRef:
|
|
5569
|
+
docRef: Yt,
|
|
5570
|
+
overlayRef: W,
|
|
5571
|
+
zoomLabelRef: Ae,
|
|
5572
|
+
minimapRectRef: De,
|
|
5567
5573
|
minimapSize: 204,
|
|
5568
|
-
onViewportChangeRef:
|
|
5569
|
-
}),
|
|
5570
|
-
|
|
5571
|
-
let
|
|
5572
|
-
t ?
|
|
5573
|
-
}, []),
|
|
5574
|
+
onViewportChangeRef: mn
|
|
5575
|
+
}), vn = O(/* @__PURE__ */ new Map()), yn = O(ue);
|
|
5576
|
+
yn.current = ue;
|
|
5577
|
+
let bn = x((e, t) => {
|
|
5578
|
+
t ? vn.current.set(e, t) : vn.current.delete(e);
|
|
5579
|
+
}, []), xn = O(null), [Cn, wn] = k(null), En = x((e) => {
|
|
5574
5580
|
if (!e.length) return;
|
|
5575
|
-
let t = new Map(
|
|
5576
|
-
|
|
5581
|
+
let t = new Map(Yt.current.getShapes().map((e) => [e.id, e]));
|
|
5582
|
+
xn.current && t.set(xn.current.id, xn.current);
|
|
5577
5583
|
for (let { id: n, points: r } of e) {
|
|
5578
|
-
let e =
|
|
5584
|
+
let e = vn.current.get(n), i = t.get(n);
|
|
5579
5585
|
if (!e || !i) continue;
|
|
5580
5586
|
let a = rt(e, r);
|
|
5581
5587
|
if (a) {
|
|
5582
5588
|
let e = it(i, r);
|
|
5583
|
-
a.textContent =
|
|
5589
|
+
a.textContent = yn.current?.(e) ?? at(e);
|
|
5584
5590
|
}
|
|
5585
5591
|
}
|
|
5586
|
-
}, []),
|
|
5587
|
-
|
|
5592
|
+
}, []), Dn = x((e) => {
|
|
5593
|
+
gn(e), En(e), Te?.(e);
|
|
5588
5594
|
}, [
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
]),
|
|
5593
|
-
if (
|
|
5595
|
+
gn,
|
|
5596
|
+
En,
|
|
5597
|
+
Te
|
|
5598
|
+
]), On = x((e) => {
|
|
5599
|
+
if (Ce?.(e ? {
|
|
5594
5600
|
...e,
|
|
5595
|
-
meta:
|
|
5596
|
-
} : null), !e || !
|
|
5597
|
-
|
|
5601
|
+
meta: zt.current
|
|
5602
|
+
} : null), !e || !Rt.current) {
|
|
5603
|
+
xn.current && (xn.current = null, wn(null));
|
|
5598
5604
|
return;
|
|
5599
5605
|
}
|
|
5600
5606
|
let t = {
|
|
5601
5607
|
id: Mr,
|
|
5602
5608
|
type: e.type,
|
|
5603
5609
|
points: e.points,
|
|
5604
|
-
style:
|
|
5605
|
-
meta:
|
|
5606
|
-
}, n =
|
|
5607
|
-
|
|
5610
|
+
style: Rt.current,
|
|
5611
|
+
meta: zt.current
|
|
5612
|
+
}, n = xn.current !== null;
|
|
5613
|
+
xn.current = t, n ? En([{
|
|
5608
5614
|
id: Mr,
|
|
5609
5615
|
points: e.points
|
|
5610
|
-
}]) :
|
|
5611
|
-
}, [
|
|
5612
|
-
let n =
|
|
5613
|
-
if (!n ||
|
|
5616
|
+
}]) : wn(t);
|
|
5617
|
+
}, [En, Ce]), kn = x((e, t) => {
|
|
5618
|
+
let n = Rt.current;
|
|
5619
|
+
if (!n || Ut.current) return;
|
|
5614
5620
|
let r = oe();
|
|
5615
|
-
|
|
5621
|
+
Yt.current.create({
|
|
5616
5622
|
id: r,
|
|
5617
5623
|
type: e,
|
|
5618
5624
|
points: t,
|
|
5619
5625
|
style: n,
|
|
5620
5626
|
meta: c
|
|
5621
|
-
}),
|
|
5622
|
-
}, [c]),
|
|
5623
|
-
|
|
5624
|
-
let
|
|
5625
|
-
toolRef:
|
|
5626
|
-
selRef:
|
|
5627
|
-
docRef:
|
|
5628
|
-
readOnlyRef:
|
|
5629
|
-
draftRef:
|
|
5630
|
-
brushSizeRef:
|
|
5631
|
-
simplifyEpsilonRef:
|
|
5627
|
+
}), cn.current([r]);
|
|
5628
|
+
}, [c]), An = O(kn);
|
|
5629
|
+
An.current = kn;
|
|
5630
|
+
let jn = Sn({
|
|
5631
|
+
toolRef: Lt,
|
|
5632
|
+
selRef: It,
|
|
5633
|
+
docRef: Yt,
|
|
5634
|
+
readOnlyRef: Ut,
|
|
5635
|
+
draftRef: Rt,
|
|
5636
|
+
brushSizeRef: Bt,
|
|
5637
|
+
simplifyEpsilonRef: Ht,
|
|
5632
5638
|
draftMeta: c,
|
|
5633
5639
|
engineRef: U,
|
|
5634
5640
|
onDrawSessionChange: x((e) => {
|
|
5635
|
-
|
|
5636
|
-
}, [
|
|
5637
|
-
onDraftShapeChange:
|
|
5638
|
-
changeSelection:
|
|
5639
|
-
createShape:
|
|
5640
|
-
}),
|
|
5641
|
-
|
|
5642
|
-
let { reset:
|
|
5643
|
-
|
|
5641
|
+
We(e), Se?.(e);
|
|
5642
|
+
}, [Se]),
|
|
5643
|
+
onDraftShapeChange: Ce,
|
|
5644
|
+
changeSelection: sn,
|
|
5645
|
+
createShape: kn
|
|
5646
|
+
}), Mn = O(jn);
|
|
5647
|
+
Mn.current = jn;
|
|
5648
|
+
let { reset: Nn, undoSession: Pn, redoSession: In, canUndoSession: Ln, canRedoSession: Rn, hasDraftSession: zn, hasDraftPoints: Bn, commitDraftSession: Vn, setBrushScalarMode: Hn, getBrushScalarMode: Un, hasBrushSession: Wn, commitBrush: Gn, cancelBrush: Kn, beginBrushEditFromSelection: qn, deleteDraftSelectedPoints: Jn, handleToolChange: Yn, handleBrushSelectionChange: Xn } = jn, Zn = O(fe);
|
|
5649
|
+
Zn.current = fe;
|
|
5644
5650
|
let Q = Zt({
|
|
5645
|
-
docRef:
|
|
5646
|
-
draftRef:
|
|
5651
|
+
docRef: Yt,
|
|
5652
|
+
draftRef: Rt,
|
|
5647
5653
|
draftMeta: c,
|
|
5648
|
-
changeSelection:
|
|
5649
|
-
assistantRef:
|
|
5650
|
-
}),
|
|
5651
|
-
|
|
5652
|
-
let
|
|
5654
|
+
changeSelection: sn,
|
|
5655
|
+
assistantRef: Zn
|
|
5656
|
+
}), Qn = O(Q);
|
|
5657
|
+
Qn.current = Q;
|
|
5658
|
+
let $n = E(() => ht(Ye), [Ye]), { selectAll: er, clearSelection: tr, deleteSelection: nr, copySelection: rr, canPaste: ir, paste: ar, duplicate: or, bringToFront: sr, sendToBack: cr, nudgeSelection: lr, getMergeTargets: ur, mergeSelection: dr } = Ar({
|
|
5653
5659
|
doc: q,
|
|
5654
|
-
selRef:
|
|
5660
|
+
selRef: It,
|
|
5655
5661
|
effectiveReadOnly: Z,
|
|
5656
|
-
changeSelection:
|
|
5657
|
-
canMergeSelection:
|
|
5658
|
-
clipboardDocumentId:
|
|
5659
|
-
clipboardScope: t ??
|
|
5660
|
-
}), { zoomToBounds:
|
|
5662
|
+
changeSelection: sn,
|
|
5663
|
+
canMergeSelection: P,
|
|
5664
|
+
clipboardDocumentId: $n,
|
|
5665
|
+
clipboardScope: t ?? $n
|
|
5666
|
+
}), { zoomToBounds: fr, zoomToShapes: pr, zoomToSelection: mr, zoomAtCenter: hr } = jr({
|
|
5661
5667
|
engineRef: U,
|
|
5662
5668
|
doc: q,
|
|
5663
|
-
selRef:
|
|
5664
|
-
zoomAnimationDuration:
|
|
5665
|
-
zoomBound:
|
|
5666
|
-
ready:
|
|
5669
|
+
selRef: It,
|
|
5670
|
+
zoomAnimationDuration: ne,
|
|
5671
|
+
zoomBound: te,
|
|
5672
|
+
ready: ze
|
|
5667
5673
|
});
|
|
5668
|
-
w(
|
|
5674
|
+
w(me, () => ({
|
|
5669
5675
|
previewRegionMask: (e) => {
|
|
5670
|
-
let t =
|
|
5676
|
+
let t = Nt.current;
|
|
5671
5677
|
if (!t) return;
|
|
5672
|
-
let n = e ? Vt(e, t.w, t.h) :
|
|
5673
|
-
U.current?.setRegionOverlay(
|
|
5678
|
+
let n = e ? Vt(e, t.w, t.h) : jt.current;
|
|
5679
|
+
U.current?.setRegionOverlay(gr.current.showRegionMask ? n : null);
|
|
5674
5680
|
},
|
|
5675
5681
|
undo: () => {
|
|
5676
|
-
|
|
5682
|
+
Pn() || q.undo();
|
|
5677
5683
|
},
|
|
5678
5684
|
redo: () => {
|
|
5679
|
-
|
|
5685
|
+
In() || q.redo();
|
|
5680
5686
|
},
|
|
5681
|
-
canUndo: () =>
|
|
5682
|
-
canRedo: () =>
|
|
5683
|
-
undoSession:
|
|
5684
|
-
redoSession:
|
|
5685
|
-
canUndoSession:
|
|
5686
|
-
canRedoSession:
|
|
5687
|
-
hasDraftSession:
|
|
5688
|
-
cancelDraftSession:
|
|
5689
|
-
commitDraftSession:
|
|
5690
|
-
setSelection:
|
|
5687
|
+
canUndo: () => Ln() || q.canUndo(),
|
|
5688
|
+
canRedo: () => Rn() || q.canRedo(),
|
|
5689
|
+
undoSession: Pn,
|
|
5690
|
+
redoSession: In,
|
|
5691
|
+
canUndoSession: Ln,
|
|
5692
|
+
canRedoSession: Rn,
|
|
5693
|
+
hasDraftSession: zn,
|
|
5694
|
+
cancelDraftSession: Nn,
|
|
5695
|
+
commitDraftSession: Vn,
|
|
5696
|
+
setSelection: sn,
|
|
5691
5697
|
createShapes: (e) => {
|
|
5692
|
-
e.length && (q.create(e),
|
|
5698
|
+
e.length && (q.create(e), sn(e.map((e) => e.id)));
|
|
5693
5699
|
},
|
|
5694
5700
|
updateShapes: q.update,
|
|
5695
5701
|
deleteShapes: q.remove,
|
|
5696
5702
|
getShapes: q.getShapes,
|
|
5697
|
-
selectAll:
|
|
5698
|
-
clearSelection:
|
|
5699
|
-
deleteSelection:
|
|
5700
|
-
copySelection:
|
|
5701
|
-
paste:
|
|
5702
|
-
duplicate:
|
|
5703
|
-
bringToFront:
|
|
5704
|
-
sendToBack:
|
|
5703
|
+
selectAll: er,
|
|
5704
|
+
clearSelection: tr,
|
|
5705
|
+
deleteSelection: nr,
|
|
5706
|
+
copySelection: rr,
|
|
5707
|
+
paste: ar,
|
|
5708
|
+
duplicate: or,
|
|
5709
|
+
bringToFront: sr,
|
|
5710
|
+
sendToBack: cr,
|
|
5705
5711
|
zoomFit: () => U.current?.fit(),
|
|
5706
5712
|
zoom100: () => U.current?.zoom100(),
|
|
5707
5713
|
zoomIn: () => {
|
|
@@ -5716,102 +5722,103 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5716
5722
|
let { w: t, h: n } = e.screenSize;
|
|
5717
5723
|
e.zoomAt(t / 2, n / 2, 1 / 1.2);
|
|
5718
5724
|
},
|
|
5719
|
-
zoomToSelection:
|
|
5720
|
-
zoomToShapes:
|
|
5721
|
-
zoomToBounds:
|
|
5725
|
+
zoomToSelection: mr,
|
|
5726
|
+
zoomToShapes: pr,
|
|
5727
|
+
zoomToBounds: fr,
|
|
5722
5728
|
brush: {
|
|
5723
|
-
setScalarMode:
|
|
5724
|
-
getScalarMode:
|
|
5725
|
-
hasSession:
|
|
5726
|
-
commit:
|
|
5727
|
-
cancel:
|
|
5728
|
-
beginEditFromSelection:
|
|
5729
|
+
setScalarMode: Hn,
|
|
5730
|
+
getScalarMode: Un,
|
|
5731
|
+
hasSession: Wn,
|
|
5732
|
+
commit: Gn,
|
|
5733
|
+
cancel: Kn,
|
|
5734
|
+
beginEditFromSelection: qn
|
|
5729
5735
|
}
|
|
5730
5736
|
}), [
|
|
5731
5737
|
q,
|
|
5732
|
-
|
|
5733
|
-
|
|
5738
|
+
sn,
|
|
5739
|
+
Pn,
|
|
5740
|
+
In,
|
|
5741
|
+
Vn,
|
|
5734
5742
|
Nn,
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
Un,
|
|
5738
|
-
Wn,
|
|
5739
|
-
Qn,
|
|
5740
|
-
$n,
|
|
5743
|
+
Gn,
|
|
5744
|
+
Kn,
|
|
5741
5745
|
er,
|
|
5742
5746
|
tr,
|
|
5747
|
+
nr,
|
|
5743
5748
|
rr,
|
|
5744
|
-
ir,
|
|
5745
5749
|
ar,
|
|
5746
5750
|
or,
|
|
5751
|
+
sr,
|
|
5752
|
+
cr,
|
|
5753
|
+
mr,
|
|
5754
|
+
pr,
|
|
5747
5755
|
fr,
|
|
5748
|
-
dr,
|
|
5749
|
-
ur,
|
|
5750
|
-
Bn,
|
|
5751
|
-
Vn,
|
|
5752
5756
|
Hn,
|
|
5753
|
-
|
|
5757
|
+
Un,
|
|
5758
|
+
Wn,
|
|
5759
|
+
qn
|
|
5754
5760
|
]);
|
|
5755
|
-
let
|
|
5756
|
-
|
|
5757
|
-
let
|
|
5761
|
+
let gr = O(Y);
|
|
5762
|
+
gr.current = Y;
|
|
5763
|
+
let _r = x(() => Xt({
|
|
5758
5764
|
engineRef: U,
|
|
5759
|
-
toolRef:
|
|
5760
|
-
externalToolMapRef:
|
|
5761
|
-
spaceRef:
|
|
5762
|
-
shiftRef:
|
|
5763
|
-
docRef:
|
|
5764
|
-
selRef:
|
|
5765
|
-
draftRef:
|
|
5766
|
-
readOnlyRef:
|
|
5767
|
-
disableMarqueeRef:
|
|
5768
|
-
lockedRef:
|
|
5769
|
-
onLockedInteraction: () =>
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5765
|
+
toolRef: Lt,
|
|
5766
|
+
externalToolMapRef: _t,
|
|
5767
|
+
spaceRef: Qt,
|
|
5768
|
+
shiftRef: $t,
|
|
5769
|
+
docRef: Yt,
|
|
5770
|
+
selRef: It,
|
|
5771
|
+
draftRef: Rt,
|
|
5772
|
+
readOnlyRef: Ut,
|
|
5773
|
+
disableMarqueeRef: Wt,
|
|
5774
|
+
lockedRef: Gt,
|
|
5775
|
+
onLockedInteraction: () => Kt.current?.(),
|
|
5776
|
+
onDrawAttemptWithoutDraft: () => qt.current?.(),
|
|
5777
|
+
createRef: An,
|
|
5778
|
+
selectRef: cn,
|
|
5779
|
+
enterEditRef: fn,
|
|
5780
|
+
editingIdRef: pn,
|
|
5781
|
+
drawSessionRef: Mn,
|
|
5782
|
+
assistantRef: Qn,
|
|
5783
|
+
setCursorHint: an,
|
|
5784
|
+
setInteractionMode: rn,
|
|
5785
|
+
syncMinimap: _n,
|
|
5786
|
+
onTransformPreview: Dn,
|
|
5787
|
+
onDrawPreview: On
|
|
5781
5788
|
}), [
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
]),
|
|
5789
|
+
an,
|
|
5790
|
+
rn,
|
|
5791
|
+
_n,
|
|
5792
|
+
Dn,
|
|
5793
|
+
On
|
|
5794
|
+
]), vr = O([]);
|
|
5788
5795
|
xr({
|
|
5789
|
-
backend:
|
|
5790
|
-
hostRef:
|
|
5796
|
+
backend: he,
|
|
5797
|
+
hostRef: Ee,
|
|
5791
5798
|
engineRef: U,
|
|
5792
|
-
documentId:
|
|
5793
|
-
renderedImageUrl:
|
|
5794
|
-
makeCallbacks:
|
|
5795
|
-
viewRef:
|
|
5796
|
-
readOnlyRef:
|
|
5797
|
-
toolRef:
|
|
5798
|
-
renderShapesRef:
|
|
5799
|
-
coordinateSizeRef:
|
|
5800
|
-
imageSizeRef:
|
|
5801
|
-
selRef:
|
|
5802
|
-
maskCanvasRef:
|
|
5803
|
-
regionOverlayRef:
|
|
5804
|
-
dimmedRef:
|
|
5805
|
-
syncMinimap:
|
|
5806
|
-
setImage:
|
|
5807
|
-
setImageVisible:
|
|
5808
|
-
setReady:
|
|
5809
|
-
setImageStatus:
|
|
5810
|
-
onContextMenuRequest:
|
|
5799
|
+
documentId: Ye,
|
|
5800
|
+
renderedImageUrl: nt,
|
|
5801
|
+
makeCallbacks: _r,
|
|
5802
|
+
viewRef: gr,
|
|
5803
|
+
readOnlyRef: Ut,
|
|
5804
|
+
toolRef: Lt,
|
|
5805
|
+
renderShapesRef: vr,
|
|
5806
|
+
coordinateSizeRef: Pt,
|
|
5807
|
+
imageSizeRef: Ft,
|
|
5808
|
+
selRef: It,
|
|
5809
|
+
maskCanvasRef: At,
|
|
5810
|
+
regionOverlayRef: jt,
|
|
5811
|
+
dimmedRef: Mt,
|
|
5812
|
+
syncMinimap: _n,
|
|
5813
|
+
setImage: Me,
|
|
5814
|
+
setImageVisible: Re,
|
|
5815
|
+
setReady: Be,
|
|
5816
|
+
setImageStatus: dt,
|
|
5817
|
+
onContextMenuRequest: He
|
|
5811
5818
|
});
|
|
5812
|
-
let
|
|
5813
|
-
let e =
|
|
5814
|
-
let t =
|
|
5819
|
+
let $ = E(() => {
|
|
5820
|
+
let e = h ? q.shapes.map((e) => {
|
|
5821
|
+
let t = h(e);
|
|
5815
5822
|
return t ? {
|
|
5816
5823
|
...e,
|
|
5817
5824
|
interaction: {
|
|
@@ -5820,7 +5827,7 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5820
5827
|
}
|
|
5821
5828
|
} : e;
|
|
5822
5829
|
}) : q.shapes;
|
|
5823
|
-
return
|
|
5830
|
+
return F?.length ? [...F.map((e) => ({
|
|
5824
5831
|
...e,
|
|
5825
5832
|
interaction: {
|
|
5826
5833
|
...e.interaction,
|
|
@@ -5832,154 +5839,154 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5832
5839
|
})), ...e] : e;
|
|
5833
5840
|
}, [
|
|
5834
5841
|
q.shapes,
|
|
5835
|
-
|
|
5836
|
-
|
|
5842
|
+
h,
|
|
5843
|
+
F
|
|
5837
5844
|
]);
|
|
5838
|
-
|
|
5839
|
-
U.current?.setShapes(
|
|
5840
|
-
}, [
|
|
5845
|
+
vr.current = $, S(() => {
|
|
5846
|
+
U.current?.setShapes($, It.current), _n();
|
|
5847
|
+
}, [$, _n]), S(() => {
|
|
5841
5848
|
U.current?.setSelection(J);
|
|
5842
5849
|
}, [J]), S(() => {
|
|
5843
|
-
U.current?.setEditing(
|
|
5844
|
-
}, [
|
|
5845
|
-
let
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
}, [
|
|
5849
|
-
|
|
5850
|
+
U.current?.setEditing(ln);
|
|
5851
|
+
}, [ln, ze]);
|
|
5852
|
+
let yr = O(ve);
|
|
5853
|
+
yr.current = ve, S(() => {
|
|
5854
|
+
yr.current?.(ln);
|
|
5855
|
+
}, [ln]), S(() => {
|
|
5856
|
+
un(null);
|
|
5850
5857
|
}, [a]), S(() => {
|
|
5851
|
-
|
|
5852
|
-
}, [J,
|
|
5858
|
+
ln && (J.length !== 1 || J[0] !== ln) && un(null);
|
|
5859
|
+
}, [J, ln]), S(() => {
|
|
5853
5860
|
let e = U.current;
|
|
5854
|
-
e && (e.setFilter(Y.brightness, Y.contrast), e.setRenderDefaults({ strokeWidth: Y.strokeSize }), e.setImageSmoothing(Y.imageSmoothing),
|
|
5861
|
+
e && (e.setFilter(Y.brightness, Y.contrast), e.setRenderDefaults({ strokeWidth: Y.strokeSize }), e.setImageSmoothing(Y.imageSmoothing), _n());
|
|
5855
5862
|
}, [
|
|
5856
5863
|
Y.brightness,
|
|
5857
5864
|
Y.contrast,
|
|
5858
5865
|
Y.strokeSize,
|
|
5859
5866
|
Y.imageSmoothing,
|
|
5860
|
-
|
|
5867
|
+
_n
|
|
5861
5868
|
]), T(() => {
|
|
5862
|
-
|
|
5869
|
+
ze && U.current?.setOverlays(Y.showGuide ? Tt : null, Y.showRegionMask ? Ot : null, r);
|
|
5863
5870
|
}, [
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5871
|
+
ze,
|
|
5872
|
+
Tt,
|
|
5873
|
+
Ot,
|
|
5867
5874
|
Y.showGuide,
|
|
5868
5875
|
Y.showRegionMask,
|
|
5869
5876
|
r
|
|
5870
5877
|
]), S(() => {
|
|
5871
|
-
!
|
|
5878
|
+
!ze || !K || _n();
|
|
5872
5879
|
}, [
|
|
5873
|
-
|
|
5880
|
+
ze,
|
|
5874
5881
|
K,
|
|
5875
|
-
|
|
5882
|
+
Dt,
|
|
5876
5883
|
Y.showGuide,
|
|
5877
5884
|
Y.showRegionMask,
|
|
5878
|
-
|
|
5879
|
-
|
|
5885
|
+
ie,
|
|
5886
|
+
_n
|
|
5880
5887
|
]), S(() => {
|
|
5881
|
-
|
|
5888
|
+
ze && U.current?.setTransformEnabled(!Z && a !== G.BRUSH);
|
|
5882
5889
|
}, [
|
|
5883
5890
|
Z,
|
|
5884
|
-
|
|
5891
|
+
ze,
|
|
5885
5892
|
a
|
|
5886
5893
|
]), S(() => {
|
|
5887
|
-
|
|
5888
|
-
}, [a,
|
|
5889
|
-
let
|
|
5894
|
+
Yn(a, _t.current.has(a));
|
|
5895
|
+
}, [a, Yn]);
|
|
5896
|
+
let br = Q.finalize;
|
|
5890
5897
|
S(() => {
|
|
5891
|
-
|
|
5892
|
-
}, [a,
|
|
5893
|
-
|
|
5898
|
+
br();
|
|
5899
|
+
}, [a, br]), S(() => {
|
|
5900
|
+
en.current = "idle", tn.current = null, nn();
|
|
5894
5901
|
}, [
|
|
5895
5902
|
a,
|
|
5896
|
-
|
|
5897
|
-
|
|
5903
|
+
he,
|
|
5904
|
+
nn
|
|
5898
5905
|
]), S(() => {
|
|
5899
|
-
|
|
5906
|
+
Xn(J, Z);
|
|
5900
5907
|
}, [
|
|
5901
5908
|
J,
|
|
5902
5909
|
a,
|
|
5903
5910
|
Z,
|
|
5904
|
-
|
|
5911
|
+
Xn
|
|
5905
5912
|
]), S(() => {
|
|
5906
|
-
|
|
5913
|
+
ze && nn();
|
|
5907
5914
|
}, [
|
|
5908
5915
|
a,
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5916
|
+
Ue,
|
|
5917
|
+
gt,
|
|
5918
|
+
ze,
|
|
5919
|
+
nn
|
|
5913
5920
|
]);
|
|
5914
|
-
let
|
|
5915
|
-
|
|
5916
|
-
let
|
|
5921
|
+
let Sr = O(tt);
|
|
5922
|
+
Sr.current = tt;
|
|
5923
|
+
let Cr = e !== null, wr = O(null);
|
|
5917
5924
|
S(() => {
|
|
5918
|
-
let e =
|
|
5919
|
-
|
|
5925
|
+
let e = Cr ? Ye : null;
|
|
5926
|
+
wr.current !== e && (wr.current = e, He(null), un(null), en.current = "idle", tn.current = null, q.reset(Cr ? et ?? [] : []), sn(Cr ? Sr.current ?? [] : []), Nn(), br(), nn());
|
|
5920
5927
|
}, [
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5928
|
+
Cr,
|
|
5929
|
+
Ye,
|
|
5930
|
+
et,
|
|
5924
5931
|
q.reset,
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5932
|
+
sn,
|
|
5933
|
+
Nn,
|
|
5934
|
+
br,
|
|
5935
|
+
nn
|
|
5929
5936
|
]);
|
|
5930
|
-
let
|
|
5931
|
-
let e =
|
|
5937
|
+
let Tr = x(() => {
|
|
5938
|
+
let e = pn.current;
|
|
5932
5939
|
if (!e || Z) return !1;
|
|
5933
5940
|
let t = U.current, n = new Set(t?.getVertexSelection() ?? []);
|
|
5934
5941
|
if (!n.size) return !1;
|
|
5935
|
-
let r =
|
|
5942
|
+
let r = Yt.current.getShapes().find((t) => t.id === e);
|
|
5936
5943
|
if (!r) return !1;
|
|
5937
|
-
let i = r.points.filter((e, t) => !n.has(t)), a = r.type ===
|
|
5938
|
-
return i.length < a ? !1 : (
|
|
5944
|
+
let i = r.points.filter((e, t) => !n.has(t)), a = r.type === I.LINE ? 2 : 3;
|
|
5945
|
+
return i.length < a ? !1 : (Yt.current.update([{
|
|
5939
5946
|
...r,
|
|
5940
5947
|
points: i
|
|
5941
5948
|
}]), t?.setVertexSelection([]), !0);
|
|
5942
5949
|
}, [Z]);
|
|
5943
5950
|
Fn({
|
|
5944
|
-
keymap:
|
|
5945
|
-
hostRef:
|
|
5951
|
+
keymap: pe,
|
|
5952
|
+
hostRef: Ee,
|
|
5946
5953
|
actions: {
|
|
5947
5954
|
undo: () => {
|
|
5948
|
-
Z ||
|
|
5955
|
+
Z || Pn() || q.undo();
|
|
5949
5956
|
},
|
|
5950
5957
|
redo: () => {
|
|
5951
|
-
Z ||
|
|
5958
|
+
Z || In() || q.redo();
|
|
5952
5959
|
},
|
|
5953
|
-
selectAll:
|
|
5954
|
-
copy:
|
|
5960
|
+
selectAll: er,
|
|
5961
|
+
copy: rr,
|
|
5955
5962
|
cut: () => {
|
|
5956
|
-
|
|
5963
|
+
rr(), nr();
|
|
5957
5964
|
},
|
|
5958
|
-
paste:
|
|
5959
|
-
duplicate:
|
|
5965
|
+
paste: ar,
|
|
5966
|
+
duplicate: or,
|
|
5960
5967
|
delete: () => {
|
|
5961
|
-
|
|
5968
|
+
Bn() && Jn() || Tr() || nr();
|
|
5962
5969
|
},
|
|
5963
5970
|
cancel: () => {
|
|
5964
|
-
let e =
|
|
5971
|
+
let e = _t.current.get(Lt.current);
|
|
5965
5972
|
if (!(e?.onCancel && e.onCancel() !== !1)) {
|
|
5966
5973
|
if (Q.isActive()) {
|
|
5967
5974
|
Q.cancel();
|
|
5968
5975
|
return;
|
|
5969
5976
|
}
|
|
5970
|
-
if (
|
|
5971
|
-
|
|
5977
|
+
if (zn()) {
|
|
5978
|
+
Nn();
|
|
5972
5979
|
return;
|
|
5973
5980
|
}
|
|
5974
|
-
if (
|
|
5975
|
-
|
|
5981
|
+
if (ln) {
|
|
5982
|
+
un(null);
|
|
5976
5983
|
return;
|
|
5977
5984
|
}
|
|
5978
|
-
if (
|
|
5979
|
-
|
|
5985
|
+
if (It.current.length) {
|
|
5986
|
+
tr();
|
|
5980
5987
|
return;
|
|
5981
5988
|
}
|
|
5982
|
-
|
|
5989
|
+
m?.();
|
|
5983
5990
|
}
|
|
5984
5991
|
},
|
|
5985
5992
|
commitDraft: () => {
|
|
@@ -5987,150 +5994,150 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5987
5994
|
Q.finalize();
|
|
5988
5995
|
return;
|
|
5989
5996
|
}
|
|
5990
|
-
if (
|
|
5991
|
-
|
|
5997
|
+
if (zn()) {
|
|
5998
|
+
Vn();
|
|
5992
5999
|
return;
|
|
5993
6000
|
}
|
|
5994
6001
|
if (Z) return;
|
|
5995
|
-
if (
|
|
5996
|
-
|
|
6002
|
+
if (ln) {
|
|
6003
|
+
un(null);
|
|
5997
6004
|
return;
|
|
5998
6005
|
}
|
|
5999
|
-
let e =
|
|
6006
|
+
let e = It.current;
|
|
6000
6007
|
if (e.length !== 1) return;
|
|
6001
|
-
let t =
|
|
6002
|
-
t && (t.type ===
|
|
6008
|
+
let t = Yt.current.getShapes().find((t) => t.id === e[0]);
|
|
6009
|
+
t && (t.type === I.POLYGON || t.type === I.LINE) && t.interaction?.editable !== !1 && !t.readOnly && un(e[0]);
|
|
6003
6010
|
},
|
|
6004
|
-
bringToFront:
|
|
6005
|
-
sendToBack:
|
|
6006
|
-
zoomIn: () =>
|
|
6007
|
-
zoomOut: () =>
|
|
6011
|
+
bringToFront: sr,
|
|
6012
|
+
sendToBack: cr,
|
|
6013
|
+
zoomIn: () => hr(1.2),
|
|
6014
|
+
zoomOut: () => hr(1 / 1.2),
|
|
6008
6015
|
zoom100: () => U.current?.zoom100(),
|
|
6009
6016
|
zoomFit: () => U.current?.fit(),
|
|
6010
|
-
toggleMinimap: () =>
|
|
6011
|
-
toggleCursorGuide: () =>
|
|
6017
|
+
toggleMinimap: () => Ke((e) => !e),
|
|
6018
|
+
toggleCursorGuide: () => xt((e) => ({
|
|
6012
6019
|
...e,
|
|
6013
6020
|
showCursorGuide: !e.showCursorGuide
|
|
6014
6021
|
})),
|
|
6015
|
-
togglePixelation: () =>
|
|
6022
|
+
togglePixelation: () => xt((e) => ({
|
|
6016
6023
|
...e,
|
|
6017
6024
|
imageSmoothing: !e.imageSmoothing
|
|
6018
6025
|
})),
|
|
6019
|
-
selectTool: () =>
|
|
6020
|
-
rectangleTool: () =>
|
|
6021
|
-
rotatedRectangleTool: () =>
|
|
6022
|
-
circleTool: () =>
|
|
6023
|
-
polygonTool: () =>
|
|
6024
|
-
pathTool: () =>
|
|
6025
|
-
brushTool: () =>
|
|
6026
|
-
pointTool: () =>
|
|
6026
|
+
selectTool: () => ge?.(G.SELECT),
|
|
6027
|
+
rectangleTool: () => ge?.(G.RECTANGLE),
|
|
6028
|
+
rotatedRectangleTool: () => ge?.(G.ROTATED_RECTANGLE),
|
|
6029
|
+
circleTool: () => ge?.(G.CIRCLE),
|
|
6030
|
+
polygonTool: () => ge?.(G.POLYGON),
|
|
6031
|
+
pathTool: () => ge?.(G.PATH),
|
|
6032
|
+
brushTool: () => ge?.(G.BRUSH),
|
|
6033
|
+
pointTool: () => ge?.(G.POINT)
|
|
6027
6034
|
},
|
|
6028
|
-
spaceRef:
|
|
6029
|
-
shiftRef:
|
|
6035
|
+
spaceRef: Qt,
|
|
6036
|
+
shiftRef: $t,
|
|
6030
6037
|
onSpaceDown: () => {
|
|
6031
|
-
U.current?.setPanMode(!0),
|
|
6038
|
+
U.current?.setPanMode(!0), nn();
|
|
6032
6039
|
},
|
|
6033
6040
|
onSpaceUp: () => {
|
|
6034
|
-
U.current?.setPanMode(!1),
|
|
6041
|
+
U.current?.setPanMode(!1), en.current === "panning" ? rn("idle") : nn();
|
|
6035
6042
|
},
|
|
6036
|
-
nudge:
|
|
6043
|
+
nudge: lr
|
|
6037
6044
|
});
|
|
6038
|
-
let
|
|
6045
|
+
let Dr = E(() => $.filter((e) => J.includes(e.id) && re(e)), [$, J]), kr = E(() => Cn ? [...Dr, Cn] : Dr, [Dr, Cn]), Fr = J.length > 0, Ir = q.shapes.some((e) => J.includes(e.id) && ae(e)), Lr = !Z && J.length === 1 && (() => {
|
|
6039
6046
|
let e = q.shapes.find((e) => e.id === J[0]);
|
|
6040
|
-
return !!e && (e.type ===
|
|
6041
|
-
})(),
|
|
6047
|
+
return !!e && (e.type === I.POLYGON || e.type === I.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
|
|
6048
|
+
})(), Rr = ur(), zr = Z || Rr.length < 2 || (P ? !P(Rr) : !1), Br = !!fe && !Z, Vr = Br && J.length === 1 ? (() => {
|
|
6042
6049
|
let e = q.shapes.find((e) => e.id === J[0]);
|
|
6043
|
-
return e && e.type ===
|
|
6044
|
-
})() : null,
|
|
6050
|
+
return e && e.type === I.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
|
|
6051
|
+
})() : null, Hr = [
|
|
6045
6052
|
{
|
|
6046
6053
|
id: "copy",
|
|
6047
6054
|
label: X.contextMenu.copy,
|
|
6048
6055
|
shortcut: "⌘C",
|
|
6049
|
-
disabled: !
|
|
6050
|
-
onClick:
|
|
6056
|
+
disabled: !Ir,
|
|
6057
|
+
onClick: rr
|
|
6051
6058
|
},
|
|
6052
6059
|
{
|
|
6053
6060
|
id: "paste",
|
|
6054
6061
|
label: X.contextMenu.paste,
|
|
6055
6062
|
shortcut: "⌘V",
|
|
6056
|
-
disabled: Z || !
|
|
6057
|
-
onClick: () =>
|
|
6063
|
+
disabled: Z || !ir(),
|
|
6064
|
+
onClick: () => ar(Ve?.img)
|
|
6058
6065
|
},
|
|
6059
6066
|
{
|
|
6060
6067
|
id: "duplicate",
|
|
6061
6068
|
label: X.contextMenu.duplicate,
|
|
6062
6069
|
shortcut: "⌘D",
|
|
6063
|
-
disabled: !
|
|
6064
|
-
onClick:
|
|
6070
|
+
disabled: !Ir || Z,
|
|
6071
|
+
onClick: or
|
|
6065
6072
|
},
|
|
6066
6073
|
{
|
|
6067
6074
|
id: "delete",
|
|
6068
6075
|
label: X.contextMenu.delete,
|
|
6069
6076
|
shortcut: "Del",
|
|
6070
6077
|
danger: !0,
|
|
6071
|
-
disabled: !
|
|
6072
|
-
onClick:
|
|
6078
|
+
disabled: !Ir || Z,
|
|
6079
|
+
onClick: nr
|
|
6073
6080
|
},
|
|
6074
6081
|
{ separator: !0 },
|
|
6075
6082
|
{
|
|
6076
6083
|
id: "editVertices",
|
|
6077
6084
|
label: X.contextMenu.editVertices,
|
|
6078
6085
|
shortcut: "Enter",
|
|
6079
|
-
disabled: !
|
|
6080
|
-
onClick: () =>
|
|
6086
|
+
disabled: !Lr,
|
|
6087
|
+
onClick: () => un(J[0])
|
|
6081
6088
|
},
|
|
6082
6089
|
{
|
|
6083
6090
|
id: "merge",
|
|
6084
6091
|
label: X.contextMenu.merge,
|
|
6085
|
-
disabled:
|
|
6086
|
-
onClick:
|
|
6092
|
+
disabled: zr,
|
|
6093
|
+
onClick: dr
|
|
6087
6094
|
},
|
|
6088
|
-
...
|
|
6095
|
+
...Br ? [{
|
|
6089
6096
|
id: "assistExpand",
|
|
6090
6097
|
label: X.contextMenu.assistExpand,
|
|
6091
6098
|
icon: /* @__PURE__ */ v(o, { size: 14 }),
|
|
6092
|
-
disabled: !
|
|
6099
|
+
disabled: !Vr,
|
|
6093
6100
|
onClick: () => {
|
|
6094
|
-
|
|
6101
|
+
Ve && Vr && Q.refineShape(Vr, Ve.img, !0);
|
|
6095
6102
|
}
|
|
6096
6103
|
}, {
|
|
6097
6104
|
id: "assistExclude",
|
|
6098
6105
|
label: X.contextMenu.assistExclude,
|
|
6099
6106
|
icon: /* @__PURE__ */ v(o, { size: 14 }),
|
|
6100
|
-
disabled: !
|
|
6107
|
+
disabled: !Vr,
|
|
6101
6108
|
onClick: () => {
|
|
6102
|
-
|
|
6109
|
+
Ve && Vr && Q.refineShape(Vr, Ve.img, !1);
|
|
6103
6110
|
}
|
|
6104
6111
|
}] : [],
|
|
6105
6112
|
{
|
|
6106
6113
|
id: "bringToFront",
|
|
6107
6114
|
label: X.contextMenu.bringToFront,
|
|
6108
|
-
disabled: !
|
|
6109
|
-
onClick:
|
|
6115
|
+
disabled: !Ir || Z,
|
|
6116
|
+
onClick: sr
|
|
6110
6117
|
},
|
|
6111
6118
|
{
|
|
6112
6119
|
id: "sendToBack",
|
|
6113
6120
|
label: X.contextMenu.sendToBack,
|
|
6114
|
-
disabled: !
|
|
6115
|
-
onClick:
|
|
6121
|
+
disabled: !Ir || Z,
|
|
6122
|
+
onClick: cr
|
|
6116
6123
|
},
|
|
6117
6124
|
{ separator: !0 },
|
|
6118
6125
|
{
|
|
6119
6126
|
id: "undo",
|
|
6120
6127
|
label: X.contextMenu.undo,
|
|
6121
6128
|
shortcut: "⌘Z",
|
|
6122
|
-
disabled: Z || !
|
|
6129
|
+
disabled: Z || !Ln() && !q.canUndo(),
|
|
6123
6130
|
onClick: () => {
|
|
6124
|
-
|
|
6131
|
+
Pn() || q.undo();
|
|
6125
6132
|
}
|
|
6126
6133
|
},
|
|
6127
6134
|
{
|
|
6128
6135
|
id: "redo",
|
|
6129
6136
|
label: X.contextMenu.redo,
|
|
6130
6137
|
shortcut: "⇧⌘Z",
|
|
6131
|
-
disabled: Z || !
|
|
6138
|
+
disabled: Z || !Rn() && !q.canRedo(),
|
|
6132
6139
|
onClick: () => {
|
|
6133
|
-
|
|
6140
|
+
In() || q.redo();
|
|
6134
6141
|
}
|
|
6135
6142
|
},
|
|
6136
6143
|
{ separator: !0 },
|
|
@@ -6138,60 +6145,60 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6138
6145
|
id: "selectAll",
|
|
6139
6146
|
label: X.contextMenu.selectAll,
|
|
6140
6147
|
shortcut: "⌘A",
|
|
6141
|
-
onClick:
|
|
6148
|
+
onClick: er
|
|
6142
6149
|
},
|
|
6143
6150
|
{
|
|
6144
6151
|
id: "clearSelection",
|
|
6145
6152
|
label: X.contextMenu.clearSelection,
|
|
6146
|
-
disabled: !
|
|
6147
|
-
onClick:
|
|
6153
|
+
disabled: !Fr,
|
|
6154
|
+
onClick: tr
|
|
6148
6155
|
},
|
|
6149
6156
|
{
|
|
6150
6157
|
id: "zoomToSelection",
|
|
6151
6158
|
label: X.contextMenu.zoomToSelection,
|
|
6152
|
-
disabled: !
|
|
6153
|
-
onClick:
|
|
6159
|
+
disabled: !Fr,
|
|
6160
|
+
onClick: mr
|
|
6154
6161
|
}
|
|
6155
|
-
],
|
|
6162
|
+
], Ur = l ? Hr.filter((e) => "separator" in e || !!e.id && Nr.has(e.id)) : Hr, Wr = M ? M(Ur, {
|
|
6156
6163
|
selectedIds: J,
|
|
6157
6164
|
readOnly: Z
|
|
6158
|
-
}) :
|
|
6165
|
+
}) : Ur, Gr = Er({
|
|
6159
6166
|
engineRef: U,
|
|
6160
6167
|
image: K,
|
|
6161
6168
|
wheelZoom: Y.wheelZoom,
|
|
6162
6169
|
minimapSize: 204
|
|
6163
|
-
}),
|
|
6170
|
+
}), Kr = x(() => {
|
|
6164
6171
|
U.current?.zoom100();
|
|
6165
|
-
}, []), Gr = x(() => {
|
|
6166
|
-
Ge((e) => !e);
|
|
6167
|
-
}, []), Kr = x(() => {
|
|
6168
|
-
qe((e) => !e);
|
|
6169
6172
|
}, []), qr = x(() => {
|
|
6170
|
-
|
|
6173
|
+
Ke((e) => !e);
|
|
6174
|
+
}, []), Jr = x(() => {
|
|
6175
|
+
Je((e) => !e);
|
|
6176
|
+
}, []), Yr = x(() => {
|
|
6177
|
+
Je(!1);
|
|
6171
6178
|
}, []);
|
|
6172
6179
|
return /* @__PURE__ */ y("div", {
|
|
6173
6180
|
className: "aivex:relative aivex:h-full aivex:w-full aivex:overflow-hidden aivex:bg-black",
|
|
6174
6181
|
children: [
|
|
6175
6182
|
/* @__PURE__ */ v("div", {
|
|
6176
|
-
ref:
|
|
6183
|
+
ref: Ee,
|
|
6177
6184
|
className: "aivex:h-full aivex:w-full",
|
|
6178
6185
|
style: {
|
|
6179
|
-
opacity: +!!
|
|
6180
|
-
transition:
|
|
6186
|
+
opacity: +!!Pe,
|
|
6187
|
+
transition: Pe ? "opacity 0.3s ease" : "none"
|
|
6181
6188
|
}
|
|
6182
6189
|
}),
|
|
6183
|
-
|
|
6184
|
-
status:
|
|
6185
|
-
error:
|
|
6190
|
+
ot !== "ready" && /* @__PURE__ */ v(Le, {
|
|
6191
|
+
status: ot,
|
|
6192
|
+
error: lt,
|
|
6186
6193
|
render: n,
|
|
6187
6194
|
loadingLabel: X.imageLoading,
|
|
6188
6195
|
errorLabel: X.imageLoadError,
|
|
6189
6196
|
errorHints: X.imageErrorHints
|
|
6190
6197
|
}),
|
|
6191
|
-
|
|
6198
|
+
ze && K && /* @__PURE__ */ v("div", {
|
|
6192
6199
|
className: "aivex:pointer-events-none aivex:absolute aivex:inset-0 aivex:overflow-hidden",
|
|
6193
6200
|
children: /* @__PURE__ */ y("div", {
|
|
6194
|
-
ref:
|
|
6201
|
+
ref: W,
|
|
6195
6202
|
style: {
|
|
6196
6203
|
position: "absolute",
|
|
6197
6204
|
top: 0,
|
|
@@ -6201,7 +6208,7 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6201
6208
|
transformOrigin: "0 0"
|
|
6202
6209
|
},
|
|
6203
6210
|
children: [
|
|
6204
|
-
!!
|
|
6211
|
+
!!B?.length && V && /* @__PURE__ */ v("div", {
|
|
6205
6212
|
style: {
|
|
6206
6213
|
position: "absolute",
|
|
6207
6214
|
left: 0,
|
|
@@ -6210,16 +6217,16 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6210
6217
|
height: K.h,
|
|
6211
6218
|
pointerEvents: "none"
|
|
6212
6219
|
},
|
|
6213
|
-
children:
|
|
6220
|
+
children: B.map((e) => /* @__PURE__ */ v("div", {
|
|
6214
6221
|
role: e.disabled ? void 0 : "button",
|
|
6215
6222
|
tabIndex: e.disabled ? void 0 : 0,
|
|
6216
6223
|
"aria-pressed": e.selected || void 0,
|
|
6217
6224
|
onPointerDown: (e) => e.stopPropagation(),
|
|
6218
6225
|
onClick: (t) => {
|
|
6219
|
-
t.stopPropagation(), e.disabled ||
|
|
6226
|
+
t.stopPropagation(), e.disabled || se?.(e);
|
|
6220
6227
|
},
|
|
6221
6228
|
onKeyDown: (t) => {
|
|
6222
|
-
e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(),
|
|
6229
|
+
e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(), se?.(e));
|
|
6223
6230
|
},
|
|
6224
6231
|
style: {
|
|
6225
6232
|
position: "absolute",
|
|
@@ -6231,10 +6238,10 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6231
6238
|
pointerEvents: e.disabled ? "none" : "auto",
|
|
6232
6239
|
cursor: e.disabled ? "default" : "pointer"
|
|
6233
6240
|
},
|
|
6234
|
-
children:
|
|
6241
|
+
children: V(e)
|
|
6235
6242
|
}, e.id))
|
|
6236
6243
|
}),
|
|
6237
|
-
|
|
6244
|
+
H?.({
|
|
6238
6245
|
image: K,
|
|
6239
6246
|
viewport: U.current?.viewport ?? {
|
|
6240
6247
|
scale: 1,
|
|
@@ -6242,14 +6249,14 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6242
6249
|
y: 0
|
|
6243
6250
|
}
|
|
6244
6251
|
}),
|
|
6245
|
-
|
|
6246
|
-
shapes:
|
|
6247
|
-
getLabel:
|
|
6248
|
-
hideDot:
|
|
6249
|
-
formatInfo:
|
|
6250
|
-
register:
|
|
6252
|
+
kr.length > 0 && /* @__PURE__ */ v(st, {
|
|
6253
|
+
shapes: kr,
|
|
6254
|
+
getLabel: ce,
|
|
6255
|
+
hideDot: le,
|
|
6256
|
+
formatInfo: ue,
|
|
6257
|
+
register: bn
|
|
6251
6258
|
}),
|
|
6252
|
-
|
|
6259
|
+
fe && (Q.status === "loading" || Q.boxes.length > 0) && /* @__PURE__ */ v(Ne, {
|
|
6253
6260
|
image: K,
|
|
6254
6261
|
points: Q.points,
|
|
6255
6262
|
boxes: Q.boxes,
|
|
@@ -6258,39 +6265,39 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6258
6265
|
]
|
|
6259
6266
|
})
|
|
6260
6267
|
}),
|
|
6261
|
-
|
|
6262
|
-
K &&
|
|
6268
|
+
ze && Y.showCursorGuide && /* @__PURE__ */ v(Ie, { color: "#1e88e5" }),
|
|
6269
|
+
K && D && /* @__PURE__ */ v(Ze, {
|
|
6263
6270
|
image: K,
|
|
6264
|
-
imageUrl:
|
|
6265
|
-
imageVisible:
|
|
6266
|
-
loading: !
|
|
6267
|
-
maskDataUrl:
|
|
6268
|
-
region:
|
|
6269
|
-
roiMaskId:
|
|
6270
|
-
shapes:
|
|
6271
|
+
imageUrl: nt,
|
|
6272
|
+
imageVisible: Pe,
|
|
6273
|
+
loading: !ze,
|
|
6274
|
+
maskDataUrl: Dt,
|
|
6275
|
+
region: Ot,
|
|
6276
|
+
roiMaskId: je,
|
|
6277
|
+
shapes: $,
|
|
6271
6278
|
view: Y,
|
|
6272
|
-
viewDefaults:
|
|
6273
|
-
onChangeView:
|
|
6274
|
-
nav:
|
|
6275
|
-
registerShape:
|
|
6276
|
-
rectRef:
|
|
6277
|
-
zoomLabelRef:
|
|
6278
|
-
onZoom100:
|
|
6279
|
-
open:
|
|
6280
|
-
onToggleOpen:
|
|
6281
|
-
position:
|
|
6279
|
+
viewDefaults: yt,
|
|
6280
|
+
onChangeView: St,
|
|
6281
|
+
nav: Gr,
|
|
6282
|
+
registerShape: hn,
|
|
6283
|
+
rectRef: De,
|
|
6284
|
+
zoomLabelRef: Ae,
|
|
6285
|
+
onZoom100: Kr,
|
|
6286
|
+
open: Ge,
|
|
6287
|
+
onToggleOpen: qr,
|
|
6288
|
+
position: A,
|
|
6282
6289
|
labels: X.minimap,
|
|
6283
6290
|
settingsLabels: X.viewSettings,
|
|
6284
|
-
showSettings:
|
|
6285
|
-
settingsOpen:
|
|
6286
|
-
onToggleSettings:
|
|
6287
|
-
onCloseSettings:
|
|
6291
|
+
showSettings: j,
|
|
6292
|
+
settingsOpen: qe,
|
|
6293
|
+
onToggleSettings: Jr,
|
|
6294
|
+
onCloseSettings: Yr
|
|
6288
6295
|
}),
|
|
6289
|
-
|
|
6290
|
-
x:
|
|
6291
|
-
y:
|
|
6292
|
-
items:
|
|
6293
|
-
onClose: () =>
|
|
6296
|
+
Ve && /* @__PURE__ */ v(Fe, {
|
|
6297
|
+
x: Ve.x,
|
|
6298
|
+
y: Ve.y,
|
|
6299
|
+
items: Wr,
|
|
6300
|
+
onClose: () => He(null)
|
|
6294
6301
|
})
|
|
6295
6302
|
]
|
|
6296
6303
|
});
|
|
@@ -6310,18 +6317,18 @@ function Lr(e, t, n, r) {
|
|
|
6310
6317
|
strokeWidth: r,
|
|
6311
6318
|
pointRadius: 2
|
|
6312
6319
|
});
|
|
6313
|
-
if (e.save(), e.globalAlpha = i.opacity, e.lineWidth = i.strokeWidth / n, e.lineJoin = "round", e.lineCap = "round", t.type ===
|
|
6320
|
+
if (e.save(), e.globalAlpha = i.opacity, e.lineWidth = i.strokeWidth / n, e.lineJoin = "round", e.lineCap = "round", t.type === I.POINT) {
|
|
6314
6321
|
let r = t.points[0];
|
|
6315
6322
|
r && (e.fillStyle = i.color, e.beginPath(), e.arc(r.x, r.y, i.pointRadius / n, 0, Math.PI * 2), e.fill()), e.restore();
|
|
6316
6323
|
return;
|
|
6317
6324
|
}
|
|
6318
|
-
if (t.type ===
|
|
6325
|
+
if (t.type === I.RECTANGLE || t.type === I.ELLIPSE) {
|
|
6319
6326
|
let [n, r] = t.points;
|
|
6320
6327
|
if (n && r) {
|
|
6321
6328
|
let i = Math.min(n.x, r.x), a = Math.min(n.y, r.y), o = Math.abs(r.x - n.x), s = Math.abs(r.y - n.y);
|
|
6322
|
-
e.beginPath(), t.type ===
|
|
6329
|
+
e.beginPath(), t.type === I.ELLIPSE ? e.ellipse(i + o / 2, a + s / 2, o / 2, s / 2, 0, 0, Math.PI * 2) : e.rect(i, a, o, s);
|
|
6323
6330
|
}
|
|
6324
|
-
} else Ir(e, t.points, t.type !==
|
|
6331
|
+
} else Ir(e, t.points, t.type !== I.LINE);
|
|
6325
6332
|
i.fillVisible && (e.save(), e.fillStyle = i.color, e.globalAlpha *= i.fillAlpha, e.fill(), e.restore()), t.style?.alternateColor && i.dash?.length && (e.setLineDash([]), e.strokeStyle = t.style.alternateColor, e.stroke()), e.setLineDash((i.dash ?? []).map((e) => e / n)), e.strokeStyle = i.color, e.stroke(), e.restore();
|
|
6326
6333
|
}
|
|
6327
6334
|
function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes: r = [], regionMask: i, guideMask: a, maskPalette: o, focusedShapeId: s, focusFit: c = "contain", zoomPadding: l = .3, strokeSize: u = 1, brightness: d = 1, contrast: f = 1, imageSmoothing: p = !0, lazy: m = !0, className: h, style: g, renderImageState: _ }) {
|
|
@@ -6360,7 +6367,7 @@ function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6360
6367
|
}, [e, w]), S(() => () => {
|
|
6361
6368
|
C.current = null;
|
|
6362
6369
|
}, []);
|
|
6363
|
-
let
|
|
6370
|
+
let ee = E(() => r.find((e) => e.id === s), [s, r]), te = E(() => a && o ? kt(a, o) : null, [a, o]);
|
|
6364
6371
|
return S(() => {
|
|
6365
6372
|
if (D === "error") {
|
|
6366
6373
|
let e = x.current;
|
|
@@ -6378,11 +6385,11 @@ function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6378
6385
|
let g = n?.width ?? a.naturalWidth, _ = n?.height ?? a.naturalHeight;
|
|
6379
6386
|
if (!g || !_) return;
|
|
6380
6387
|
let v = Math.min(o / g, s / _), y = (o - g * v) / 2, S = (s - _ * v) / 2;
|
|
6381
|
-
if (
|
|
6382
|
-
let e = V(
|
|
6388
|
+
if (ee && ee.points.length > 0) {
|
|
6389
|
+
let e = V(ee.points), t = Math.max(e.maxX - e.minX, 50), n = Math.max(e.maxY - e.minY, 50), r = Math.min(t, n) * l;
|
|
6383
6390
|
v = Math.min(o / (t + r * 2), s / (n + r * 2)), c === "cover" && (v = Math.max(v, Math.max(o / g, s / _))), y = o / 2 - (e.minX + e.maxX) / 2 * v, S = s / 2 - (e.minY + e.maxY) / 2 * v, c === "cover" && (y = Math.min(0, Math.max(y, o - g * v)), S = Math.min(0, Math.max(S, s - _ * v)));
|
|
6384
6391
|
}
|
|
6385
|
-
h.setTransform(m, 0, 0, m, 0, 0), h.clearRect(0, 0, o, s), h.save(), h.translate(y, S), h.scale(v, v), h.imageSmoothingEnabled = p, h.filter = `brightness(${d}) contrast(${f})`, h.drawImage(a, 0, 0, g, _), h.filter = "none",
|
|
6392
|
+
h.setTransform(m, 0, 0, m, 0, 0), h.clearRect(0, 0, o, s), h.save(), h.translate(y, S), h.scale(v, v), h.imageSmoothingEnabled = p, h.filter = `brightness(${d}) contrast(${f})`, h.drawImage(a, 0, 0, g, _), h.filter = "none", te && (h.save(), h.globalAlpha = .55, h.drawImage(te, 0, 0, g, _), h.restore());
|
|
6386
6393
|
let w = i ? Vt(i, g, _) : null;
|
|
6387
6394
|
if (w && (It(h, w, g, _), w.outlineStyles)) {
|
|
6388
6395
|
let e = (e, t) => {
|
|
@@ -6396,16 +6403,16 @@ function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6396
6403
|
};
|
|
6397
6404
|
e(w.visibleOutline, w.outlineStyles.visible), e(w.occludedOutline, w.outlineStyles.occluded);
|
|
6398
6405
|
}
|
|
6399
|
-
for (let e of
|
|
6406
|
+
for (let e of z(r)) Lr(h, e, v, u);
|
|
6400
6407
|
h.restore();
|
|
6401
6408
|
}, [
|
|
6402
6409
|
d,
|
|
6403
6410
|
f,
|
|
6404
6411
|
n,
|
|
6405
|
-
|
|
6412
|
+
ee,
|
|
6406
6413
|
c,
|
|
6407
6414
|
p,
|
|
6408
|
-
|
|
6415
|
+
te,
|
|
6409
6416
|
i,
|
|
6410
6417
|
r,
|
|
6411
6418
|
N,
|
|
@@ -6465,6 +6472,6 @@ function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6465
6472
|
});
|
|
6466
6473
|
}
|
|
6467
6474
|
//#endregion
|
|
6468
|
-
export { W as DEFAULT_EDITOR_STRINGS, ke as DEFAULT_VIEW_SETTINGS,
|
|
6475
|
+
export { W as DEFAULT_EDITOR_STRINGS, ke as DEFAULT_VIEW_SETTINGS, I as SHAPE_TYPE, Fr as ShapeEditor, Fr as default, Rr as ShapeViewer, G as TOOL, oe as generateId };
|
|
6469
6476
|
|
|
6470
6477
|
//# sourceMappingURL=shape-editor.js.map
|