@glodon-aiot/dataset-annotation 3.10.0-alpha.21 → 3.10.0-alpha.22
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/es/components/DetectionAnnotation/components/LabelMaker/Drawable.mjs +12 -12
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +122 -97
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +197 -162
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.mjs +75 -34
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +159 -131
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +59 -48
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +158 -154
- package/dist/es/index.mjs +1 -1
- package/dist/lib/index.js +3 -3
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.d.ts +2 -1
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +2 -1
- package/package.json +2 -2
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
var
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { fabric as
|
|
5
|
-
import { useKeyPress as
|
|
1
|
+
var Q = Math.pow;
|
|
2
|
+
import { jsx as c, jsxs as $ } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as ae, useState as x, useEffect as d } from "react";
|
|
4
|
+
import { fabric as z } from "fabric";
|
|
5
|
+
import { useKeyPress as O } from "ahooks";
|
|
6
6
|
import "./style.less.mjs";
|
|
7
|
-
import
|
|
8
|
-
import { Spin as
|
|
9
|
-
import
|
|
10
|
-
import { drawable as
|
|
11
|
-
import { ZoomInOutlined as
|
|
7
|
+
import ce from "react-dom";
|
|
8
|
+
import { Spin as le, Space as fe, Tooltip as R, Button as X } from "antd";
|
|
9
|
+
import V from "./RectLabel.mjs";
|
|
10
|
+
import { drawable as ue } from "./Drawable.mjs";
|
|
11
|
+
import { ZoomInOutlined as de, ZoomOutOutlined as me, DragOutlined as ge } from "@ant-design/icons";
|
|
12
12
|
import he from "classnames";
|
|
13
13
|
import { approxeq as L } from "../../../../utils/index.mjs";
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
var
|
|
18
|
-
let
|
|
19
|
-
(
|
|
20
|
-
const
|
|
14
|
+
const ee = (s) => {
|
|
15
|
+
s.off("mouse:down"), s.off("mouse:up");
|
|
16
|
+
}, E = (s) => {
|
|
17
|
+
var i, j, f;
|
|
18
|
+
let a = [];
|
|
19
|
+
(i = s.object) != null && i.aCoords && (a = [s.object.aCoords.tl, s.object.aCoords.tr, s.object.aCoords.br, s.object.aCoords.bl]);
|
|
20
|
+
const l = {
|
|
21
21
|
x: 0,
|
|
22
22
|
y: 0
|
|
23
|
-
},
|
|
23
|
+
}, m = {
|
|
24
24
|
width: 0,
|
|
25
25
|
height: 0
|
|
26
26
|
};
|
|
27
|
-
return
|
|
28
|
-
id:
|
|
29
|
-
label:
|
|
30
|
-
color:
|
|
31
|
-
box: (
|
|
27
|
+
return s.canvas.backgroundImage && typeof s.canvas.backgroundImage != "string" && (l.x = ((j = s.canvas.backgroundImage.aCoords) == null ? void 0 : j.tl.x) || 0, l.y = ((f = s.canvas.backgroundImage.aCoords) == null ? void 0 : f.tl.y) || 0, m.width = s.canvas.backgroundImage.width || 0, m.height = s.canvas.backgroundImage.height || 0), {
|
|
28
|
+
id: s.config.id,
|
|
29
|
+
label: s.config.name,
|
|
30
|
+
color: s.config.color,
|
|
31
|
+
box: (a == null ? void 0 : a.map((h) => [L(h.x - l.x, 0) ? 0 : L(h.x - l.x, m.width) ? m.width : h.x - l.x, L(h.y - l.y, 0) ? 0 : L(h.y - l.y, m.height) ? m.height : h.y - l.y])) || []
|
|
32
32
|
};
|
|
33
|
-
},
|
|
34
|
-
const
|
|
35
|
-
labels:
|
|
36
|
-
imageUrl:
|
|
37
|
-
pen:
|
|
38
|
-
onImageLoad:
|
|
33
|
+
}, Le = (s) => {
|
|
34
|
+
const a = ae(null), {
|
|
35
|
+
labels: l,
|
|
36
|
+
imageUrl: m,
|
|
37
|
+
pen: i,
|
|
38
|
+
onImageLoad: j,
|
|
39
39
|
onChange: f,
|
|
40
|
-
isPreLabel:
|
|
41
|
-
disabled:
|
|
42
|
-
renderLabelItem:
|
|
43
|
-
} =
|
|
40
|
+
isPreLabel: h,
|
|
41
|
+
disabled: k,
|
|
42
|
+
renderLabelItem: N
|
|
43
|
+
} = s, [S, B] = x(!0), [e, Z] = x(), [pe, te] = x({}), [I, _] = x(), [W, oe] = x({
|
|
44
44
|
left: 0,
|
|
45
45
|
top: 0
|
|
46
|
-
}), [
|
|
46
|
+
}), [re, A] = x([1, 1]), [M, H] = x(), [b, v] = x([]), [y, P] = x(k || !1), T = (t, o) => {
|
|
47
47
|
if (!e)
|
|
48
48
|
return;
|
|
49
49
|
o || (o = {
|
|
50
50
|
x: e.getCenter().left,
|
|
51
51
|
y: e.getCenter().top
|
|
52
52
|
});
|
|
53
|
-
let
|
|
54
|
-
|
|
53
|
+
let r = e.getZoom();
|
|
54
|
+
r *= Q(0.999, t), r > 20 && (r = 20), r < 0.01 && (r = 0.01), e.zoomToPoint(
|
|
55
55
|
o,
|
|
56
|
-
|
|
56
|
+
r
|
|
57
57
|
// 传入修改后的缩放级别
|
|
58
|
-
),
|
|
58
|
+
), A([r, r]);
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
d(() => {
|
|
61
|
+
b.forEach((t) => {
|
|
62
62
|
t.renderLabel();
|
|
63
63
|
});
|
|
64
|
-
}, [
|
|
65
|
-
const
|
|
66
|
-
var
|
|
67
|
-
if (((
|
|
64
|
+
}, [re, b, e]);
|
|
65
|
+
const K = (t) => {
|
|
66
|
+
var r;
|
|
67
|
+
if (((r = t.target) == null ? void 0 : r.tagName) === "INPUT" || !e)
|
|
68
68
|
return;
|
|
69
69
|
const o = e == null ? void 0 : e.getActiveObject();
|
|
70
|
-
o && v((
|
|
71
|
-
const
|
|
72
|
-
return
|
|
70
|
+
o && v((n) => {
|
|
71
|
+
const g = n.findIndex((C) => C.object === o);
|
|
72
|
+
return n[g] && (n[g].destroy(), n.splice(g, 1)), f && f(n.map(E)), [...n];
|
|
73
73
|
});
|
|
74
74
|
};
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
O("Delete", K), O("Backspace", K), O("ctrl", () => {
|
|
76
|
+
P(!0);
|
|
77
77
|
}, {
|
|
78
78
|
events: ["keydown"]
|
|
79
|
-
}),
|
|
80
|
-
|
|
79
|
+
}), O("ctrl", () => {
|
|
80
|
+
k || P(!1);
|
|
81
81
|
}, {
|
|
82
82
|
events: ["keyup"]
|
|
83
|
-
}),
|
|
84
|
-
|
|
85
|
-
}, [
|
|
83
|
+
}), d(() => {
|
|
84
|
+
P(k || !1);
|
|
85
|
+
}, [k]);
|
|
86
86
|
const q = (t) => {
|
|
87
|
-
e &&
|
|
88
|
-
const
|
|
89
|
-
return
|
|
87
|
+
e && ee(e), v((o) => {
|
|
88
|
+
const r = o.findIndex((n) => n === t);
|
|
89
|
+
return r > -1 && (o.splice(r, 1), f && f(o.map(E)), U()), [...o];
|
|
90
90
|
});
|
|
91
91
|
}, F = (t) => {
|
|
92
92
|
v((o) => {
|
|
93
|
-
const
|
|
94
|
-
return
|
|
93
|
+
const r = o.findIndex((n) => n === t);
|
|
94
|
+
return r > -1 && (o[r] = t, f && f(o.map(E))), [...o];
|
|
95
95
|
});
|
|
96
96
|
};
|
|
97
|
-
|
|
97
|
+
d(() => {
|
|
98
98
|
if (!e)
|
|
99
99
|
return;
|
|
100
100
|
const t = [];
|
|
101
|
-
return
|
|
102
|
-
t.push(new
|
|
101
|
+
return l.filter((o) => o.color).forEach((o) => {
|
|
102
|
+
t.push(new V({
|
|
103
103
|
id: o.id,
|
|
104
104
|
name: o.label,
|
|
105
105
|
color: o.color,
|
|
106
|
-
points: o.box.map((
|
|
107
|
-
hideDelete:
|
|
106
|
+
points: o.box.map((r) => [r[0] + W.left, r[1] + W.top]),
|
|
107
|
+
hideDelete: h
|
|
108
108
|
}, e, {
|
|
109
109
|
onChange: F,
|
|
110
110
|
onDelete: q,
|
|
111
|
-
renderLabelItem:
|
|
111
|
+
renderLabelItem: N ? (r) => N ? N(o) : r.name : void 0
|
|
112
112
|
}));
|
|
113
113
|
}), v(t), t.forEach((o) => {
|
|
114
114
|
o.render(e);
|
|
@@ -117,199 +117,234 @@ const $ = (r) => {
|
|
|
117
117
|
o.canvas !== e && o.destroy();
|
|
118
118
|
});
|
|
119
119
|
};
|
|
120
|
-
}, [e,
|
|
121
|
-
const
|
|
122
|
-
e &&
|
|
123
|
-
const o = new
|
|
124
|
-
id: (
|
|
125
|
-
name: (
|
|
126
|
-
color: (
|
|
127
|
-
points: t.box.map((
|
|
128
|
-
hideDelete:
|
|
120
|
+
}, [e, m]);
|
|
121
|
+
const U = () => {
|
|
122
|
+
e && ue(e, (t) => {
|
|
123
|
+
const o = new V({
|
|
124
|
+
id: (i == null ? void 0 : i.id) || t.id,
|
|
125
|
+
name: (i == null ? void 0 : i.label) || t.label,
|
|
126
|
+
color: (i == null ? void 0 : i.color) || t.color,
|
|
127
|
+
points: t.box.map((r) => [r[0], r[1]]),
|
|
128
|
+
hideDelete: h
|
|
129
129
|
}, e, {
|
|
130
130
|
onChange: F,
|
|
131
131
|
onDelete: q
|
|
132
132
|
});
|
|
133
|
-
o.active = !0,
|
|
134
|
-
},
|
|
135
|
-
},
|
|
133
|
+
o.active = !0, b.push(o), f && f(b.map(E)), v([...b]);
|
|
134
|
+
}, h);
|
|
135
|
+
}, ne = () => {
|
|
136
136
|
let t = !1;
|
|
137
137
|
e && (e.on("mouse:down", (o) => {
|
|
138
138
|
t = !0, e.selection = !1;
|
|
139
139
|
}), e.on("mouse:move", (o) => {
|
|
140
140
|
if (t && o && o.e) {
|
|
141
|
-
const
|
|
142
|
-
e.relativePan(
|
|
141
|
+
const r = new z.Point(o.e.movementX, o.e.movementY);
|
|
142
|
+
e.relativePan(r);
|
|
143
143
|
}
|
|
144
144
|
}), e.on("mouse:up", (o) => {
|
|
145
145
|
t = !1, e.selection = !0;
|
|
146
146
|
}));
|
|
147
|
-
},
|
|
147
|
+
}, se = () => {
|
|
148
148
|
e && (e.off("mouse:down"), e.off("mouse:move"), e.off("mouse:up"));
|
|
149
149
|
};
|
|
150
|
-
|
|
150
|
+
d(() => {
|
|
151
|
+
if (!e)
|
|
152
|
+
return;
|
|
153
|
+
const t = (o) => {
|
|
154
|
+
const r = e, n = r == null ? void 0 : r._currentTransform;
|
|
155
|
+
if (!n)
|
|
156
|
+
return;
|
|
157
|
+
const g = n.action;
|
|
158
|
+
if (!g || !g.startsWith("scale"))
|
|
159
|
+
return;
|
|
160
|
+
const C = e.backgroundImage, u = C == null ? void 0 : C.aCoords;
|
|
161
|
+
if (!u)
|
|
162
|
+
return;
|
|
163
|
+
const D = e.getPointer(o.e);
|
|
164
|
+
if (D.x < u.tl.x || D.x > u.br.x || D.y < u.tl.y || D.y > u.br.y) {
|
|
165
|
+
const w = r == null ? void 0 : r._onMouseUp;
|
|
166
|
+
typeof w == "function" && w(o.e);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
return e.on("mouse:move", t), () => {
|
|
170
|
+
e.off("mouse:move", t);
|
|
171
|
+
};
|
|
172
|
+
}, [e]), d(() => {
|
|
173
|
+
if (!e)
|
|
174
|
+
return;
|
|
175
|
+
const t = (o) => {
|
|
176
|
+
const r = e;
|
|
177
|
+
if (!!!(r != null && r._currentTransform))
|
|
178
|
+
return;
|
|
179
|
+
const g = r == null ? void 0 : r._onMouseUp;
|
|
180
|
+
typeof g == "function" && g(o.e);
|
|
181
|
+
};
|
|
182
|
+
return e.on("mouse:out", t), () => {
|
|
183
|
+
e.off("mouse:out", t);
|
|
184
|
+
};
|
|
185
|
+
}, [e]), d(() => {
|
|
151
186
|
if (e)
|
|
152
|
-
return
|
|
187
|
+
return y ? (ne(), e.defaultCursor = "grab", e.on("mouse:down:before", () => {
|
|
153
188
|
e.setCursor("grabbing");
|
|
154
189
|
}), e.on("mouse:up", () => {
|
|
155
190
|
e.defaultCursor = "grab";
|
|
156
191
|
}), e.getObjects(), v((t) => (t.forEach((o) => {
|
|
157
|
-
var
|
|
158
|
-
return (
|
|
192
|
+
var r;
|
|
193
|
+
return (r = o.object) == null ? void 0 : r.set("evented", !1);
|
|
159
194
|
}), t))) : (e.defaultCursor = "default", e.off("mouse:down:before"), e.off("mouse:up"), e.setCursor("default"), v((t) => (t.forEach((o) => {
|
|
160
|
-
var
|
|
161
|
-
return (
|
|
162
|
-
}), t)),
|
|
163
|
-
|
|
195
|
+
var r;
|
|
196
|
+
return (r = o.object) == null ? void 0 : r.set("evented", !0);
|
|
197
|
+
}), t)), U()), () => {
|
|
198
|
+
se();
|
|
164
199
|
};
|
|
165
|
-
}, [e,
|
|
200
|
+
}, [e, y]), d(() => {
|
|
166
201
|
if (e == null || e.on("mouse:wheel", (t) => {
|
|
167
202
|
const o = t.e.deltaY;
|
|
168
|
-
|
|
203
|
+
T(o, {
|
|
169
204
|
x: t.e.offsetX,
|
|
170
205
|
y: t.e.offsetY
|
|
171
|
-
}),
|
|
172
|
-
|
|
206
|
+
}), b.forEach((r) => {
|
|
207
|
+
r.renderLabel();
|
|
173
208
|
});
|
|
174
|
-
}), !
|
|
175
|
-
return
|
|
176
|
-
e && (
|
|
209
|
+
}), !y)
|
|
210
|
+
return U(), () => {
|
|
211
|
+
e && (ee(e), e.off("mouse:wheel"));
|
|
177
212
|
};
|
|
178
|
-
}, [e,
|
|
179
|
-
const
|
|
180
|
-
|
|
213
|
+
}, [e, i, b, y]);
|
|
214
|
+
const ie = () => {
|
|
215
|
+
te({}), _(void 0), A([1, 1]), e == null || e.dispose(), Z(void 0);
|
|
181
216
|
};
|
|
182
|
-
return
|
|
183
|
-
B(!0),
|
|
217
|
+
return d(() => {
|
|
218
|
+
B(!0), ie(), !(!a.current || !m) && z.Image.fromURL(m, (t) => {
|
|
184
219
|
t.set({
|
|
185
220
|
originX: "center",
|
|
186
221
|
originY: "center"
|
|
187
|
-
}),
|
|
222
|
+
}), _(t), B(!1);
|
|
188
223
|
}, {
|
|
189
224
|
crossOrigin: "anonymous"
|
|
190
225
|
});
|
|
191
|
-
}, [
|
|
192
|
-
if (!
|
|
226
|
+
}, [m]), d(() => {
|
|
227
|
+
if (!I && e) {
|
|
193
228
|
try {
|
|
194
229
|
e.clear();
|
|
195
|
-
} catch (
|
|
230
|
+
} catch (Y) {
|
|
196
231
|
}
|
|
197
232
|
return;
|
|
198
233
|
}
|
|
199
|
-
if (!
|
|
234
|
+
if (!a.current || !a.current.parentElement)
|
|
200
235
|
return;
|
|
201
|
-
const t =
|
|
236
|
+
const t = I == null ? void 0 : I.getElement();
|
|
202
237
|
if (!(t != null && t.width) || !(t != null && t.height))
|
|
203
238
|
return;
|
|
204
|
-
const o = t.width / t.height,
|
|
205
|
-
let
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
const
|
|
239
|
+
const o = t.width / t.height, r = a.current.parentElement.offsetWidth, n = a.current.parentElement.offsetHeight, g = r / t.width, C = n / t.height;
|
|
240
|
+
let u = [r, n];
|
|
241
|
+
g > C ? u = [n * o, n] : u = [r, r / o];
|
|
242
|
+
const D = u[0] / t.width, G = u[1] / t.height, w = Math.min(D, G);
|
|
243
|
+
A([w, w]);
|
|
244
|
+
const p = new z.Canvas(a.current, {
|
|
210
245
|
containerClass: "marking-canvas",
|
|
211
|
-
width:
|
|
212
|
-
height:
|
|
246
|
+
width: r,
|
|
247
|
+
height: n
|
|
213
248
|
});
|
|
214
|
-
if (
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
249
|
+
if (p == null || p.setZoom(w), p == null || p.renderAll(), p && I) {
|
|
250
|
+
const Y = (r - u[0]) / w / 2, J = (n - u[1]) / w / 2;
|
|
251
|
+
p.setBackgroundImage(
|
|
252
|
+
I,
|
|
218
253
|
() => {
|
|
219
|
-
|
|
220
|
-
left:
|
|
221
|
-
top:
|
|
222
|
-
}),
|
|
254
|
+
p.renderAll(), oe({
|
|
255
|
+
left: Y,
|
|
256
|
+
top: J
|
|
257
|
+
}), Z(p), j && j();
|
|
223
258
|
},
|
|
224
259
|
// 刷新画布
|
|
225
260
|
{
|
|
226
261
|
originX: "left",
|
|
227
262
|
originY: "top",
|
|
228
|
-
left:
|
|
229
|
-
top:
|
|
263
|
+
left: Y,
|
|
264
|
+
top: J
|
|
230
265
|
}
|
|
231
266
|
);
|
|
232
267
|
}
|
|
233
|
-
}, [
|
|
234
|
-
|
|
235
|
-
|
|
268
|
+
}, [I]), d(() => {
|
|
269
|
+
b.length > l.length && b.forEach((t) => {
|
|
270
|
+
l.find((o) => o.id === t.config.id) || t.destroy();
|
|
236
271
|
});
|
|
237
|
-
}, [
|
|
238
|
-
e && (
|
|
239
|
-
const o = e == null ? void 0 : e.getActiveObject(),
|
|
240
|
-
return
|
|
241
|
-
id:
|
|
242
|
-
name:
|
|
243
|
-
color:
|
|
244
|
-
}, f && f(t.map(
|
|
272
|
+
}, [l.length]), d(() => {
|
|
273
|
+
e && (y || v((t) => {
|
|
274
|
+
const o = e == null ? void 0 : e.getActiveObject(), r = t.find((n) => n.object === o);
|
|
275
|
+
return r && i && (r.labelConfig = {
|
|
276
|
+
id: i.id,
|
|
277
|
+
name: i.label,
|
|
278
|
+
color: i.color
|
|
279
|
+
}, f && f(t.map(E))), e && (i ? e.defaultCursor = "copy" : e.defaultCursor = "default"), [...t];
|
|
245
280
|
}));
|
|
246
|
-
}, [
|
|
281
|
+
}, [i, e, y]), d(() => {
|
|
247
282
|
var t;
|
|
248
|
-
if (
|
|
283
|
+
if (S && a.current && !M) {
|
|
249
284
|
const o = document.createElement("div");
|
|
250
|
-
o.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (t =
|
|
285
|
+
o.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (t = a.current.parentElement) == null || t.appendChild(o), ce.render(/* @__PURE__ */ c(le, {}), o), H(o);
|
|
251
286
|
} else
|
|
252
|
-
!
|
|
253
|
-
}, [
|
|
287
|
+
!S && M && (M.remove(), H(null));
|
|
288
|
+
}, [S, a.current, M]), /* @__PURE__ */ $("div", {
|
|
254
289
|
style: {
|
|
255
290
|
width: "100%",
|
|
256
291
|
height: "100%",
|
|
257
292
|
display: "flex"
|
|
258
293
|
},
|
|
259
|
-
children: [/* @__PURE__ */
|
|
294
|
+
children: [/* @__PURE__ */ c("div", {
|
|
260
295
|
className: "marker-toolbar",
|
|
261
|
-
children: /* @__PURE__ */
|
|
296
|
+
children: /* @__PURE__ */ c("div", {
|
|
262
297
|
className: "create-mode-select",
|
|
263
|
-
children: /* @__PURE__ */
|
|
298
|
+
children: /* @__PURE__ */ $(fe, {
|
|
264
299
|
direction: "vertical",
|
|
265
300
|
size: 16,
|
|
266
|
-
children: [/* @__PURE__ */
|
|
301
|
+
children: [/* @__PURE__ */ c(R, {
|
|
267
302
|
title: "放大-鼠标滚轮前滑",
|
|
268
303
|
placement: "right",
|
|
269
|
-
children: /* @__PURE__ */
|
|
270
|
-
icon: /* @__PURE__ */
|
|
304
|
+
children: /* @__PURE__ */ c(X, {
|
|
305
|
+
icon: /* @__PURE__ */ c(de, {}),
|
|
271
306
|
onClick: () => {
|
|
272
|
-
|
|
307
|
+
T(-100);
|
|
273
308
|
}
|
|
274
309
|
})
|
|
275
|
-
}), /* @__PURE__ */
|
|
310
|
+
}), /* @__PURE__ */ c(R, {
|
|
276
311
|
title: "缩小-鼠标滚轮后滑",
|
|
277
312
|
placement: "right",
|
|
278
|
-
children: /* @__PURE__ */
|
|
279
|
-
icon: /* @__PURE__ */
|
|
313
|
+
children: /* @__PURE__ */ c(X, {
|
|
314
|
+
icon: /* @__PURE__ */ c(me, {}),
|
|
280
315
|
onClick: () => {
|
|
281
|
-
|
|
316
|
+
T(100);
|
|
282
317
|
}
|
|
283
318
|
})
|
|
284
|
-
}), !
|
|
319
|
+
}), !k && /* @__PURE__ */ c(R, {
|
|
285
320
|
title: "拖动-按住ctrl",
|
|
286
321
|
placement: "right",
|
|
287
|
-
children: /* @__PURE__ */
|
|
288
|
-
disabled:
|
|
289
|
-
icon: /* @__PURE__ */
|
|
290
|
-
className:
|
|
322
|
+
children: /* @__PURE__ */ c(X, {
|
|
323
|
+
disabled: k,
|
|
324
|
+
icon: /* @__PURE__ */ c(ge, {}),
|
|
325
|
+
className: y ? "active" : "",
|
|
291
326
|
onClick: () => {
|
|
292
|
-
|
|
327
|
+
P(!y);
|
|
293
328
|
}
|
|
294
329
|
})
|
|
295
330
|
})]
|
|
296
331
|
})
|
|
297
332
|
})
|
|
298
|
-
}), /* @__PURE__ */
|
|
333
|
+
}), /* @__PURE__ */ c("div", {
|
|
299
334
|
className: he({
|
|
300
335
|
"label-maker-wrap": !0,
|
|
301
|
-
draggable:
|
|
336
|
+
draggable: y
|
|
302
337
|
}),
|
|
303
338
|
onContextMenu: (t) => {
|
|
304
339
|
t.preventDefault();
|
|
305
340
|
},
|
|
306
|
-
children: /* @__PURE__ */
|
|
341
|
+
children: /* @__PURE__ */ c("canvas", {
|
|
307
342
|
className: "label-maker-canvas",
|
|
308
|
-
ref:
|
|
343
|
+
ref: a
|
|
309
344
|
})
|
|
310
345
|
})]
|
|
311
346
|
});
|
|
312
347
|
};
|
|
313
348
|
export {
|
|
314
|
-
|
|
349
|
+
Le as default
|
|
315
350
|
};
|
|
@@ -1,27 +1,58 @@
|
|
|
1
1
|
import { useEffect as b } from "react";
|
|
2
|
-
import { fabric as
|
|
3
|
-
const
|
|
2
|
+
import { fabric as u } from "fabric";
|
|
3
|
+
const O = ({
|
|
4
4
|
canvas: e,
|
|
5
|
-
draggable:
|
|
6
|
-
drawingMode: f
|
|
5
|
+
draggable: i,
|
|
6
|
+
drawingMode: f,
|
|
7
|
+
textLayersMapRef: n
|
|
7
8
|
}) => {
|
|
9
|
+
const s = () => {
|
|
10
|
+
const c = /* @__PURE__ */ new Set();
|
|
11
|
+
return n.current.forEach((l) => {
|
|
12
|
+
l.forEach((r) => {
|
|
13
|
+
c.add(r);
|
|
14
|
+
});
|
|
15
|
+
}), c;
|
|
16
|
+
};
|
|
8
17
|
b(() => {
|
|
9
18
|
if (!e || f) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
if (e) {
|
|
20
|
+
e.selection = !1, e.skipTargetFind = !1;
|
|
21
|
+
const o = s();
|
|
22
|
+
e.getObjects().forEach((t) => {
|
|
23
|
+
t instanceof u.Rect && o.has(t) ? t.set({
|
|
24
|
+
evented: !0,
|
|
25
|
+
selectable: !1,
|
|
26
|
+
lockMovementX: !0,
|
|
27
|
+
lockMovementY: !0,
|
|
28
|
+
lockScalingX: !0,
|
|
29
|
+
lockScalingY: !0,
|
|
30
|
+
lockRotation: !0
|
|
31
|
+
}) : t.set({
|
|
32
|
+
evented: !0,
|
|
33
|
+
selectable: !0,
|
|
34
|
+
lockMovementX: !1,
|
|
35
|
+
lockMovementY: !1,
|
|
36
|
+
lockScalingX: !1,
|
|
37
|
+
lockScalingY: !1
|
|
38
|
+
});
|
|
39
|
+
}), e.defaultCursor = "default", e.setCursor("default");
|
|
40
|
+
}
|
|
20
41
|
return;
|
|
21
42
|
}
|
|
22
|
-
if (!
|
|
23
|
-
e.selection = !1, e.skipTargetFind = !1
|
|
24
|
-
|
|
43
|
+
if (!i) {
|
|
44
|
+
e.selection = !1, e.skipTargetFind = !1;
|
|
45
|
+
const o = s();
|
|
46
|
+
e.getObjects().forEach((t) => {
|
|
47
|
+
t instanceof u.Rect && o.has(t) ? t.set({
|
|
48
|
+
evented: !0,
|
|
49
|
+
selectable: !1,
|
|
50
|
+
lockMovementX: !0,
|
|
51
|
+
lockMovementY: !0,
|
|
52
|
+
lockScalingX: !0,
|
|
53
|
+
lockScalingY: !0,
|
|
54
|
+
lockRotation: !0
|
|
55
|
+
}) : t.set({
|
|
25
56
|
evented: !0,
|
|
26
57
|
selectable: !0,
|
|
27
58
|
lockMovementX: !1,
|
|
@@ -32,8 +63,8 @@ const j = ({
|
|
|
32
63
|
}), e.defaultCursor = "default", e.setCursor("default");
|
|
33
64
|
return;
|
|
34
65
|
}
|
|
35
|
-
e.selection = !1, e.skipTargetFind = !0, e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), e.getObjects().forEach((
|
|
36
|
-
|
|
66
|
+
e.selection = !1, e.skipTargetFind = !0, e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), e.getObjects().forEach((o) => {
|
|
67
|
+
o.set({
|
|
37
68
|
evented: !1,
|
|
38
69
|
selectable: !1,
|
|
39
70
|
lockMovementX: !0,
|
|
@@ -43,22 +74,32 @@ const j = ({
|
|
|
43
74
|
lockRotation: !0
|
|
44
75
|
});
|
|
45
76
|
}), e.defaultCursor = "grab";
|
|
46
|
-
let
|
|
47
|
-
const
|
|
48
|
-
e.getActiveObject() && (e.discardActiveObject(), e.renderAll()),
|
|
49
|
-
},
|
|
50
|
-
if (
|
|
51
|
-
const
|
|
52
|
-
e.relativePan(
|
|
77
|
+
let l = !1;
|
|
78
|
+
const r = (o) => {
|
|
79
|
+
e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), l = !0, e.selection = !1, e.skipTargetFind = !0, e.setCursor("grabbing");
|
|
80
|
+
}, d = (o) => {
|
|
81
|
+
if (l && o && o.e) {
|
|
82
|
+
const t = o.e, m = new u.Point(t.movementX, t.movementY);
|
|
83
|
+
e.relativePan(m);
|
|
53
84
|
}
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
},
|
|
85
|
+
}, k = () => {
|
|
86
|
+
l = !1, e.selection = !1, e.skipTargetFind = !0, e.defaultCursor = "grab", e.setCursor("grab"), e.getActiveObject() && (e.discardActiveObject(), e.renderAll());
|
|
87
|
+
}, g = () => {
|
|
57
88
|
e.setCursor("grabbing");
|
|
58
89
|
};
|
|
59
|
-
return e.on("mouse:down",
|
|
60
|
-
e.off("mouse:down",
|
|
61
|
-
|
|
90
|
+
return e.on("mouse:down", r), e.on("mouse:move", d), e.on("mouse:up", k), e.on("mouse:down:before", g), () => {
|
|
91
|
+
e.off("mouse:down", r), e.off("mouse:move", d), e.off("mouse:up", k), e.off("mouse:down:before", g), e.selection = !1, e.skipTargetFind = !1;
|
|
92
|
+
const o = s();
|
|
93
|
+
e.getObjects().forEach((t) => {
|
|
94
|
+
t instanceof u.Rect && o.has(t) ? t.set({
|
|
95
|
+
evented: !0,
|
|
96
|
+
selectable: !1,
|
|
97
|
+
lockMovementX: !0,
|
|
98
|
+
lockMovementY: !0,
|
|
99
|
+
lockScalingX: !0,
|
|
100
|
+
lockScalingY: !0,
|
|
101
|
+
lockRotation: !0
|
|
102
|
+
}) : t.set({
|
|
62
103
|
evented: !0,
|
|
63
104
|
selectable: !0,
|
|
64
105
|
lockMovementX: !1,
|
|
@@ -68,8 +109,8 @@ const j = ({
|
|
|
68
109
|
});
|
|
69
110
|
});
|
|
70
111
|
};
|
|
71
|
-
}, [e,
|
|
112
|
+
}, [e, i, f, n]);
|
|
72
113
|
};
|
|
73
114
|
export {
|
|
74
|
-
|
|
115
|
+
O as useCanvasDrag
|
|
75
116
|
};
|