@glodon-aiot/dataset-annotation 3.1.0-beta.15 → 3.2.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/dataset-annotation.js +123591 -0
- package/dist/dataset-annotation.umd.cjs +1017 -0
- package/dist/example/DatasetAnnotationDemo.d.ts +3 -0
- package/dist/example/DemoTabs.d.ts +3 -0
- package/dist/example/DetectionDatasetDemo.d.ts +5 -0
- package/dist/example/DetectionImageDemo.d.ts +5 -0
- package/dist/example/OcrDatasetDemo.d.ts +5 -0
- package/dist/example/OcrImageDemo.d.ts +5 -0
- package/dist/example/OcrkvcDatasetDemo.d.ts +5 -0
- package/dist/example/constant.local.d.ts +6 -0
- package/dist/example/index.d.ts +1 -0
- package/dist/src/Common/Page/index.d.ts +2 -1
- package/dist/src/Common/PageHeader/index.d.ts +1 -0
- package/dist/src/DatasetContext/index.d.ts +4 -3
- package/dist/src/components/CompositionInput/index.d.ts +2 -2
- package/dist/src/components/DataEmpty/index.d.ts +2 -1
- package/dist/src/components/DetectionAnnotation/PreSamplesPage/index.d.ts +2 -1
- package/dist/src/components/DetectionAnnotation/components/DisabledTooltip/index.d.ts +2 -2
- package/dist/src/components/DetectionAnnotation/components/ImageDetail/index.d.ts +2 -1
- package/dist/src/components/DetectionAnnotation/components/LabelMaker/Drawable.d.ts +2 -2
- package/dist/src/components/DetectionAnnotation/components/LabelMaker/RectLabel.d.ts +2 -2
- package/dist/src/components/DetectionAnnotation/components/LabelMaker/index.d.ts +1 -0
- package/dist/src/components/DetectionAnnotation/components/Labels/index.d.ts +1 -0
- package/dist/src/components/DetectionAnnotation/components/TagItem/index.d.ts +2 -1
- package/dist/src/components/DetectionAnnotation/index.d.ts +2 -1
- package/dist/src/components/DetectionImageAnnotation/index.d.ts +2 -0
- package/dist/src/components/Iconfont/index.d.ts +1 -1
- package/dist/src/components/MarkDescriptions/index.d.ts +1 -0
- package/dist/src/components/OCRImageViewer/index.d.ts +2 -1
- package/dist/src/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorInput.d.ts +2 -2
- package/dist/src/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorItem.d.ts +2 -1
- package/dist/src/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LableEditor.d.ts +1 -0
- package/dist/src/components/OcrAnnotation/MarkKVOCRModal/index.d.ts +1 -0
- package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/ImageDetail/index.d.ts +2 -1
- package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/LabelEditorInput.d.ts +2 -2
- package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/LabelEditorItem.d.ts +1 -0
- package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/LableEditor.d.ts +1 -0
- package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.d.ts +1 -0
- package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/index.d.ts +1 -0
- package/dist/src/components/OcrAnnotation/OcrModal/index.d.ts +2 -1
- package/dist/src/components/OcrAnnotation/PreLabelOCR/PreLabelModal.d.ts +2 -1
- package/dist/src/components/OcrAnnotation/PreLabelOCR/index.d.ts +2 -1
- package/dist/src/components/OcrAnnotation/index.d.ts +2 -1
- package/dist/src/components/OcrImageAnnotation/index.d.ts +2 -0
- package/dist/src/components/PageNav/index.d.ts +2 -1
- package/dist/src/components/PicZipImportModal/index.d.ts +2 -1
- package/dist/src/components/PreLabelOCR/PreLabelModal.d.ts +2 -1
- package/dist/src/components/PreLabelOCR/index.d.ts +2 -1
- package/dist/src/components/ScanTable/index.d.ts +2 -1
- package/dist/src/components/Thumbnail/index.d.ts +2 -1
- package/dist/src/components/hooks/useBlocker.d.ts +1 -1
- package/dist/src/featuresConfig.d.ts +1 -1
- package/package.json +15 -22
- package/dist/es/Common/Page/index.mjs +0 -28
- package/dist/es/Common/PageContent/index.mjs +0 -18
- package/dist/es/Common/PageHeader/index.mjs +0 -38
- package/dist/es/DatasetContext/index.mjs +0 -11
- package/dist/es/_virtual/_commonjsHelpers.mjs +0 -6
- package/dist/es/_virtual/index.mjs +0 -4
- package/dist/es/access/images/data_empty.svg.mjs +0 -4
- package/dist/es/components/CompositionInput/index.mjs +0 -53
- package/dist/es/components/DataEmpty/index.mjs +0 -50
- package/dist/es/components/DetectionAnnotation/PreSamplesPage/index.mjs +0 -291
- package/dist/es/components/DetectionAnnotation/components/DisabledTooltip/index.mjs +0 -23
- package/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +0 -165
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/Drawable.mjs +0 -51
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/FabricCustomize.mjs +0 -42
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +0 -283
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/icons/delete-icon.svg.mjs +0 -4
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +0 -314
- package/dist/es/components/DetectionAnnotation/components/Labels/index.mjs +0 -200
- package/dist/es/components/DetectionAnnotation/components/TagItem/index.mjs +0 -143
- package/dist/es/components/DetectionAnnotation/icon_item_empty.svg.mjs +0 -4
- package/dist/es/components/DetectionAnnotation/index.mjs +0 -712
- package/dist/es/components/DetectionImageAnnotation/index.mjs +0 -61
- package/dist/es/components/Iconfont/index.mjs +0 -16
- package/dist/es/components/MarkDescriptions/index.mjs +0 -65
- package/dist/es/components/OCRImageViewer/index.mjs +0 -212
- package/dist/es/components/OcrAnnotation/MarkKVOCRModal/CategoryDrawer.mjs +0 -136
- package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorInput.mjs +0 -57
- package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorItem.mjs +0 -72
- package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LableEditor.mjs +0 -54
- package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/index.mjs +0 -366
- package/dist/es/components/OcrAnnotation/MarkKVOCRModal/index.mjs +0 -254
- package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/ImageDetail/index.mjs +0 -100
- package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/images/delete.png.mjs +0 -4
- package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.mjs +0 -755
- package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/index.mjs +0 -230
- package/dist/es/components/OcrAnnotation/OcrModal/index.mjs +0 -179
- package/dist/es/components/OcrAnnotation/PreLabelOCR/PreLabelModal.mjs +0 -280
- package/dist/es/components/OcrAnnotation/PreLabelOCR/index.mjs +0 -43
- package/dist/es/components/OcrAnnotation/constant.mjs +0 -5
- package/dist/es/components/OcrAnnotation/index.mjs +0 -381
- package/dist/es/components/OcrImageAnnotation/index.mjs +0 -39
- package/dist/es/components/PageNav/index.mjs +0 -29
- package/dist/es/components/PicZipImportModal/index.mjs +0 -583
- package/dist/es/components/PicZipImportModal/pic_zip.svg.mjs +0 -4
- package/dist/es/components/PicZipImportModal/pic_zip_json.svg.mjs +0 -4
- package/dist/es/components/PreLabelOCR/PreLabelModal.mjs +0 -275
- package/dist/es/components/PreLabelOCR/index.mjs +0 -43
- package/dist/es/components/ScanTable/index.mjs +0 -96
- package/dist/es/components/Thumbnail/default.png.mjs +0 -4
- package/dist/es/components/Thumbnail/index.mjs +0 -30
- package/dist/es/components/hooks/Prompt.mjs +0 -33
- package/dist/es/constant.mjs +0 -13
- package/dist/es/createDatasetAnnotation/index.mjs +0 -133
- package/dist/es/createDetectionDatasetAnnotation/index.mjs +0 -129
- package/dist/es/createDetectionImageAnnotation/index.mjs +0 -31
- package/dist/es/createOcrDatasetAnnotation/index.mjs +0 -129
- package/dist/es/createOcrImageAnnotation/index.mjs +0 -33
- package/dist/es/featuresConfig.mjs +0 -79
- package/dist/es/index.mjs +0 -35
- package/dist/es/node_modules/classnames/index.mjs +0 -42
- package/dist/es/utils/color.mjs +0 -30
- package/dist/es/utils/index.mjs +0 -22
- package/dist/es/utils/sign.mjs +0 -33
- package/dist/lib/index.js +0 -7
- package/dist/src/components/Iconfont/font_3140028_iptomfpgyu.d.ts +0 -0
- package/dist/src/components/Iconfont/font_3454453_gu5ijeufyng.d.ts +0 -0
- package/dist/src/components/Iconfont/font_4108228_3slzqhoow93.d.ts +0 -0
- package/dist/src/components/Iconfont/font_4439177_k3mjwv7kzfd.d.ts +0 -0
|
@@ -1,755 +0,0 @@
|
|
|
1
|
-
var Re = Object.defineProperty, ve = Object.defineProperties;
|
|
2
|
-
var Ue = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var fe = Object.getOwnPropertySymbols;
|
|
4
|
-
var Ce = Object.prototype.hasOwnProperty, Ye = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var Ee = Math.pow, ke = (r, m, s) => m in r ? Re(r, m, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[m] = s, Q = (r, m) => {
|
|
6
|
-
for (var s in m || (m = {}))
|
|
7
|
-
Ce.call(m, s) && ke(r, s, m[s]);
|
|
8
|
-
if (fe)
|
|
9
|
-
for (var s of fe(m))
|
|
10
|
-
Ye.call(m, s) && ke(r, s, m[s]);
|
|
11
|
-
return r;
|
|
12
|
-
}, re = (r, m) => ve(r, Ue(m));
|
|
13
|
-
var ge = (r, m) => {
|
|
14
|
-
var s = {};
|
|
15
|
-
for (var p in r)
|
|
16
|
-
Ce.call(r, p) && m.indexOf(p) < 0 && (s[p] = r[p]);
|
|
17
|
-
if (r != null && fe)
|
|
18
|
-
for (var p of fe(r))
|
|
19
|
-
m.indexOf(p) < 0 && Ye.call(r, p) && (s[p] = r[p]);
|
|
20
|
-
return s;
|
|
21
|
-
};
|
|
22
|
-
import { jsx as S, jsxs as Xe } from "react/jsx-runtime";
|
|
23
|
-
import { useState as U, useEffect as F } from "react";
|
|
24
|
-
import { fabric as z } from "fabric";
|
|
25
|
-
import le from "ahooks/lib/useKeyPress";
|
|
26
|
-
import { Spin as $e, Space as Ie, Radio as me, Tooltip as se, Button as he } from "antd";
|
|
27
|
-
import Me from "react-dom";
|
|
28
|
-
/* empty css */import Fe from "./images/delete.png.mjs";
|
|
29
|
-
import { ZoomInOutlined as Ne, ZoomOutOutlined as Le, DragOutlined as We } from "@ant-design/icons";
|
|
30
|
-
import Ae from "../../../Iconfont/index.mjs";
|
|
31
|
-
import { getUuid as Te } from "../../../../utils/index.mjs";
|
|
32
|
-
const Pe = (r) => {
|
|
33
|
-
const m = r.calcTransformMatrix(), s = r.canvas.backgroundImage;
|
|
34
|
-
return r.get("points").map(function(g) {
|
|
35
|
-
return new z.Point(g.x - r.pathOffset.x, g.y - r.pathOffset.y);
|
|
36
|
-
}).map(function(g) {
|
|
37
|
-
return z.util.transformPoint(g, m);
|
|
38
|
-
}).map((g) => {
|
|
39
|
-
let f, w;
|
|
40
|
-
return g.x <= s.left ? f = s.left : g.x > s.left + s.width ? f = s.left + s.width : f = g.x, g.y <= s.top ? w = s.top : g.y > s.top + s.height ? w = s.top + s.height : w = g.y, {
|
|
41
|
-
x: f,
|
|
42
|
-
y: w
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
}, ze = (r, m) => {
|
|
46
|
-
const s = r.backgroundImage;
|
|
47
|
-
return !(s && typeof s != "string" && s.top !== void 0 && s.height !== void 0 && s.left !== void 0 && s.width !== void 0 && (m.x < s.left || m.y < s.top || m.x > s.left + s.width || m.y > s.top + s.height));
|
|
48
|
-
};
|
|
49
|
-
function Se(r, m) {
|
|
50
|
-
let s = -1, p = -1, a = 0, g = 0, f, w, X = !1;
|
|
51
|
-
r.on("mouse:down", (e) => {
|
|
52
|
-
X = !0;
|
|
53
|
-
const I = r.getZoom(), h = r.viewportTransform ? r.viewportTransform[4] / I : 0, T = r.viewportTransform ? r.viewportTransform[5] / I : 0;
|
|
54
|
-
p = e.e.offsetX / I - h, s = e.e.offsetY / I - T;
|
|
55
|
-
}), r.on("mouse:up", (e) => {
|
|
56
|
-
if (X = !1, p === -1 && s === -1)
|
|
57
|
-
return;
|
|
58
|
-
const I = r.getZoom(), h = r.viewportTransform ? r.viewportTransform[4] / I : 0, T = r.viewportTransform ? r.viewportTransform[5] / I : 0, P = (e.e.offsetX > r.getWidth() ? r.getWidth() / I : e.e.offsetX / I) - h, Z = (e.e.offsetY > r.getHeight() ? r.getHeight() / I : e.e.offsetY / I) - T;
|
|
59
|
-
if (a = Math.abs(P - p), g = Math.abs(Z - s), a === 0 || g === 0)
|
|
60
|
-
return;
|
|
61
|
-
const k = s > Z ? Z : s, D = p > P ? P : p, C = a, L = g, W = [{
|
|
62
|
-
x: D,
|
|
63
|
-
y: k
|
|
64
|
-
}, {
|
|
65
|
-
x: D + C,
|
|
66
|
-
y: k
|
|
67
|
-
}, {
|
|
68
|
-
x: D + C,
|
|
69
|
-
y: k + L
|
|
70
|
-
}, {
|
|
71
|
-
x: D,
|
|
72
|
-
y: k + L
|
|
73
|
-
}];
|
|
74
|
-
W.every((_) => ze(r, _)) && (f = new z.Polygon(W, {
|
|
75
|
-
fill: "rgba(255, 69, 0, 0.45)",
|
|
76
|
-
stroke: "rgb(255, 69, 0)",
|
|
77
|
-
strokeWidth: 1
|
|
78
|
-
}), f.set("strokeUniform", !0), r.add(f), r.setActiveObject(f), m && m(f, w), r.skipTargetFind = !1);
|
|
79
|
-
}), r.on("mouse:move", (e) => {
|
|
80
|
-
e.target;
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function pe(r, m, s) {
|
|
84
|
-
const p = {
|
|
85
|
-
type: "roof",
|
|
86
|
-
background: "",
|
|
87
|
-
border: ""
|
|
88
|
-
};
|
|
89
|
-
let a, g = [], f = [], w = [], X = [], e = 0, I = null, h, T, P, Z = !1, k, D, C;
|
|
90
|
-
const L = r.getZoom(), W = 2 / L, _ = [7 / L, 10 / L];
|
|
91
|
-
r.on("mouse:down", (l) => {
|
|
92
|
-
var G;
|
|
93
|
-
const u = r.getZoom(), x = r.viewportTransform ? r.viewportTransform[4] / u : 0, B = r.viewportTransform ? r.viewportTransform[5] / u : 0;
|
|
94
|
-
if (a && l.e.offsetX / u - x === a.x - x)
|
|
95
|
-
return;
|
|
96
|
-
X = [], a = {
|
|
97
|
-
x: l.e.offsetX / u - x,
|
|
98
|
-
y: l.e.offsetY / u - B
|
|
99
|
-
}, e || (h = l.e.offsetX / u - x, T = l.e.offsetY / u - B);
|
|
100
|
-
const R = {
|
|
101
|
-
x: a.x,
|
|
102
|
-
y: a.y
|
|
103
|
-
};
|
|
104
|
-
g.push(R);
|
|
105
|
-
const O = [R.x, R.y, R.x, R.y], j = [h, T, R.x, R.y];
|
|
106
|
-
if ((G = f[f.length - 1]) == null || G.set({
|
|
107
|
-
strokeDashArray: []
|
|
108
|
-
}), f.push(new z.Line(O, {
|
|
109
|
-
strokeWidth: W,
|
|
110
|
-
selectable: !1,
|
|
111
|
-
stroke: "#508BEE",
|
|
112
|
-
strokeUniform: !0
|
|
113
|
-
})), w.push(new z.Line(j, {
|
|
114
|
-
strokeWidth: W,
|
|
115
|
-
strokeDashArray: _,
|
|
116
|
-
selectable: !1,
|
|
117
|
-
stroke: "#508BEE",
|
|
118
|
-
strokeUniform: !0
|
|
119
|
-
})), X.push(new z.Line(j, {
|
|
120
|
-
strokeWidth: W,
|
|
121
|
-
selectable: !1,
|
|
122
|
-
stroke: "#508BEE",
|
|
123
|
-
strokeUniform: !0
|
|
124
|
-
})), e > 1) {
|
|
125
|
-
if (s && e >= s - 1) {
|
|
126
|
-
b();
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const N = f.length - 2;
|
|
130
|
-
if (P = f.some((K) => V(K, f[N])), Z = f.some((K) => V(K, X[0])), P || Z) {
|
|
131
|
-
e--, P = !1, g.splice(g.length - 1, 1), r.remove(f[N]), f.splice(N, 2);
|
|
132
|
-
const K = [f[f.length - 1].x2, f[f.length - 1].y2, f[f.length - 1].x2, f[f.length - 1].y2];
|
|
133
|
-
f.push(new z.Line(K, {
|
|
134
|
-
strokeWidth: W,
|
|
135
|
-
selectable: !1,
|
|
136
|
-
stroke: "#508BEE"
|
|
137
|
-
})), w[0].set({
|
|
138
|
-
x2: f[f.length - 1].x2,
|
|
139
|
-
y2: f[f.length - 1].y2
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
const te = w.splice(0, 1);
|
|
143
|
-
w = [], w.push(...te), r.add(f[e]);
|
|
144
|
-
} else
|
|
145
|
-
e !== 1 ? r.add(f[e], w[e]) : r.add(f[e]);
|
|
146
|
-
e++;
|
|
147
|
-
}), r.on("mouse:move", (l) => {
|
|
148
|
-
const u = r.getZoom(), x = r.viewportTransform ? r.viewportTransform[4] / u : 0, B = r.viewportTransform ? r.viewportTransform[5] / u : 0;
|
|
149
|
-
f[0] !== null && f[0] !== void 0 && p.type == "roof" && (k = l.e.offsetX / u - x, D = l.e.offsetY / u - B, f[e - 1].set({
|
|
150
|
-
x2: k,
|
|
151
|
-
y2: D,
|
|
152
|
-
strokeDashArray: _
|
|
153
|
-
}), w[0].set({
|
|
154
|
-
x2: k,
|
|
155
|
-
y2: D
|
|
156
|
-
}), r.renderAll());
|
|
157
|
-
});
|
|
158
|
-
const b = () => {
|
|
159
|
-
r.off("mouse:down"), f.forEach((l) => r.remove(l)), w.forEach((l) => r.remove(l)), d(), I && r.add(I), r.renderAll(), g = [], f = [], w = [], e = 0;
|
|
160
|
-
}, q = () => {
|
|
161
|
-
[...f, ...w, ...X].forEach((l) => r.remove(l)), r.renderAll(), g = [], f = [], w = [], e = 0;
|
|
162
|
-
};
|
|
163
|
-
r.on("selection:created", q), document.addEventListener("keydown", (l) => {
|
|
164
|
-
l.key === "Escape" && q();
|
|
165
|
-
});
|
|
166
|
-
const d = () => {
|
|
167
|
-
const l = oe(g), u = J(g), x = Q({}, g[0]);
|
|
168
|
-
g.push(x), g.some((B, R) => {
|
|
169
|
-
var O, j;
|
|
170
|
-
((j = (O = f[f.length - 1]) == null ? void 0 : O.aCoords) == null ? void 0 : j.bl.x) == B.x && g.splice(R, 1);
|
|
171
|
-
}), g.every((B) => ze(r, B)) ? (I = new z.Polyline(g, {
|
|
172
|
-
fill: "rgba(80, 139, 238, 0.45)",
|
|
173
|
-
strokeWidth: W,
|
|
174
|
-
stroke: "#508BEE",
|
|
175
|
-
left: l,
|
|
176
|
-
top: u
|
|
177
|
-
}), q(), m && m(I, C)) : pe(r, m, 4);
|
|
178
|
-
}, J = (l) => {
|
|
179
|
-
let u = 999999;
|
|
180
|
-
for (let x = 0; x < e; x++)
|
|
181
|
-
l[x].y < u && (u = l[x].y);
|
|
182
|
-
return Math.abs(u);
|
|
183
|
-
}, oe = (l) => {
|
|
184
|
-
let u = 999999;
|
|
185
|
-
for (let x = 0; x < e; x++)
|
|
186
|
-
l[x].x < u && (u = l[x].x);
|
|
187
|
-
return Math.abs(u);
|
|
188
|
-
}, V = (l, u) => {
|
|
189
|
-
const x = l.y2 - l.y1, B = l.x1 - l.x2, R = x * l.x1 + B * l.y1, O = u.y2 - u.y1, j = u.x1 - u.x2, G = O * u.x1 + j * u.y1, N = x * j - O * B;
|
|
190
|
-
if (N == 0)
|
|
191
|
-
return !1;
|
|
192
|
-
{
|
|
193
|
-
const te = (j * R - B * G) / N, K = (x * G - O * R) / N;
|
|
194
|
-
if ((y(l.x1, te, l.x2) || y(l.y1, K, l.y2)) && (y(u.x1, te, u.x2) || y(u.y1, K, u.y2)))
|
|
195
|
-
return !0;
|
|
196
|
-
}
|
|
197
|
-
return !1;
|
|
198
|
-
}, y = (l, u, x) => Math.abs(l - u) < 1e-6 || Math.abs(u - x) < 1e-6 ? !1 : l < u && u < x || x < u && u < l;
|
|
199
|
-
}
|
|
200
|
-
const de = (r) => {
|
|
201
|
-
r.off("mouse:down"), r.off("mouse:up"), r.off("mouse:move");
|
|
202
|
-
}, je = (r, [m, s, p], a, g) => {
|
|
203
|
-
const f = new z.Polygon(r, {
|
|
204
|
-
fill: `rgba(${m},${s}, ${p}, 0.45)`,
|
|
205
|
-
stroke: `rgba(${m},${s}, ${p}, 1)`,
|
|
206
|
-
strokeWidth: 0
|
|
207
|
-
});
|
|
208
|
-
a == null || a.add(f);
|
|
209
|
-
const w = () => {
|
|
210
|
-
if (!g || !a)
|
|
211
|
-
return;
|
|
212
|
-
const h = new z.Text(g(), {
|
|
213
|
-
fill: "#FFFFFF",
|
|
214
|
-
fontSize: 12,
|
|
215
|
-
selectable: !1,
|
|
216
|
-
top: 4,
|
|
217
|
-
left: 8
|
|
218
|
-
}), T = new z.Rect({
|
|
219
|
-
selectable: !1,
|
|
220
|
-
strokeWidth: 0,
|
|
221
|
-
fill: `rgb(${m},${s},${p})`,
|
|
222
|
-
rx: 2,
|
|
223
|
-
ry: 2,
|
|
224
|
-
width: (h.width || 0) + 16,
|
|
225
|
-
height: (h.height || 0) + 8,
|
|
226
|
-
left: 0,
|
|
227
|
-
top: 0
|
|
228
|
-
});
|
|
229
|
-
return new z.Group([T, h], {
|
|
230
|
-
selectable: !1,
|
|
231
|
-
// lockScalingX: false,
|
|
232
|
-
// lockScalingY: false,
|
|
233
|
-
scaleX: 1 / a.getZoom(),
|
|
234
|
-
scaleY: 1 / a.getZoom()
|
|
235
|
-
});
|
|
236
|
-
};
|
|
237
|
-
let X;
|
|
238
|
-
const e = () => {
|
|
239
|
-
var h, T;
|
|
240
|
-
if (!(!f || !g || !a)) {
|
|
241
|
-
if (X || (X = w(), I()), X.canvas === a) {
|
|
242
|
-
const P = X.getObjects().find((k) => k.type === "rect"), Z = X.getObjects().find((k) => k.type === "text");
|
|
243
|
-
if (Z && g) {
|
|
244
|
-
Z.set({
|
|
245
|
-
text: g(),
|
|
246
|
-
left: 8
|
|
247
|
-
// fontSize: this.scaledNumber(12),
|
|
248
|
-
});
|
|
249
|
-
const k = (Z.getBoundingRect().width || 0) + 16;
|
|
250
|
-
P == null || P.set({
|
|
251
|
-
fill: `rgba(${m},${s}, ${p}, 1)`,
|
|
252
|
-
width: k,
|
|
253
|
-
left: -k / 2
|
|
254
|
-
}), Z.set({
|
|
255
|
-
left: -k / 2 + 8
|
|
256
|
-
});
|
|
257
|
-
const D = ((h = f.aCoords) == null ? void 0 : h.tl.x) !== void 0 ? (T = f.aCoords) == null ? void 0 : T.tl.x : void 0;
|
|
258
|
-
X.set({
|
|
259
|
-
left: D,
|
|
260
|
-
width: k
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
} else
|
|
264
|
-
a == null || a.add(X);
|
|
265
|
-
I();
|
|
266
|
-
}
|
|
267
|
-
}, I = () => {
|
|
268
|
-
var D, C, L, W;
|
|
269
|
-
if (!f || !X || !a)
|
|
270
|
-
return;
|
|
271
|
-
const h = X.getObjects().find((_) => _.type === "rect");
|
|
272
|
-
if (!h)
|
|
273
|
-
return;
|
|
274
|
-
const T = h.height ? h.height : void 0, P = h.width ? h.width : void 0, Z = ((D = f.aCoords) == null ? void 0 : D.tl.y) !== void 0 && T !== void 0 && h.scaleY ? ((C = f.aCoords) == null ? void 0 : C.tl.y) - T / a.getZoom() : void 0, k = ((L = f.aCoords) == null ? void 0 : L.tl.x) !== void 0 ? (W = f.aCoords) == null ? void 0 : W.tl.x : void 0;
|
|
275
|
-
X.set({
|
|
276
|
-
top: Z,
|
|
277
|
-
left: k,
|
|
278
|
-
height: T,
|
|
279
|
-
width: P,
|
|
280
|
-
scaleX: 1 / a.getZoom(),
|
|
281
|
-
scaleY: 1 / a.getZoom()
|
|
282
|
-
});
|
|
283
|
-
};
|
|
284
|
-
return e(), [f, X];
|
|
285
|
-
}, He = (r, m, s, p) => {
|
|
286
|
-
if (!r) {
|
|
287
|
-
console.error("canvas is not exist");
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
try {
|
|
291
|
-
r.remove(m), p && r.remove(p), s.canvas !== r && r.add(s);
|
|
292
|
-
} catch (a) {
|
|
293
|
-
console.error(a);
|
|
294
|
-
}
|
|
295
|
-
}, ut = (r) => {
|
|
296
|
-
const {
|
|
297
|
-
imageUrl: m,
|
|
298
|
-
canvasElement: s,
|
|
299
|
-
labels: p = [],
|
|
300
|
-
onChange: a,
|
|
301
|
-
disabled: g,
|
|
302
|
-
renderLabelItem: f
|
|
303
|
-
} = r, [w, X] = U(!0), [e, I] = U(), [h, T] = U({}), [P, Z] = U({}), [k, D] = U(), [C, L] = U({
|
|
304
|
-
left: 0,
|
|
305
|
-
top: 0
|
|
306
|
-
}), [W, _] = U([1, 1]), [b, q] = U(), [d, J] = U(null), [oe, V] = U(), [y, l] = U([]), [u, x] = U(!0), [B, R] = U(), [O, j] = U("rect"), [G, N] = U(g || !1);
|
|
307
|
-
F(() => {
|
|
308
|
-
var i;
|
|
309
|
-
y.forEach((n) => {
|
|
310
|
-
p.find((t) => t.uuid === n.uuid) || e == null || e.remove(h[n.uuid]);
|
|
311
|
-
}), l((i = p == null ? void 0 : p.filter((n) => !!n)) == null ? void 0 : i.map((n) => {
|
|
312
|
-
var M, A;
|
|
313
|
-
const v = n, {
|
|
314
|
-
uuid: t,
|
|
315
|
-
box: o,
|
|
316
|
-
words: c,
|
|
317
|
-
type: Y,
|
|
318
|
-
catagoryId: E
|
|
319
|
-
} = v, $ = ge(v, [
|
|
320
|
-
"uuid",
|
|
321
|
-
"box",
|
|
322
|
-
"words",
|
|
323
|
-
"type",
|
|
324
|
-
"catagoryId"
|
|
325
|
-
]);
|
|
326
|
-
return Q({
|
|
327
|
-
uuid: n.uuid,
|
|
328
|
-
box: ((M = n.box) == null ? void 0 : M.map((H) => [H[0] + C.left, H[1] + C.top])) || [],
|
|
329
|
-
words: n.words,
|
|
330
|
-
type: (A = n.type) == null ? void 0 : A.toLowerCase(),
|
|
331
|
-
catagoryId: n.catagoryId
|
|
332
|
-
}, $);
|
|
333
|
-
}));
|
|
334
|
-
}, [p, C]), F(() => {
|
|
335
|
-
if (e && u) {
|
|
336
|
-
const i = e.getActiveObject();
|
|
337
|
-
if (i) {
|
|
338
|
-
i === (b == null ? void 0 : b.polygon) && (e == null || e.remove(b == null ? void 0 : b.text), q(void 0)), e.remove(i), e.renderAll();
|
|
339
|
-
const n = y.findIndex((t) => h[t.uuid] === i);
|
|
340
|
-
n > -1 && (h[y[n].uuid] && (e == null || e.remove(h[y[n].uuid])), y.splice(n, 1), l([...y]), a([...y.map((t) => re(Q({}, t), {
|
|
341
|
-
box: t.box.map((o) => [o[0] - C.left, o[1] - C.top])
|
|
342
|
-
}))]));
|
|
343
|
-
} else
|
|
344
|
-
console.log("no active object", e.selection), e.discardActiveObject(), e.requestRenderAll();
|
|
345
|
-
x(!1);
|
|
346
|
-
}
|
|
347
|
-
}, [e, u, y]);
|
|
348
|
-
const te = (i) => {
|
|
349
|
-
var n;
|
|
350
|
-
((n = i.target) == null ? void 0 : n.tagName) !== "INPUT" && x(!0);
|
|
351
|
-
};
|
|
352
|
-
le("Delete", te), le("Backspace", te), le("ctrl", () => {
|
|
353
|
-
N(!0);
|
|
354
|
-
}, {
|
|
355
|
-
events: ["keydown"]
|
|
356
|
-
}), le("ctrl", () => {
|
|
357
|
-
N(!1);
|
|
358
|
-
}, {
|
|
359
|
-
events: ["keyup"]
|
|
360
|
-
});
|
|
361
|
-
const K = () => {
|
|
362
|
-
T({}), Z({}), D(void 0), _([1, 1]), q(void 0), V(void 0), J(null), l([]), L({
|
|
363
|
-
left: 0,
|
|
364
|
-
top: 0
|
|
365
|
-
}), e == null || e.dispose(), I(void 0);
|
|
366
|
-
};
|
|
367
|
-
F(() => {
|
|
368
|
-
X(!0), K(), !(!s || !m) && z.Image.fromURL(m, (i) => {
|
|
369
|
-
i.set({
|
|
370
|
-
originX: "center",
|
|
371
|
-
originY: "center"
|
|
372
|
-
}), D(i), X(!1);
|
|
373
|
-
}, {
|
|
374
|
-
crossOrigin: "anonymous"
|
|
375
|
-
});
|
|
376
|
-
}, [s, m]), F(() => {
|
|
377
|
-
var H;
|
|
378
|
-
if (!s || !s.parentElement)
|
|
379
|
-
return;
|
|
380
|
-
if (!k && e) {
|
|
381
|
-
e.clear();
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
const i = k == null ? void 0 : k.getElement();
|
|
385
|
-
if (!(i != null && i.width) || !(i != null && i.height))
|
|
386
|
-
return;
|
|
387
|
-
const n = i.width / i.height, t = s.parentElement.offsetWidth, o = s.parentElement.offsetHeight, c = t / i.width, Y = o / i.height;
|
|
388
|
-
let E = [t, o];
|
|
389
|
-
c > Y ? E = [o * n, o] : E = [t, t / n];
|
|
390
|
-
const $ = E[0] / i.width, v = E[1] / i.height, M = Math.min($, v);
|
|
391
|
-
_([M, M]);
|
|
392
|
-
const A = new z.Canvas(s, {
|
|
393
|
-
containerClass: "marking-canvas",
|
|
394
|
-
width: t,
|
|
395
|
-
height: o
|
|
396
|
-
});
|
|
397
|
-
if (A == null || A.setZoom(M), A == null || A.renderAll(), A && k) {
|
|
398
|
-
const ne = (t - E[0]) / M / 2, ae = (o - E[1]) / M / 2;
|
|
399
|
-
A.setBackgroundImage(
|
|
400
|
-
k,
|
|
401
|
-
A.renderAll.bind(A),
|
|
402
|
-
// 刷新画布
|
|
403
|
-
{
|
|
404
|
-
originX: "left",
|
|
405
|
-
originY: "top",
|
|
406
|
-
left: ne,
|
|
407
|
-
top: ae
|
|
408
|
-
}
|
|
409
|
-
), L({
|
|
410
|
-
left: ne,
|
|
411
|
-
top: ae
|
|
412
|
-
}), J(null), l((H = p == null ? void 0 : p.filter((ee) => !!ee)) == null ? void 0 : H.map((ee) => {
|
|
413
|
-
var xe, we;
|
|
414
|
-
const ye = ee, {
|
|
415
|
-
uuid: qe,
|
|
416
|
-
box: Ge,
|
|
417
|
-
words: Ke,
|
|
418
|
-
type: _e,
|
|
419
|
-
catagoryId: Je
|
|
420
|
-
} = ye, Oe = ge(ye, [
|
|
421
|
-
"uuid",
|
|
422
|
-
"box",
|
|
423
|
-
"words",
|
|
424
|
-
"type",
|
|
425
|
-
"catagoryId"
|
|
426
|
-
]);
|
|
427
|
-
return Q({
|
|
428
|
-
uuid: ee.uuid,
|
|
429
|
-
box: ((xe = ee.box) == null ? void 0 : xe.map((be) => [be[0] + C.left, be[1] + C.top])) || [],
|
|
430
|
-
words: ee.words,
|
|
431
|
-
type: (we = ee.type) == null ? void 0 : we.toLowerCase(),
|
|
432
|
-
catagoryId: ee.catagoryId
|
|
433
|
-
}, Oe);
|
|
434
|
-
})), I(A);
|
|
435
|
-
}
|
|
436
|
-
}, [k]), F(() => {
|
|
437
|
-
w || !e || (ue(e, y, oe), N((i) => (i ? e.getObjects().forEach((n) => n.set("evented", !1)) : e.getObjects().forEach((n) => n.set("evented", !0)), i)));
|
|
438
|
-
}, [y, e, oe, w]), F(() => {
|
|
439
|
-
oe || a([...y.map((i) => re(Q({}, i), {
|
|
440
|
-
box: i.box.map((n) => [n[0] - C.left, n[1] - C.top])
|
|
441
|
-
}))]);
|
|
442
|
-
}, [oe]);
|
|
443
|
-
const ue = (i, n, t = "") => {
|
|
444
|
-
T((o) => {
|
|
445
|
-
if (n == null || n.map((c) => {
|
|
446
|
-
var $, v;
|
|
447
|
-
const [Y, E] = je(($ = c.box) == null ? void 0 : $.map((M) => ({
|
|
448
|
-
x: M[0],
|
|
449
|
-
y: M[1]
|
|
450
|
-
})), ((v = c.type) == null ? void 0 : v.toLowerCase()) === "key" ? [255, 193, 0] : [80, 139, 238], i, f ? () => (console.log(c), f(c)) : void 0);
|
|
451
|
-
o[c.uuid] ? He(i, o[c.uuid], Y, P[c.uuid]) : Y.canvas !== i && (i.add(Y), i.add(E)), o[c.uuid] = Y, T(() => o), P[c.uuid] = E, Z(() => P);
|
|
452
|
-
}), t && (!d || d !== i.getActiveObject()))
|
|
453
|
-
try {
|
|
454
|
-
i == null || i.setActiveObject(o[t]), J(o[t]);
|
|
455
|
-
} catch (c) {
|
|
456
|
-
J(null), console.error(c);
|
|
457
|
-
}
|
|
458
|
-
return o;
|
|
459
|
-
});
|
|
460
|
-
};
|
|
461
|
-
F(() => {
|
|
462
|
-
const n = document.createElement("img");
|
|
463
|
-
n.src = Fe, n.setAttribute("style", "background: rgba(0, 0, 0, 0.45)");
|
|
464
|
-
function t(c, Y, E, $, v) {
|
|
465
|
-
c.save(), c.translate(Y, E), c.rotate(z.util.degreesToRadians(v.angle)), c.beginPath(), c.arc(0, 0, 12, 0, 2 * Math.PI), c.fillStyle = "rgba(0, 0, 0, 0.45)", c.fill(), c.strokeStyle = "rgba(0, 0, 0, 0)", c.stroke(), c.drawImage(n, -24 / 2, -24 / 2, 24, 24), c.restore();
|
|
466
|
-
}
|
|
467
|
-
const o = (c, Y, E, $) => {
|
|
468
|
-
var M;
|
|
469
|
-
const v = Y.target;
|
|
470
|
-
if (v) {
|
|
471
|
-
v === (b == null ? void 0 : b.polygon) && q(void 0), e == null || e.remove(v), e == null || e.renderAll();
|
|
472
|
-
const A = y.findIndex((H) => h[H.uuid].left === v.left && h[H.uuid].top === v.top);
|
|
473
|
-
console.log(e), A > -1 && (h[y[A].uuid] && (e == null || e.remove(h[y[A].uuid]), (M = P[y[A].uuid]) == null || M.remove()), y.splice(A, 1), a([...y.map((H) => re(Q({}, H), {
|
|
474
|
-
box: H.box.map((ne) => [ne[0] - C.left, ne[1] - C.top])
|
|
475
|
-
}))]));
|
|
476
|
-
}
|
|
477
|
-
return !1;
|
|
478
|
-
};
|
|
479
|
-
z.Object.prototype.controls.deleteControl = new z.Control({
|
|
480
|
-
x: 0.5,
|
|
481
|
-
y: -0.5,
|
|
482
|
-
offsetX: 16,
|
|
483
|
-
cursorStyle: "pointer",
|
|
484
|
-
mouseUpHandler: o,
|
|
485
|
-
render: t,
|
|
486
|
-
sizeX: 24,
|
|
487
|
-
sizeY: 24
|
|
488
|
-
});
|
|
489
|
-
}, [d, e]), F(() => {
|
|
490
|
-
var i;
|
|
491
|
-
if (w && s && !B) {
|
|
492
|
-
const n = document.createElement("div");
|
|
493
|
-
n.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (i = s.parentElement) == null || i.appendChild(n), Me.render(/* @__PURE__ */ S($e, {}), n), R(n);
|
|
494
|
-
} else
|
|
495
|
-
!w && B && (B.remove(), R(null));
|
|
496
|
-
}, [w, s, B]), F(() => {
|
|
497
|
-
var i, n;
|
|
498
|
-
b && (l([...y, {
|
|
499
|
-
uuid: b.uuid,
|
|
500
|
-
box: ((i = b.polygon.points) == null ? void 0 : i.map((t) => [t.x, t.y])) || [],
|
|
501
|
-
words: b.value || ""
|
|
502
|
-
}]), a([...y.map((t) => re(Q({}, t), {
|
|
503
|
-
box: t.box.map((o) => [o[0] - C.left, o[1] - C.top])
|
|
504
|
-
})), {
|
|
505
|
-
uuid: b.uuid,
|
|
506
|
-
box: ((n = b.polygon.points) == null ? void 0 : n.map((t) => [t.x - C.left, t.y - C.top])) || [],
|
|
507
|
-
words: b.value || ""
|
|
508
|
-
}]), e == null || e.remove(b.text), e == null || e.remove(b.polygon), q(void 0), V(b.uuid));
|
|
509
|
-
}, [b]);
|
|
510
|
-
const Be = () => {
|
|
511
|
-
let i = !1;
|
|
512
|
-
e && (e.on("mouse:down", (n) => {
|
|
513
|
-
i = !0, e.selection = !1;
|
|
514
|
-
}), e.on("mouse:move", (n) => {
|
|
515
|
-
if (i && n && n.e) {
|
|
516
|
-
const t = new z.Point(n.e.movementX, n.e.movementY);
|
|
517
|
-
e.relativePan(t);
|
|
518
|
-
}
|
|
519
|
-
}), e.on("mouse:up", (n) => {
|
|
520
|
-
i = !1, e.selection = !0;
|
|
521
|
-
}));
|
|
522
|
-
};
|
|
523
|
-
F(() => {
|
|
524
|
-
if (w && e && (ue(e, []), e.renderAll()), w || !e)
|
|
525
|
-
return;
|
|
526
|
-
if (ue(e, []), e.renderAll(), de(e), G) {
|
|
527
|
-
Be(), e.defaultCursor = "grab", e.on("mouse:down", () => e.setCursor("grabbing")), e.on("mouse:up", () => e.setCursor("grab")), console.log("evented", !1, e.getObjects()), e.getObjects().forEach((c) => c.set("evented", !1));
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
console.log("evented", !0, e.getObjects()), e.getObjects().forEach((c) => c.set("evented", !0)), e.defaultCursor = "default", e.setCursor("default");
|
|
531
|
-
const i = (c, Y) => {
|
|
532
|
-
b && (e == null || e.remove(b.text), e == null || e.remove(b.polygon)), q({
|
|
533
|
-
polygon: c,
|
|
534
|
-
text: Y,
|
|
535
|
-
uuid: Te()
|
|
536
|
-
});
|
|
537
|
-
};
|
|
538
|
-
O === "rect" ? Se(e, i) : O === "quadri" && pe(e, i, 4);
|
|
539
|
-
const n = (c) => {
|
|
540
|
-
var E;
|
|
541
|
-
J(e.getActiveObject());
|
|
542
|
-
const Y = e.getActiveObject();
|
|
543
|
-
Y == null || Y.set({
|
|
544
|
-
borderColor: "#508BEE",
|
|
545
|
-
cornerColor: "white",
|
|
546
|
-
cornerSize: 7,
|
|
547
|
-
transparentCorners: !1,
|
|
548
|
-
cornerStrokeColor: "#508BEE"
|
|
549
|
-
}), (E = Object.keys(h)) == null || E.map(($) => {
|
|
550
|
-
Y === h[$] && V($);
|
|
551
|
-
});
|
|
552
|
-
}, t = (c) => {
|
|
553
|
-
var E;
|
|
554
|
-
de(e), J(e.getActiveObject());
|
|
555
|
-
const Y = e.getActiveObject();
|
|
556
|
-
(E = Object.keys(h)) == null || E.map(($) => {
|
|
557
|
-
Y === h[$] && V($);
|
|
558
|
-
});
|
|
559
|
-
}, o = () => {
|
|
560
|
-
J(null), V(void 0);
|
|
561
|
-
};
|
|
562
|
-
return e.on("selection:created", n), e.on("selection:updated", t), e.on("selection:cleared", o), () => {
|
|
563
|
-
e.off("selection:created", n), e.off("selection:updated", t), e.off("selection:cleared", o), e.off("mouse:down"), e.off("mouse:up"), e.off("mouse:move");
|
|
564
|
-
};
|
|
565
|
-
}, [e, O, G]), F(() => {
|
|
566
|
-
if (e)
|
|
567
|
-
return e.on("mouse:wheel", (i) => {
|
|
568
|
-
const n = i.e.deltaY;
|
|
569
|
-
ce(n, {
|
|
570
|
-
x: i.e.offsetX,
|
|
571
|
-
y: i.e.offsetY
|
|
572
|
-
});
|
|
573
|
-
}), () => {
|
|
574
|
-
e == null || e.off("mouse:wheel");
|
|
575
|
-
};
|
|
576
|
-
}, [e]), F(() => {
|
|
577
|
-
if (e)
|
|
578
|
-
return d == null || d.on("mousedown", () => {
|
|
579
|
-
e && de(e);
|
|
580
|
-
}), d == null || d.on("mouseup:before", () => {
|
|
581
|
-
var n;
|
|
582
|
-
if (!e)
|
|
583
|
-
return;
|
|
584
|
-
const i = d;
|
|
585
|
-
(n = Object.keys(h)) == null || n.map((t) => {
|
|
586
|
-
if (i === h[t]) {
|
|
587
|
-
const o = y.findIndex((c) => c.uuid === t);
|
|
588
|
-
if (o > -1) {
|
|
589
|
-
const c = Pe(i);
|
|
590
|
-
y[o].box = (c == null ? void 0 : c.map((Y) => [Y.x, Y.y])) || [];
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
}), l([...y]), a([...y.map((t) => re(Q({}, t), {
|
|
594
|
-
box: t.box.map((o) => [o[0] - C.left < 1e-11 ? 0 : o[0] - C.left, o[1] - C.top < 1e-11 ? 0 : o[1] - C.top])
|
|
595
|
-
}))]);
|
|
596
|
-
}), d == null || d.on("moving", (i) => {
|
|
597
|
-
var t;
|
|
598
|
-
if (!e)
|
|
599
|
-
return;
|
|
600
|
-
const n = d;
|
|
601
|
-
e.getZoom(), (t = Object.keys(h)) == null || t.map((o) => {
|
|
602
|
-
if (n === h[o]) {
|
|
603
|
-
const c = y.findIndex((E) => E.uuid === o), Y = Pe(n);
|
|
604
|
-
y[c].box = (Y == null ? void 0 : Y.map((E) => [E.x, E.y])) || [];
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
}), () => {
|
|
608
|
-
d == null || d.off("mousedown"), d == null || d.off("mouseup:before"), d == null || d.off("moving");
|
|
609
|
-
};
|
|
610
|
-
}, [d, y, O]), F(() => {
|
|
611
|
-
if (e) {
|
|
612
|
-
if (!d) {
|
|
613
|
-
const i = (n, t) => {
|
|
614
|
-
b && (e == null || e.remove(b.text), e == null || e.remove(b.polygon)), q({
|
|
615
|
-
polygon: n,
|
|
616
|
-
text: t,
|
|
617
|
-
uuid: Te()
|
|
618
|
-
});
|
|
619
|
-
};
|
|
620
|
-
de(e), O === "rect" ? Se(e, i) : O === "quadri" && pe(e, i, 4);
|
|
621
|
-
}
|
|
622
|
-
d == null || d.on("moving", ie), d == null || d.on("scaling", ie), d == null || d.on("rotating", ie), d == null || d.on("skewing", ie), d == null || d.on("resizing", ie);
|
|
623
|
-
}
|
|
624
|
-
}, [d]);
|
|
625
|
-
const ie = (i) => {
|
|
626
|
-
Ze(i);
|
|
627
|
-
}, Ze = (i) => {
|
|
628
|
-
if (!e)
|
|
629
|
-
return;
|
|
630
|
-
const n = i.transform.action;
|
|
631
|
-
i.transform.corner;
|
|
632
|
-
const t = i.transform.target, o = i.transform.target.canvas.backgroundImage;
|
|
633
|
-
i.transform.original, o && (t.top < o.top && t.set({
|
|
634
|
-
top: o.top
|
|
635
|
-
}), t.left < o.left && t.set({
|
|
636
|
-
left: o.left
|
|
637
|
-
}), (n === "drag" || n === "rotate") && (t.top + t.height > o.top + o.height && t.set({
|
|
638
|
-
top: o.height + o.top - t.height * t.scaleY
|
|
639
|
-
}), t.left + t.width > o.left + o.width && t.set({
|
|
640
|
-
left: o.width + o.left - t.width * t.scaleX
|
|
641
|
-
})), n === "rotate" && (t.aCoords.bl.x < o.left && t.set({
|
|
642
|
-
left: t.left + (o.left - t.aCoords.bl.x)
|
|
643
|
-
}), t.aCoords.tr.y < o.top && t.set({
|
|
644
|
-
top: t.top + (o.top - t.aCoords.tr.y)
|
|
645
|
-
}), t.aCoords.br.x > o.left + o.width && t.set({
|
|
646
|
-
left: t.left - (t.aCoords.br.x - (o.left + o.width))
|
|
647
|
-
}), t.aCoords.br.y > o.top + o.height && t.set({
|
|
648
|
-
top: t.top - (t.aCoords.br.y - (o.top + o.height))
|
|
649
|
-
})), n === "scale" && (t.top + t.height * t.scaleY > o.top + o.height && t.set({
|
|
650
|
-
top: t.height * t.scaleY > o.height ? o.top : o.top + o.height - t.height * t.scaleY,
|
|
651
|
-
height: t.height * t.scaleY > o.height ? o.height : t.height
|
|
652
|
-
}), t.left + t.width * t.scaleX > o.left + o.width && t.set({
|
|
653
|
-
left: o.width + o.left - t.width * t.scaleX
|
|
654
|
-
})), n === "scaleX" && (t.left + t.width * t.scaleX > o.left + o.width && t.set({
|
|
655
|
-
left: t.left - (t.left + t.width * t.scaleX - (o.left + o.width))
|
|
656
|
-
}), t.left < o.left && t.set({
|
|
657
|
-
left: o.left
|
|
658
|
-
})), n === "scaleY" && (t.top + t.height * t.scaleY > o.top + o.height && t.set({
|
|
659
|
-
top: t.top - (t.top + t.height * t.scaleY - (o.top + o.height))
|
|
660
|
-
}), t.top < o.top && t.set({
|
|
661
|
-
top: o.top
|
|
662
|
-
})), t.width * t.scaleX >= o.width && t.set({
|
|
663
|
-
left: o.left,
|
|
664
|
-
width: o.width / t.scaleX
|
|
665
|
-
}), t.height * t.scaleY >= o.height && t.set({
|
|
666
|
-
top: o.top,
|
|
667
|
-
height: o.height / t.scaleY
|
|
668
|
-
})), e.renderAll();
|
|
669
|
-
}, ce = (i, n) => {
|
|
670
|
-
if (!e)
|
|
671
|
-
return;
|
|
672
|
-
n || (n = {
|
|
673
|
-
x: e.getCenter().left,
|
|
674
|
-
y: e.getCenter().top
|
|
675
|
-
});
|
|
676
|
-
let t = e.getZoom();
|
|
677
|
-
t *= Ee(0.999, i), t > 20 && (t = 20), t < 0.01 && (t = 0.01), e.zoomToPoint(
|
|
678
|
-
n,
|
|
679
|
-
t
|
|
680
|
-
// 传入修改后的缩放级别
|
|
681
|
-
);
|
|
682
|
-
}, De = () => {
|
|
683
|
-
N(!G);
|
|
684
|
-
};
|
|
685
|
-
return F(() => {
|
|
686
|
-
N(g || !1);
|
|
687
|
-
}, [g]), /* @__PURE__ */ S("div", {
|
|
688
|
-
className: "marker-toolbar",
|
|
689
|
-
children: /* @__PURE__ */ S("div", {
|
|
690
|
-
className: "create-mode-select",
|
|
691
|
-
children: /* @__PURE__ */ Xe(Ie, {
|
|
692
|
-
direction: "vertical",
|
|
693
|
-
size: 16,
|
|
694
|
-
children: [!g && /* @__PURE__ */ S(me.Group, {
|
|
695
|
-
value: O,
|
|
696
|
-
buttonStyle: "solid",
|
|
697
|
-
onChange: (i) => j(i.target.value),
|
|
698
|
-
children: /* @__PURE__ */ Xe(Ie, {
|
|
699
|
-
direction: "vertical",
|
|
700
|
-
size: 16,
|
|
701
|
-
children: [/* @__PURE__ */ S(se, {
|
|
702
|
-
title: "矩形标注",
|
|
703
|
-
placement: "right",
|
|
704
|
-
children: /* @__PURE__ */ S(me.Button, {
|
|
705
|
-
value: "rect",
|
|
706
|
-
type: "icon",
|
|
707
|
-
children: /* @__PURE__ */ S(Ae, {
|
|
708
|
-
type: "icon-biaozhu-juxingkuang"
|
|
709
|
-
})
|
|
710
|
-
})
|
|
711
|
-
}), /* @__PURE__ */ S(se, {
|
|
712
|
-
title: "四边形标注",
|
|
713
|
-
placement: "right",
|
|
714
|
-
children: /* @__PURE__ */ S(me.Button, {
|
|
715
|
-
value: "quadri",
|
|
716
|
-
children: /* @__PURE__ */ S(Ae, {
|
|
717
|
-
type: "icon-biaozhu-sibianxing"
|
|
718
|
-
})
|
|
719
|
-
})
|
|
720
|
-
})]
|
|
721
|
-
})
|
|
722
|
-
}), /* @__PURE__ */ S(se, {
|
|
723
|
-
title: "放大-鼠标滚轮前滑",
|
|
724
|
-
placement: "right",
|
|
725
|
-
children: /* @__PURE__ */ S(he, {
|
|
726
|
-
icon: /* @__PURE__ */ S(Ne, {}),
|
|
727
|
-
onClick: () => {
|
|
728
|
-
ce(-100);
|
|
729
|
-
}
|
|
730
|
-
})
|
|
731
|
-
}), /* @__PURE__ */ S(se, {
|
|
732
|
-
title: "缩小-鼠标滚轮后滑",
|
|
733
|
-
placement: "right",
|
|
734
|
-
children: /* @__PURE__ */ S(he, {
|
|
735
|
-
icon: /* @__PURE__ */ S(Le, {}),
|
|
736
|
-
onClick: () => {
|
|
737
|
-
ce(100);
|
|
738
|
-
}
|
|
739
|
-
})
|
|
740
|
-
}), !g && /* @__PURE__ */ S(se, {
|
|
741
|
-
title: "拖动-按住ctrl",
|
|
742
|
-
placement: "right",
|
|
743
|
-
children: /* @__PURE__ */ S(he, {
|
|
744
|
-
icon: /* @__PURE__ */ S(We, {}),
|
|
745
|
-
className: G ? "active" : "",
|
|
746
|
-
onClick: De
|
|
747
|
-
})
|
|
748
|
-
})]
|
|
749
|
-
})
|
|
750
|
-
})
|
|
751
|
-
});
|
|
752
|
-
};
|
|
753
|
-
export {
|
|
754
|
-
ut as default
|
|
755
|
-
};
|