@glodon-aiot/dataset-annotation 3.14.0-alpha.32 → 3.15.0-alpha.1
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/DatasetContext/index.mjs +3 -6
- package/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +91 -94
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/Drawable.mjs +28 -37
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +101 -145
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +195 -256
- package/dist/es/components/DetectionAnnotation/index.mjs +424 -456
- package/dist/es/components/Iconfont/index.mjs +2 -2
- package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/index.mjs +1 -1
- package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.mjs +1 -1
- package/dist/es/components/OcrAnnotation/OcrModal/index.mjs +45 -43
- package/dist/es/components/PicZipImportModal/index.mjs +293 -308
- package/dist/es/components/PreLabelOCR/index.mjs +1 -1
- package/dist/es/constant.mjs +3 -3
- package/dist/es/featuresConfig.mjs +9 -13
- package/dist/es/index.mjs +7 -11
- package/dist/lib/index.js +3 -4
- package/dist/src/DatasetContext/index.d.ts +0 -2
- package/dist/src/components/DetectionAnnotation/components/ImageDetail/index.d.ts +0 -1
- package/dist/src/constant.d.ts +1 -1
- package/dist/src/featuresConfig.d.ts +0 -4
- package/dist/src/index.d.ts +0 -3
- package/package.json +2 -2
- package/dist/es/components/DetectionAnnotation/components/ImageModal/index.mjs +0 -129
- package/dist/es/components/DetectionAnnotation/components/ImageModal/style.less.mjs +0 -4
- package/dist/es/components/PicZipImportModal/config.mjs +0 -47
- package/dist/es/components/PicZipImportModal/pic_vlm_json_zip.svg.mjs +0 -4
- package/dist/es/components/PicZipImportModal/pic_vlm_zip.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/RegionItem.mjs +0 -170
- package/dist/es/components/VLMAnnotation/TextAnnotationPanel.mjs +0 -94
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.mjs +0 -116
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.mjs +0 -115
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.mjs +0 -42
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.mjs +0 -55
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.mjs +0 -51
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.mjs +0 -62
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +0 -421
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.mjs +0 -100
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.mjs +0 -106
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +0 -101
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.mjs +0 -103
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.mjs +0 -38
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.mjs +0 -173
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.mjs +0 -72
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +0 -116
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +0 -98
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.mjs +0 -156
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/ai.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/del.png.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/error.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/loading.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/star.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +0 -651
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.mjs +0 -33
- package/dist/es/components/VLMAnnotation/components/DragButton.mjs +0 -18
- package/dist/es/components/VLMAnnotation/components/FitToScreenButton.mjs +0 -16
- package/dist/es/components/VLMAnnotation/components/RectangleButton.mjs +0 -30
- package/dist/es/components/VLMAnnotation/components/Toolbar.mjs +0 -40
- package/dist/es/components/VLMAnnotation/components/ZoomControls.mjs +0 -44
- package/dist/es/components/VLMAnnotation/constants.mjs +0 -57
- package/dist/es/components/VLMAnnotation/index.mjs +0 -279
- package/dist/es/components/VLMAnnotation/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.mjs +0 -343
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.mjs +0 -240
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.mjs +0 -201
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/index.mjs +0 -455
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/VlmModal/index.mjs +0 -149
- package/dist/es/components/VLMAnnotationDetail/VlmModal/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/index.mjs +0 -449
- package/dist/es/components/VLMAnnotationDetail/style.less.mjs +0 -4
- package/dist/es/createVlmtasetAnnotation/index.mjs +0 -131
- package/dist/src/components/DetectionAnnotation/components/ImageModal/index.d.ts +0 -34
- package/dist/src/components/Iconfont/font_4439177_tgvowh6bmlb.d.ts +0 -0
- package/dist/src/components/PicZipImportModal/config.d.ts +0 -23
- package/dist/src/components/VLMAnnotation/ImageAnnotationDebugger.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/RegionItem.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/TextAnnotationPanel.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.d.ts +0 -13
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.d.ts +0 -38
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.d.ts +0 -18
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.d.ts +0 -7
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.d.ts +0 -13
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.d.ts +0 -22
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +0 -34
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.d.ts +0 -16
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.d.ts +0 -11
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.d.ts +0 -29
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.d.ts +0 -31
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.d.ts +0 -13
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.d.ts +0 -41
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.d.ts +0 -12
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.d.ts +0 -16
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.d.ts +0 -32
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.d.ts +0 -25
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/index.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.d.ts +0 -32
- package/dist/src/components/VLMAnnotation/components/DragButton.d.ts +0 -7
- package/dist/src/components/VLMAnnotation/components/FitToScreenButton.d.ts +0 -6
- package/dist/src/components/VLMAnnotation/components/RectangleButton.d.ts +0 -7
- package/dist/src/components/VLMAnnotation/components/Toolbar.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/components/ZoomControls.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/constants.d.ts +0 -113
- package/dist/src/components/VLMAnnotation/index.d.ts +0 -6
- package/dist/src/components/VLMAnnotation/types.d.ts +0 -187
- package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.d.ts +0 -14
- package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.d.ts +0 -12
- package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.d.ts +0 -12
- package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/index.d.ts +0 -12
- package/dist/src/components/VLMAnnotationDetail/VlmModal/index.d.ts +0 -17
- package/dist/src/components/VLMAnnotationDetail/index.d.ts +0 -6
- package/dist/src/createVlmtasetAnnotation/index.d.ts +0 -16
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var p = Object.defineProperty, m = Object.defineProperties;
|
|
2
|
+
var u = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var b = Object.getOwnPropertySymbols;
|
|
4
|
+
var w = Object.prototype.hasOwnProperty, C = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var g = (l, e, s) => e in l ? p(l, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : l[e] = s, n = (l, e) => {
|
|
6
6
|
for (var s in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var s of
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
import { fabric as
|
|
15
|
-
import
|
|
16
|
-
import { formatColorToArray as
|
|
17
|
-
const
|
|
7
|
+
w.call(e, s) && g(l, s, e[s]);
|
|
8
|
+
if (b)
|
|
9
|
+
for (var s of b(e))
|
|
10
|
+
C.call(e, s) && g(l, s, e[s]);
|
|
11
|
+
return l;
|
|
12
|
+
}, v = (l, e) => m(l, u(e));
|
|
13
|
+
var f = (l, e, s) => (g(l, typeof e != "symbol" ? e + "" : e, s), s);
|
|
14
|
+
import { fabric as d } from "fabric";
|
|
15
|
+
import y from "./FabricCustomize.mjs";
|
|
16
|
+
import { formatColorToArray as _ } from "../../../../utils/color.mjs";
|
|
17
|
+
const $ = {
|
|
18
18
|
borderWidth: 2,
|
|
19
19
|
controls: ["TL", "BL", "TR", "BR"],
|
|
20
20
|
cornerStrokeColor: "#84868C",
|
|
@@ -22,16 +22,16 @@ const O = {
|
|
|
22
22
|
visible: !0,
|
|
23
23
|
active: !1
|
|
24
24
|
};
|
|
25
|
-
class
|
|
26
|
-
constructor(e, s,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this._canvas = s, this.handlers =
|
|
25
|
+
class F {
|
|
26
|
+
constructor(e, s, h) {
|
|
27
|
+
f(this, "config");
|
|
28
|
+
f(this, "color");
|
|
29
|
+
f(this, "_active", !1);
|
|
30
|
+
f(this, "_fabricRect", null);
|
|
31
|
+
f(this, "_label", null);
|
|
32
|
+
f(this, "_hover", !1);
|
|
33
|
+
f(this, "_strokeRect");
|
|
34
|
+
this._canvas = s, this.handlers = h, d.Rect.prototype.cornerColor = "blue", this.config = n(n({}, $), e), this.color = _(e.color), this._active = this.config.active || !1, s && this.render(s);
|
|
35
35
|
}
|
|
36
36
|
get object() {
|
|
37
37
|
return this._fabricRect;
|
|
@@ -41,16 +41,14 @@ class M {
|
|
|
41
41
|
}
|
|
42
42
|
set active(e) {
|
|
43
43
|
var s;
|
|
44
|
-
this._active = e, (s = this._fabricRect) != null && s.canvas && (e && !this.config.hideDelete ? (this._fabricRect.set(
|
|
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());
|
|
44
|
+
this._active = e, (s = this._fabricRect) != null && s.canvas && (e && !this.config.hideDelete ? (this._fabricRect.set(this.activeStyle), this.canvas.setActiveObject(this._fabricRect)) : (this.canvas.discardActiveObject(), this.hover || this._fabricRect.set(this.normalStyle)), this.canvas.requestRenderAll());
|
|
47
45
|
}
|
|
48
46
|
get hover() {
|
|
49
47
|
return this._hover;
|
|
50
48
|
}
|
|
51
49
|
set hover(e) {
|
|
52
|
-
var s,
|
|
53
|
-
this._hover = e, e ? (s = this._fabricRect) == null || s.set(this.hoverStyle) : this.active || (
|
|
50
|
+
var s, h;
|
|
51
|
+
this._hover = e, e ? (s = this._fabricRect) == null || s.set(this.hoverStyle) : this.active || (h = this._fabricRect) == null || h.set(this.normalStyle), this.canvas.requestRenderAll();
|
|
54
52
|
}
|
|
55
53
|
get canvas() {
|
|
56
54
|
return this._canvas;
|
|
@@ -70,7 +68,7 @@ class M {
|
|
|
70
68
|
};
|
|
71
69
|
}
|
|
72
70
|
get activeStyle() {
|
|
73
|
-
return
|
|
71
|
+
return v(n({}, this.normalStyle), {
|
|
74
72
|
content: `<svg height="500" width="500"><text fill="#ffffff" font-size="45" x="50" y="86">${this.config.name}</text></svg>`,
|
|
75
73
|
fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 0.1)`
|
|
76
74
|
});
|
|
@@ -85,33 +83,28 @@ class M {
|
|
|
85
83
|
cornerStrokeColor: "#84868C",
|
|
86
84
|
cornerColor: "#FFFFFF",
|
|
87
85
|
transparentCorners: !1
|
|
88
|
-
}, s = 0,
|
|
86
|
+
}, s = 0, h = new d.Rect(
|
|
89
87
|
// this.config.points?.map((p) => ({ x: p[0], y: p[1] })),
|
|
90
|
-
|
|
88
|
+
n(n({
|
|
91
89
|
left: this.config.points[0][0],
|
|
92
90
|
top: this.config.points[0][1],
|
|
93
91
|
width: this.config.points[2][0] - this.config.points[0][0] - s,
|
|
94
92
|
height: this.config.points[2][1] - this.config.points[0][1] - s
|
|
95
|
-
}, e), this.normalStyle)
|
|
96
|
-
// 禁止缩放时翻转
|
|
97
|
-
lockScalingFlip: !0,
|
|
98
|
-
// 允许不保持比例调整(可以自由调整宽高)
|
|
99
|
-
lockUniScaling: !1
|
|
100
|
-
})
|
|
93
|
+
}, e), this.normalStyle)
|
|
101
94
|
);
|
|
102
|
-
|
|
95
|
+
h.setControlsVisibility({
|
|
103
96
|
mtr: !1
|
|
104
97
|
});
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
107
|
-
this.canvas.off("after:render",
|
|
98
|
+
const a = () => {
|
|
99
|
+
if (h.canvas !== this.canvas) {
|
|
100
|
+
this.canvas.off("after:render", a);
|
|
108
101
|
return;
|
|
109
102
|
}
|
|
110
103
|
this.canvas.contextContainer.strokeStyle = `rgb(${this.color[0]},${this.color[1]}, ${this.color[2]})`;
|
|
111
|
-
const o =
|
|
104
|
+
const o = h.getBoundingRect();
|
|
112
105
|
this._strokeRect = this.canvas.contextContainer.strokeRect(o.left + 0.5, o.top + 0.5, o.width, o.height);
|
|
113
106
|
};
|
|
114
|
-
return this.canvas.on("after:render",
|
|
107
|
+
return this.canvas.on("after:render", a), h;
|
|
115
108
|
}
|
|
116
109
|
scaledNumber(e) {
|
|
117
110
|
return e / this.canvas.getZoom();
|
|
@@ -137,28 +130,25 @@ class M {
|
|
|
137
130
|
// });
|
|
138
131
|
// }
|
|
139
132
|
createLabelName() {
|
|
140
|
-
const [e, s,
|
|
133
|
+
const [e, s, h] = this.color, a = new d.Text(this.handlers.renderLabelItem ? this.handlers.renderLabelItem(this.config) : this.config.name, {
|
|
141
134
|
fill: "#FFFFFF",
|
|
142
135
|
fontSize: 12,
|
|
143
136
|
selectable: !1,
|
|
144
|
-
evented: !1,
|
|
145
137
|
top: 4,
|
|
146
138
|
left: 8
|
|
147
|
-
}), o = new
|
|
139
|
+
}), o = new d.Rect({
|
|
148
140
|
selectable: !1,
|
|
149
|
-
evented: !1,
|
|
150
141
|
strokeWidth: 0,
|
|
151
|
-
fill: `rgb(${e},${s},${
|
|
142
|
+
fill: `rgb(${e},${s},${h})`,
|
|
152
143
|
rx: 2,
|
|
153
144
|
ry: 2,
|
|
154
|
-
width: (
|
|
155
|
-
height: (
|
|
145
|
+
width: (a.width || 0) + 16,
|
|
146
|
+
height: (a.height || 0) + 8,
|
|
156
147
|
left: 0,
|
|
157
148
|
top: 0
|
|
158
149
|
});
|
|
159
|
-
return new
|
|
150
|
+
return new d.Group([o, a], {
|
|
160
151
|
selectable: !1,
|
|
161
|
-
evented: !1,
|
|
162
152
|
// lockScalingX: false,
|
|
163
153
|
// lockScalingY: false,
|
|
164
154
|
scaleX: 1 / this.canvas.getZoom(),
|
|
@@ -169,24 +159,24 @@ class M {
|
|
|
169
159
|
var e, s;
|
|
170
160
|
if (this._fabricRect) {
|
|
171
161
|
if (this._label || (this._label = this.createLabelName(), this.setLabelPosition()), this._label.canvas === this.canvas) {
|
|
172
|
-
const
|
|
173
|
-
if (
|
|
174
|
-
|
|
162
|
+
const h = this._label.getObjects().find((o) => o.type === "rect"), a = this._label.getObjects().find((o) => o.type === "text");
|
|
163
|
+
if (a) {
|
|
164
|
+
a.set({
|
|
175
165
|
text: this.handlers.renderLabelItem ? this.handlers.renderLabelItem(this.config) : this.config.name,
|
|
176
166
|
left: 8
|
|
177
167
|
// fontSize: this.scaledNumber(12),
|
|
178
168
|
});
|
|
179
|
-
const o = (
|
|
180
|
-
|
|
169
|
+
const o = (a.getBoundingRect().width || 0) + 16;
|
|
170
|
+
h == null || h.set({
|
|
181
171
|
fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 1)`,
|
|
182
172
|
width: o,
|
|
183
173
|
left: -o / 2
|
|
184
|
-
}),
|
|
174
|
+
}), a.set({
|
|
185
175
|
left: -o / 2 + 8
|
|
186
176
|
});
|
|
187
|
-
const
|
|
177
|
+
const r = ((e = this._fabricRect.aCoords) == null ? void 0 : e.tl.x) !== void 0 ? (s = this._fabricRect.aCoords) == null ? void 0 : s.tl.x : void 0;
|
|
188
178
|
this._label.set({
|
|
189
|
-
left:
|
|
179
|
+
left: r,
|
|
190
180
|
width: o
|
|
191
181
|
});
|
|
192
182
|
}
|
|
@@ -196,109 +186,82 @@ class M {
|
|
|
196
186
|
}
|
|
197
187
|
}
|
|
198
188
|
setLabelPosition() {
|
|
199
|
-
var
|
|
189
|
+
var r, t, i, c;
|
|
200
190
|
if (!this._fabricRect || !this._label)
|
|
201
191
|
return;
|
|
202
|
-
const e = this._label.getObjects().find((
|
|
192
|
+
const e = this._label.getObjects().find((R) => R.type === "rect");
|
|
203
193
|
if (!e)
|
|
204
194
|
return;
|
|
205
|
-
const s = e.height ? e.height : void 0,
|
|
195
|
+
const s = e.height ? e.height : void 0, h = e.width ? e.width : void 0, a = ((r = this._fabricRect.aCoords) == null ? void 0 : r.tl.y) !== void 0 && s !== void 0 && e.scaleY ? ((t = this._fabricRect.aCoords) == null ? void 0 : t.tl.y) - s / this.canvas.getZoom() : void 0, o = ((i = this._fabricRect.aCoords) == null ? void 0 : i.tl.x) !== void 0 ? (c = this._fabricRect.aCoords) == null ? void 0 : c.tl.x : void 0;
|
|
206
196
|
this._label.set({
|
|
207
|
-
top:
|
|
197
|
+
top: a,
|
|
208
198
|
left: o,
|
|
209
199
|
height: s,
|
|
210
|
-
width:
|
|
200
|
+
width: h,
|
|
211
201
|
scaleX: 1 / this.canvas.getZoom(),
|
|
212
202
|
scaleY: 1 / this.canvas.getZoom()
|
|
213
|
-
}), this.config =
|
|
203
|
+
}), this.config = n({}, this.config);
|
|
214
204
|
}
|
|
215
205
|
addToCanvas(e) {
|
|
216
206
|
if (!this._fabricRect)
|
|
217
207
|
return;
|
|
218
|
-
this.canvas = e, this.canvas.add(this._fabricRect), this._fabricRect.on("mouseover", (
|
|
208
|
+
this.canvas = e, this.canvas.add(this._fabricRect), this._fabricRect.on("mouseover", (o) => {
|
|
219
209
|
this.hover = !0;
|
|
220
|
-
}), this._fabricRect.on("mouseout", (
|
|
210
|
+
}), this._fabricRect.on("mouseout", (o) => {
|
|
221
211
|
this.hover = !1;
|
|
222
212
|
}), this._fabricRect.on("mousedown", () => {
|
|
223
213
|
this._fabricRect && this.canvas.setActiveObject(this._fabricRect);
|
|
224
|
-
})
|
|
225
|
-
const s = (
|
|
226
|
-
var
|
|
227
|
-
(
|
|
228
|
-
lockUniScaling: !1
|
|
229
|
-
}), this._fabricRect.uniformScaling = !1)) : this.active && (this.active = !1);
|
|
230
|
-
}, c = (h) => {
|
|
231
|
-
this.active && (this.active = !1);
|
|
214
|
+
});
|
|
215
|
+
const s = (o) => {
|
|
216
|
+
var r;
|
|
217
|
+
(r = o.selected) != null && r.some((t) => t === this._fabricRect) ? this.active = !0 : this.active && (this.active = !1);
|
|
232
218
|
};
|
|
233
|
-
this.canvas.on("selection:created", s), this.canvas.on("selection:updated", s), this.canvas.on("selection:cleared",
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
219
|
+
this.canvas.on("selection:created", s), this.canvas.on("selection:updated", s), this.canvas.on("selection:cleared", (o) => {
|
|
220
|
+
this.active && (this.active = !1);
|
|
221
|
+
});
|
|
222
|
+
const h = (o) => {
|
|
223
|
+
const r = o.transform.action;
|
|
224
|
+
o.transform.corner;
|
|
225
|
+
const t = o.transform.target, i = o.transform.target.canvas.backgroundImage, c = 0;
|
|
226
|
+
i && (r === "drag" && (t.top < i.top && t.set({
|
|
240
227
|
top: i.top
|
|
241
|
-
}), t.top + (t.height +
|
|
242
|
-
top: i.height + i.top - (t.height +
|
|
228
|
+
}), t.top + (t.height + c) * t.scaleY > i.top + i.height && t.set({
|
|
229
|
+
top: i.height + i.top - (t.height + c) * t.scaleY
|
|
243
230
|
}), t.left < i.left && t.set({
|
|
244
231
|
left: i.left
|
|
245
|
-
}), t.left + (t.width +
|
|
246
|
-
left: i.width + i.left - (t.width +
|
|
247
|
-
})),
|
|
248
|
-
top: (t.height +
|
|
249
|
-
height: (t.height +
|
|
250
|
-
}), t.left + (t.width +
|
|
251
|
-
left: i.width + i.left - (t.width +
|
|
252
|
-
})),
|
|
253
|
-
left: t.left - (t.left + (t.width +
|
|
232
|
+
}), t.left + (t.width + c) * t.scaleX > i.left + i.width && t.set({
|
|
233
|
+
left: i.width + i.left - (t.width + c) * t.scaleX
|
|
234
|
+
})), r === "scale" && (t.top + (t.height + c) * t.scaleY > i.top + i.height && t.set({
|
|
235
|
+
top: (t.height + c) * t.scaleY > i.height ? i.top : i.top + i.height - (t.height + c) * t.scaleY,
|
|
236
|
+
height: (t.height + c) * t.scaleY > i.height ? i.height - c : t.height + c
|
|
237
|
+
}), t.left + (t.width + c) * t.scaleX > i.left + i.width && t.set({
|
|
238
|
+
left: i.width + i.left - (t.width + c) * t.scaleX
|
|
239
|
+
})), r === "scaleX" && (t.left + (t.width + c) * t.scaleX > i.left + i.width && t.set({
|
|
240
|
+
left: t.left - (t.left + (t.width + c) * t.scaleX - (i.left + i.width))
|
|
254
241
|
}), t.left < i.left && t.set({
|
|
255
242
|
left: i.left
|
|
256
|
-
})),
|
|
257
|
-
top: t.top - (t.top + (t.height +
|
|
243
|
+
})), r === "scaleY" && (t.top + (t.height + c) * t.scaleY > i.top + i.height && t.set({
|
|
244
|
+
top: t.top - (t.top + (t.height + c) * t.scaleY - (i.top + i.height))
|
|
258
245
|
}), t.top < i.top && t.set({
|
|
259
246
|
top: i.top
|
|
260
|
-
})), (t.width +
|
|
247
|
+
})), (t.width + c) * t.scaleX > i.width && t.set({
|
|
261
248
|
left: i.left,
|
|
262
|
-
width: (i.width -
|
|
263
|
-
}), (t.height +
|
|
249
|
+
width: (i.width - c) / t.scaleX
|
|
250
|
+
}), (t.height + c) * t.scaleY > i.height && t.set({
|
|
264
251
|
top: i.top,
|
|
265
|
-
height: (i.height -
|
|
266
|
-
})),
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const w = (i.width - a) / Math.max(t.width, 1);
|
|
270
|
-
t.set({
|
|
271
|
-
scaleX: Math.min(t.scaleX, w)
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
if (_.height > ((L = i.height) != null ? L : _.height)) {
|
|
275
|
-
const w = (i.height - a) / Math.max(t.height, 1);
|
|
276
|
-
t.set({
|
|
277
|
-
scaleY: Math.min(t.scaleY, w)
|
|
278
|
-
});
|
|
279
|
-
}
|
|
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
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
this.canvas.renderAll();
|
|
288
|
-
}, o = (h) => {
|
|
289
|
-
l(h), this.setLabelPosition();
|
|
252
|
+
height: (i.height - c) / t.scaleY
|
|
253
|
+
})), this.canvas.renderAll();
|
|
254
|
+
}, a = (o) => {
|
|
255
|
+
h(o), this.setLabelPosition();
|
|
290
256
|
};
|
|
291
|
-
this._fabricRect.on("moving",
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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));
|
|
257
|
+
this._fabricRect.on("moving", a), this._fabricRect.on("scaling", a), this._fabricRect.on("rotating", a), this._fabricRect.on("skewing", a), this._fabricRect.on("resizing", a), this.canvas.on("object:removed", (o) => {
|
|
258
|
+
o.target === this._fabricRect && this.destroy();
|
|
259
|
+
}), this.canvas.on("object:modified", (o) => {
|
|
260
|
+
o.target === this._fabricRect && (this.setLabelPosition(), this.handlers.onChange && this.handlers.onChange(this));
|
|
298
261
|
});
|
|
299
262
|
}
|
|
300
263
|
render(e) {
|
|
301
|
-
|
|
264
|
+
y(d), this._fabricRect || (this._fabricRect = this.createRect()), this._fabricRect.canvas === this.canvas ? this._fabricRect.set({
|
|
302
265
|
fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 0)`,
|
|
303
266
|
stroke: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 1)`
|
|
304
267
|
}) : this.addToCanvas(e), this.renderLabel();
|
|
@@ -309,19 +272,12 @@ class M {
|
|
|
309
272
|
}
|
|
310
273
|
}
|
|
311
274
|
set labelConfig(e) {
|
|
312
|
-
this.config =
|
|
275
|
+
this.config = n(n({}, this.config), e), this.color = _(e.color), this.render(this.canvas), this.handlers.onChange && this.handlers.onChange(this);
|
|
313
276
|
}
|
|
314
277
|
destroy() {
|
|
315
|
-
|
|
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
|
-
}
|
|
278
|
+
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);
|
|
323
279
|
}
|
|
324
280
|
}
|
|
325
281
|
export {
|
|
326
|
-
|
|
282
|
+
F as default
|
|
327
283
|
};
|