@glodon-aiot/dataset-annotation 3.14.0-alpha.31 → 3.14.0-alpha.33
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/VLMAnnotation/RegionItem.mjs +1 -1
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useAIButtonHover.mjs +193 -0
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.mjs +18 -18
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +345 -238
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +158 -56
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +424 -397
- package/dist/es/components/VLMAnnotation/components/AIErrorTooltip/AIErrorTooltip.less.mjs +4 -0
- package/dist/es/components/VLMAnnotation/components/AIErrorTooltip/index.mjs +24 -0
- package/dist/es/components/VLMAnnotation/components/ZoomControls.mjs +1 -1
- package/dist/es/components/VLMAnnotation/constants.mjs +1 -1
- package/dist/es/index.mjs +1 -1
- package/dist/lib/index.js +4 -4
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useAIButtonHover.d.ts +16 -0
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +2 -1
- package/dist/src/components/VLMAnnotation/components/AIErrorTooltip/index.d.ts +8 -0
- package/dist/src/components/VLMAnnotation/constants.d.ts +2 -2
- package/package.json +2 -2
|
@@ -1,237 +1,239 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
for (var
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
import { jsxs as
|
|
14
|
-
import
|
|
15
|
-
import { fabric as
|
|
16
|
-
import { useKeyPress as
|
|
17
|
-
import
|
|
1
|
+
var Qt = Object.defineProperty, Vt = Object.defineProperties;
|
|
2
|
+
var te = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var wt = Object.getOwnPropertySymbols;
|
|
4
|
+
var ee = Object.prototype.hasOwnProperty, oe = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Ot = (i, g, d) => g in i ? Qt(i, g, { enumerable: !0, configurable: !0, writable: !0, value: d }) : i[g] = d, it = (i, g) => {
|
|
6
|
+
for (var d in g || (g = {}))
|
|
7
|
+
ee.call(g, d) && Ot(i, d, g[d]);
|
|
8
|
+
if (wt)
|
|
9
|
+
for (var d of wt(g))
|
|
10
|
+
oe.call(g, d) && Ot(i, d, g[d]);
|
|
11
|
+
return i;
|
|
12
|
+
}, _t = (i, g) => Vt(i, te(g));
|
|
13
|
+
import { jsxs as Lt, jsx as L } from "react/jsx-runtime";
|
|
14
|
+
import re, { useRef as T, useState as S, useCallback as w, useEffect as E, useImperativeHandle as ne } from "react";
|
|
15
|
+
import { fabric as W } from "fabric";
|
|
16
|
+
import { useKeyPress as Z } from "ahooks";
|
|
17
|
+
import se from "classnames";
|
|
18
18
|
import "./style.less.mjs";
|
|
19
|
-
import
|
|
20
|
-
import { useOCRLoadingIcon as
|
|
21
|
-
import { useRegionNameText as
|
|
22
|
-
import { useCropRegionImage as
|
|
23
|
-
import { useDrawingMode as
|
|
24
|
-
import { useRegionLoader as
|
|
25
|
-
import { useCanvasSetup as
|
|
26
|
-
import { useTextLayouts as
|
|
27
|
-
import { useRegionUpdate as
|
|
28
|
-
import { useCanvasDrag as
|
|
29
|
-
import { useRegionSelection as
|
|
30
|
-
import { useOCRRecognition as
|
|
31
|
-
import { useDeleteRegion as
|
|
32
|
-
import { useDeleteControl as
|
|
33
|
-
import { useOCRControl as
|
|
34
|
-
import { useCanvasZoom as
|
|
35
|
-
import { useRegionHover as
|
|
36
|
-
import { useRegionBoundaryCheck as
|
|
37
|
-
import {
|
|
38
|
-
import
|
|
39
|
-
|
|
40
|
-
|
|
19
|
+
import ie from "../components/Toolbar.mjs";
|
|
20
|
+
import { useOCRLoadingIcon as ce } from "./hooks/useOCRLoadingIcon.mjs";
|
|
21
|
+
import { useRegionNameText as ae } from "./hooks/useRegionNameText.mjs";
|
|
22
|
+
import { useCropRegionImage as fe } from "./hooks/useCropRegionImage.mjs";
|
|
23
|
+
import { useDrawingMode as ue } from "./hooks/useDrawingMode.mjs";
|
|
24
|
+
import { useRegionLoader as le } from "./hooks/useRegionLoader.mjs";
|
|
25
|
+
import { useCanvasSetup as me } from "./hooks/useCanvasSetup.mjs";
|
|
26
|
+
import { useTextLayouts as de } from "./hooks/useTextLayouts.mjs";
|
|
27
|
+
import { useRegionUpdate as he } from "./hooks/useRegionUpdate.mjs";
|
|
28
|
+
import { useCanvasDrag as ge } from "./hooks/useCanvasDrag.mjs";
|
|
29
|
+
import { useRegionSelection as Re } from "./hooks/useRegionSelection.mjs";
|
|
30
|
+
import { useOCRRecognition as pe } from "./hooks/useOCRRecognition.mjs";
|
|
31
|
+
import { useDeleteRegion as Ee } from "./hooks/useDeleteRegion.mjs";
|
|
32
|
+
import { useDeleteControl as Te } from "./hooks/useDeleteControl.mjs";
|
|
33
|
+
import { useOCRControl as Ce } from "./hooks/useOCRControl.mjs";
|
|
34
|
+
import { useCanvasZoom as ve } from "./hooks/useCanvasZoom.mjs";
|
|
35
|
+
import { useRegionHover as Ie } from "./hooks/useRegionHover.mjs";
|
|
36
|
+
import { useRegionBoundaryCheck as ke } from "./hooks/useRegionBoundaryCheck.mjs";
|
|
37
|
+
import { useAIButtonHover as Ae } from "./hooks/useAIButtonHover.mjs";
|
|
38
|
+
import Ne from "../components/AIErrorTooltip/index.mjs";
|
|
39
|
+
import { canvasToImageCoords as Se, imageToCanvasCoords as xe } from "./utils/coordinateUtils.mjs";
|
|
40
|
+
import { REGION_NAME_PREFIX as we, DEFAULT_REGION_NAME as Oe, ZOOM_PRECISION_ERROR as _e, TEXT_LAYOUT_RECT_FILL_COLOR as Le, TEXT_LAYOUT_RECT_STROKE_COLOR as ye, TRANSPARENT_FILL as yt, SELECTED_RECT_FILL_COLOR as Me, RECT_STROKE_COLOR as Mt, BASE_STROKE_WIDTH as ct, ACTIVE_RECT_STROKE_COLOR as De } from "../constants.mjs";
|
|
41
|
+
const be = re.forwardRef(({
|
|
42
|
+
sample: i,
|
|
41
43
|
labelDefinitions: g,
|
|
42
|
-
labels:
|
|
43
|
-
onImageLoad:
|
|
44
|
+
labels: d,
|
|
45
|
+
onImageLoad: Dt,
|
|
44
46
|
onChange: O,
|
|
45
|
-
onRegionSelect:
|
|
47
|
+
onRegionSelect: at,
|
|
46
48
|
onRegionChange: J,
|
|
47
|
-
ocrRecognize:
|
|
49
|
+
ocrRecognize: bt,
|
|
48
50
|
activeLabelValue: R,
|
|
49
51
|
onClearActive: Q,
|
|
50
|
-
selectedRegion:
|
|
51
|
-
onAppendTextToActive:
|
|
52
|
+
selectedRegion: C,
|
|
53
|
+
onAppendTextToActive: Pt,
|
|
52
54
|
readOnly: h
|
|
53
|
-
},
|
|
54
|
-
var
|
|
55
|
-
const
|
|
55
|
+
}, Ut) => {
|
|
56
|
+
var Nt, St;
|
|
57
|
+
const ft = T(null), v = T(null), [Wt, Xt] = S(!0), [t, jt] = S(), [y, Ft] = S(), [I, ut] = S(1), [N, X] = S(h || !1), [k, _] = S(!1), [V, Bt] = S({
|
|
56
58
|
left: 0,
|
|
57
59
|
top: 0
|
|
58
|
-
}),
|
|
60
|
+
}), [Ht, lt] = S(!1), [tt, mt] = S(null), j = T({
|
|
59
61
|
left: 0,
|
|
60
62
|
top: 0
|
|
61
|
-
}),
|
|
63
|
+
}), dt = T({
|
|
62
64
|
width: 0,
|
|
63
65
|
height: 0
|
|
64
|
-
}),
|
|
66
|
+
}), c = T(/* @__PURE__ */ new Map()), ht = T(null), gt = T(void 0), Rt = T(!1), pt = T(!1), Y = T({
|
|
65
67
|
width: 0,
|
|
66
68
|
height: 0
|
|
67
|
-
}),
|
|
68
|
-
updateOCRLoadingIcon:
|
|
69
|
+
}), Et = T(!1), {
|
|
70
|
+
updateOCRLoadingIcon: Pe,
|
|
69
71
|
ocrLoadingIconMapRef: M
|
|
70
|
-
} =
|
|
71
|
-
updateRegionNameText:
|
|
72
|
-
regionNameTextMapRef:
|
|
73
|
-
} =
|
|
74
|
-
|
|
75
|
-
const n = r.left || 0,
|
|
76
|
-
|
|
72
|
+
} = ce(t), {
|
|
73
|
+
updateRegionNameText: z,
|
|
74
|
+
regionNameTextMapRef: A
|
|
75
|
+
} = ae(t), et = fe(i == null ? void 0 : i.fileUrl), Zt = w((o) => {
|
|
76
|
+
t && (A.current.forEach((e, r) => {
|
|
77
|
+
const n = r.left || 0, u = r.top || 0;
|
|
78
|
+
e.set({
|
|
77
79
|
left: n,
|
|
78
80
|
// 与标注框左边对齐
|
|
79
|
-
top:
|
|
81
|
+
top: u,
|
|
80
82
|
// 下边缘与标注框上边缘对齐(因为 originY 是 'bottom')
|
|
81
83
|
scaleX: 1 / o,
|
|
82
84
|
// 反向缩放,抵消画布缩放
|
|
83
85
|
scaleY: 1 / o
|
|
84
86
|
// 反向缩放,抵消画布缩放
|
|
85
87
|
});
|
|
86
|
-
}),
|
|
87
|
-
}, [
|
|
88
|
-
updateCanvas:
|
|
89
|
-
} =
|
|
90
|
-
sample:
|
|
91
|
-
image:
|
|
92
|
-
onImageLoad:
|
|
93
|
-
canvasRef:
|
|
94
|
-
containerRef:
|
|
95
|
-
canvasInitializedRef:
|
|
96
|
-
bgImagePositionRef:
|
|
97
|
-
bgImageSizeRef:
|
|
98
|
-
rectMapRef:
|
|
99
|
-
updateTextLayersRef:
|
|
100
|
-
onRectPositionUpdated:
|
|
101
|
-
setCanvas:
|
|
102
|
-
setImage:
|
|
103
|
-
setScale:
|
|
104
|
-
setBgImagePosition:
|
|
105
|
-
setLoading:
|
|
106
|
-
}),
|
|
107
|
-
const o = Array.from(
|
|
108
|
-
o.forEach((
|
|
109
|
-
|
|
110
|
-
}),
|
|
111
|
-
const n =
|
|
112
|
-
n && (n.set("text",
|
|
88
|
+
}), t.renderAll());
|
|
89
|
+
}, [t]), {
|
|
90
|
+
updateCanvas: F
|
|
91
|
+
} = me({
|
|
92
|
+
sample: i,
|
|
93
|
+
image: y,
|
|
94
|
+
onImageLoad: Dt,
|
|
95
|
+
canvasRef: ft,
|
|
96
|
+
containerRef: v,
|
|
97
|
+
canvasInitializedRef: Rt,
|
|
98
|
+
bgImagePositionRef: j,
|
|
99
|
+
bgImageSizeRef: dt,
|
|
100
|
+
rectMapRef: c,
|
|
101
|
+
updateTextLayersRef: ht,
|
|
102
|
+
onRectPositionUpdated: Zt,
|
|
103
|
+
setCanvas: jt,
|
|
104
|
+
setImage: Ft,
|
|
105
|
+
setScale: ut,
|
|
106
|
+
setBgImagePosition: Bt,
|
|
107
|
+
setLoading: Xt
|
|
108
|
+
}), Yt = w(() => {
|
|
109
|
+
const o = Array.from(c.current.values());
|
|
110
|
+
o.forEach((e, r) => {
|
|
111
|
+
e.name = `${we}${r + 1}`;
|
|
112
|
+
}), c.current.forEach((e, r) => {
|
|
113
|
+
const n = A.current.get(r);
|
|
114
|
+
n && (n.set("text", e.name || Oe), t == null || t.renderAll());
|
|
113
115
|
}), O && O(o);
|
|
114
|
-
}, [O,
|
|
115
|
-
zoom:
|
|
116
|
-
} =
|
|
117
|
-
canvas:
|
|
118
|
-
setScale:
|
|
119
|
-
isZoomingRef:
|
|
120
|
-
}),
|
|
121
|
-
(o,
|
|
122
|
-
[
|
|
116
|
+
}, [O, t]), {
|
|
117
|
+
zoom: zt
|
|
118
|
+
} = ve({
|
|
119
|
+
canvas: t,
|
|
120
|
+
setScale: ut,
|
|
121
|
+
isZoomingRef: Et
|
|
122
|
+
}), B = w(
|
|
123
|
+
(o, e) => Se(o, e, t, y, j),
|
|
124
|
+
[t, y, V]
|
|
123
125
|
// 添加 bgImagePosition 作为依赖,确保在图片位置更新后函数能正确工作
|
|
124
126
|
), K = w(
|
|
125
|
-
(o,
|
|
126
|
-
[
|
|
127
|
+
(o, e) => xe(o, e, t, j),
|
|
128
|
+
[t, V]
|
|
127
129
|
// 添加 bgImagePosition 作为依赖,确保在图片位置更新后函数能正确工作
|
|
128
130
|
), {
|
|
129
131
|
updateTextLayers: $,
|
|
130
|
-
textLayersMapRef:
|
|
132
|
+
textLayersMapRef: m,
|
|
131
133
|
textLayoutContentMapRef: G
|
|
132
|
-
} =
|
|
133
|
-
canvas:
|
|
134
|
+
} = de({
|
|
135
|
+
canvas: t,
|
|
134
136
|
imageToCanvasCoords: K,
|
|
135
137
|
activeLabelValue: R,
|
|
136
|
-
onAppendTextToActive:
|
|
138
|
+
onAppendTextToActive: Pt
|
|
137
139
|
});
|
|
138
|
-
|
|
140
|
+
ht.current = $;
|
|
139
141
|
const {
|
|
140
|
-
performOCRIfNeeded:
|
|
142
|
+
performOCRIfNeeded: Tt,
|
|
141
143
|
performOCR: q,
|
|
142
|
-
ocrRecognizingRef:
|
|
143
|
-
ocrErrorRef:
|
|
144
|
-
} =
|
|
145
|
-
ocrRecognize:
|
|
144
|
+
ocrRecognizingRef: Ct,
|
|
145
|
+
ocrErrorRef: ot
|
|
146
|
+
} = pe({
|
|
147
|
+
ocrRecognize: bt,
|
|
146
148
|
onChange: O,
|
|
147
149
|
updateTextLayers: $,
|
|
148
|
-
canvas:
|
|
149
|
-
rectMapRef:
|
|
150
|
-
textLayersMapRef:
|
|
150
|
+
canvas: t,
|
|
151
|
+
rectMapRef: c,
|
|
152
|
+
textLayersMapRef: m,
|
|
151
153
|
textLayoutContentMapRef: G
|
|
152
154
|
}), {
|
|
153
|
-
updateRegionShapeAndImage:
|
|
154
|
-
} =
|
|
155
|
-
canvas:
|
|
156
|
-
image:
|
|
155
|
+
updateRegionShapeAndImage: vt
|
|
156
|
+
} = he({
|
|
157
|
+
canvas: t,
|
|
158
|
+
image: y,
|
|
157
159
|
draggable: N,
|
|
158
|
-
canvasToImageCoords:
|
|
160
|
+
canvasToImageCoords: B,
|
|
159
161
|
imageToCanvasCoords: K,
|
|
160
|
-
cropRegionImage:
|
|
162
|
+
cropRegionImage: et,
|
|
161
163
|
onChange: O,
|
|
162
164
|
onRegionChange: J,
|
|
163
|
-
performOCRIfNeeded:
|
|
165
|
+
performOCRIfNeeded: Tt,
|
|
164
166
|
updateTextLayers: $,
|
|
165
|
-
rectMapRef:
|
|
166
|
-
regionNameTextMapRef:
|
|
167
|
+
rectMapRef: c,
|
|
168
|
+
regionNameTextMapRef: A,
|
|
167
169
|
ocrLoadingIconMapRef: M
|
|
168
170
|
}), {
|
|
169
|
-
setupBoundaryCheck:
|
|
170
|
-
} =
|
|
171
|
-
canvas:
|
|
172
|
-
image:
|
|
173
|
-
canvasToImageCoords:
|
|
171
|
+
setupBoundaryCheck: It
|
|
172
|
+
} = ke({
|
|
173
|
+
canvas: t,
|
|
174
|
+
image: y,
|
|
175
|
+
canvasToImageCoords: B,
|
|
174
176
|
imageToCanvasCoords: K,
|
|
175
|
-
bgImagePositionRef:
|
|
176
|
-
bgImageSizeRef:
|
|
177
|
-
regionNameTextMapRef:
|
|
177
|
+
bgImagePositionRef: j,
|
|
178
|
+
bgImageSizeRef: dt,
|
|
179
|
+
regionNameTextMapRef: A
|
|
178
180
|
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}, [
|
|
182
|
-
|
|
183
|
-
o.forEach((
|
|
184
|
-
|
|
181
|
+
E(() => {
|
|
182
|
+
F();
|
|
183
|
+
}, [F]), E(() => {
|
|
184
|
+
t && (m.current.forEach((o) => {
|
|
185
|
+
o.forEach((e) => {
|
|
186
|
+
e.off("mousedown"), e.off("mouseover"), e.off("mouseout"), t.remove(e), G.current.delete(e);
|
|
185
187
|
});
|
|
186
|
-
}),
|
|
187
|
-
|
|
188
|
-
}),
|
|
189
|
-
|
|
190
|
-
}), M.current.clear(),
|
|
191
|
-
|
|
192
|
-
}),
|
|
193
|
-
}, [
|
|
194
|
-
if (!
|
|
188
|
+
}), m.current.clear(), A.current.forEach((o) => {
|
|
189
|
+
t.remove(o);
|
|
190
|
+
}), A.current.clear(), M.current.forEach((o) => {
|
|
191
|
+
t.remove(o);
|
|
192
|
+
}), M.current.clear(), c.current.forEach((o, e) => {
|
|
193
|
+
e.off("modified"), e.off("moved"), t.remove(e);
|
|
194
|
+
}), c.current.clear(), pt.current = !1, gt.current = void 0, t.renderAll());
|
|
195
|
+
}, [t, i == null ? void 0 : i.id]), E(() => {
|
|
196
|
+
if (!v.current)
|
|
195
197
|
return;
|
|
196
|
-
|
|
197
|
-
width:
|
|
198
|
-
height:
|
|
198
|
+
Y.current = {
|
|
199
|
+
width: v.current.offsetWidth,
|
|
200
|
+
height: v.current.offsetHeight
|
|
199
201
|
};
|
|
200
202
|
const o = new ResizeObserver(() => {
|
|
201
|
-
if (!
|
|
203
|
+
if (!v.current || Et.current)
|
|
202
204
|
return;
|
|
203
|
-
if (
|
|
204
|
-
const s =
|
|
205
|
-
if (Math.abs(s -
|
|
205
|
+
if (t) {
|
|
206
|
+
const s = t.getZoom();
|
|
207
|
+
if (Math.abs(s - I) > _e)
|
|
206
208
|
return;
|
|
207
209
|
}
|
|
208
|
-
const
|
|
209
|
-
(
|
|
210
|
-
width:
|
|
210
|
+
const e = v.current.offsetWidth, r = v.current.offsetHeight, n = Y.current.width, u = Y.current.height;
|
|
211
|
+
(e !== n || r !== u) && (Y.current = {
|
|
212
|
+
width: e,
|
|
211
213
|
height: r
|
|
212
|
-
},
|
|
214
|
+
}, F());
|
|
213
215
|
});
|
|
214
|
-
return o.observe(
|
|
216
|
+
return o.observe(v.current), () => {
|
|
215
217
|
o.disconnect();
|
|
216
218
|
};
|
|
217
|
-
}, [
|
|
218
|
-
h || (
|
|
219
|
+
}, [F, t, I]), Z("ctrl", () => {
|
|
220
|
+
h || (k && (_(!1), b()), X(!0));
|
|
219
221
|
}, {
|
|
220
222
|
events: ["keydown"]
|
|
221
|
-
}),
|
|
222
|
-
h ||
|
|
223
|
+
}), Z("ctrl", () => {
|
|
224
|
+
h || X(!1);
|
|
223
225
|
}, {
|
|
224
226
|
events: ["keyup"]
|
|
225
|
-
}),
|
|
226
|
-
if (!
|
|
227
|
+
}), E(() => {
|
|
228
|
+
if (!t)
|
|
227
229
|
return;
|
|
228
|
-
const o =
|
|
229
|
-
|
|
230
|
+
const o = ct / I, e = /* @__PURE__ */ new Set();
|
|
231
|
+
m.current.forEach((r) => {
|
|
230
232
|
r.forEach((n) => {
|
|
231
|
-
|
|
233
|
+
e.add(n);
|
|
232
234
|
});
|
|
233
|
-
}),
|
|
234
|
-
r instanceof
|
|
235
|
+
}), t.getObjects().forEach((r) => {
|
|
236
|
+
r instanceof W.Rect && !e.has(r) && r.set({
|
|
235
237
|
strokeWidth: o,
|
|
236
238
|
strokeUniform: !0,
|
|
237
239
|
objectCaching: !1,
|
|
@@ -239,12 +241,12 @@ const _t = Qe.forwardRef(({
|
|
|
239
241
|
statefullCache: !1,
|
|
240
242
|
noScaleCache: !1
|
|
241
243
|
});
|
|
242
|
-
}),
|
|
244
|
+
}), m.current.forEach((r) => {
|
|
243
245
|
r.forEach((n) => {
|
|
244
246
|
n.set({
|
|
245
|
-
fill:
|
|
247
|
+
fill: Le,
|
|
246
248
|
// 确保填充色被保留
|
|
247
|
-
stroke:
|
|
249
|
+
stroke: ye,
|
|
248
250
|
// 确保边框色被保留
|
|
249
251
|
strokeWidth: o,
|
|
250
252
|
// 根据缩放调整边框宽度,保持视觉一致
|
|
@@ -255,135 +257,154 @@ const _t = Qe.forwardRef(({
|
|
|
255
257
|
noScaleCache: !1
|
|
256
258
|
});
|
|
257
259
|
});
|
|
258
|
-
}),
|
|
259
|
-
const
|
|
260
|
+
}), A.current.forEach((r, n) => {
|
|
261
|
+
const u = n.left || 0, s = n.top || 0;
|
|
260
262
|
r.set({
|
|
261
|
-
left:
|
|
263
|
+
left: u,
|
|
262
264
|
// 与标注框左边对齐
|
|
263
265
|
top: s,
|
|
264
266
|
// 下边缘与标注框上边缘对齐(因为 originY 是 'bottom')
|
|
265
|
-
scaleX: 1 /
|
|
267
|
+
scaleX: 1 / I,
|
|
266
268
|
// 反向缩放,抵消画布缩放
|
|
267
|
-
scaleY: 1 /
|
|
269
|
+
scaleY: 1 / I
|
|
268
270
|
// 反向缩放,抵消画布缩放
|
|
269
271
|
});
|
|
270
272
|
const a = M.current.get(n);
|
|
271
273
|
if (a) {
|
|
272
|
-
const
|
|
274
|
+
const l = n.getScaledWidth();
|
|
273
275
|
n.getScaledHeight(), a.set({
|
|
274
|
-
left:
|
|
276
|
+
left: u,
|
|
275
277
|
// top 位置由动画控制,这里不更新
|
|
276
|
-
scaleX: 1 /
|
|
278
|
+
scaleX: 1 / I,
|
|
277
279
|
// 反向缩放,抵消画布缩放,保持固定视觉粗细
|
|
278
|
-
scaleY: 1 /
|
|
280
|
+
scaleY: 1 / I
|
|
279
281
|
// 反向缩放,抵消画布缩放,保持固定视觉粗细
|
|
280
282
|
});
|
|
281
283
|
const f = a.getObjects();
|
|
282
284
|
if (f && f.length > 0) {
|
|
283
|
-
const
|
|
284
|
-
f.forEach((
|
|
285
|
-
|
|
285
|
+
const p = l * I;
|
|
286
|
+
f.forEach((x) => {
|
|
287
|
+
x instanceof W.Rect && x.set("width", p);
|
|
286
288
|
});
|
|
287
289
|
}
|
|
288
290
|
}
|
|
289
|
-
}),
|
|
290
|
-
}, [
|
|
291
|
-
canvas:
|
|
291
|
+
}), t.renderAll();
|
|
292
|
+
}, [t, I]), ge({
|
|
293
|
+
canvas: t,
|
|
292
294
|
draggable: N,
|
|
293
|
-
drawingMode:
|
|
294
|
-
textLayersMapRef:
|
|
295
|
+
drawingMode: k,
|
|
296
|
+
textLayersMapRef: m
|
|
295
297
|
});
|
|
296
298
|
const {
|
|
297
299
|
performDelete: D,
|
|
298
|
-
deleteDirectly:
|
|
299
|
-
} =
|
|
300
|
-
canvas:
|
|
300
|
+
deleteDirectly: Kt
|
|
301
|
+
} = Ee({
|
|
302
|
+
canvas: t,
|
|
301
303
|
onRegionChange: J,
|
|
302
|
-
updateRegionNames:
|
|
303
|
-
rectMapRef:
|
|
304
|
-
textLayersMapRef:
|
|
304
|
+
updateRegionNames: Yt,
|
|
305
|
+
rectMapRef: c,
|
|
306
|
+
textLayersMapRef: m,
|
|
305
307
|
textLayoutContentMapRef: G,
|
|
306
|
-
regionNameTextMapRef:
|
|
308
|
+
regionNameTextMapRef: A,
|
|
307
309
|
ocrLoadingIconMapRef: M
|
|
308
310
|
});
|
|
309
311
|
w((o) => {
|
|
310
|
-
if (!
|
|
312
|
+
if (!t)
|
|
311
313
|
return;
|
|
312
|
-
let
|
|
313
|
-
|
|
314
|
-
r.id === o && (
|
|
315
|
-
}),
|
|
316
|
-
}, [
|
|
317
|
-
const
|
|
318
|
-
if (!
|
|
314
|
+
let e = null;
|
|
315
|
+
c.current.forEach((r, n) => {
|
|
316
|
+
r.id === o && (e = n);
|
|
317
|
+
}), e && D(e);
|
|
318
|
+
}, [t, D]);
|
|
319
|
+
const $t = w((o) => {
|
|
320
|
+
if (!t)
|
|
319
321
|
return;
|
|
320
|
-
let
|
|
321
|
-
|
|
322
|
-
r.id === o && (
|
|
323
|
-
}),
|
|
324
|
-
}, [
|
|
325
|
-
if (!
|
|
322
|
+
let e = null;
|
|
323
|
+
c.current.forEach((r) => {
|
|
324
|
+
r.id === o && (e = r);
|
|
325
|
+
}), e && q(e);
|
|
326
|
+
}, [t, q]), Gt = w((o) => {
|
|
327
|
+
if (!t)
|
|
326
328
|
return;
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
}, [
|
|
330
|
-
|
|
331
|
-
performOCRById:
|
|
332
|
-
ocrRecognizingRef:
|
|
333
|
-
ocrErrorRef:
|
|
329
|
+
const e = c.current.get(o);
|
|
330
|
+
e && q(e);
|
|
331
|
+
}, [t, q]);
|
|
332
|
+
ne(Ut, () => ({
|
|
333
|
+
performOCRById: $t,
|
|
334
|
+
ocrRecognizingRef: Ct,
|
|
335
|
+
ocrErrorRef: ot
|
|
334
336
|
}));
|
|
335
337
|
const {
|
|
336
|
-
createDeleteControl:
|
|
337
|
-
} =
|
|
338
|
+
createDeleteControl: rt
|
|
339
|
+
} = Te({
|
|
338
340
|
performDelete: D
|
|
339
341
|
}), {
|
|
340
|
-
createOCRControl:
|
|
341
|
-
} =
|
|
342
|
-
performOCR:
|
|
343
|
-
ocrRecognizingRef:
|
|
344
|
-
ocrErrorRef:
|
|
345
|
-
rectMapRef:
|
|
342
|
+
createOCRControl: nt
|
|
343
|
+
} = Ce({
|
|
344
|
+
performOCR: Gt,
|
|
345
|
+
ocrRecognizingRef: Ct,
|
|
346
|
+
ocrErrorRef: ot,
|
|
347
|
+
rectMapRef: c
|
|
346
348
|
});
|
|
347
|
-
|
|
348
|
-
canvas:
|
|
349
|
-
onRegionSelect:
|
|
350
|
-
createDeleteControl:
|
|
351
|
-
createOCRControl:
|
|
352
|
-
textLayersMapRef:
|
|
353
|
-
rectMapRef:
|
|
349
|
+
Re({
|
|
350
|
+
canvas: t,
|
|
351
|
+
onRegionSelect: at,
|
|
352
|
+
createDeleteControl: rt,
|
|
353
|
+
createOCRControl: nt,
|
|
354
|
+
textLayersMapRef: m,
|
|
355
|
+
rectMapRef: c
|
|
356
|
+
}), Ae({
|
|
357
|
+
canvas: t,
|
|
358
|
+
ocrErrorRef: ot,
|
|
359
|
+
rectMapRef: c,
|
|
360
|
+
onAIButtonHover: (o, e) => {
|
|
361
|
+
var r;
|
|
362
|
+
if (o && e) {
|
|
363
|
+
const n = (r = v.current) == null ? void 0 : r.getBoundingClientRect();
|
|
364
|
+
if (n) {
|
|
365
|
+
const u = e.x - n.left, s = e.y - n.top;
|
|
366
|
+
lt(!0), mt({
|
|
367
|
+
x: u,
|
|
368
|
+
y: s
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
} else
|
|
372
|
+
lt(!1), mt(null);
|
|
373
|
+
}
|
|
354
374
|
});
|
|
355
375
|
const {
|
|
356
|
-
stopDraw:
|
|
357
|
-
} =
|
|
358
|
-
canvas:
|
|
359
|
-
drawingMode:
|
|
376
|
+
stopDraw: b
|
|
377
|
+
} = ue({
|
|
378
|
+
canvas: t,
|
|
379
|
+
drawingMode: k,
|
|
360
380
|
draggable: N,
|
|
361
381
|
setDrawingMode: _,
|
|
362
|
-
canvasToImageCoords:
|
|
382
|
+
canvasToImageCoords: B,
|
|
363
383
|
labelDefinitions: g,
|
|
364
384
|
onChange: O,
|
|
365
|
-
cropRegionImage:
|
|
366
|
-
updateRegionShapeAndImage:
|
|
367
|
-
performOCRIfNeeded:
|
|
368
|
-
createDeleteControl:
|
|
369
|
-
createOCRControl:
|
|
370
|
-
updateRegionNameText:
|
|
385
|
+
cropRegionImage: et,
|
|
386
|
+
updateRegionShapeAndImage: vt,
|
|
387
|
+
performOCRIfNeeded: Tt,
|
|
388
|
+
createDeleteControl: rt,
|
|
389
|
+
createOCRControl: nt,
|
|
390
|
+
updateRegionNameText: z,
|
|
371
391
|
onRegionChange: J,
|
|
372
|
-
onRegionSelect:
|
|
373
|
-
rectMapRef:
|
|
374
|
-
textLayersMapRef:
|
|
375
|
-
|
|
392
|
+
onRegionSelect: at,
|
|
393
|
+
rectMapRef: c,
|
|
394
|
+
textLayersMapRef: m,
|
|
395
|
+
regionNameTextMapRef: A,
|
|
396
|
+
setupBoundaryCheck: It
|
|
376
397
|
});
|
|
377
|
-
|
|
378
|
-
R && (_(!1),
|
|
379
|
-
}, [R,
|
|
380
|
-
h && (
|
|
381
|
-
}, [h,
|
|
382
|
-
if (!
|
|
398
|
+
E(() => {
|
|
399
|
+
R && (_(!1), b());
|
|
400
|
+
}, [R, b]), E(() => {
|
|
401
|
+
h && (X(!0), _(!1), b());
|
|
402
|
+
}, [h, b]), E(() => {
|
|
403
|
+
if (!t)
|
|
383
404
|
return;
|
|
384
405
|
const o = () => {
|
|
385
|
-
|
|
386
|
-
|
|
406
|
+
t.getObjects().forEach((e) => {
|
|
407
|
+
e instanceof W.Rect && e.selectable && (e.set({
|
|
387
408
|
lockMovementX: h,
|
|
388
409
|
lockMovementY: h,
|
|
389
410
|
lockScalingX: h,
|
|
@@ -391,240 +412,242 @@ const _t = Qe.forwardRef(({
|
|
|
391
412
|
hasControls: !h
|
|
392
413
|
// 在只读模式下,如果有 activeLabelValue,我们可能希望它保持选中状态
|
|
393
414
|
// 但不允许用户通过点击来取消选中或选中其他(这个由 canvas.selection 控制)
|
|
394
|
-
}), h &&
|
|
395
|
-
}),
|
|
415
|
+
}), h && e.controls);
|
|
416
|
+
}), t.requestRenderAll();
|
|
396
417
|
};
|
|
397
|
-
return o(),
|
|
398
|
-
|
|
418
|
+
return o(), t.on("object:added", o), () => {
|
|
419
|
+
t.off("object:added", o);
|
|
399
420
|
};
|
|
400
|
-
}, [
|
|
401
|
-
canvas:
|
|
402
|
-
sample:
|
|
403
|
-
image:
|
|
421
|
+
}, [t, h]), le({
|
|
422
|
+
canvas: t,
|
|
423
|
+
sample: i,
|
|
424
|
+
image: y,
|
|
404
425
|
bgImagePosition: V,
|
|
405
|
-
canvasInitializedRef:
|
|
406
|
-
bgImagePositionRef:
|
|
407
|
-
sampleRef:
|
|
408
|
-
labelsLoadedRef:
|
|
409
|
-
rectMapRef:
|
|
410
|
-
textLayersMapRef:
|
|
426
|
+
canvasInitializedRef: Rt,
|
|
427
|
+
bgImagePositionRef: j,
|
|
428
|
+
sampleRef: gt,
|
|
429
|
+
labelsLoadedRef: pt,
|
|
430
|
+
rectMapRef: c,
|
|
431
|
+
textLayersMapRef: m,
|
|
411
432
|
textLayoutContentMapRef: G,
|
|
412
|
-
regionNameTextMapRef:
|
|
433
|
+
regionNameTextMapRef: A,
|
|
413
434
|
ocrLoadingIconMapRef: M,
|
|
414
435
|
imageToCanvasCoords: K,
|
|
415
|
-
updateRegionShapeAndImage:
|
|
416
|
-
createDeleteControl:
|
|
417
|
-
createOCRControl:
|
|
418
|
-
updateRegionNameText:
|
|
436
|
+
updateRegionShapeAndImage: vt,
|
|
437
|
+
createDeleteControl: rt,
|
|
438
|
+
createOCRControl: nt,
|
|
439
|
+
updateRegionNameText: z,
|
|
419
440
|
updateTextLayers: $,
|
|
420
|
-
setupBoundaryCheck:
|
|
421
|
-
cropRegionImage:
|
|
441
|
+
setupBoundaryCheck: It,
|
|
442
|
+
cropRegionImage: et,
|
|
422
443
|
onChange: O
|
|
423
444
|
});
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
if (!
|
|
445
|
+
const kt = T([]);
|
|
446
|
+
E(() => {
|
|
447
|
+
if (!t)
|
|
427
448
|
return;
|
|
428
|
-
const o =
|
|
429
|
-
if (
|
|
449
|
+
const o = kt.current, e = d != null ? d : [], r = new Set(o.map((s) => s.id)), n = new Set(e.map((s) => s.id));
|
|
450
|
+
if (e.length < o.length) {
|
|
430
451
|
const s = [];
|
|
431
|
-
|
|
432
|
-
r.has(a.id) && !n.has(a.id) && s.push(
|
|
452
|
+
c.current.forEach((a, l) => {
|
|
453
|
+
r.has(a.id) && !n.has(a.id) && s.push(l);
|
|
433
454
|
}), s.forEach((a) => {
|
|
434
|
-
|
|
455
|
+
Kt(a);
|
|
435
456
|
});
|
|
436
457
|
}
|
|
437
|
-
if (
|
|
458
|
+
if (kt.current = e, !d || d.length === 0)
|
|
438
459
|
return;
|
|
439
|
-
let
|
|
440
|
-
|
|
441
|
-
var
|
|
442
|
-
const
|
|
443
|
-
if (!
|
|
460
|
+
let u = !1;
|
|
461
|
+
c.current.forEach((s, a) => {
|
|
462
|
+
var p, x;
|
|
463
|
+
const l = d.find((H) => H.id === s.id);
|
|
464
|
+
if (!l)
|
|
444
465
|
return;
|
|
445
|
-
const f =
|
|
466
|
+
const f = _t(it(it({}, s), l), {
|
|
446
467
|
// Keep shape from canvas to avoid desync
|
|
447
468
|
shape: s.shape,
|
|
448
|
-
image: (
|
|
449
|
-
textLayouts: (
|
|
469
|
+
image: (p = l.image) != null ? p : s.image,
|
|
470
|
+
textLayouts: (x = l.textLayouts) != null ? x : s.textLayouts
|
|
450
471
|
});
|
|
451
|
-
(f.name !== s.name || f.content !== s.content || f.image !== s.image || f.textLayouts !== s.textLayouts) && (
|
|
452
|
-
}),
|
|
453
|
-
}, [
|
|
454
|
-
canvas:
|
|
455
|
-
drawingMode:
|
|
472
|
+
(f.name !== s.name || f.content !== s.content || f.image !== s.image || f.textLayouts !== s.textLayouts) && (c.current.set(a, f), f.name !== s.name && z(a, f), u = !0);
|
|
473
|
+
}), u && (t == null || t.renderAll());
|
|
474
|
+
}, [d, t, z, D]), Ie({
|
|
475
|
+
canvas: t,
|
|
476
|
+
drawingMode: k,
|
|
456
477
|
draggable: N,
|
|
457
|
-
textLayersMapRef:
|
|
458
|
-
}),
|
|
459
|
-
if (
|
|
460
|
-
if (
|
|
478
|
+
textLayersMapRef: m
|
|
479
|
+
}), E(() => {
|
|
480
|
+
if (t)
|
|
481
|
+
if (C === null) {
|
|
461
482
|
const o = /* @__PURE__ */ new Set();
|
|
462
|
-
|
|
483
|
+
m.current.forEach((r) => {
|
|
463
484
|
r.forEach((n) => {
|
|
464
485
|
o.add(n);
|
|
465
486
|
});
|
|
466
|
-
}),
|
|
467
|
-
r instanceof
|
|
468
|
-
fill:
|
|
487
|
+
}), t.getObjects().forEach((r) => {
|
|
488
|
+
r instanceof W.Rect && !o.has(r) && r.set({
|
|
489
|
+
fill: yt
|
|
469
490
|
// 移除填充色
|
|
470
491
|
});
|
|
471
|
-
}),
|
|
492
|
+
}), t.getActiveObject() && (t.discardActiveObject(), t.renderAll());
|
|
472
493
|
} else {
|
|
473
|
-
const o =
|
|
474
|
-
if ((
|
|
494
|
+
const o = t.getActiveObject(), e = o ? c.current.get(o) : null;
|
|
495
|
+
if ((e == null ? void 0 : e.id) === (C == null ? void 0 : C.id))
|
|
475
496
|
return;
|
|
476
|
-
if (
|
|
497
|
+
if (C) {
|
|
477
498
|
let r = null;
|
|
478
|
-
if (
|
|
479
|
-
n.id ===
|
|
499
|
+
if (c.current.forEach((n, u) => {
|
|
500
|
+
n.id === C.id && (r = u);
|
|
480
501
|
}), r) {
|
|
481
502
|
const n = /* @__PURE__ */ new Set();
|
|
482
|
-
|
|
483
|
-
|
|
503
|
+
m.current.forEach((l) => {
|
|
504
|
+
l.forEach((f) => {
|
|
484
505
|
n.add(f);
|
|
485
506
|
});
|
|
486
|
-
}),
|
|
487
|
-
|
|
488
|
-
fill:
|
|
507
|
+
}), t.getObjects().forEach((l) => {
|
|
508
|
+
l instanceof W.Rect && !n.has(l) && l.set({
|
|
509
|
+
fill: yt
|
|
489
510
|
// 移除填充色
|
|
490
511
|
});
|
|
491
512
|
});
|
|
492
|
-
const
|
|
513
|
+
const u = t.getZoom(), s = ct / u, a = r;
|
|
493
514
|
a.set({
|
|
494
|
-
fill:
|
|
515
|
+
fill: Me,
|
|
495
516
|
// 选中时添加填充色
|
|
517
|
+
stroke: Mt,
|
|
518
|
+
// 选中时取消高亮,使用普通边框颜色
|
|
496
519
|
strokeUniform: !0,
|
|
497
520
|
strokeWidth: s,
|
|
498
521
|
objectCaching: !1,
|
|
499
522
|
statefullCache: !1,
|
|
500
523
|
noScaleCache: !1
|
|
501
|
-
}),
|
|
524
|
+
}), t.setActiveObject(a), t.renderAll();
|
|
502
525
|
}
|
|
503
526
|
}
|
|
504
527
|
}
|
|
505
|
-
}, [
|
|
528
|
+
}, [t, C, c, m]), E(() => {
|
|
506
529
|
var a;
|
|
507
|
-
if (!
|
|
530
|
+
if (!t)
|
|
508
531
|
return;
|
|
509
|
-
const o = (a = R == null ? void 0 : R.region) == null ? void 0 : a.id,
|
|
510
|
-
|
|
511
|
-
|
|
532
|
+
const o = (a = R == null ? void 0 : R.region) == null ? void 0 : a.id, e = C == null ? void 0 : C.id, r = /* @__PURE__ */ new Set();
|
|
533
|
+
m.current.forEach((l) => {
|
|
534
|
+
l.forEach((f) => {
|
|
512
535
|
r.add(f);
|
|
513
536
|
});
|
|
514
537
|
});
|
|
515
538
|
let n = !1;
|
|
516
|
-
const
|
|
517
|
-
|
|
539
|
+
const u = t.getZoom(), s = ct / u;
|
|
540
|
+
c.current.forEach((l, f) => {
|
|
518
541
|
if (r.has(f))
|
|
519
542
|
return;
|
|
520
|
-
const
|
|
521
|
-
if (
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
visible:
|
|
543
|
+
const p = o === l.id;
|
|
544
|
+
if (e === l.id) {
|
|
545
|
+
const U = m.current.get(f);
|
|
546
|
+
U && U.length > 0 && U.forEach((xt) => {
|
|
547
|
+
xt.visible !== p && (xt.set({
|
|
548
|
+
visible: p
|
|
526
549
|
}), n = !0);
|
|
527
550
|
});
|
|
528
551
|
return;
|
|
529
552
|
}
|
|
530
|
-
const H = f.stroke,
|
|
531
|
-
H !==
|
|
532
|
-
stroke:
|
|
553
|
+
const H = f.stroke, st = p ? De : Mt;
|
|
554
|
+
H !== st && (f.set({
|
|
555
|
+
stroke: st,
|
|
533
556
|
strokeWidth: s,
|
|
534
557
|
strokeUniform: !0
|
|
535
558
|
}), n = !0);
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
visible:
|
|
559
|
+
const P = m.current.get(f);
|
|
560
|
+
P && P.length > 0 && P.forEach((U) => {
|
|
561
|
+
U.visible !== p && (U.set({
|
|
562
|
+
visible: p
|
|
540
563
|
}), n = !0);
|
|
541
564
|
});
|
|
542
|
-
}), n &&
|
|
543
|
-
}, [
|
|
544
|
-
var n,
|
|
545
|
-
if (!
|
|
565
|
+
}), n && t.renderAll();
|
|
566
|
+
}, [t, R, C, m, c]), E(() => {
|
|
567
|
+
var n, u;
|
|
568
|
+
if (!t)
|
|
546
569
|
return;
|
|
547
570
|
const o = (n = R == null ? void 0 : R.region) == null ? void 0 : n.id;
|
|
548
571
|
if (!o)
|
|
549
572
|
return;
|
|
550
|
-
let
|
|
551
|
-
if (
|
|
552
|
-
s.id === o && (
|
|
553
|
-
}), !
|
|
573
|
+
let e = null;
|
|
574
|
+
if (c.current.forEach((s, a) => {
|
|
575
|
+
s.id === o && (e = a);
|
|
576
|
+
}), !e)
|
|
554
577
|
return;
|
|
555
|
-
|
|
578
|
+
e.bringToFront(), ((u = m.current.get(e)) != null ? u : []).forEach((s) => {
|
|
556
579
|
s.bringToFront();
|
|
557
|
-
}),
|
|
558
|
-
}, [
|
|
559
|
-
if (!
|
|
580
|
+
}), t.renderAll();
|
|
581
|
+
}, [t, R, c, m]), E(() => {
|
|
582
|
+
if (!t || !R || !Q)
|
|
560
583
|
return;
|
|
561
|
-
const o = (
|
|
562
|
-
var
|
|
563
|
-
if (
|
|
584
|
+
const o = (e) => {
|
|
585
|
+
var P;
|
|
586
|
+
if (k)
|
|
564
587
|
return;
|
|
565
|
-
const r = (
|
|
588
|
+
const r = (P = e.e) == null ? void 0 : P.target;
|
|
566
589
|
if ((r == null ? void 0 : r.tagName) === "INPUT" || (r == null ? void 0 : r.tagName) === "TEXTAREA")
|
|
567
590
|
return;
|
|
568
|
-
const n =
|
|
591
|
+
const n = t.getPointer(e.e), u = n.x, s = n.y, a = B(u, s), l = R.region, {
|
|
569
592
|
x: f,
|
|
570
|
-
y:
|
|
571
|
-
width:
|
|
593
|
+
y: p,
|
|
594
|
+
width: x,
|
|
572
595
|
height: H
|
|
573
|
-
} =
|
|
574
|
-
a.x >= f && a.x <= f +
|
|
596
|
+
} = l.shape;
|
|
597
|
+
a.x >= f && a.x <= f + x && a.y >= p && a.y <= p + H || Q();
|
|
575
598
|
};
|
|
576
|
-
return
|
|
577
|
-
|
|
599
|
+
return t.on("mouse:down", o), () => {
|
|
600
|
+
t.off("mouse:down", o);
|
|
578
601
|
};
|
|
579
|
-
}, [
|
|
580
|
-
const
|
|
581
|
-
const
|
|
582
|
-
if ((
|
|
602
|
+
}, [t, R, Q, B, k]);
|
|
603
|
+
const At = w((o) => {
|
|
604
|
+
const e = o.target;
|
|
605
|
+
if ((e == null ? void 0 : e.tagName) === "INPUT" || (e == null ? void 0 : e.tagName) === "TEXTAREA" || !t || h)
|
|
583
606
|
return;
|
|
584
|
-
const r =
|
|
585
|
-
!r || !(r instanceof
|
|
586
|
-
}, [
|
|
587
|
-
|
|
588
|
-
const
|
|
589
|
-
(
|
|
607
|
+
const r = t.getActiveObject();
|
|
608
|
+
!r || !(r instanceof W.Rect) || D(r);
|
|
609
|
+
}, [t, D]);
|
|
610
|
+
Z("Delete", At), Z("Backspace", At), Z("r", (o) => {
|
|
611
|
+
const e = o.target;
|
|
612
|
+
(e == null ? void 0 : e.tagName) === "INPUT" || (e == null ? void 0 : e.tagName) === "TEXTAREA" || e != null && e.isContentEditable || h || !k && !N && _(!0);
|
|
590
613
|
}, {
|
|
591
614
|
exactMatch: !1
|
|
592
615
|
// 允许大小写
|
|
593
616
|
});
|
|
594
|
-
const
|
|
595
|
-
h || (
|
|
596
|
-
},
|
|
597
|
-
h || (N &&
|
|
617
|
+
const qt = () => {
|
|
618
|
+
h || (k && (_(!1), b()), X(!N));
|
|
619
|
+
}, Jt = () => {
|
|
620
|
+
h || (N && X(!1), _(!k));
|
|
598
621
|
};
|
|
599
|
-
return
|
|
600
|
-
|
|
601
|
-
}, []), /* @__PURE__ */
|
|
622
|
+
return E(() => () => {
|
|
623
|
+
t && t.dispose();
|
|
624
|
+
}, []), /* @__PURE__ */ Lt("div", {
|
|
602
625
|
style: {
|
|
603
626
|
width: "100%",
|
|
604
627
|
height: "100%",
|
|
605
628
|
display: "flex",
|
|
606
629
|
position: "relative"
|
|
607
630
|
},
|
|
608
|
-
children: [
|
|
631
|
+
children: [Wt && /* @__PURE__ */ L("div", {
|
|
609
632
|
className: "vlm-loading-overlay",
|
|
610
|
-
children: /* @__PURE__ */
|
|
633
|
+
children: /* @__PURE__ */ L("div", {
|
|
611
634
|
className: "vlm-loading-spinner"
|
|
612
635
|
})
|
|
613
|
-
}), /* @__PURE__ */
|
|
636
|
+
}), /* @__PURE__ */ L("div", {
|
|
614
637
|
className: "vlm-marker-toolbar",
|
|
615
|
-
children: /* @__PURE__ */
|
|
616
|
-
drawingMode:
|
|
638
|
+
children: /* @__PURE__ */ L(ie, {
|
|
639
|
+
drawingMode: k,
|
|
617
640
|
draggable: N,
|
|
618
|
-
scale:
|
|
619
|
-
onToggleDrawingMode:
|
|
620
|
-
onToggleDrag:
|
|
621
|
-
onZoom:
|
|
622
|
-
onFitToScreen:
|
|
641
|
+
scale: I,
|
|
642
|
+
onToggleDrawingMode: Jt,
|
|
643
|
+
onToggleDrag: qt,
|
|
644
|
+
onZoom: zt,
|
|
645
|
+
onFitToScreen: F,
|
|
623
646
|
readOnly: h
|
|
624
647
|
})
|
|
625
|
-
}), /* @__PURE__ */
|
|
626
|
-
ref:
|
|
627
|
-
className:
|
|
648
|
+
}), /* @__PURE__ */ Lt("div", {
|
|
649
|
+
ref: v,
|
|
650
|
+
className: se({
|
|
628
651
|
"vlm-label-maker-wrap": !0,
|
|
629
652
|
draggable: N
|
|
630
653
|
}),
|
|
@@ -635,17 +658,21 @@ const _t = Qe.forwardRef(({
|
|
|
635
658
|
flex: 1,
|
|
636
659
|
position: "relative"
|
|
637
660
|
},
|
|
638
|
-
children: [(((
|
|
661
|
+
children: [(((Nt = i == null ? void 0 : i.sampleFileName) == null ? void 0 : Nt.originalName) || ((St = i == null ? void 0 : i.sampleFileName) == null ? void 0 : St.name)) && /* @__PURE__ */ L("div", {
|
|
639
662
|
className: "vlm-image-name",
|
|
640
|
-
children:
|
|
641
|
-
}), /* @__PURE__ */
|
|
663
|
+
children: i.sampleFileName.originalName || i.sampleFileName.name
|
|
664
|
+
}), /* @__PURE__ */ L("canvas", {
|
|
642
665
|
className: "vlm-label-maker-canvas",
|
|
643
|
-
ref:
|
|
666
|
+
ref: ft
|
|
667
|
+
}), tt && /* @__PURE__ */ L(Ne, {
|
|
668
|
+
visible: Ht,
|
|
669
|
+
x: tt.x,
|
|
670
|
+
y: tt.y
|
|
644
671
|
})]
|
|
645
672
|
})]
|
|
646
673
|
});
|
|
647
674
|
});
|
|
648
|
-
|
|
675
|
+
be.displayName = "VLMLabelMaker";
|
|
649
676
|
export {
|
|
650
|
-
|
|
677
|
+
be as default
|
|
651
678
|
};
|