@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,19 +1,19 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var Pe = Object.defineProperty, Ue = Object.defineProperties;
|
|
2
|
+
var be = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var le = Object.getOwnPropertySymbols;
|
|
4
4
|
var Xe = Object.prototype.hasOwnProperty, We = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var ge = (s, f, a) => f in s ?
|
|
5
|
+
var ge = (s, f, a) => f in s ? Pe(s, f, { enumerable: !0, configurable: !0, writable: !0, value: a }) : s[f] = a, q = (s, f) => {
|
|
6
6
|
for (var a in f || (f = {}))
|
|
7
7
|
Xe.call(f, a) && ge(s, a, f[a]);
|
|
8
|
-
if (
|
|
9
|
-
for (var a of
|
|
8
|
+
if (le)
|
|
9
|
+
for (var a of le(f))
|
|
10
10
|
We.call(f, a) && ge(s, a, f[a]);
|
|
11
11
|
return s;
|
|
12
|
-
}, he = (s, f) =>
|
|
13
|
-
import { jsxs as Re, jsx as
|
|
14
|
-
import { useRef as
|
|
15
|
-
import { fabric as
|
|
16
|
-
import { useKeyPress as
|
|
12
|
+
}, he = (s, f) => Ue(s, be(f));
|
|
13
|
+
import { jsxs as Re, jsx as S } from "react/jsx-runtime";
|
|
14
|
+
import { useRef as h, useState as A, useCallback as P, useEffect as l } from "react";
|
|
15
|
+
import { fabric as U } from "fabric";
|
|
16
|
+
import { useKeyPress as b } from "ahooks";
|
|
17
17
|
import Oe from "classnames";
|
|
18
18
|
import "./style.less.mjs";
|
|
19
19
|
import Fe from "../components/Toolbar.mjs";
|
|
@@ -39,36 +39,36 @@ const Wt = ({
|
|
|
39
39
|
labelDefinitions: f,
|
|
40
40
|
labels: a,
|
|
41
41
|
onImageLoad: pe,
|
|
42
|
-
onChange:
|
|
42
|
+
onChange: k,
|
|
43
43
|
onRegionSelect: J,
|
|
44
44
|
onRegionChange: H,
|
|
45
45
|
ocrRecognize: ve,
|
|
46
|
-
activeLabelValue:
|
|
46
|
+
activeLabelValue: R,
|
|
47
47
|
onClearActive: Z,
|
|
48
48
|
selectedRegion: Q,
|
|
49
49
|
onAppendTextToActive: Ee,
|
|
50
50
|
readOnly: c
|
|
51
51
|
}) => {
|
|
52
52
|
var ue, me;
|
|
53
|
-
const V =
|
|
53
|
+
const V = h(null), v = h(null), [Te, Ce] = A(!0), [e, Ne] = A(), [D, Ie] = A(), [p, ee] = A(1), [E, _] = A(c || !1), [T, I] = A(!1), [K, Ae] = A({
|
|
54
54
|
left: 0,
|
|
55
55
|
top: 0
|
|
56
|
-
}),
|
|
56
|
+
}), X = h({
|
|
57
57
|
left: 0,
|
|
58
58
|
top: 0
|
|
59
|
-
}), ke =
|
|
59
|
+
}), ke = h({
|
|
60
60
|
width: 0,
|
|
61
61
|
height: 0
|
|
62
|
-
}), u =
|
|
62
|
+
}), u = h(/* @__PURE__ */ new Map()), te = h(null), oe = h(void 0), re = h(!1), ne = h(!1), W = h({
|
|
63
63
|
width: 0,
|
|
64
64
|
height: 0
|
|
65
|
-
}), se =
|
|
65
|
+
}), se = h(!1), {
|
|
66
66
|
updateOCRLoadingIcon: we,
|
|
67
67
|
ocrLoadingIconMapRef: w
|
|
68
68
|
} = Ye(e), {
|
|
69
|
-
updateRegionNameText:
|
|
69
|
+
updateRegionNameText: O,
|
|
70
70
|
regionNameTextMapRef: C
|
|
71
|
-
} = je(e), ie = ye(s == null ? void 0 : s.fileUrl), xe =
|
|
71
|
+
} = je(e), ie = ye(s == null ? void 0 : s.fileUrl), xe = P((o) => {
|
|
72
72
|
e && (C.current.forEach((t, r) => {
|
|
73
73
|
const n = r.left || 0, i = r.top || 0;
|
|
74
74
|
t.set({
|
|
@@ -83,15 +83,15 @@ const Wt = ({
|
|
|
83
83
|
});
|
|
84
84
|
}), e.renderAll());
|
|
85
85
|
}, [e]), {
|
|
86
|
-
updateCanvas:
|
|
86
|
+
updateCanvas: L
|
|
87
87
|
} = Ze({
|
|
88
88
|
sample: s,
|
|
89
|
-
image:
|
|
89
|
+
image: D,
|
|
90
90
|
onImageLoad: pe,
|
|
91
91
|
canvasRef: V,
|
|
92
|
-
containerRef:
|
|
92
|
+
containerRef: v,
|
|
93
93
|
canvasInitializedRef: re,
|
|
94
|
-
bgImagePositionRef:
|
|
94
|
+
bgImagePositionRef: X,
|
|
95
95
|
bgImageSizeRef: ke,
|
|
96
96
|
rectMapRef: u,
|
|
97
97
|
updateTextLayersRef: te,
|
|
@@ -101,124 +101,124 @@ const Wt = ({
|
|
|
101
101
|
setScale: ee,
|
|
102
102
|
setBgImagePosition: Ae,
|
|
103
103
|
setLoading: Ce
|
|
104
|
-
}), Me =
|
|
104
|
+
}), Me = P(() => {
|
|
105
105
|
const o = Array.from(u.current.values());
|
|
106
106
|
o.forEach((t, r) => {
|
|
107
107
|
t.name = `${rt}${r + 1}`;
|
|
108
108
|
}), u.current.forEach((t, r) => {
|
|
109
109
|
const n = C.current.get(r);
|
|
110
110
|
n && (n.set("text", t.name || nt), e == null || e.renderAll());
|
|
111
|
-
}),
|
|
112
|
-
}, [
|
|
111
|
+
}), k && k(o);
|
|
112
|
+
}, [k, e]), {
|
|
113
113
|
zoom: Se
|
|
114
114
|
} = Ve({
|
|
115
115
|
canvas: e,
|
|
116
116
|
setScale: ee,
|
|
117
117
|
isZoomingRef: se
|
|
118
|
-
}),
|
|
119
|
-
(o, t) => tt(o, t, e,
|
|
120
|
-
[e,
|
|
118
|
+
}), F = P(
|
|
119
|
+
(o, t) => tt(o, t, e, D, X),
|
|
120
|
+
[e, D, K]
|
|
121
121
|
// 添加 bgImagePosition 作为依赖,确保在图片位置更新后函数能正确工作
|
|
122
|
-
), $ =
|
|
123
|
-
(o, t) => ot(o, t, e,
|
|
122
|
+
), $ = P(
|
|
123
|
+
(o, t) => ot(o, t, e, X),
|
|
124
124
|
[e, K]
|
|
125
125
|
// 添加 bgImagePosition 作为依赖,确保在图片位置更新后函数能正确工作
|
|
126
126
|
), {
|
|
127
|
-
updateTextLayers:
|
|
128
|
-
textLayersMapRef:
|
|
129
|
-
textLayoutContentMapRef:
|
|
127
|
+
updateTextLayers: Y,
|
|
128
|
+
textLayersMapRef: d,
|
|
129
|
+
textLayoutContentMapRef: j
|
|
130
130
|
} = Ke({
|
|
131
131
|
canvas: e,
|
|
132
132
|
imageToCanvasCoords: $,
|
|
133
|
-
activeLabelValue:
|
|
133
|
+
activeLabelValue: R,
|
|
134
134
|
onAppendTextToActive: Ee
|
|
135
135
|
});
|
|
136
|
-
te.current =
|
|
136
|
+
te.current = Y;
|
|
137
137
|
const {
|
|
138
138
|
performOCRIfNeeded: ce,
|
|
139
139
|
ocrRecognizingRef: ut
|
|
140
140
|
} = qe({
|
|
141
141
|
ocrRecognize: ve,
|
|
142
|
-
onChange:
|
|
143
|
-
updateTextLayers:
|
|
142
|
+
onChange: k,
|
|
143
|
+
updateTextLayers: Y,
|
|
144
144
|
canvas: e,
|
|
145
145
|
updateOCRLoadingIcon: we,
|
|
146
146
|
rectMapRef: u,
|
|
147
|
-
textLayersMapRef:
|
|
148
|
-
textLayoutContentMapRef:
|
|
147
|
+
textLayersMapRef: d,
|
|
148
|
+
textLayoutContentMapRef: j
|
|
149
149
|
}), {
|
|
150
150
|
updateRegionShapeAndImage: ae
|
|
151
151
|
} = $e({
|
|
152
152
|
canvas: e,
|
|
153
|
-
image:
|
|
154
|
-
draggable:
|
|
155
|
-
canvasToImageCoords:
|
|
153
|
+
image: D,
|
|
154
|
+
draggable: E,
|
|
155
|
+
canvasToImageCoords: F,
|
|
156
156
|
imageToCanvasCoords: $,
|
|
157
157
|
cropRegionImage: ie,
|
|
158
|
-
onChange:
|
|
158
|
+
onChange: k,
|
|
159
159
|
onRegionChange: H,
|
|
160
160
|
performOCRIfNeeded: ce,
|
|
161
|
-
updateTextLayers:
|
|
161
|
+
updateTextLayers: Y,
|
|
162
162
|
rectMapRef: u,
|
|
163
163
|
regionNameTextMapRef: C,
|
|
164
164
|
ocrLoadingIconMapRef: w
|
|
165
165
|
});
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}, [
|
|
169
|
-
e && (
|
|
166
|
+
l(() => {
|
|
167
|
+
L();
|
|
168
|
+
}, [L]), l(() => {
|
|
169
|
+
e && (d.current.forEach((o) => {
|
|
170
170
|
o.forEach((t) => {
|
|
171
|
-
t.off("mousedown"), t.off("mouseover"), t.off("mouseout"), e.remove(t),
|
|
171
|
+
t.off("mousedown"), t.off("mouseover"), t.off("mouseout"), e.remove(t), j.current.delete(t);
|
|
172
172
|
});
|
|
173
|
-
}),
|
|
173
|
+
}), d.current.clear(), C.current.forEach((o) => {
|
|
174
174
|
e.remove(o);
|
|
175
175
|
}), C.current.clear(), w.current.forEach((o) => {
|
|
176
176
|
e.remove(o);
|
|
177
177
|
}), w.current.clear(), u.current.forEach((o, t) => {
|
|
178
178
|
t.off("modified"), t.off("moved"), e.remove(t);
|
|
179
179
|
}), u.current.clear(), ne.current = !1, oe.current = void 0, e.renderAll());
|
|
180
|
-
}, [e, s == null ? void 0 : s.id]),
|
|
181
|
-
if (!
|
|
180
|
+
}, [e, s == null ? void 0 : s.id]), l(() => {
|
|
181
|
+
if (!v.current)
|
|
182
182
|
return;
|
|
183
|
-
|
|
184
|
-
width:
|
|
185
|
-
height:
|
|
183
|
+
W.current = {
|
|
184
|
+
width: v.current.offsetWidth,
|
|
185
|
+
height: v.current.offsetHeight
|
|
186
186
|
};
|
|
187
187
|
const o = new ResizeObserver(() => {
|
|
188
|
-
if (!
|
|
188
|
+
if (!v.current || se.current)
|
|
189
189
|
return;
|
|
190
190
|
if (e) {
|
|
191
|
-
const
|
|
192
|
-
if (Math.abs(
|
|
191
|
+
const g = e.getZoom();
|
|
192
|
+
if (Math.abs(g - p) > st)
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
195
|
-
const t =
|
|
196
|
-
(t !== n || r !== i) && (
|
|
195
|
+
const t = v.current.offsetWidth, r = v.current.offsetHeight, n = W.current.width, i = W.current.height;
|
|
196
|
+
(t !== n || r !== i) && (W.current = {
|
|
197
197
|
width: t,
|
|
198
198
|
height: r
|
|
199
|
-
},
|
|
199
|
+
}, L());
|
|
200
200
|
});
|
|
201
|
-
return o.observe(
|
|
201
|
+
return o.observe(v.current), () => {
|
|
202
202
|
o.disconnect();
|
|
203
203
|
};
|
|
204
|
-
}, [
|
|
205
|
-
c || (T && (
|
|
204
|
+
}, [L, e, p]), b("ctrl", () => {
|
|
205
|
+
c || (T && (I(!1), x()), _(!0));
|
|
206
206
|
}, {
|
|
207
207
|
events: ["keydown"]
|
|
208
|
-
}),
|
|
209
|
-
c ||
|
|
208
|
+
}), b("ctrl", () => {
|
|
209
|
+
c || _(!1);
|
|
210
210
|
}, {
|
|
211
211
|
events: ["keyup"]
|
|
212
|
-
}),
|
|
212
|
+
}), l(() => {
|
|
213
213
|
if (!e)
|
|
214
214
|
return;
|
|
215
|
-
const o = ft /
|
|
216
|
-
|
|
215
|
+
const o = ft / p, t = /* @__PURE__ */ new Set();
|
|
216
|
+
d.current.forEach((r) => {
|
|
217
217
|
r.forEach((n) => {
|
|
218
218
|
t.add(n);
|
|
219
219
|
});
|
|
220
220
|
}), e.getObjects().forEach((r) => {
|
|
221
|
-
r instanceof
|
|
221
|
+
r instanceof U.Rect && !t.has(r) && r.set({
|
|
222
222
|
strokeWidth: o,
|
|
223
223
|
strokeUniform: !0,
|
|
224
224
|
objectCaching: !1,
|
|
@@ -226,7 +226,7 @@ const Wt = ({
|
|
|
226
226
|
statefullCache: !1,
|
|
227
227
|
noScaleCache: !1
|
|
228
228
|
});
|
|
229
|
-
}),
|
|
229
|
+
}), d.current.forEach((r) => {
|
|
230
230
|
r.forEach((n) => {
|
|
231
231
|
n.set({
|
|
232
232
|
fill: it,
|
|
@@ -243,15 +243,15 @@ const Wt = ({
|
|
|
243
243
|
});
|
|
244
244
|
});
|
|
245
245
|
}), C.current.forEach((r, n) => {
|
|
246
|
-
const i = n.left || 0,
|
|
246
|
+
const i = n.left || 0, g = n.top || 0;
|
|
247
247
|
r.set({
|
|
248
248
|
left: i,
|
|
249
249
|
// 与标注框左边对齐
|
|
250
|
-
top:
|
|
250
|
+
top: g,
|
|
251
251
|
// 下边缘与标注框上边缘对齐(因为 originY 是 'bottom')
|
|
252
|
-
scaleX: 1 /
|
|
252
|
+
scaleX: 1 / p,
|
|
253
253
|
// 反向缩放,抵消画布缩放
|
|
254
|
-
scaleY: 1 /
|
|
254
|
+
scaleY: 1 / p
|
|
255
255
|
// 反向缩放,抵消画布缩放
|
|
256
256
|
});
|
|
257
257
|
const m = w.current.get(n);
|
|
@@ -260,24 +260,25 @@ const Wt = ({
|
|
|
260
260
|
n.getScaledHeight(), m.set({
|
|
261
261
|
left: i,
|
|
262
262
|
// top 位置由动画控制,这里不更新
|
|
263
|
-
scaleX: 1 /
|
|
263
|
+
scaleX: 1 / p,
|
|
264
264
|
// 反向缩放,抵消画布缩放,保持固定视觉粗细
|
|
265
|
-
scaleY: 1 /
|
|
265
|
+
scaleY: 1 / p
|
|
266
266
|
// 反向缩放,抵消画布缩放,保持固定视觉粗细
|
|
267
267
|
});
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
const y = N *
|
|
271
|
-
|
|
272
|
-
z instanceof
|
|
268
|
+
const M = m.getObjects();
|
|
269
|
+
if (M && M.length > 0) {
|
|
270
|
+
const y = N * p;
|
|
271
|
+
M.forEach((z) => {
|
|
272
|
+
z instanceof U.Rect && z.set("width", y);
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
}), e.renderAll();
|
|
277
|
-
}, [e,
|
|
277
|
+
}, [e, p]), Be({
|
|
278
278
|
canvas: e,
|
|
279
|
-
draggable:
|
|
280
|
-
drawingMode: T
|
|
279
|
+
draggable: E,
|
|
280
|
+
drawingMode: T,
|
|
281
|
+
textLayersMapRef: d
|
|
281
282
|
});
|
|
282
283
|
const {
|
|
283
284
|
performDelete: B
|
|
@@ -286,8 +287,8 @@ const Wt = ({
|
|
|
286
287
|
onRegionChange: H,
|
|
287
288
|
updateRegionNames: Me,
|
|
288
289
|
rectMapRef: u,
|
|
289
|
-
textLayersMapRef:
|
|
290
|
-
textLayoutContentMapRef:
|
|
290
|
+
textLayersMapRef: d,
|
|
291
|
+
textLayoutContentMapRef: j,
|
|
291
292
|
regionNameTextMapRef: C,
|
|
292
293
|
ocrLoadingIconMapRef: w
|
|
293
294
|
}), {
|
|
@@ -299,36 +300,39 @@ const Wt = ({
|
|
|
299
300
|
canvas: e,
|
|
300
301
|
onRegionSelect: J,
|
|
301
302
|
createDeleteControl: G,
|
|
302
|
-
textLayersMapRef:
|
|
303
|
+
textLayersMapRef: d,
|
|
303
304
|
rectMapRef: u
|
|
304
305
|
});
|
|
305
306
|
const {
|
|
306
|
-
stopDraw:
|
|
307
|
+
stopDraw: x
|
|
307
308
|
} = ze({
|
|
308
309
|
canvas: e,
|
|
309
310
|
drawingMode: T,
|
|
310
|
-
draggable:
|
|
311
|
-
setDrawingMode:
|
|
312
|
-
canvasToImageCoords:
|
|
311
|
+
draggable: E,
|
|
312
|
+
setDrawingMode: I,
|
|
313
|
+
canvasToImageCoords: F,
|
|
313
314
|
labelDefinitions: f,
|
|
314
|
-
onChange:
|
|
315
|
+
onChange: k,
|
|
315
316
|
cropRegionImage: ie,
|
|
316
317
|
updateRegionShapeAndImage: ae,
|
|
317
318
|
performOCRIfNeeded: ce,
|
|
318
319
|
createDeleteControl: G,
|
|
319
|
-
updateRegionNameText:
|
|
320
|
+
updateRegionNameText: O,
|
|
320
321
|
onRegionChange: H,
|
|
321
322
|
onRegionSelect: J,
|
|
322
|
-
rectMapRef: u
|
|
323
|
+
rectMapRef: u,
|
|
324
|
+
textLayersMapRef: d
|
|
323
325
|
});
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}, [
|
|
326
|
+
l(() => {
|
|
327
|
+
R && (I(!1), x());
|
|
328
|
+
}, [R, x]), l(() => {
|
|
329
|
+
c && (_(!0), I(!1), x());
|
|
330
|
+
}, [c, x]), l(() => {
|
|
327
331
|
if (!e)
|
|
328
332
|
return;
|
|
329
333
|
const o = () => {
|
|
330
334
|
e.getObjects().forEach((t) => {
|
|
331
|
-
t instanceof
|
|
335
|
+
t instanceof U.Rect && t.selectable && (t.set({
|
|
332
336
|
lockMovementX: c,
|
|
333
337
|
lockMovementY: c,
|
|
334
338
|
lockScalingX: c,
|
|
@@ -345,68 +349,68 @@ const Wt = ({
|
|
|
345
349
|
}, [e, c]), He({
|
|
346
350
|
canvas: e,
|
|
347
351
|
sample: s,
|
|
348
|
-
image:
|
|
352
|
+
image: D,
|
|
349
353
|
bgImagePosition: K,
|
|
350
354
|
canvasInitializedRef: re,
|
|
351
|
-
bgImagePositionRef:
|
|
355
|
+
bgImagePositionRef: X,
|
|
352
356
|
sampleRef: oe,
|
|
353
357
|
labelsLoadedRef: ne,
|
|
354
358
|
rectMapRef: u,
|
|
355
|
-
textLayersMapRef:
|
|
356
|
-
textLayoutContentMapRef:
|
|
359
|
+
textLayersMapRef: d,
|
|
360
|
+
textLayoutContentMapRef: j,
|
|
357
361
|
regionNameTextMapRef: C,
|
|
358
362
|
ocrLoadingIconMapRef: w,
|
|
359
363
|
imageToCanvasCoords: $,
|
|
360
364
|
updateRegionShapeAndImage: ae,
|
|
361
365
|
createDeleteControl: G,
|
|
362
|
-
updateRegionNameText:
|
|
363
|
-
updateTextLayers:
|
|
364
|
-
}),
|
|
366
|
+
updateRegionNameText: O,
|
|
367
|
+
updateTextLayers: Y
|
|
368
|
+
}), l(() => {
|
|
365
369
|
if (!a || a.length === 0)
|
|
366
370
|
return;
|
|
367
371
|
let o = !1;
|
|
368
372
|
u.current.forEach((t, r) => {
|
|
369
|
-
var
|
|
373
|
+
var g, m;
|
|
370
374
|
const n = a.find((N) => N.id === t.id);
|
|
371
375
|
if (!n)
|
|
372
376
|
return;
|
|
373
377
|
const i = he(q(q({}, t), n), {
|
|
374
378
|
// Keep shape from canvas to avoid desync
|
|
375
379
|
shape: t.shape,
|
|
376
|
-
image: (
|
|
380
|
+
image: (g = n.image) != null ? g : t.image,
|
|
377
381
|
textLayouts: (m = n.textLayouts) != null ? m : t.textLayouts
|
|
378
382
|
});
|
|
379
|
-
(i.name !== t.name || i.content !== t.content || i.image !== t.image || i.textLayouts !== t.textLayouts) && (u.current.set(r, i), i.name !== t.name &&
|
|
383
|
+
(i.name !== t.name || i.content !== t.content || i.image !== t.image || i.textLayouts !== t.textLayouts) && (u.current.set(r, i), i.name !== t.name && O(r, i), o = !0);
|
|
380
384
|
}), o && (e == null || e.renderAll());
|
|
381
|
-
}, [a, e,
|
|
385
|
+
}, [a, e, O]), et({
|
|
382
386
|
canvas: e,
|
|
383
387
|
drawingMode: T,
|
|
384
|
-
draggable:
|
|
385
|
-
textLayersMapRef:
|
|
386
|
-
}),
|
|
388
|
+
draggable: E,
|
|
389
|
+
textLayersMapRef: d
|
|
390
|
+
}), l(() => {
|
|
387
391
|
if (e && Q === null) {
|
|
388
392
|
const o = /* @__PURE__ */ new Set();
|
|
389
|
-
|
|
393
|
+
d.current.forEach((r) => {
|
|
390
394
|
r.forEach((n) => {
|
|
391
395
|
o.add(n);
|
|
392
396
|
});
|
|
393
397
|
}), e.getObjects().forEach((r) => {
|
|
394
|
-
r instanceof
|
|
398
|
+
r instanceof U.Rect && !o.has(r) && r.set({
|
|
395
399
|
fill: at
|
|
396
400
|
// 移除填充色
|
|
397
401
|
});
|
|
398
402
|
}), e.getActiveObject() && (e.discardActiveObject(), e.renderAll());
|
|
399
403
|
}
|
|
400
|
-
}, [e, Q]),
|
|
404
|
+
}, [e, Q]), l(() => {
|
|
401
405
|
var r;
|
|
402
406
|
if (!e)
|
|
403
407
|
return;
|
|
404
|
-
const o = (r =
|
|
408
|
+
const o = (r = R == null ? void 0 : R.region) == null ? void 0 : r.id;
|
|
405
409
|
let t = !1;
|
|
406
|
-
|
|
407
|
-
const
|
|
408
|
-
if (
|
|
409
|
-
const m = o ===
|
|
410
|
+
d.current.forEach((n, i) => {
|
|
411
|
+
const g = u.current.get(i);
|
|
412
|
+
if (g && n.length > 0) {
|
|
413
|
+
const m = o === g.id;
|
|
410
414
|
n.forEach((N) => {
|
|
411
415
|
N.visible !== m && (N.set({
|
|
412
416
|
visible: m
|
|
@@ -414,46 +418,46 @@ const Wt = ({
|
|
|
414
418
|
});
|
|
415
419
|
}
|
|
416
420
|
}), t && e.renderAll();
|
|
417
|
-
}, [e,
|
|
418
|
-
if (!e || !
|
|
421
|
+
}, [e, R]), l(() => {
|
|
422
|
+
if (!e || !R || !Z)
|
|
419
423
|
return;
|
|
420
424
|
const o = (t) => {
|
|
421
|
-
var
|
|
422
|
-
const r = (
|
|
425
|
+
var de;
|
|
426
|
+
const r = (de = t.e) == null ? void 0 : de.target;
|
|
423
427
|
if ((r == null ? void 0 : r.tagName) === "INPUT" || (r == null ? void 0 : r.tagName) === "TEXTAREA")
|
|
424
428
|
return;
|
|
425
|
-
const n = e.getPointer(t.e), i = n.x,
|
|
426
|
-
x,
|
|
429
|
+
const n = e.getPointer(t.e), i = n.x, g = n.y, m = F(i, g), N = R.region, {
|
|
430
|
+
x: M,
|
|
427
431
|
y,
|
|
428
432
|
width: z,
|
|
429
|
-
height:
|
|
433
|
+
height: Le
|
|
430
434
|
} = N.shape;
|
|
431
|
-
m.x >=
|
|
435
|
+
m.x >= M && m.x <= M + z && m.y >= y && m.y <= y + Le || Z();
|
|
432
436
|
};
|
|
433
437
|
return e.on("mouse:down", o), () => {
|
|
434
438
|
e.off("mouse:down", o);
|
|
435
439
|
};
|
|
436
|
-
}, [e,
|
|
437
|
-
const fe =
|
|
440
|
+
}, [e, R, Z, F]);
|
|
441
|
+
const fe = P((o) => {
|
|
438
442
|
const t = o.target;
|
|
439
443
|
if ((t == null ? void 0 : t.tagName) === "INPUT" || (t == null ? void 0 : t.tagName) === "TEXTAREA" || !e || c)
|
|
440
444
|
return;
|
|
441
445
|
const r = e.getActiveObject();
|
|
442
|
-
!r || !(r instanceof
|
|
446
|
+
!r || !(r instanceof U.Rect) || B(r);
|
|
443
447
|
}, [e, B]);
|
|
444
|
-
|
|
448
|
+
b("Delete", fe), b("Backspace", fe), b("r", (o) => {
|
|
445
449
|
const t = o.target;
|
|
446
|
-
(t == null ? void 0 : t.tagName) === "INPUT" || (t == null ? void 0 : t.tagName) === "TEXTAREA" || t != null && t.isContentEditable || c || !T && !
|
|
450
|
+
(t == null ? void 0 : t.tagName) === "INPUT" || (t == null ? void 0 : t.tagName) === "TEXTAREA" || t != null && t.isContentEditable || c || !T && !E && I(!0);
|
|
447
451
|
}, {
|
|
448
452
|
exactMatch: !1
|
|
449
453
|
// 允许大小写
|
|
450
454
|
});
|
|
451
|
-
const
|
|
452
|
-
c || (T && (
|
|
453
|
-
},
|
|
454
|
-
c || (
|
|
455
|
+
const De = () => {
|
|
456
|
+
c || (T && (I(!1), x()), _(!E));
|
|
457
|
+
}, _e = () => {
|
|
458
|
+
c || (E && _(!1), I(!T));
|
|
455
459
|
};
|
|
456
|
-
return
|
|
460
|
+
return l(() => () => {
|
|
457
461
|
e && e.dispose();
|
|
458
462
|
}, []), /* @__PURE__ */ Re("div", {
|
|
459
463
|
style: {
|
|
@@ -462,28 +466,28 @@ const Wt = ({
|
|
|
462
466
|
display: "flex",
|
|
463
467
|
position: "relative"
|
|
464
468
|
},
|
|
465
|
-
children: [Te && /* @__PURE__ */
|
|
469
|
+
children: [Te && /* @__PURE__ */ S("div", {
|
|
466
470
|
className: "vlm-loading-overlay",
|
|
467
|
-
children: /* @__PURE__ */
|
|
471
|
+
children: /* @__PURE__ */ S("div", {
|
|
468
472
|
className: "vlm-loading-spinner"
|
|
469
473
|
})
|
|
470
|
-
}), /* @__PURE__ */
|
|
474
|
+
}), /* @__PURE__ */ S("div", {
|
|
471
475
|
className: "vlm-marker-toolbar",
|
|
472
|
-
children: /* @__PURE__ */
|
|
476
|
+
children: /* @__PURE__ */ S(Fe, {
|
|
473
477
|
drawingMode: T,
|
|
474
|
-
draggable:
|
|
475
|
-
scale:
|
|
476
|
-
onToggleDrawingMode:
|
|
477
|
-
onToggleDrag:
|
|
478
|
+
draggable: E,
|
|
479
|
+
scale: p,
|
|
480
|
+
onToggleDrawingMode: _e,
|
|
481
|
+
onToggleDrag: De,
|
|
478
482
|
onZoom: Se,
|
|
479
|
-
onFitToScreen:
|
|
483
|
+
onFitToScreen: L,
|
|
480
484
|
readOnly: c
|
|
481
485
|
})
|
|
482
486
|
}), /* @__PURE__ */ Re("div", {
|
|
483
|
-
ref:
|
|
487
|
+
ref: v,
|
|
484
488
|
className: Oe({
|
|
485
489
|
"vlm-label-maker-wrap": !0,
|
|
486
|
-
draggable:
|
|
490
|
+
draggable: E
|
|
487
491
|
}),
|
|
488
492
|
onContextMenu: (o) => {
|
|
489
493
|
o.preventDefault();
|
|
@@ -492,10 +496,10 @@ const Wt = ({
|
|
|
492
496
|
flex: 1,
|
|
493
497
|
position: "relative"
|
|
494
498
|
},
|
|
495
|
-
children: [(((ue = s == null ? void 0 : s.sampleFileName) == null ? void 0 : ue.originalName) || ((me = s == null ? void 0 : s.sampleFileName) == null ? void 0 : me.name)) && /* @__PURE__ */
|
|
499
|
+
children: [(((ue = s == null ? void 0 : s.sampleFileName) == null ? void 0 : ue.originalName) || ((me = s == null ? void 0 : s.sampleFileName) == null ? void 0 : me.name)) && /* @__PURE__ */ S("div", {
|
|
496
500
|
className: "vlm-image-name",
|
|
497
501
|
children: s.sampleFileName.originalName || s.sampleFileName.name
|
|
498
|
-
}), /* @__PURE__ */
|
|
502
|
+
}), /* @__PURE__ */ S("canvas", {
|
|
499
503
|
className: "vlm-label-maker-canvas",
|
|
500
504
|
ref: V
|
|
501
505
|
})]
|