@glodon-aiot/dataset-annotation 3.14.0-alpha.33 → 3.15.0-alpha.2
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/useAIButtonHover.mjs +0 -193
- 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 -484
- 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 -218
- 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 -678
- 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/AIErrorTooltip/AIErrorTooltip.less.mjs +0 -4
- package/dist/es/components/VLMAnnotation/components/AIErrorTooltip/index.mjs +0 -24
- 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/useAIButtonHover.d.ts +0 -16
- 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 -35
- 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/AIErrorTooltip/index.d.ts +0 -8
- 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,42 +0,0 @@
|
|
|
1
|
-
var l = Math.pow;
|
|
2
|
-
import { useCallback as h, useEffect as C } from "react";
|
|
3
|
-
import { ZOOM_FACTOR as M, MAX_ZOOM as n, MIN_ZOOM as O } from "../../constants.mjs";
|
|
4
|
-
const w = ({
|
|
5
|
-
canvas: t,
|
|
6
|
-
setScale: m,
|
|
7
|
-
isZoomingRef: f
|
|
8
|
-
}) => {
|
|
9
|
-
const u = h((r, o) => {
|
|
10
|
-
if (!t)
|
|
11
|
-
return;
|
|
12
|
-
o || (o = {
|
|
13
|
-
x: t.getCenter().left,
|
|
14
|
-
y: t.getCenter().top
|
|
15
|
-
});
|
|
16
|
-
let e = t.getZoom();
|
|
17
|
-
e *= l(M, r), e > n && (e = n), e < O && (e = O), f.current = !0, t.zoomToPoint(o, e), m(e), requestAnimationFrame(() => {
|
|
18
|
-
requestAnimationFrame(() => {
|
|
19
|
-
f.current = !1;
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
}, [t, m, f]);
|
|
23
|
-
return C(() => {
|
|
24
|
-
if (!t)
|
|
25
|
-
return;
|
|
26
|
-
const r = (o) => {
|
|
27
|
-
const e = o.e, i = e.deltaY;
|
|
28
|
-
u(i, {
|
|
29
|
-
x: e.offsetX,
|
|
30
|
-
y: e.offsetY
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
return t.on("mouse:wheel", r), () => {
|
|
34
|
-
t.off("mouse:wheel", r);
|
|
35
|
-
};
|
|
36
|
-
}, [t, u]), {
|
|
37
|
-
zoom: u
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export {
|
|
41
|
-
w as useCanvasZoom
|
|
42
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
var f = (r, p, n) => new Promise((i, a) => {
|
|
2
|
-
var t = (o) => {
|
|
3
|
-
try {
|
|
4
|
-
c(n.next(o));
|
|
5
|
-
} catch (s) {
|
|
6
|
-
a(s);
|
|
7
|
-
}
|
|
8
|
-
}, e = (o) => {
|
|
9
|
-
try {
|
|
10
|
-
c(n.throw(o));
|
|
11
|
-
} catch (s) {
|
|
12
|
-
a(s);
|
|
13
|
-
}
|
|
14
|
-
}, c = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(t, e);
|
|
15
|
-
c((n = n.apply(r, p)).next());
|
|
16
|
-
});
|
|
17
|
-
import { useCallback as l } from "react";
|
|
18
|
-
import { IMAGE_EXPORT_FORMAT as A } from "../../constants.mjs";
|
|
19
|
-
const _ = (r) => l((n) => f(void 0, null, function* () {
|
|
20
|
-
if (r)
|
|
21
|
-
return new Promise((i, a) => {
|
|
22
|
-
const t = new Image();
|
|
23
|
-
t.crossOrigin = "anonymous", t.onload = () => {
|
|
24
|
-
try {
|
|
25
|
-
const {
|
|
26
|
-
x: e,
|
|
27
|
-
y: c,
|
|
28
|
-
width: o,
|
|
29
|
-
height: s
|
|
30
|
-
} = n.shape, x = e, M = e + o, w = c, I = c + s, T = 0, y = t.width, E = 0, L = t.height, d = Math.max(T, x), v = Math.min(y, M), u = Math.max(E, w), B = Math.min(L, I), m = Math.max(0, v - d), g = Math.max(0, B - u);
|
|
31
|
-
if (m <= 0 || g <= 0) {
|
|
32
|
-
i(void 0);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const C = d, O = u, h = document.createElement("canvas");
|
|
36
|
-
h.width = m, h.height = g;
|
|
37
|
-
const R = h.getContext("2d");
|
|
38
|
-
if (!R) {
|
|
39
|
-
i(void 0);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
R.drawImage(t, C, O, m, g, 0, 0, m, g);
|
|
43
|
-
const b = h.toDataURL(A);
|
|
44
|
-
i(b);
|
|
45
|
-
} catch (e) {
|
|
46
|
-
a(e);
|
|
47
|
-
}
|
|
48
|
-
}, t.onerror = () => {
|
|
49
|
-
a(new Error("Failed to load image"));
|
|
50
|
-
}, t.src = r;
|
|
51
|
-
});
|
|
52
|
-
}), [r]);
|
|
53
|
-
export {
|
|
54
|
-
_ as useCropRegionImage
|
|
55
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { useRef as E, useEffect as I, useCallback as g } from "react";
|
|
2
|
-
import { fabric as f } from "fabric";
|
|
3
|
-
import { DELETE_CONTROL_OFFSET_X as O, DELETE_CONTROL_OFFSET_Y as C, DELETE_ICON_SIZE as T } from "../../constants.mjs";
|
|
4
|
-
import _ from "../icons/del.png.mjs";
|
|
5
|
-
const S = ({
|
|
6
|
-
performDelete: a
|
|
7
|
-
}) => {
|
|
8
|
-
const i = (e) => !(!e.complete || e.naturalWidth === 0), n = E(null);
|
|
9
|
-
return I(() => {
|
|
10
|
-
if (!n.current) {
|
|
11
|
-
const e = document.createElement("img");
|
|
12
|
-
e.src = _, n.current = e;
|
|
13
|
-
}
|
|
14
|
-
}, []), {
|
|
15
|
-
createDeleteControl: g(() => {
|
|
16
|
-
const e = T, r = n.current, d = (t, o, s, D, l) => {
|
|
17
|
-
if (!r)
|
|
18
|
-
return;
|
|
19
|
-
const c = () => {
|
|
20
|
-
t.save(), t.translate(o, s), t.rotate(f.util.degreesToRadians(l.angle || 0)), t.drawImage(r, -e / 2, -e / 2, e, e), t.restore();
|
|
21
|
-
};
|
|
22
|
-
i(r) ? c() : r.onload = () => {
|
|
23
|
-
c();
|
|
24
|
-
const u = l.canvas;
|
|
25
|
-
u && u.renderAll();
|
|
26
|
-
};
|
|
27
|
-
}, m = (t, o) => {
|
|
28
|
-
const s = o.target;
|
|
29
|
-
return a(s), !1;
|
|
30
|
-
};
|
|
31
|
-
return new f.Control({
|
|
32
|
-
x: 0.5,
|
|
33
|
-
// 右侧(0 = 左边,0.5 = 中间,1 = 右边)
|
|
34
|
-
y: -0.5,
|
|
35
|
-
// 顶部(0 = 顶部,0.5 = 中间,1 = 底部)
|
|
36
|
-
offsetX: O,
|
|
37
|
-
// 向右偏移,让按钮更靠近矩形边缘
|
|
38
|
-
offsetY: C,
|
|
39
|
-
// 向上偏移,让按钮更靠近矩形边缘
|
|
40
|
-
cursorStyle: "pointer",
|
|
41
|
-
mouseUpHandler: m,
|
|
42
|
-
render: d,
|
|
43
|
-
sizeX: e,
|
|
44
|
-
sizeY: e
|
|
45
|
-
});
|
|
46
|
-
}, [a])
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
export {
|
|
50
|
-
S as useDeleteControl
|
|
51
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { useRef as X, useCallback as A } from "react";
|
|
2
|
-
import { Modal as K } from "antd";
|
|
3
|
-
import { DELETE_MODAL_TITLE as q, DELETE_MODAL_CONTENT as z, DELETE_MODAL_OK_TEXT as B, DELETE_MODAL_CANCEL_TEXT as F } from "../../constants.mjs";
|
|
4
|
-
const O = ({
|
|
5
|
-
canvas: l,
|
|
6
|
-
onRegionChange: o,
|
|
7
|
-
updateRegionNames: _,
|
|
8
|
-
rectMapRef: f,
|
|
9
|
-
textLayersMapRef: e,
|
|
10
|
-
textLayoutContentMapRef: s,
|
|
11
|
-
regionNameTextMapRef: m,
|
|
12
|
-
ocrLoadingIconMapRef: d
|
|
13
|
-
}) => {
|
|
14
|
-
const E = X(!1), k = A((r) => {
|
|
15
|
-
if (!l || E.current)
|
|
16
|
-
return;
|
|
17
|
-
const D = f.current.get(r);
|
|
18
|
-
D && (E.current = !0, K.confirm({
|
|
19
|
-
title: q,
|
|
20
|
-
content: z,
|
|
21
|
-
okText: B,
|
|
22
|
-
cancelText: F,
|
|
23
|
-
onOk: () => {
|
|
24
|
-
const i = e.current.get(r);
|
|
25
|
-
i && (i.forEach((u) => {
|
|
26
|
-
u.off("mousedown"), u.off("mouseover"), u.off("mouseout"), s.current.delete(u), l.remove(u);
|
|
27
|
-
}), e.current.delete(r));
|
|
28
|
-
const T = m.current.get(r);
|
|
29
|
-
T && (r.off("moved"), r.off("modified"), l.remove(T), m.current.delete(r));
|
|
30
|
-
const n = d.current.get(r);
|
|
31
|
-
n && (l.remove(n), d.current.delete(r)), l.remove(r), f.current.delete(r), _(), o && o(D, "delete"), l.renderAll(), E.current = !1;
|
|
32
|
-
},
|
|
33
|
-
onCancel: () => {
|
|
34
|
-
E.current = !1;
|
|
35
|
-
},
|
|
36
|
-
afterClose: () => {
|
|
37
|
-
E.current = !1;
|
|
38
|
-
}
|
|
39
|
-
}));
|
|
40
|
-
}, [l, o, _, f, e, s, m, d]), w = A((r) => {
|
|
41
|
-
if (!l)
|
|
42
|
-
return;
|
|
43
|
-
const D = f.current.get(r);
|
|
44
|
-
if (!D)
|
|
45
|
-
return;
|
|
46
|
-
const i = e.current.get(r);
|
|
47
|
-
i && (i.forEach((u) => {
|
|
48
|
-
u.off("mousedown"), u.off("mouseover"), u.off("mouseout"), s.current.delete(u), l.remove(u);
|
|
49
|
-
}), e.current.delete(r));
|
|
50
|
-
const T = m.current.get(r);
|
|
51
|
-
T && (r.off("moved"), r.off("modified"), l.remove(T), m.current.delete(r));
|
|
52
|
-
const n = d.current.get(r);
|
|
53
|
-
n && (l.remove(n), d.current.delete(r)), l.remove(r), f.current.delete(r), _(), o && o(D, "delete"), l.renderAll();
|
|
54
|
-
}, [l, o, _, f, e, s, m, d]);
|
|
55
|
-
return {
|
|
56
|
-
performDelete: k,
|
|
57
|
-
deleteDirectly: w
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
export {
|
|
61
|
-
O as useDeleteRegion
|
|
62
|
-
};
|
|
@@ -1,484 +0,0 @@
|
|
|
1
|
-
import { useCallback as Ae, useRef as ne, useEffect as se } from "react";
|
|
2
|
-
import { fabric as T } from "fabric";
|
|
3
|
-
import { CROSSHAIR_LINE_COLOR as Ye, CROSSHAIR_LINE_DASH_ARRAY as Ce, CROSSHAIR_LINE_WIDTH as Xe, TEMP_RECT_FILL_COLOR as Se, RECT_STROKE_COLOR as ie, TEMP_RECT_STROKE_DASH_ARRAY as je, TRANSPARENT_FILL as Be, REGION_NAME_PREFIX as Ue, BASE_STROKE_WIDTH as le } from "../../constants.mjs";
|
|
4
|
-
const Ge = ({
|
|
5
|
-
canvas: e,
|
|
6
|
-
drawingMode: y,
|
|
7
|
-
draggable: ce,
|
|
8
|
-
setDrawingMode: de,
|
|
9
|
-
canvasToImageCoords: ue,
|
|
10
|
-
labelDefinitions: J,
|
|
11
|
-
onChange: I,
|
|
12
|
-
cropRegionImage: fe,
|
|
13
|
-
updateRegionShapeAndImage: D,
|
|
14
|
-
performOCRIfNeeded: he,
|
|
15
|
-
createDeleteControl: me,
|
|
16
|
-
createOCRControl: ge,
|
|
17
|
-
updateRegionNameText: be,
|
|
18
|
-
onRegionChange: Q,
|
|
19
|
-
onRegionSelect: P,
|
|
20
|
-
rectMapRef: x,
|
|
21
|
-
textLayersMapRef: ke,
|
|
22
|
-
regionNameTextMapRef: v,
|
|
23
|
-
setupBoundaryCheck: pe
|
|
24
|
-
}) => {
|
|
25
|
-
const V = Ae(() => {
|
|
26
|
-
const L = /* @__PURE__ */ new Set();
|
|
27
|
-
return ke.current.forEach((w) => {
|
|
28
|
-
w.forEach((z) => {
|
|
29
|
-
L.add(z);
|
|
30
|
-
});
|
|
31
|
-
}), L;
|
|
32
|
-
}, [ke]), i = ne({
|
|
33
|
-
horizontal: null,
|
|
34
|
-
vertical: null
|
|
35
|
-
}), N = ne(null), Oe = ne({
|
|
36
|
-
dleft: -1,
|
|
37
|
-
dtop: -1,
|
|
38
|
-
dw: 0,
|
|
39
|
-
dh: 0,
|
|
40
|
-
rect: null
|
|
41
|
-
}), G = Ae(() => {
|
|
42
|
-
e && (e.skipTargetFind = !1);
|
|
43
|
-
}, [e]);
|
|
44
|
-
return se(() => {
|
|
45
|
-
if (!e || !y || ce) {
|
|
46
|
-
if (G(), e && !y) {
|
|
47
|
-
i.current.horizontal && e.getObjects().includes(i.current.horizontal) && e.remove(i.current.horizontal), i.current.vertical && e.getObjects().includes(i.current.vertical) && e.remove(i.current.vertical), i.current = {
|
|
48
|
-
horizontal: null,
|
|
49
|
-
vertical: null
|
|
50
|
-
};
|
|
51
|
-
const o = e.getActiveObject();
|
|
52
|
-
e.selection = !1, e.skipTargetFind = !1;
|
|
53
|
-
const s = V(), r = new Set(v.current.values());
|
|
54
|
-
e.getObjects().forEach((n) => {
|
|
55
|
-
n instanceof T.Rect && s.has(n) ? n.set({
|
|
56
|
-
evented: !0,
|
|
57
|
-
selectable: !1,
|
|
58
|
-
lockMovementX: !0,
|
|
59
|
-
lockMovementY: !0,
|
|
60
|
-
lockScalingX: !0,
|
|
61
|
-
lockScalingY: !0,
|
|
62
|
-
lockRotation: !0
|
|
63
|
-
}) : r.has(n) ? n.set({
|
|
64
|
-
evented: !1,
|
|
65
|
-
selectable: !1,
|
|
66
|
-
lockMovementX: !0,
|
|
67
|
-
lockMovementY: !0,
|
|
68
|
-
lockScalingX: !1,
|
|
69
|
-
// 允许缩放,用于抵消画布缩放
|
|
70
|
-
lockScalingY: !1,
|
|
71
|
-
// 允许缩放,用于抵消画布缩放
|
|
72
|
-
lockRotation: !0,
|
|
73
|
-
hasControls: !1,
|
|
74
|
-
hasBorders: !1
|
|
75
|
-
}) : (n.set("evented", !0), n.set("selectable", !0), n instanceof T.Rect && n.set("hasControls", !0));
|
|
76
|
-
}), o && e.getObjects().includes(o) && (e.setActiveObject(o), e.renderAll()), e.defaultCursor = "default";
|
|
77
|
-
}
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
G(), e.selection = !1, e.skipTargetFind = !0, e.getActiveObject() && (e.discardActiveObject(), e.renderAll());
|
|
81
|
-
const w = new Set(v.current.values());
|
|
82
|
-
e.getObjects().forEach((o) => {
|
|
83
|
-
w.has(o) ? o.set({
|
|
84
|
-
evented: !1,
|
|
85
|
-
selectable: !1,
|
|
86
|
-
lockMovementX: !0,
|
|
87
|
-
lockMovementY: !0,
|
|
88
|
-
lockScalingX: !1,
|
|
89
|
-
// 允许缩放,用于抵消画布缩放
|
|
90
|
-
lockScalingY: !1,
|
|
91
|
-
// 允许缩放,用于抵消画布缩放
|
|
92
|
-
lockRotation: !0,
|
|
93
|
-
hasControls: !1,
|
|
94
|
-
hasBorders: !1
|
|
95
|
-
}) : (o.set("evented", !1), o.set("selectable", !1), o instanceof T.Rect && o.hasControls && o.set("hasControls", !1));
|
|
96
|
-
}), e.defaultCursor = "crosshair", e.setCursor("crosshair"), i.current.horizontal && e.getObjects().includes(i.current.horizontal) && e.remove(i.current.horizontal), i.current.vertical && e.getObjects().includes(i.current.vertical) && e.remove(i.current.vertical), i.current = {
|
|
97
|
-
horizontal: null,
|
|
98
|
-
vertical: null
|
|
99
|
-
};
|
|
100
|
-
const z = e.getWidth(), S = e.getHeight(), E = e.getZoom(), j = z / E, $ = S / E, _ = Math.max(j, $) * 3, K = Xe / E, F = new T.Line([-_, 0, _, 0], {
|
|
101
|
-
stroke: Ye,
|
|
102
|
-
strokeWidth: K,
|
|
103
|
-
strokeDashArray: Ce,
|
|
104
|
-
selectable: !1,
|
|
105
|
-
evented: !1,
|
|
106
|
-
excludeFromExport: !0,
|
|
107
|
-
// 导出时不包含此线
|
|
108
|
-
strokeUniform: !0,
|
|
109
|
-
// 设置为 true,使线宽随缩放调整以保持视觉一致
|
|
110
|
-
visible: !0
|
|
111
|
-
// 画框模式下常显辅助线
|
|
112
|
-
}), Z = new T.Line([0, -_, 0, _], {
|
|
113
|
-
stroke: Ye,
|
|
114
|
-
strokeWidth: K,
|
|
115
|
-
strokeDashArray: Ce,
|
|
116
|
-
selectable: !1,
|
|
117
|
-
evented: !1,
|
|
118
|
-
excludeFromExport: !0,
|
|
119
|
-
// 导出时不包含此线
|
|
120
|
-
strokeUniform: !0,
|
|
121
|
-
// 设置为 true,使线宽随缩放调整以保持视觉一致
|
|
122
|
-
visible: !0
|
|
123
|
-
// 画框模式下常显辅助线
|
|
124
|
-
});
|
|
125
|
-
i.current = {
|
|
126
|
-
horizontal: F,
|
|
127
|
-
vertical: Z
|
|
128
|
-
}, e.add(F), e.add(Z), F.sendToBack(), Z.sendToBack();
|
|
129
|
-
const R = (o, s) => {
|
|
130
|
-
const r = i.current.horizontal, n = i.current.vertical;
|
|
131
|
-
if (!r || !n)
|
|
132
|
-
return;
|
|
133
|
-
const u = e.getZoom(), b = e.getWidth(), l = e.getHeight(), h = b / u, f = l / u, m = e.viewportTransform || [1, 0, 0, 1, 0, 0];
|
|
134
|
-
m[4] / u, m[5] / u;
|
|
135
|
-
const k = e.backgroundImage;
|
|
136
|
-
let g = h, p = f;
|
|
137
|
-
if (k) {
|
|
138
|
-
const a = k.getElement();
|
|
139
|
-
if (a != null && a.width && (a != null && a.height)) {
|
|
140
|
-
const re = k, Fe = re.scaleX || 1, Ze = re.scaleY || 1;
|
|
141
|
-
g = a.width * Fe, p = a.height * Ze;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
const A = Math.max(h, f, g, p) * 10, M = m[3] || u, Y = m[5] || 0, d = 0, C = l, X = (d - Y) / M, H = (C - Y) / M;
|
|
145
|
-
let W = s;
|
|
146
|
-
s < X ? W = X : s > H && (W = H);
|
|
147
|
-
const q = m[0] || u, oe = m[4] || 0, We = 0, ye = b, Re = (We - oe) / q, Te = (ye - oe) / q;
|
|
148
|
-
let U = o;
|
|
149
|
-
isNaN(o) || !isFinite(o) ? U = (b / 2 - oe) / q : o < Re ? U = Re : o > Te && (U = Te);
|
|
150
|
-
const ze = -A, _e = h + A, He = -A, Ie = f + A;
|
|
151
|
-
r.set({
|
|
152
|
-
x1: ze,
|
|
153
|
-
y1: W,
|
|
154
|
-
x2: _e,
|
|
155
|
-
y2: W,
|
|
156
|
-
visible: !0
|
|
157
|
-
// 显示辅助线
|
|
158
|
-
}), r.setCoords(), n.set({
|
|
159
|
-
x1: U,
|
|
160
|
-
y1: He,
|
|
161
|
-
x2: U,
|
|
162
|
-
y2: Ie,
|
|
163
|
-
visible: !0
|
|
164
|
-
// 显示辅助线
|
|
165
|
-
}), n.setCoords(), r.sendToBack(), n.sendToBack(), e.renderAll();
|
|
166
|
-
const O = Oe.current, Pe = O.rect && e.getObjects().includes(O.rect);
|
|
167
|
-
if (O.rect && !e.getObjects().includes(O.rect) && O.dleft !== -1 && O.dtop !== -1 && O.dw > 0 && O.dh > 0 && e.add(O.rect), Pe && O.rect) {
|
|
168
|
-
const a = Math.min(e.getObjects().indexOf(r), e.getObjects().indexOf(n));
|
|
169
|
-
e.getObjects().indexOf(O.rect) <= a && e.moveTo(O.rect, a + 1);
|
|
170
|
-
}
|
|
171
|
-
e.renderAll();
|
|
172
|
-
};
|
|
173
|
-
if (N.current) {
|
|
174
|
-
const s = e.getElement().getBoundingClientRect(), {
|
|
175
|
-
clientX: r,
|
|
176
|
-
clientY: n
|
|
177
|
-
} = N.current;
|
|
178
|
-
if (r >= s.left && r <= s.right && n >= s.top && n <= s.bottom) {
|
|
179
|
-
const b = new MouseEvent("mousemove", {
|
|
180
|
-
bubbles: !0,
|
|
181
|
-
cancelable: !0,
|
|
182
|
-
clientX: r,
|
|
183
|
-
clientY: n
|
|
184
|
-
}), l = e.getPointer(b);
|
|
185
|
-
R(l.x, l.y);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
const t = Oe.current, B = (o) => {
|
|
189
|
-
if (e.skipTargetFind && (t.dleft === -1 || t.dtop === -1)) {
|
|
190
|
-
const s = e.getPointer(o.e);
|
|
191
|
-
t.dleft = s.x, t.dtop = s.y;
|
|
192
|
-
}
|
|
193
|
-
}, Me = (o) => {
|
|
194
|
-
const s = e.getPointer(o.e);
|
|
195
|
-
R(s.x, s.y);
|
|
196
|
-
}, ee = (o) => {
|
|
197
|
-
const s = e.getPointer(o.e);
|
|
198
|
-
if (t.dleft !== -1 && t.dtop !== -1) {
|
|
199
|
-
let r = s.x, n = s.y;
|
|
200
|
-
if (t.dw = Math.abs(r - t.dleft), t.dh = Math.abs(n - t.dtop), t.dw > 0 && t.dh > 0) {
|
|
201
|
-
let u = t.dtop > n ? n : t.dtop, b = t.dleft > r ? r : t.dleft, l = t.dw, h = t.dh;
|
|
202
|
-
if (!t.rect || t.rect.left !== b || t.rect.top !== u || t.rect.width !== l || t.rect.height !== h || !e.getObjects().includes(t.rect)) {
|
|
203
|
-
t.rect && e.getObjects().includes(t.rect) && e.remove(t.rect);
|
|
204
|
-
const g = e.getZoom(), p = le / g;
|
|
205
|
-
t.rect = new T.Rect({
|
|
206
|
-
left: b,
|
|
207
|
-
top: u,
|
|
208
|
-
width: l,
|
|
209
|
-
height: h,
|
|
210
|
-
fill: Se,
|
|
211
|
-
stroke: ie,
|
|
212
|
-
strokeWidth: p,
|
|
213
|
-
strokeUniform: !0,
|
|
214
|
-
// 边框宽度不受缩放影响
|
|
215
|
-
strokeDashArray: je,
|
|
216
|
-
selectable: !1,
|
|
217
|
-
evented: !1,
|
|
218
|
-
objectCaching: !1,
|
|
219
|
-
// 禁用缓存,避免缩放时边框变虚
|
|
220
|
-
statefullCache: !1,
|
|
221
|
-
noScaleCache: !1
|
|
222
|
-
}), e.add(t.rect);
|
|
223
|
-
}
|
|
224
|
-
const m = i.current.horizontal, k = i.current.vertical;
|
|
225
|
-
if (t.rect && m && k && e.getObjects().includes(m) && e.getObjects().includes(k) && e.getObjects().includes(t.rect)) {
|
|
226
|
-
const g = Math.min(e.getObjects().indexOf(m), e.getObjects().indexOf(k));
|
|
227
|
-
e.getObjects().indexOf(t.rect) <= g && e.moveTo(t.rect, g + 1);
|
|
228
|
-
}
|
|
229
|
-
} else
|
|
230
|
-
t.rect && e.getObjects().includes(t.rect) && (e.remove(t.rect), t.rect = null);
|
|
231
|
-
}
|
|
232
|
-
Me(o);
|
|
233
|
-
}, te = (o) => {
|
|
234
|
-
if (t.dleft === -1 || t.dtop === -1) {
|
|
235
|
-
t.dtop = -1, t.dleft = -1;
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
const s = e.getPointer(o.e);
|
|
239
|
-
let r = s.x, n = s.y;
|
|
240
|
-
if (t.dw = Math.abs(r - t.dleft), t.dh = Math.abs(n - t.dtop), t.dw === 0 || t.dh === 0) {
|
|
241
|
-
t.rect && (e.remove(t.rect), e.renderAll()), t.dtop = -1, t.dleft = -1;
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
let u = t.dtop > n ? n : t.dtop, b = t.dleft > r ? r : t.dleft, l = t.dw, h = t.dh;
|
|
245
|
-
t.rect && (e.remove(t.rect), t.rect = null);
|
|
246
|
-
const f = ue(b, u), m = l, k = h, g = e.getZoom(), p = le / g, c = new T.Rect({
|
|
247
|
-
left: b,
|
|
248
|
-
top: u,
|
|
249
|
-
width: l,
|
|
250
|
-
height: h,
|
|
251
|
-
fill: Be,
|
|
252
|
-
// 无填充色
|
|
253
|
-
stroke: ie,
|
|
254
|
-
strokeWidth: p,
|
|
255
|
-
strokeUniform: !0,
|
|
256
|
-
// 边框宽度不受缩放影响
|
|
257
|
-
selectable: !0,
|
|
258
|
-
evented: !0,
|
|
259
|
-
hasRotatingPoint: !1,
|
|
260
|
-
// 隐藏旋转点
|
|
261
|
-
lockRotation: !0,
|
|
262
|
-
// 锁定旋转
|
|
263
|
-
lockUniScaling: !1,
|
|
264
|
-
// 允许非等比缩放,控制点跟随鼠标
|
|
265
|
-
lockScalingFlip: !0,
|
|
266
|
-
// 禁止缩放时翻转
|
|
267
|
-
objectCaching: !1,
|
|
268
|
-
// 禁用缓存,避免缩放时边框变虚
|
|
269
|
-
statefullCache: !1,
|
|
270
|
-
noScaleCache: !1,
|
|
271
|
-
hasControls: !0
|
|
272
|
-
// 启用控件
|
|
273
|
-
});
|
|
274
|
-
e.add(c), c.controls.deleteControl = me(), c.controls.ocrControl = ge(), c.set("hasControls", !1);
|
|
275
|
-
const A = x.current.size, M = {};
|
|
276
|
-
J == null || J.forEach((d) => {
|
|
277
|
-
M[d.id] = "";
|
|
278
|
-
});
|
|
279
|
-
const Y = {
|
|
280
|
-
id: `region-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
281
|
-
name: `${Ue}${A + 1}`,
|
|
282
|
-
// 设置名称:区域+(索引+1)
|
|
283
|
-
shape: {
|
|
284
|
-
name: "rect",
|
|
285
|
-
x: Math.max(0, f.x),
|
|
286
|
-
y: Math.max(0, f.y),
|
|
287
|
-
width: m,
|
|
288
|
-
height: k
|
|
289
|
-
},
|
|
290
|
-
content: M
|
|
291
|
-
};
|
|
292
|
-
if (x.current.set(c, Y), be(c, Y), D(c), Q) {
|
|
293
|
-
const d = x.current.get(c);
|
|
294
|
-
d && Q(d, "create");
|
|
295
|
-
}
|
|
296
|
-
fe(Y).then((d) => {
|
|
297
|
-
if (d) {
|
|
298
|
-
const C = x.current.get(c);
|
|
299
|
-
if (C) {
|
|
300
|
-
if (C.image = d, delete C.textLayouts, I) {
|
|
301
|
-
const X = Array.from(x.current.values());
|
|
302
|
-
I(X);
|
|
303
|
-
}
|
|
304
|
-
he(C, "create");
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}).catch((d) => {
|
|
308
|
-
console.error("Failed to crop region image:", d);
|
|
309
|
-
}), e.setActiveObject(c), e.renderAll(), setTimeout(() => {
|
|
310
|
-
if (P) {
|
|
311
|
-
const d = x.current.get(c);
|
|
312
|
-
d && P(d);
|
|
313
|
-
}
|
|
314
|
-
setTimeout(() => {
|
|
315
|
-
if (e && c && e.getObjects().includes(c) && (e.setActiveObject(c), e.renderAll(), P)) {
|
|
316
|
-
const d = x.current.get(c);
|
|
317
|
-
d && P(d);
|
|
318
|
-
}
|
|
319
|
-
}, 0);
|
|
320
|
-
}, 0), pe(c), c.on("modified", () => {
|
|
321
|
-
D(c);
|
|
322
|
-
}), c.on("moved", () => {
|
|
323
|
-
D(c);
|
|
324
|
-
}), setTimeout(() => {
|
|
325
|
-
if (I) {
|
|
326
|
-
const d = Array.from(x.current.values());
|
|
327
|
-
I(d);
|
|
328
|
-
}
|
|
329
|
-
}, 0), t.dtop = -1, t.dleft = -1, e.selection = !1, de(!1);
|
|
330
|
-
}, ae = (o) => {
|
|
331
|
-
N.current = {
|
|
332
|
-
clientX: o.clientX,
|
|
333
|
-
clientY: o.clientY
|
|
334
|
-
};
|
|
335
|
-
const r = e.getElement().getBoundingClientRect(), n = o.clientX, u = o.clientY, b = n >= r.left && n <= r.right && u >= r.top && u <= r.bottom;
|
|
336
|
-
if (t.dleft !== -1 && t.dtop !== -1)
|
|
337
|
-
if (b) {
|
|
338
|
-
const l = e.getPointer(o);
|
|
339
|
-
ee({
|
|
340
|
-
e: o,
|
|
341
|
-
pointer: l
|
|
342
|
-
});
|
|
343
|
-
} else {
|
|
344
|
-
const l = e.getZoom(), h = e.viewportTransform ? e.viewportTransform[4] / l : 0, f = e.viewportTransform ? e.viewportTransform[5] / l : 0, m = e.getWidth() / l, k = e.getHeight() / l;
|
|
345
|
-
let g = (n - r.left) / l - h, p = (u - r.top) / l - f;
|
|
346
|
-
if (g = Math.max(0, Math.min(g, m)), p = Math.max(0, Math.min(p, k)), t.dw = Math.abs(g - t.dleft), t.dh = Math.abs(p - t.dtop), t.dw === 0 || t.dh === 0)
|
|
347
|
-
return;
|
|
348
|
-
let c = t.dtop > p ? p : t.dtop, A = t.dleft > g ? g : t.dleft, M = t.dw, Y = t.dh;
|
|
349
|
-
t.rect && e.remove(t.rect);
|
|
350
|
-
const d = e.getZoom(), C = le / d;
|
|
351
|
-
t.rect = new T.Rect({
|
|
352
|
-
left: A,
|
|
353
|
-
top: c,
|
|
354
|
-
width: M,
|
|
355
|
-
height: Y,
|
|
356
|
-
fill: Se,
|
|
357
|
-
stroke: ie,
|
|
358
|
-
strokeWidth: C,
|
|
359
|
-
strokeUniform: !0,
|
|
360
|
-
strokeDashArray: je,
|
|
361
|
-
selectable: !1,
|
|
362
|
-
evented: !1,
|
|
363
|
-
objectCaching: !1,
|
|
364
|
-
statefullCache: !1,
|
|
365
|
-
noScaleCache: !1
|
|
366
|
-
}), e.add(t.rect);
|
|
367
|
-
const X = i.current.horizontal, H = i.current.vertical;
|
|
368
|
-
if (X && H && e.getObjects().includes(X) && e.getObjects().includes(H)) {
|
|
369
|
-
const W = Math.min(e.getObjects().indexOf(X), e.getObjects().indexOf(H));
|
|
370
|
-
e.getObjects().indexOf(t.rect) < W && e.moveTo(t.rect, W + 1);
|
|
371
|
-
}
|
|
372
|
-
e.renderAll();
|
|
373
|
-
}
|
|
374
|
-
if (t.dleft === -1 || t.dtop === -1) {
|
|
375
|
-
let l, h;
|
|
376
|
-
if (b) {
|
|
377
|
-
const f = e.getPointer(o);
|
|
378
|
-
l = f.x, h = f.y;
|
|
379
|
-
} else {
|
|
380
|
-
const f = e.getZoom(), m = e.viewportTransform ? e.viewportTransform[4] / f : 0, k = e.viewportTransform ? e.viewportTransform[5] / f : 0;
|
|
381
|
-
l = (n - r.left) / f - m, h = (u - r.top) / f - k;
|
|
382
|
-
}
|
|
383
|
-
R(l, h);
|
|
384
|
-
}
|
|
385
|
-
}, xe = () => {
|
|
386
|
-
}, Le = (o) => {
|
|
387
|
-
const s = e.getPointer(o.e);
|
|
388
|
-
R(s.x, s.y);
|
|
389
|
-
}, we = (o) => {
|
|
390
|
-
if (!y)
|
|
391
|
-
return;
|
|
392
|
-
e.skipTargetFind = !0, e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), t.dtop = -1, t.dleft = -1, t.dw = 0, t.dh = 0;
|
|
393
|
-
const r = e.getPointer(o.e);
|
|
394
|
-
t.dleft = r.x, t.dtop = r.y;
|
|
395
|
-
};
|
|
396
|
-
e.on("mouse:down:before", we), e.on("mouse:down", B), e.on("mouse:move", ee), e.on("mouse:up", te), e.on("mouse:out", xe), e.on("mouse:over", Le), document.addEventListener("mousemove", ae);
|
|
397
|
-
const Ee = (o) => {
|
|
398
|
-
if (t.dleft === -1 || t.dtop === -1)
|
|
399
|
-
return;
|
|
400
|
-
const s = e.getPointer(o);
|
|
401
|
-
te({
|
|
402
|
-
e: o,
|
|
403
|
-
pointer: s
|
|
404
|
-
});
|
|
405
|
-
};
|
|
406
|
-
return document.addEventListener("mouseup", Ee), () => {
|
|
407
|
-
e.off("mouse:down:before", we), e.off("mouse:down", B), e.off("mouse:move", ee), e.off("mouse:up", te), e.off("mouse:out", xe), e.off("mouse:over", Le), document.removeEventListener("mousemove", ae), document.removeEventListener("mouseup", Ee), t.rect && (e.remove(t.rect), e.renderAll()), i.current.horizontal && e.getObjects().includes(i.current.horizontal) && e.remove(i.current.horizontal), i.current.vertical && e.getObjects().includes(i.current.vertical) && e.remove(i.current.vertical), i.current = {
|
|
408
|
-
horizontal: null,
|
|
409
|
-
vertical: null
|
|
410
|
-
}, e.skipTargetFind = !1, e.defaultCursor = "default";
|
|
411
|
-
const o = V(), s = new Set(v.current.values());
|
|
412
|
-
e.getObjects().forEach((r) => {
|
|
413
|
-
r instanceof T.Rect && o.has(r) ? r.set({
|
|
414
|
-
evented: !0,
|
|
415
|
-
selectable: !1,
|
|
416
|
-
lockMovementX: !0,
|
|
417
|
-
lockMovementY: !0,
|
|
418
|
-
lockScalingX: !0,
|
|
419
|
-
lockScalingY: !0,
|
|
420
|
-
lockRotation: !0
|
|
421
|
-
}) : s.has(r) ? r.set({
|
|
422
|
-
evented: !1,
|
|
423
|
-
selectable: !1,
|
|
424
|
-
lockMovementX: !0,
|
|
425
|
-
lockMovementY: !0,
|
|
426
|
-
lockScalingX: !1,
|
|
427
|
-
// 允许缩放,用于抵消画布缩放
|
|
428
|
-
lockScalingY: !1,
|
|
429
|
-
// 允许缩放,用于抵消画布缩放
|
|
430
|
-
lockRotation: !0,
|
|
431
|
-
hasControls: !1,
|
|
432
|
-
hasBorders: !1
|
|
433
|
-
}) : (r.set("evented", !0), r.set("selectable", !0));
|
|
434
|
-
});
|
|
435
|
-
};
|
|
436
|
-
}, [e, y, ce, G, ue, I, fe, D, he, me, ge, be, Q, P, de, x, V, v, pe]), se(() => {
|
|
437
|
-
if (!e)
|
|
438
|
-
return;
|
|
439
|
-
const L = (w) => {
|
|
440
|
-
N.current = {
|
|
441
|
-
clientX: w.clientX,
|
|
442
|
-
clientY: w.clientY
|
|
443
|
-
};
|
|
444
|
-
};
|
|
445
|
-
return document.addEventListener("mousemove", L), () => {
|
|
446
|
-
document.removeEventListener("mousemove", L);
|
|
447
|
-
};
|
|
448
|
-
}, [e]), se(() => {
|
|
449
|
-
if (!e || !y)
|
|
450
|
-
return;
|
|
451
|
-
let L = e.getZoom();
|
|
452
|
-
const w = () => {
|
|
453
|
-
const S = i.current.horizontal, E = i.current.vertical;
|
|
454
|
-
if (!S || !E)
|
|
455
|
-
return;
|
|
456
|
-
const j = e.getZoom();
|
|
457
|
-
if (Math.abs(j - L) < 1e-3)
|
|
458
|
-
return;
|
|
459
|
-
L = j;
|
|
460
|
-
const $ = Xe / j, _ = e.getWidth(), K = e.getHeight(), F = _ / j, Z = K / j, R = Math.max(F, Z) * 3, t = (S.x1 + S.x2) / 2;
|
|
461
|
-
S.y1, E.x1;
|
|
462
|
-
const B = (E.y1 + E.y2) / 2;
|
|
463
|
-
S.set({
|
|
464
|
-
strokeWidth: $,
|
|
465
|
-
x1: t - R,
|
|
466
|
-
x2: t + R
|
|
467
|
-
}), E.set({
|
|
468
|
-
strokeWidth: $,
|
|
469
|
-
y1: B - R,
|
|
470
|
-
y2: B + R
|
|
471
|
-
}), e.renderAll();
|
|
472
|
-
}, z = () => {
|
|
473
|
-
w();
|
|
474
|
-
};
|
|
475
|
-
return e.on("after:render", z), w(), () => {
|
|
476
|
-
e.off("after:render", z);
|
|
477
|
-
};
|
|
478
|
-
}, [e, y]), {
|
|
479
|
-
stopDraw: G
|
|
480
|
-
};
|
|
481
|
-
};
|
|
482
|
-
export {
|
|
483
|
-
Ge as useDrawingMode
|
|
484
|
-
};
|