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