@glodon-aiot/dataset-annotation 3.13.0-alpha.29 → 3.14.0-alpha.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +151 -135
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +244 -218
- package/dist/es/components/VLMAnnotation/RegionItem.mjs +135 -59
- package/dist/es/components/VLMAnnotation/TextAnnotationPanel.mjs +73 -62
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.mjs +55 -40
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +291 -162
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.mjs +100 -0
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +88 -55
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.mjs +103 -0
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.mjs +123 -91
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +42 -39
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +55 -60
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/ai.svg.mjs +4 -0
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/error.svg.mjs +4 -0
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/loading.svg.mjs +4 -0
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/star.svg.mjs +4 -0
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +512 -387
- package/dist/es/components/VLMAnnotation/constants.mjs +39 -32
- package/dist/es/components/VLMAnnotation/index.mjs +187 -150
- package/dist/es/index.mjs +1 -1
- package/dist/lib/index.js +4 -4
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.d.ts +1 -0
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +3 -1
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.d.ts +16 -0
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.d.ts +3 -2
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.d.ts +31 -0
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.d.ts +5 -1
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.d.ts +2 -1
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/index.d.ts +2 -2
- package/dist/src/components/VLMAnnotation/constants.d.ts +19 -3
- package/dist/src/components/VLMAnnotation/index.d.ts +1 -1
- package/dist/src/components/VLMAnnotation/types.d.ts +15 -0
- package/package.json +2 -2
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
for (var s in
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var s of
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
import { fabric as
|
|
15
|
-
import
|
|
1
|
+
var A = Object.defineProperty, B = Object.defineProperties;
|
|
2
|
+
var T = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var U = Object.getOwnPropertySymbols;
|
|
4
|
+
var H = Object.prototype.hasOwnProperty, D = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var C = (r, e, s) => e in r ? A(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s, d = (r, e) => {
|
|
6
|
+
for (var s in e || (e = {}))
|
|
7
|
+
H.call(e, s) && C(r, s, e[s]);
|
|
8
|
+
if (U)
|
|
9
|
+
for (var s of U(e))
|
|
10
|
+
D.call(e, s) && C(r, s, e[s]);
|
|
11
|
+
return r;
|
|
12
|
+
}, m = (r, e) => B(r, T(e));
|
|
13
|
+
var b = (r, e, s) => (C(r, typeof e != "symbol" ? e + "" : e, s), s);
|
|
14
|
+
import { fabric as v } from "fabric";
|
|
15
|
+
import I from "./FabricCustomize.mjs";
|
|
16
16
|
import { formatColorToArray as X } from "../../../../utils/color.mjs";
|
|
17
|
-
const
|
|
17
|
+
const O = {
|
|
18
18
|
borderWidth: 2,
|
|
19
19
|
controls: ["TL", "BL", "TR", "BR"],
|
|
20
20
|
cornerStrokeColor: "#84868C",
|
|
@@ -23,15 +23,15 @@ const z = {
|
|
|
23
23
|
active: !1
|
|
24
24
|
};
|
|
25
25
|
class M {
|
|
26
|
-
constructor(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this._canvas = s, this.handlers =
|
|
26
|
+
constructor(e, s, c) {
|
|
27
|
+
b(this, "config");
|
|
28
|
+
b(this, "color");
|
|
29
|
+
b(this, "_active", !1);
|
|
30
|
+
b(this, "_fabricRect", null);
|
|
31
|
+
b(this, "_label", null);
|
|
32
|
+
b(this, "_hover", !1);
|
|
33
|
+
b(this, "_strokeRect");
|
|
34
|
+
this._canvas = s, this.handlers = c, v.Rect.prototype.cornerColor = "blue", this.config = d(d({}, O), e), this.color = X(e.color), this._active = this.config.active || !1, s && this.render(s);
|
|
35
35
|
}
|
|
36
36
|
get object() {
|
|
37
37
|
return this._fabricRect;
|
|
@@ -39,22 +39,24 @@ class M {
|
|
|
39
39
|
get active() {
|
|
40
40
|
return this._active;
|
|
41
41
|
}
|
|
42
|
-
set active(
|
|
42
|
+
set active(e) {
|
|
43
43
|
var s;
|
|
44
|
-
this._active =
|
|
44
|
+
this._active = e, (s = this._fabricRect) != null && s.canvas && (e && !this.config.hideDelete ? (this._fabricRect.set(m(d({}, this.activeStyle), {
|
|
45
|
+
lockUniScaling: !1
|
|
46
|
+
})), this._fabricRect.uniformScaling = !1, this.canvas.setActiveObject(this._fabricRect)) : (this.canvas.discardActiveObject(), this.hover || this._fabricRect.set(this.normalStyle)), this.canvas.requestRenderAll());
|
|
45
47
|
}
|
|
46
48
|
get hover() {
|
|
47
49
|
return this._hover;
|
|
48
50
|
}
|
|
49
|
-
set hover(
|
|
50
|
-
var s,
|
|
51
|
-
this._hover =
|
|
51
|
+
set hover(e) {
|
|
52
|
+
var s, c;
|
|
53
|
+
this._hover = e, e ? (s = this._fabricRect) == null || s.set(this.hoverStyle) : this.active || (c = this._fabricRect) == null || c.set(this.normalStyle), this.canvas.requestRenderAll();
|
|
52
54
|
}
|
|
53
55
|
get canvas() {
|
|
54
56
|
return this._canvas;
|
|
55
57
|
}
|
|
56
|
-
set canvas(
|
|
57
|
-
this._canvas !==
|
|
58
|
+
set canvas(e) {
|
|
59
|
+
this._canvas !== e && (this._canvas = e, this.render(e));
|
|
58
60
|
}
|
|
59
61
|
get normalStyle() {
|
|
60
62
|
return {
|
|
@@ -68,7 +70,7 @@ class M {
|
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
72
|
get activeStyle() {
|
|
71
|
-
return
|
|
73
|
+
return m(d({}, this.normalStyle), {
|
|
72
74
|
content: `<svg height="500" width="500"><text fill="#ffffff" font-size="45" x="50" y="86">${this.config.name}</text></svg>`,
|
|
73
75
|
fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 0.1)`
|
|
74
76
|
});
|
|
@@ -77,40 +79,42 @@ class M {
|
|
|
77
79
|
return this.activeStyle;
|
|
78
80
|
}
|
|
79
81
|
createRect() {
|
|
80
|
-
const
|
|
82
|
+
const e = {
|
|
81
83
|
hasBorders: !1,
|
|
82
84
|
cornerSize: 6,
|
|
83
85
|
cornerStrokeColor: "#84868C",
|
|
84
86
|
cornerColor: "#FFFFFF",
|
|
85
87
|
transparentCorners: !1
|
|
86
|
-
}, s = 0,
|
|
88
|
+
}, s = 0, c = new v.Rect(
|
|
87
89
|
// this.config.points?.map((p) => ({ x: p[0], y: p[1] })),
|
|
88
|
-
|
|
90
|
+
m(d(d({
|
|
89
91
|
left: this.config.points[0][0],
|
|
90
92
|
top: this.config.points[0][1],
|
|
91
93
|
width: this.config.points[2][0] - this.config.points[0][0] - s,
|
|
92
94
|
height: this.config.points[2][1] - this.config.points[0][1] - s
|
|
93
|
-
},
|
|
95
|
+
}, e), this.normalStyle), {
|
|
94
96
|
// 禁止缩放时翻转
|
|
95
|
-
lockScalingFlip: !0
|
|
97
|
+
lockScalingFlip: !0,
|
|
98
|
+
// 允许不保持比例调整(可以自由调整宽高)
|
|
99
|
+
lockUniScaling: !1
|
|
96
100
|
})
|
|
97
101
|
);
|
|
98
|
-
|
|
102
|
+
c.setControlsVisibility({
|
|
99
103
|
mtr: !1
|
|
100
104
|
});
|
|
101
|
-
const
|
|
102
|
-
if (
|
|
103
|
-
this.canvas.off("after:render",
|
|
105
|
+
const l = () => {
|
|
106
|
+
if (c.canvas !== this.canvas) {
|
|
107
|
+
this.canvas.off("after:render", l);
|
|
104
108
|
return;
|
|
105
109
|
}
|
|
106
110
|
this.canvas.contextContainer.strokeStyle = `rgb(${this.color[0]},${this.color[1]}, ${this.color[2]})`;
|
|
107
|
-
const o =
|
|
111
|
+
const o = c.getBoundingRect();
|
|
108
112
|
this._strokeRect = this.canvas.contextContainer.strokeRect(o.left + 0.5, o.top + 0.5, o.width, o.height);
|
|
109
113
|
};
|
|
110
|
-
return this.canvas.on("after:render",
|
|
114
|
+
return this.canvas.on("after:render", l), c;
|
|
111
115
|
}
|
|
112
|
-
scaledNumber(
|
|
113
|
-
return
|
|
116
|
+
scaledNumber(e) {
|
|
117
|
+
return e / this.canvas.getZoom();
|
|
114
118
|
}
|
|
115
119
|
// getPolyVertices(poly: fabric.Rect) {
|
|
116
120
|
// const points = poly.points,
|
|
@@ -133,26 +137,26 @@ class M {
|
|
|
133
137
|
// });
|
|
134
138
|
// }
|
|
135
139
|
createLabelName() {
|
|
136
|
-
const [
|
|
140
|
+
const [e, s, c] = this.color, l = new v.Text(this.handlers.renderLabelItem ? this.handlers.renderLabelItem(this.config) : this.config.name, {
|
|
137
141
|
fill: "#FFFFFF",
|
|
138
142
|
fontSize: 12,
|
|
139
143
|
selectable: !1,
|
|
140
144
|
evented: !1,
|
|
141
145
|
top: 4,
|
|
142
146
|
left: 8
|
|
143
|
-
}), o = new
|
|
147
|
+
}), o = new v.Rect({
|
|
144
148
|
selectable: !1,
|
|
145
149
|
evented: !1,
|
|
146
150
|
strokeWidth: 0,
|
|
147
|
-
fill: `rgb(${
|
|
151
|
+
fill: `rgb(${e},${s},${c})`,
|
|
148
152
|
rx: 2,
|
|
149
153
|
ry: 2,
|
|
150
|
-
width: (
|
|
151
|
-
height: (
|
|
154
|
+
width: (l.width || 0) + 16,
|
|
155
|
+
height: (l.height || 0) + 8,
|
|
152
156
|
left: 0,
|
|
153
157
|
top: 0
|
|
154
158
|
});
|
|
155
|
-
return new
|
|
159
|
+
return new v.Group([o, l], {
|
|
156
160
|
selectable: !1,
|
|
157
161
|
evented: !1,
|
|
158
162
|
// lockScalingX: false,
|
|
@@ -162,27 +166,27 @@ class M {
|
|
|
162
166
|
});
|
|
163
167
|
}
|
|
164
168
|
renderLabel() {
|
|
165
|
-
var
|
|
169
|
+
var e, s;
|
|
166
170
|
if (this._fabricRect) {
|
|
167
171
|
if (this._label || (this._label = this.createLabelName(), this.setLabelPosition()), this._label.canvas === this.canvas) {
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
170
|
-
|
|
172
|
+
const c = this._label.getObjects().find((o) => o.type === "rect"), l = this._label.getObjects().find((o) => o.type === "text");
|
|
173
|
+
if (l) {
|
|
174
|
+
l.set({
|
|
171
175
|
text: this.handlers.renderLabelItem ? this.handlers.renderLabelItem(this.config) : this.config.name,
|
|
172
176
|
left: 8
|
|
173
177
|
// fontSize: this.scaledNumber(12),
|
|
174
178
|
});
|
|
175
|
-
const o = (
|
|
176
|
-
|
|
179
|
+
const o = (l.getBoundingRect().width || 0) + 16;
|
|
180
|
+
c == null || c.set({
|
|
177
181
|
fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 1)`,
|
|
178
182
|
width: o,
|
|
179
183
|
left: -o / 2
|
|
180
|
-
}),
|
|
184
|
+
}), l.set({
|
|
181
185
|
left: -o / 2 + 8
|
|
182
186
|
});
|
|
183
|
-
const
|
|
187
|
+
const g = ((e = this._fabricRect.aCoords) == null ? void 0 : e.tl.x) !== void 0 ? (s = this._fabricRect.aCoords) == null ? void 0 : s.tl.x : void 0;
|
|
184
188
|
this._label.set({
|
|
185
|
-
left:
|
|
189
|
+
left: g,
|
|
186
190
|
width: o
|
|
187
191
|
});
|
|
188
192
|
}
|
|
@@ -192,118 +196,130 @@ class M {
|
|
|
192
196
|
}
|
|
193
197
|
}
|
|
194
198
|
setLabelPosition() {
|
|
195
|
-
var
|
|
199
|
+
var g, h, n, t;
|
|
196
200
|
if (!this._fabricRect || !this._label)
|
|
197
201
|
return;
|
|
198
|
-
const
|
|
199
|
-
if (!
|
|
202
|
+
const e = this._label.getObjects().find((i) => i.type === "rect");
|
|
203
|
+
if (!e)
|
|
200
204
|
return;
|
|
201
|
-
const s =
|
|
205
|
+
const s = e.height ? e.height : void 0, c = e.width ? e.width : void 0, l = ((g = this._fabricRect.aCoords) == null ? void 0 : g.tl.y) !== void 0 && s !== void 0 && e.scaleY ? ((h = this._fabricRect.aCoords) == null ? void 0 : h.tl.y) - s / this.canvas.getZoom() : void 0, o = ((n = this._fabricRect.aCoords) == null ? void 0 : n.tl.x) !== void 0 ? (t = this._fabricRect.aCoords) == null ? void 0 : t.tl.x : void 0;
|
|
202
206
|
this._label.set({
|
|
203
|
-
top:
|
|
207
|
+
top: l,
|
|
204
208
|
left: o,
|
|
205
209
|
height: s,
|
|
206
|
-
width:
|
|
210
|
+
width: c,
|
|
207
211
|
scaleX: 1 / this.canvas.getZoom(),
|
|
208
212
|
scaleY: 1 / this.canvas.getZoom()
|
|
209
|
-
}), this.config =
|
|
213
|
+
}), this.config = d({}, this.config);
|
|
210
214
|
}
|
|
211
|
-
addToCanvas(
|
|
215
|
+
addToCanvas(e) {
|
|
212
216
|
if (!this._fabricRect)
|
|
213
217
|
return;
|
|
214
|
-
this.canvas =
|
|
218
|
+
this.canvas = e, this.canvas.add(this._fabricRect), this._fabricRect.on("mouseover", (h) => {
|
|
215
219
|
this.hover = !0;
|
|
216
|
-
}), this._fabricRect.on("mouseout", (
|
|
220
|
+
}), this._fabricRect.on("mouseout", (h) => {
|
|
217
221
|
this.hover = !1;
|
|
218
222
|
}), this._fabricRect.on("mousedown", () => {
|
|
219
223
|
this._fabricRect && this.canvas.setActiveObject(this._fabricRect);
|
|
220
|
-
});
|
|
221
|
-
const s = (
|
|
222
|
-
var
|
|
223
|
-
(
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
}), this._handleSelectionUpdate && (this.canvas.off("selection:created", this._handleSelectionUpdate), this.canvas.off("selection:updated", this._handleSelectionUpdate)), this._handleSelectionCleared && this.canvas.off("selection:cleared", this._handleSelectionCleared);
|
|
225
|
+
const s = (h) => {
|
|
226
|
+
var n;
|
|
227
|
+
(n = h.selected) != null && n.some((t) => t === this._fabricRect) ? (this.active = !0, this._fabricRect && (this._fabricRect.set({
|
|
228
|
+
lockUniScaling: !1
|
|
229
|
+
}), this._fabricRect.uniformScaling = !1)) : this.active && (this.active = !1);
|
|
230
|
+
}, c = (h) => {
|
|
226
231
|
this.active && (this.active = !1);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
232
|
+
};
|
|
233
|
+
this.canvas.on("selection:created", s), this.canvas.on("selection:updated", s), this.canvas.on("selection:cleared", c), this._handleSelectionUpdate = s, this._handleSelectionCleared = c;
|
|
234
|
+
const l = (h) => {
|
|
235
|
+
var y, x, $, j, k, L;
|
|
236
|
+
const n = h.transform.action;
|
|
237
|
+
h.transform.corner;
|
|
238
|
+
const t = h.transform.target, i = h.transform.target.canvas.backgroundImage, a = 0;
|
|
239
|
+
if (i && (n === "drag" && (t.top < i.top && t.set({
|
|
240
|
+
top: i.top
|
|
241
|
+
}), t.top + (t.height + a) * t.scaleY > i.top + i.height && t.set({
|
|
242
|
+
top: i.height + i.top - (t.height + a) * t.scaleY
|
|
243
|
+
}), t.left < i.left && t.set({
|
|
244
|
+
left: i.left
|
|
245
|
+
}), t.left + (t.width + a) * t.scaleX > i.left + i.width && t.set({
|
|
246
|
+
left: i.width + i.left - (t.width + a) * t.scaleX
|
|
247
|
+
})), n === "scale" && (t.top + (t.height + a) * t.scaleY > i.top + i.height && t.set({
|
|
248
|
+
top: (t.height + a) * t.scaleY > i.height ? i.top : i.top + i.height - (t.height + a) * t.scaleY,
|
|
249
|
+
height: (t.height + a) * t.scaleY > i.height ? i.height - a : t.height + a
|
|
250
|
+
}), t.left + (t.width + a) * t.scaleX > i.left + i.width && t.set({
|
|
251
|
+
left: i.width + i.left - (t.width + a) * t.scaleX
|
|
252
|
+
})), n === "scaleX" && (t.left + (t.width + a) * t.scaleX > i.left + i.width && t.set({
|
|
253
|
+
left: t.left - (t.left + (t.width + a) * t.scaleX - (i.left + i.width))
|
|
254
|
+
}), t.left < i.left && t.set({
|
|
255
|
+
left: i.left
|
|
256
|
+
})), n === "scaleY" && (t.top + (t.height + a) * t.scaleY > i.top + i.height && t.set({
|
|
257
|
+
top: t.top - (t.top + (t.height + a) * t.scaleY - (i.top + i.height))
|
|
258
|
+
}), t.top < i.top && t.set({
|
|
259
|
+
top: i.top
|
|
260
|
+
})), (t.width + a) * t.scaleX > i.width && t.set({
|
|
261
|
+
left: i.left,
|
|
262
|
+
width: (i.width - a) / t.scaleX
|
|
263
|
+
}), (t.height + a) * t.scaleY > i.height && t.set({
|
|
264
|
+
top: i.top,
|
|
265
|
+
height: (i.height - a) / t.scaleY
|
|
266
|
+
})), i) {
|
|
267
|
+
const _ = t.getBoundingRect(!0), u = (y = i.left) != null ? y : 0, S = (x = i.top) != null ? x : 0, Y = u + (($ = i.width) != null ? $ : 0), F = S + ((j = i.height) != null ? j : 0);
|
|
268
|
+
if (_.width > ((k = i.width) != null ? k : _.width)) {
|
|
269
|
+
const w = (i.width - a) / Math.max(t.width, 1);
|
|
264
270
|
t.set({
|
|
265
|
-
scaleX: Math.min(t.scaleX,
|
|
271
|
+
scaleX: Math.min(t.scaleX, w)
|
|
266
272
|
});
|
|
267
273
|
}
|
|
268
|
-
if (
|
|
269
|
-
const
|
|
274
|
+
if (_.height > ((L = i.height) != null ? L : _.height)) {
|
|
275
|
+
const w = (i.height - a) / Math.max(t.height, 1);
|
|
270
276
|
t.set({
|
|
271
|
-
scaleY: Math.min(t.scaleY,
|
|
277
|
+
scaleY: Math.min(t.scaleY, w)
|
|
272
278
|
});
|
|
273
279
|
}
|
|
274
|
-
const
|
|
275
|
-
let
|
|
276
|
-
|
|
277
|
-
left: t.left +
|
|
278
|
-
top: t.top +
|
|
280
|
+
const f = t.getBoundingRect(!0);
|
|
281
|
+
let p = 0, R = 0;
|
|
282
|
+
f.left < u ? p = u - f.left : f.left + f.width > Y && (p = Y - (f.left + f.width)), f.top < S ? R = S - f.top : f.top + f.height > F && (R = F - (f.top + f.height)), (p !== 0 || R !== 0) && t.set({
|
|
283
|
+
left: t.left + p,
|
|
284
|
+
top: t.top + R
|
|
279
285
|
});
|
|
280
286
|
}
|
|
281
287
|
this.canvas.renderAll();
|
|
282
|
-
},
|
|
283
|
-
|
|
288
|
+
}, o = (h) => {
|
|
289
|
+
l(h), this.setLabelPosition();
|
|
284
290
|
};
|
|
285
|
-
this._fabricRect.on("moving",
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
291
|
+
this._fabricRect.on("moving", o), this._fabricRect.on("scaling", o), this._fabricRect.on("rotating", o), this._fabricRect.on("skewing", o), this._fabricRect.on("resizing", o), this._objectRemovedHandler && this.canvas.off("object:removed", this._objectRemovedHandler);
|
|
292
|
+
const g = (h) => {
|
|
293
|
+
var n;
|
|
294
|
+
((n = h.target) == null ? void 0 : n.type) === "rect" && h.target === this._fabricRect && !this._isDestroying && this._fabricRect && this.destroy();
|
|
295
|
+
};
|
|
296
|
+
this.canvas.on("object:removed", g), this._objectRemovedHandler = g, this.canvas.on("object:modified", (h) => {
|
|
297
|
+
h.target === this._fabricRect && (this.setLabelPosition(), this.handlers.onChange && this.handlers.onChange(this));
|
|
289
298
|
});
|
|
290
299
|
}
|
|
291
|
-
render(
|
|
292
|
-
|
|
300
|
+
render(e) {
|
|
301
|
+
I(v), this._fabricRect || (this._fabricRect = this.createRect()), this._fabricRect.canvas === this.canvas ? this._fabricRect.set({
|
|
293
302
|
fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 0)`,
|
|
294
303
|
stroke: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 1)`
|
|
295
|
-
}) : this.addToCanvas(
|
|
304
|
+
}) : this.addToCanvas(e), this.renderLabel();
|
|
296
305
|
try {
|
|
297
306
|
this.canvas.renderAll();
|
|
298
307
|
} catch (s) {
|
|
299
308
|
console.log("render failed");
|
|
300
309
|
}
|
|
301
310
|
}
|
|
302
|
-
set labelConfig(
|
|
303
|
-
this.config =
|
|
311
|
+
set labelConfig(e) {
|
|
312
|
+
this.config = d(d({}, this.config), e), this.color = X(e.color), this.render(this.canvas), this.handlers.onChange && this.handlers.onChange(this);
|
|
304
313
|
}
|
|
305
314
|
destroy() {
|
|
306
|
-
|
|
315
|
+
if (!this._isDestroying) {
|
|
316
|
+
if (this._isDestroying = !0, this._objectRemovedHandler) {
|
|
317
|
+
this.canvas.off("object:removed", this._objectRemovedHandler);
|
|
318
|
+
const e = this._objectRemovedHandler;
|
|
319
|
+
this.canvas.off("object:removed", e), this._objectRemovedHandler = null;
|
|
320
|
+
}
|
|
321
|
+
this._handleSelectionUpdate && (this.canvas.off("selection:created", this._handleSelectionUpdate), this.canvas.off("selection:updated", this._handleSelectionUpdate), this._handleSelectionUpdate = null), this._handleSelectionCleared && (this.canvas.off("selection:cleared", this._handleSelectionCleared), this._handleSelectionCleared = null), this._fabricRect && this.canvas.remove(this._fabricRect), this._label && this.canvas.remove(this._label), this._label = null, this._fabricRect = null, this.canvas.requestRenderAll(), this.handlers.onDelete && this.handlers.onDelete(this);
|
|
322
|
+
}
|
|
307
323
|
}
|
|
308
324
|
}
|
|
309
325
|
export {
|