@glodon-aiot/dataset-annotation 3.14.0-alpha.32 → 3.15.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/DatasetContext/index.mjs +3 -6
- package/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +91 -94
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/Drawable.mjs +28 -37
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +101 -145
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +195 -256
- package/dist/es/components/DetectionAnnotation/index.mjs +424 -456
- package/dist/es/components/Iconfont/index.mjs +2 -2
- package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/index.mjs +1 -1
- package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.mjs +1 -1
- package/dist/es/components/OcrAnnotation/OcrModal/index.mjs +45 -43
- package/dist/es/components/PicZipImportModal/index.mjs +293 -308
- package/dist/es/components/PreLabelOCR/index.mjs +1 -1
- package/dist/es/constant.mjs +3 -3
- package/dist/es/featuresConfig.mjs +9 -13
- package/dist/es/index.mjs +7 -11
- package/dist/lib/index.js +3 -4
- package/dist/src/DatasetContext/index.d.ts +0 -2
- package/dist/src/components/DetectionAnnotation/components/ImageDetail/index.d.ts +0 -1
- package/dist/src/constant.d.ts +1 -1
- package/dist/src/featuresConfig.d.ts +0 -4
- package/dist/src/index.d.ts +0 -3
- package/package.json +2 -2
- package/dist/es/components/DetectionAnnotation/components/ImageModal/index.mjs +0 -129
- package/dist/es/components/DetectionAnnotation/components/ImageModal/style.less.mjs +0 -4
- package/dist/es/components/PicZipImportModal/config.mjs +0 -47
- package/dist/es/components/PicZipImportModal/pic_vlm_json_zip.svg.mjs +0 -4
- package/dist/es/components/PicZipImportModal/pic_vlm_zip.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/RegionItem.mjs +0 -170
- package/dist/es/components/VLMAnnotation/TextAnnotationPanel.mjs +0 -94
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.mjs +0 -116
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.mjs +0 -115
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.mjs +0 -42
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.mjs +0 -55
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.mjs +0 -51
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.mjs +0 -62
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +0 -421
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.mjs +0 -100
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.mjs +0 -106
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +0 -101
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.mjs +0 -103
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.mjs +0 -38
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.mjs +0 -173
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.mjs +0 -72
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +0 -116
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +0 -98
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.mjs +0 -156
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/ai.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/del.png.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/error.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/loading.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/star.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +0 -651
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.mjs +0 -33
- package/dist/es/components/VLMAnnotation/components/DragButton.mjs +0 -18
- package/dist/es/components/VLMAnnotation/components/FitToScreenButton.mjs +0 -16
- package/dist/es/components/VLMAnnotation/components/RectangleButton.mjs +0 -30
- package/dist/es/components/VLMAnnotation/components/Toolbar.mjs +0 -40
- package/dist/es/components/VLMAnnotation/components/ZoomControls.mjs +0 -44
- package/dist/es/components/VLMAnnotation/constants.mjs +0 -57
- package/dist/es/components/VLMAnnotation/index.mjs +0 -279
- package/dist/es/components/VLMAnnotation/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.mjs +0 -343
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.mjs +0 -240
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.mjs +0 -201
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/index.mjs +0 -455
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/VlmModal/index.mjs +0 -149
- package/dist/es/components/VLMAnnotationDetail/VlmModal/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/index.mjs +0 -449
- package/dist/es/components/VLMAnnotationDetail/style.less.mjs +0 -4
- package/dist/es/createVlmtasetAnnotation/index.mjs +0 -131
- package/dist/src/components/DetectionAnnotation/components/ImageModal/index.d.ts +0 -34
- package/dist/src/components/Iconfont/font_4439177_tgvowh6bmlb.d.ts +0 -0
- package/dist/src/components/PicZipImportModal/config.d.ts +0 -23
- package/dist/src/components/VLMAnnotation/ImageAnnotationDebugger.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/RegionItem.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/TextAnnotationPanel.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.d.ts +0 -13
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.d.ts +0 -38
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.d.ts +0 -18
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.d.ts +0 -7
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.d.ts +0 -13
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.d.ts +0 -22
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +0 -34
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.d.ts +0 -16
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.d.ts +0 -11
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.d.ts +0 -29
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.d.ts +0 -31
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.d.ts +0 -13
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.d.ts +0 -41
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.d.ts +0 -12
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.d.ts +0 -16
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.d.ts +0 -32
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.d.ts +0 -25
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/index.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.d.ts +0 -32
- package/dist/src/components/VLMAnnotation/components/DragButton.d.ts +0 -7
- package/dist/src/components/VLMAnnotation/components/FitToScreenButton.d.ts +0 -6
- package/dist/src/components/VLMAnnotation/components/RectangleButton.d.ts +0 -7
- package/dist/src/components/VLMAnnotation/components/Toolbar.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/components/ZoomControls.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/constants.d.ts +0 -113
- package/dist/src/components/VLMAnnotation/index.d.ts +0 -6
- package/dist/src/components/VLMAnnotation/types.d.ts +0 -187
- package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.d.ts +0 -14
- package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.d.ts +0 -12
- package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.d.ts +0 -12
- package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/index.d.ts +0 -12
- package/dist/src/components/VLMAnnotationDetail/VlmModal/index.d.ts +0 -17
- package/dist/src/components/VLMAnnotationDetail/index.d.ts +0 -6
- package/dist/src/createVlmtasetAnnotation/index.d.ts +0 -16
|
@@ -1,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,421 +0,0 @@
|
|
|
1
|
-
import { useCallback as pe, useRef as Q, useEffect as V } from "react";
|
|
2
|
-
import { fabric as L } from "fabric";
|
|
3
|
-
import { CROSSHAIR_LINE_COLOR as ke, CROSSHAIR_LINE_DASH_ARRAY as xe, CROSSHAIR_LINE_WIDTH as Ee, TEMP_RECT_FILL_COLOR as Le, RECT_STROKE_COLOR as a, TEMP_RECT_STROKE_DASH_ARRAY as je, TRANSPARENT_FILL as Re, REGION_NAME_PREFIX as Ae, BASE_STROKE_WIDTH as v } from "../../constants.mjs";
|
|
4
|
-
const We = ({
|
|
5
|
-
canvas: e,
|
|
6
|
-
drawingMode: T,
|
|
7
|
-
draggable: ee,
|
|
8
|
-
setDrawingMode: te,
|
|
9
|
-
canvasToImageCoords: oe,
|
|
10
|
-
labelDefinitions: D,
|
|
11
|
-
onChange: y,
|
|
12
|
-
cropRegionImage: re,
|
|
13
|
-
updateRegionShapeAndImage: X,
|
|
14
|
-
performOCRIfNeeded: ie,
|
|
15
|
-
createDeleteControl: ne,
|
|
16
|
-
createOCRControl: le,
|
|
17
|
-
updateRegionNameText: se,
|
|
18
|
-
onRegionChange: N,
|
|
19
|
-
onRegionSelect: S,
|
|
20
|
-
rectMapRef: p,
|
|
21
|
-
textLayersMapRef: ce,
|
|
22
|
-
setupBoundaryCheck: de
|
|
23
|
-
}) => {
|
|
24
|
-
const G = pe(() => {
|
|
25
|
-
const k = /* @__PURE__ */ new Set();
|
|
26
|
-
return ce.current.forEach((x) => {
|
|
27
|
-
x.forEach((C) => {
|
|
28
|
-
k.add(C);
|
|
29
|
-
});
|
|
30
|
-
}), k;
|
|
31
|
-
}, [ce]), n = Q({
|
|
32
|
-
horizontal: null,
|
|
33
|
-
vertical: null
|
|
34
|
-
}), P = Q(null), ue = Q({
|
|
35
|
-
dleft: -1,
|
|
36
|
-
dtop: -1,
|
|
37
|
-
dw: 0,
|
|
38
|
-
dh: 0,
|
|
39
|
-
rect: null
|
|
40
|
-
}), F = pe(() => {
|
|
41
|
-
e && (e.skipTargetFind = !1);
|
|
42
|
-
}, [e]);
|
|
43
|
-
return V(() => {
|
|
44
|
-
if (!e || !T || ee) {
|
|
45
|
-
if (F(), e && !T) {
|
|
46
|
-
n.current.horizontal && e.getObjects().includes(n.current.horizontal) && e.remove(n.current.horizontal), n.current.vertical && e.getObjects().includes(n.current.vertical) && e.remove(n.current.vertical), n.current = {
|
|
47
|
-
horizontal: null,
|
|
48
|
-
vertical: null
|
|
49
|
-
};
|
|
50
|
-
const o = e.getActiveObject();
|
|
51
|
-
e.selection = !1, e.skipTargetFind = !1;
|
|
52
|
-
const r = G();
|
|
53
|
-
e.getObjects().forEach((i) => {
|
|
54
|
-
i instanceof L.Rect && r.has(i) ? i.set({
|
|
55
|
-
evented: !0,
|
|
56
|
-
selectable: !1,
|
|
57
|
-
lockMovementX: !0,
|
|
58
|
-
lockMovementY: !0,
|
|
59
|
-
lockScalingX: !0,
|
|
60
|
-
lockScalingY: !0,
|
|
61
|
-
lockRotation: !0
|
|
62
|
-
}) : (i.set("evented", !0), i.set("selectable", !0), i instanceof L.Rect && i.set("hasControls", !0));
|
|
63
|
-
}), o && e.getObjects().includes(o) && (e.setActiveObject(o), e.renderAll()), e.defaultCursor = "default";
|
|
64
|
-
}
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
F(), e.selection = !1, e.skipTargetFind = !0, e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), e.getObjects().forEach((o) => {
|
|
68
|
-
o.set("evented", !1), o.set("selectable", !1), o instanceof L.Rect && o.hasControls && o.set("hasControls", !1);
|
|
69
|
-
}), e.defaultCursor = "crosshair", e.setCursor("crosshair"), n.current.horizontal && e.getObjects().includes(n.current.horizontal) && e.remove(n.current.horizontal), n.current.vertical && e.getObjects().includes(n.current.vertical) && e.remove(n.current.vertical), n.current = {
|
|
70
|
-
horizontal: null,
|
|
71
|
-
vertical: null
|
|
72
|
-
};
|
|
73
|
-
const x = e.getWidth(), C = e.getHeight(), E = e.getZoom(), j = x / E, R = C / E, A = Math.max(j, R) * 3, Z = Ee / E, z = new L.Line([-A, 0, A, 0], {
|
|
74
|
-
stroke: ke,
|
|
75
|
-
strokeWidth: Z,
|
|
76
|
-
strokeDashArray: xe,
|
|
77
|
-
selectable: !1,
|
|
78
|
-
evented: !1,
|
|
79
|
-
excludeFromExport: !0,
|
|
80
|
-
// 导出时不包含此线
|
|
81
|
-
strokeUniform: !0,
|
|
82
|
-
// 设置为 true,使线宽随缩放调整以保持视觉一致
|
|
83
|
-
visible: !0
|
|
84
|
-
// 画框模式下常显辅助线
|
|
85
|
-
}), _ = new L.Line([0, -A, 0, A], {
|
|
86
|
-
stroke: ke,
|
|
87
|
-
strokeWidth: Z,
|
|
88
|
-
strokeDashArray: xe,
|
|
89
|
-
selectable: !1,
|
|
90
|
-
evented: !1,
|
|
91
|
-
excludeFromExport: !0,
|
|
92
|
-
// 导出时不包含此线
|
|
93
|
-
strokeUniform: !0,
|
|
94
|
-
// 设置为 true,使线宽随缩放调整以保持视觉一致
|
|
95
|
-
visible: !0
|
|
96
|
-
// 画框模式下常显辅助线
|
|
97
|
-
});
|
|
98
|
-
n.current = {
|
|
99
|
-
horizontal: z,
|
|
100
|
-
vertical: _
|
|
101
|
-
}, e.add(z), e.add(_), z.sendToBack(), _.sendToBack();
|
|
102
|
-
const M = (o, r) => {
|
|
103
|
-
const i = n.current.horizontal, c = n.current.vertical;
|
|
104
|
-
if (!i || !c)
|
|
105
|
-
return;
|
|
106
|
-
const h = e.getZoom(), g = e.getWidth(), s = e.getHeight(), O = g / h, w = s / h, b = Math.max(O, w) * 3;
|
|
107
|
-
i.set({
|
|
108
|
-
x1: o - b,
|
|
109
|
-
y1: r,
|
|
110
|
-
x2: o + b,
|
|
111
|
-
y2: r,
|
|
112
|
-
visible: !0
|
|
113
|
-
// 显示辅助线
|
|
114
|
-
}), c.set({
|
|
115
|
-
x1: o,
|
|
116
|
-
y1: r - b,
|
|
117
|
-
x2: o,
|
|
118
|
-
y2: r + b,
|
|
119
|
-
visible: !0
|
|
120
|
-
// 显示辅助线
|
|
121
|
-
}), i.sendToBack(), c.sendToBack();
|
|
122
|
-
const d = ue.current, f = d.rect && e.getObjects().includes(d.rect);
|
|
123
|
-
if (d.rect && !e.getObjects().includes(d.rect) && d.dleft !== -1 && d.dtop !== -1 && d.dw > 0 && d.dh > 0 && e.add(d.rect), f && d.rect) {
|
|
124
|
-
const m = Math.min(e.getObjects().indexOf(i), e.getObjects().indexOf(c));
|
|
125
|
-
e.getObjects().indexOf(d.rect) <= m && e.moveTo(d.rect, m + 1);
|
|
126
|
-
}
|
|
127
|
-
e.renderAll();
|
|
128
|
-
};
|
|
129
|
-
if (P.current) {
|
|
130
|
-
const r = e.getElement().getBoundingClientRect(), {
|
|
131
|
-
clientX: i,
|
|
132
|
-
clientY: c
|
|
133
|
-
} = P.current;
|
|
134
|
-
if (i >= r.left && i <= r.right && c >= r.top && c <= r.bottom) {
|
|
135
|
-
const g = new MouseEvent("mousemove", {
|
|
136
|
-
bubbles: !0,
|
|
137
|
-
cancelable: !0,
|
|
138
|
-
clientX: i,
|
|
139
|
-
clientY: c
|
|
140
|
-
}), s = e.getPointer(g);
|
|
141
|
-
M(s.x, s.y);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
const t = ue.current, H = (o) => {
|
|
145
|
-
if (e.skipTargetFind && (t.dleft === -1 || t.dtop === -1)) {
|
|
146
|
-
const r = e.getPointer(o.e);
|
|
147
|
-
t.dleft = r.x, t.dtop = r.y;
|
|
148
|
-
}
|
|
149
|
-
}, U = (o) => {
|
|
150
|
-
const r = e.getPointer(o.e);
|
|
151
|
-
M(r.x, r.y);
|
|
152
|
-
}, $ = (o) => {
|
|
153
|
-
const r = e.getPointer(o.e);
|
|
154
|
-
if (t.dleft !== -1 && t.dtop !== -1) {
|
|
155
|
-
let i = r.x, c = r.y;
|
|
156
|
-
if (t.dw = Math.abs(i - t.dleft), t.dh = Math.abs(c - t.dtop), t.dw > 0 && t.dh > 0) {
|
|
157
|
-
let h = t.dtop > c ? c : t.dtop, g = t.dleft > i ? i : t.dleft, s = t.dw, O = t.dh;
|
|
158
|
-
if (!t.rect || t.rect.left !== g || t.rect.top !== h || t.rect.width !== s || t.rect.height !== O || !e.getObjects().includes(t.rect)) {
|
|
159
|
-
t.rect && e.getObjects().includes(t.rect) && e.remove(t.rect);
|
|
160
|
-
const f = e.getZoom(), m = v / f;
|
|
161
|
-
t.rect = new L.Rect({
|
|
162
|
-
left: g,
|
|
163
|
-
top: h,
|
|
164
|
-
width: s,
|
|
165
|
-
height: O,
|
|
166
|
-
fill: Le,
|
|
167
|
-
stroke: a,
|
|
168
|
-
strokeWidth: m,
|
|
169
|
-
strokeUniform: !0,
|
|
170
|
-
// 边框宽度不受缩放影响
|
|
171
|
-
strokeDashArray: je,
|
|
172
|
-
selectable: !1,
|
|
173
|
-
evented: !1,
|
|
174
|
-
objectCaching: !1,
|
|
175
|
-
// 禁用缓存,避免缩放时边框变虚
|
|
176
|
-
statefullCache: !1,
|
|
177
|
-
noScaleCache: !1
|
|
178
|
-
}), e.add(t.rect);
|
|
179
|
-
}
|
|
180
|
-
const b = n.current.horizontal, d = n.current.vertical;
|
|
181
|
-
if (t.rect && b && d && e.getObjects().includes(b) && e.getObjects().includes(d) && e.getObjects().includes(t.rect)) {
|
|
182
|
-
const f = Math.min(e.getObjects().indexOf(b), e.getObjects().indexOf(d));
|
|
183
|
-
e.getObjects().indexOf(t.rect) <= f && e.moveTo(t.rect, f + 1);
|
|
184
|
-
}
|
|
185
|
-
} else
|
|
186
|
-
t.rect && e.getObjects().includes(t.rect) && (e.remove(t.rect), t.rect = null);
|
|
187
|
-
}
|
|
188
|
-
U(o);
|
|
189
|
-
}, K = (o) => {
|
|
190
|
-
if (t.dleft === -1 || t.dtop === -1) {
|
|
191
|
-
t.dtop = -1, t.dleft = -1;
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
const r = e.getPointer(o.e);
|
|
195
|
-
let i = r.x, c = r.y;
|
|
196
|
-
if (t.dw = Math.abs(i - t.dleft), t.dh = Math.abs(c - t.dtop), t.dw === 0 || t.dh === 0) {
|
|
197
|
-
t.rect && (e.remove(t.rect), e.renderAll()), t.dtop = -1, t.dleft = -1;
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
let h = t.dtop > c ? c : t.dtop, g = t.dleft > i ? i : t.dleft, s = t.dw, O = t.dh;
|
|
201
|
-
t.rect && (e.remove(t.rect), t.rect = null);
|
|
202
|
-
const w = oe(g, h), b = s, d = O, f = e.getZoom(), m = v / f, l = new L.Rect({
|
|
203
|
-
left: g,
|
|
204
|
-
top: h,
|
|
205
|
-
width: s,
|
|
206
|
-
height: O,
|
|
207
|
-
fill: Re,
|
|
208
|
-
// 无填充色
|
|
209
|
-
stroke: a,
|
|
210
|
-
strokeWidth: m,
|
|
211
|
-
strokeUniform: !0,
|
|
212
|
-
// 边框宽度不受缩放影响
|
|
213
|
-
selectable: !0,
|
|
214
|
-
evented: !0,
|
|
215
|
-
hasRotatingPoint: !1,
|
|
216
|
-
// 隐藏旋转点
|
|
217
|
-
lockRotation: !0,
|
|
218
|
-
// 锁定旋转
|
|
219
|
-
lockUniScaling: !1,
|
|
220
|
-
// 允许非等比缩放,控制点跟随鼠标
|
|
221
|
-
lockScalingFlip: !0,
|
|
222
|
-
// 禁止缩放时翻转
|
|
223
|
-
objectCaching: !1,
|
|
224
|
-
// 禁用缓存,避免缩放时边框变虚
|
|
225
|
-
statefullCache: !1,
|
|
226
|
-
noScaleCache: !1,
|
|
227
|
-
hasControls: !0
|
|
228
|
-
// 启用控件
|
|
229
|
-
});
|
|
230
|
-
e.add(l), l.controls.deleteControl = ne(), l.controls.ocrControl = le(), l.set("hasControls", !1);
|
|
231
|
-
const q = p.current.size, B = {};
|
|
232
|
-
D == null || D.forEach((u) => {
|
|
233
|
-
B[u.id] = "";
|
|
234
|
-
});
|
|
235
|
-
const Y = {
|
|
236
|
-
id: `region-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
237
|
-
name: `${Ae}${q + 1}`,
|
|
238
|
-
// 设置名称:区域+(索引+1)
|
|
239
|
-
shape: {
|
|
240
|
-
name: "rect",
|
|
241
|
-
x: Math.max(0, w.x),
|
|
242
|
-
y: Math.max(0, w.y),
|
|
243
|
-
width: b,
|
|
244
|
-
height: d
|
|
245
|
-
},
|
|
246
|
-
content: B
|
|
247
|
-
};
|
|
248
|
-
if (p.current.set(l, Y), se(l, Y), X(l), N) {
|
|
249
|
-
const u = p.current.get(l);
|
|
250
|
-
u && N(u, "create");
|
|
251
|
-
}
|
|
252
|
-
re(Y).then((u) => {
|
|
253
|
-
if (u) {
|
|
254
|
-
const W = p.current.get(l);
|
|
255
|
-
if (W) {
|
|
256
|
-
if (W.image = u, delete W.textLayouts, y) {
|
|
257
|
-
const I = Array.from(p.current.values());
|
|
258
|
-
y(I);
|
|
259
|
-
}
|
|
260
|
-
ie(W, "create");
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}).catch((u) => {
|
|
264
|
-
console.error("Failed to crop region image:", u);
|
|
265
|
-
}), e.setActiveObject(l), e.renderAll(), setTimeout(() => {
|
|
266
|
-
if (S) {
|
|
267
|
-
const u = p.current.get(l);
|
|
268
|
-
u && S(u);
|
|
269
|
-
}
|
|
270
|
-
setTimeout(() => {
|
|
271
|
-
if (e && l && e.getObjects().includes(l) && (e.setActiveObject(l), e.renderAll(), S)) {
|
|
272
|
-
const u = p.current.get(l);
|
|
273
|
-
u && S(u);
|
|
274
|
-
}
|
|
275
|
-
}, 0);
|
|
276
|
-
}, 0), de(l), l.on("modified", () => {
|
|
277
|
-
X(l);
|
|
278
|
-
}), l.on("moved", () => {
|
|
279
|
-
X(l);
|
|
280
|
-
}), setTimeout(() => {
|
|
281
|
-
if (y) {
|
|
282
|
-
const u = Array.from(p.current.values());
|
|
283
|
-
y(u);
|
|
284
|
-
}
|
|
285
|
-
}, 0), t.dtop = -1, t.dleft = -1, e.selection = !1, te(!1);
|
|
286
|
-
}, fe = (o) => {
|
|
287
|
-
P.current = {
|
|
288
|
-
clientX: o.clientX,
|
|
289
|
-
clientY: o.clientY
|
|
290
|
-
};
|
|
291
|
-
const i = e.getElement().getBoundingClientRect(), c = o.clientX, h = o.clientY, g = c >= i.left && c <= i.right && h >= i.top && h <= i.bottom;
|
|
292
|
-
if (t.dleft !== -1 && t.dtop !== -1)
|
|
293
|
-
if (g) {
|
|
294
|
-
const s = e.getPointer(o);
|
|
295
|
-
$({
|
|
296
|
-
e: o,
|
|
297
|
-
pointer: s
|
|
298
|
-
});
|
|
299
|
-
} else {
|
|
300
|
-
const s = e.getZoom(), O = e.viewportTransform ? e.viewportTransform[4] / s : 0, w = e.viewportTransform ? e.viewportTransform[5] / s : 0, b = e.getWidth() / s, d = e.getHeight() / s;
|
|
301
|
-
let f = (c - i.left) / s - O, m = (h - i.top) / s - w;
|
|
302
|
-
if (f = Math.max(0, Math.min(f, b)), m = Math.max(0, Math.min(m, d)), t.dw = Math.abs(f - t.dleft), t.dh = Math.abs(m - t.dtop), t.dw === 0 || t.dh === 0)
|
|
303
|
-
return;
|
|
304
|
-
let l = t.dtop > m ? m : t.dtop, q = t.dleft > f ? f : t.dleft, B = t.dw, Y = t.dh;
|
|
305
|
-
t.rect && e.remove(t.rect);
|
|
306
|
-
const u = e.getZoom(), W = v / u;
|
|
307
|
-
t.rect = new L.Rect({
|
|
308
|
-
left: q,
|
|
309
|
-
top: l,
|
|
310
|
-
width: B,
|
|
311
|
-
height: Y,
|
|
312
|
-
fill: Le,
|
|
313
|
-
stroke: a,
|
|
314
|
-
strokeWidth: W,
|
|
315
|
-
strokeUniform: !0,
|
|
316
|
-
strokeDashArray: je,
|
|
317
|
-
selectable: !1,
|
|
318
|
-
evented: !1,
|
|
319
|
-
objectCaching: !1,
|
|
320
|
-
statefullCache: !1,
|
|
321
|
-
noScaleCache: !1
|
|
322
|
-
}), e.add(t.rect);
|
|
323
|
-
const I = n.current.horizontal, J = n.current.vertical;
|
|
324
|
-
if (I && J && e.getObjects().includes(I) && e.getObjects().includes(J)) {
|
|
325
|
-
const Oe = Math.min(e.getObjects().indexOf(I), e.getObjects().indexOf(J));
|
|
326
|
-
e.getObjects().indexOf(t.rect) < Oe && e.moveTo(t.rect, Oe + 1);
|
|
327
|
-
}
|
|
328
|
-
e.renderAll();
|
|
329
|
-
}
|
|
330
|
-
if (g && (t.dleft === -1 || t.dtop === -1)) {
|
|
331
|
-
const s = e.getPointer(o);
|
|
332
|
-
M(s.x, s.y);
|
|
333
|
-
}
|
|
334
|
-
}, he = () => {
|
|
335
|
-
}, me = (o) => {
|
|
336
|
-
const r = e.getPointer(o.e);
|
|
337
|
-
M(r.x, r.y);
|
|
338
|
-
}, ge = (o) => {
|
|
339
|
-
if (!T)
|
|
340
|
-
return;
|
|
341
|
-
e.skipTargetFind = !0, e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), t.dtop = -1, t.dleft = -1, t.dw = 0, t.dh = 0;
|
|
342
|
-
const i = e.getPointer(o.e);
|
|
343
|
-
t.dleft = i.x, t.dtop = i.y;
|
|
344
|
-
};
|
|
345
|
-
e.on("mouse:down:before", ge), e.on("mouse:down", H), e.on("mouse:move", $), e.on("mouse:up", K), e.on("mouse:out", he), e.on("mouse:over", me), document.addEventListener("mousemove", fe);
|
|
346
|
-
const be = (o) => {
|
|
347
|
-
if (t.dleft === -1 || t.dtop === -1)
|
|
348
|
-
return;
|
|
349
|
-
const r = e.getPointer(o);
|
|
350
|
-
K({
|
|
351
|
-
e: o,
|
|
352
|
-
pointer: r
|
|
353
|
-
});
|
|
354
|
-
};
|
|
355
|
-
return document.addEventListener("mouseup", be), () => {
|
|
356
|
-
e.off("mouse:down:before", ge), e.off("mouse:down", H), e.off("mouse:move", $), e.off("mouse:up", K), e.off("mouse:out", he), e.off("mouse:over", me), document.removeEventListener("mousemove", fe), document.removeEventListener("mouseup", be), t.rect && (e.remove(t.rect), e.renderAll()), n.current.horizontal && e.getObjects().includes(n.current.horizontal) && e.remove(n.current.horizontal), n.current.vertical && e.getObjects().includes(n.current.vertical) && e.remove(n.current.vertical), n.current = {
|
|
357
|
-
horizontal: null,
|
|
358
|
-
vertical: null
|
|
359
|
-
}, e.skipTargetFind = !1, e.defaultCursor = "default";
|
|
360
|
-
const o = G();
|
|
361
|
-
e.getObjects().forEach((r) => {
|
|
362
|
-
r instanceof L.Rect && o.has(r) ? r.set({
|
|
363
|
-
evented: !0,
|
|
364
|
-
selectable: !1,
|
|
365
|
-
lockMovementX: !0,
|
|
366
|
-
lockMovementY: !0,
|
|
367
|
-
lockScalingX: !0,
|
|
368
|
-
lockScalingY: !0,
|
|
369
|
-
lockRotation: !0
|
|
370
|
-
}) : (r.set("evented", !0), r.set("selectable", !0));
|
|
371
|
-
});
|
|
372
|
-
};
|
|
373
|
-
}, [e, T, ee, F, oe, y, re, X, ie, ne, le, se, N, S, te, p, G, de]), V(() => {
|
|
374
|
-
if (!e)
|
|
375
|
-
return;
|
|
376
|
-
const k = (x) => {
|
|
377
|
-
P.current = {
|
|
378
|
-
clientX: x.clientX,
|
|
379
|
-
clientY: x.clientY
|
|
380
|
-
};
|
|
381
|
-
};
|
|
382
|
-
return document.addEventListener("mousemove", k), () => {
|
|
383
|
-
document.removeEventListener("mousemove", k);
|
|
384
|
-
};
|
|
385
|
-
}, [e]), V(() => {
|
|
386
|
-
if (!e || !T)
|
|
387
|
-
return;
|
|
388
|
-
let k = e.getZoom();
|
|
389
|
-
const x = () => {
|
|
390
|
-
const E = n.current.horizontal, j = n.current.vertical;
|
|
391
|
-
if (!E || !j)
|
|
392
|
-
return;
|
|
393
|
-
const R = e.getZoom();
|
|
394
|
-
if (Math.abs(R - k) < 1e-3)
|
|
395
|
-
return;
|
|
396
|
-
k = R;
|
|
397
|
-
const A = Ee / R, Z = e.getWidth(), z = e.getHeight(), _ = Z / R, M = z / R, t = Math.max(_, M) * 3, H = (E.x1 + E.x2) / 2;
|
|
398
|
-
E.y1, j.x1;
|
|
399
|
-
const U = (j.y1 + j.y2) / 2;
|
|
400
|
-
E.set({
|
|
401
|
-
strokeWidth: A,
|
|
402
|
-
x1: H - t,
|
|
403
|
-
x2: H + t
|
|
404
|
-
}), j.set({
|
|
405
|
-
strokeWidth: A,
|
|
406
|
-
y1: U - t,
|
|
407
|
-
y2: U + t
|
|
408
|
-
}), e.renderAll();
|
|
409
|
-
}, C = () => {
|
|
410
|
-
x();
|
|
411
|
-
};
|
|
412
|
-
return e.on("after:render", C), x(), () => {
|
|
413
|
-
e.off("after:render", C);
|
|
414
|
-
};
|
|
415
|
-
}, [e, T]), {
|
|
416
|
-
stopDraw: F
|
|
417
|
-
};
|
|
418
|
-
};
|
|
419
|
-
export {
|
|
420
|
-
We as useDrawingMode
|
|
421
|
-
};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { useRef as a, useEffect as X, useCallback as H } from "react";
|
|
2
|
-
import { fabric as Y } from "fabric";
|
|
3
|
-
import { AI_CONTROL_OFFSET_X as P, AI_CONTROL_OFFSET_Y as U, AI_ICON_SIZE as y } from "../../constants.mjs";
|
|
4
|
-
import W from "../icons/ai.svg.mjs";
|
|
5
|
-
import Z from "../icons/star.svg.mjs";
|
|
6
|
-
import B from "../icons/error.svg.mjs";
|
|
7
|
-
import G from "../icons/loading.svg.mjs";
|
|
8
|
-
const nr = ({
|
|
9
|
-
performOCR: O,
|
|
10
|
-
ocrRecognizingRef: s,
|
|
11
|
-
ocrErrorRef: S,
|
|
12
|
-
rectMapRef: w
|
|
13
|
-
}) => {
|
|
14
|
-
const f = (r) => !(!r.complete || r.naturalWidth === 0), g = a(null), A = a(null), v = a(null), h = a(null), d = a(/* @__PURE__ */ new Set()), t = a(null), C = a(null);
|
|
15
|
-
return X(() => {
|
|
16
|
-
if (!g.current) {
|
|
17
|
-
const r = document.createElement("img");
|
|
18
|
-
r.src = W, g.current = r;
|
|
19
|
-
}
|
|
20
|
-
if (!A.current) {
|
|
21
|
-
const r = document.createElement("img");
|
|
22
|
-
r.src = Z, A.current = r;
|
|
23
|
-
}
|
|
24
|
-
if (!v.current) {
|
|
25
|
-
const r = document.createElement("img");
|
|
26
|
-
r.src = B, v.current = r;
|
|
27
|
-
}
|
|
28
|
-
if (!h.current) {
|
|
29
|
-
const r = document.createElement("img");
|
|
30
|
-
r.src = G, h.current = r;
|
|
31
|
-
}
|
|
32
|
-
}, []), X(() => {
|
|
33
|
-
const r = () => {
|
|
34
|
-
s.current.size > 0 ? (d.current.forEach((o) => {
|
|
35
|
-
o.renderAll();
|
|
36
|
-
}), t.current = requestAnimationFrame(r)) : t.current = null;
|
|
37
|
-
};
|
|
38
|
-
C.current = r, s.current.size > 0 && (t.current = requestAnimationFrame(r));
|
|
39
|
-
const m = setInterval(() => {
|
|
40
|
-
const c = s.current.size > 0, o = t.current !== null;
|
|
41
|
-
c && !o && (t.current = requestAnimationFrame(r));
|
|
42
|
-
}, 100);
|
|
43
|
-
return () => {
|
|
44
|
-
t.current !== null && cancelAnimationFrame(t.current), clearInterval(m);
|
|
45
|
-
};
|
|
46
|
-
}, [s]), {
|
|
47
|
-
createOCRControl: H(() => {
|
|
48
|
-
const r = y, l = g.current, m = A.current, c = v.current, o = h.current, n = 14, N = (e, p, F, M, I) => {
|
|
49
|
-
if (!l)
|
|
50
|
-
return;
|
|
51
|
-
const D = I, _ = w.current.get(D);
|
|
52
|
-
if (!_)
|
|
53
|
-
return;
|
|
54
|
-
const z = _.id, T = s.current.has(z), k = S.current.has(z), q = () => {
|
|
55
|
-
e.save(), e.translate(p, F), e.rotate(Y.util.degreesToRadians(I.angle || 0)), e.drawImage(l, -r / 2, -r / 2, r, r);
|
|
56
|
-
const u = r / 2 - n / 2 + 8, E = -r / 2 + n / 2 - 8;
|
|
57
|
-
if (T) {
|
|
58
|
-
if (o && f(o)) {
|
|
59
|
-
e.save(), e.translate(u, E);
|
|
60
|
-
const L = Date.now() / 500 % (Math.PI * 2);
|
|
61
|
-
e.rotate(L), e.drawImage(o, -n / 2, -n / 2, n, n), e.restore();
|
|
62
|
-
}
|
|
63
|
-
const i = I.canvas;
|
|
64
|
-
i && (d.current.has(i), d.current.add(i), s.current.size > 0 && !t.current && C.current && (t.current = requestAnimationFrame(C.current)));
|
|
65
|
-
} else {
|
|
66
|
-
const i = I.canvas;
|
|
67
|
-
i && s.current.size === 0 && d.current.delete(i), k && c && f(c) ? e.drawImage(c, u - n / 2, E - n / 2, n, n) : !T && !k && m && f(m) && e.drawImage(m, u - n / 2, E - n / 2, n, n);
|
|
68
|
-
}
|
|
69
|
-
e.restore();
|
|
70
|
-
};
|
|
71
|
-
f(l) ? q() : l.onload = () => {
|
|
72
|
-
q();
|
|
73
|
-
const u = I.canvas;
|
|
74
|
-
u && u.renderAll();
|
|
75
|
-
};
|
|
76
|
-
}, R = (e, p) => {
|
|
77
|
-
const F = p.target;
|
|
78
|
-
return O(F), !1;
|
|
79
|
-
};
|
|
80
|
-
return new Y.Control({
|
|
81
|
-
x: 0.5,
|
|
82
|
-
// 右侧(0 = 左边,0.5 = 中间,1 = 右边)
|
|
83
|
-
y: -0.5,
|
|
84
|
-
// 顶部(0 = 顶部,0.5 = 中间,1 = 底部)
|
|
85
|
-
offsetX: P,
|
|
86
|
-
// 与删除按钮相同的X偏移
|
|
87
|
-
offsetY: U + y + 4,
|
|
88
|
-
// 向下偏移,放在删除按钮下方(删除按钮的offsetY + 删除按钮大小 + 间距)
|
|
89
|
-
cursorStyle: "pointer",
|
|
90
|
-
mouseUpHandler: R,
|
|
91
|
-
render: N,
|
|
92
|
-
sizeX: r,
|
|
93
|
-
sizeY: r
|
|
94
|
-
});
|
|
95
|
-
}, [O, s, S, w])
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
export {
|
|
99
|
-
nr as useOCRControl
|
|
100
|
-
};
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { useRef as h, useCallback as W, useEffect as X } from "react";
|
|
2
|
-
import { fabric as l } from "fabric";
|
|
3
|
-
import { OCR_SCAN_LINE_GLOW_MULTIPLIER as Y, OCR_SCAN_LINE_GLOW_COLOR as k, OCR_SCAN_LINE_BRIGHT_COLOR as G, OCR_SCAN_LINE_CORE_POSITION_MULTIPLIER as P, OCR_SCAN_LINE_CORE_HEIGHT_MULTIPLIER as Z, OCR_SCAN_LINE_CORE_COLOR as j, OCR_SCAN_LINE_BASE_HEIGHT as B, OCR_SCAN_ANIMATION_SPEED as F } from "../../constants.mjs";
|
|
4
|
-
const v = (t) => {
|
|
5
|
-
const o = h(/* @__PURE__ */ new Map()), c = h(null), L = W((e, U, C) => {
|
|
6
|
-
if (!t)
|
|
7
|
-
return;
|
|
8
|
-
const _ = o.current.get(e);
|
|
9
|
-
if (_ && (t.remove(_), o.current.delete(e)), !C)
|
|
10
|
-
return;
|
|
11
|
-
const s = t.getZoom(), O = e.left || 0, p = e.top || 0, I = e.getScaledWidth();
|
|
12
|
-
e.getScaledHeight();
|
|
13
|
-
const i = B, a = I * s, m = new l.Rect({
|
|
14
|
-
left: 0,
|
|
15
|
-
top: 0,
|
|
16
|
-
width: a,
|
|
17
|
-
height: i * Y,
|
|
18
|
-
// 光晕层更宽
|
|
19
|
-
fill: k,
|
|
20
|
-
// 紫色光晕
|
|
21
|
-
selectable: !1,
|
|
22
|
-
evented: !1,
|
|
23
|
-
originX: "left",
|
|
24
|
-
originY: "top"
|
|
25
|
-
}), E = new l.Rect({
|
|
26
|
-
left: 0,
|
|
27
|
-
top: i,
|
|
28
|
-
width: a,
|
|
29
|
-
height: i,
|
|
30
|
-
fill: G,
|
|
31
|
-
// 紫色较亮层
|
|
32
|
-
selectable: !1,
|
|
33
|
-
evented: !1,
|
|
34
|
-
originX: "left",
|
|
35
|
-
originY: "top"
|
|
36
|
-
}), S = new l.Rect({
|
|
37
|
-
left: 0,
|
|
38
|
-
top: i * P,
|
|
39
|
-
width: a,
|
|
40
|
-
height: i * Z,
|
|
41
|
-
fill: j,
|
|
42
|
-
// 紫色核心线条
|
|
43
|
-
selectable: !1,
|
|
44
|
-
evented: !1,
|
|
45
|
-
originX: "left",
|
|
46
|
-
originY: "top"
|
|
47
|
-
}), r = new l.Group([m, E, S], {
|
|
48
|
-
left: O,
|
|
49
|
-
top: p,
|
|
50
|
-
// 初始位置在顶部
|
|
51
|
-
originX: "left",
|
|
52
|
-
originY: "top",
|
|
53
|
-
selectable: !1,
|
|
54
|
-
evented: !1,
|
|
55
|
-
lockMovementX: !0,
|
|
56
|
-
lockMovementY: !0,
|
|
57
|
-
lockScalingX: !1,
|
|
58
|
-
lockScalingY: !1,
|
|
59
|
-
lockRotation: !0,
|
|
60
|
-
hasControls: !1,
|
|
61
|
-
hasBorders: !1,
|
|
62
|
-
objectCaching: !1,
|
|
63
|
-
statefullCache: !1,
|
|
64
|
-
noScaleCache: !1,
|
|
65
|
-
scaleX: 1 / s,
|
|
66
|
-
// 反向缩放,抵消画布缩放,保持固定视觉粗细
|
|
67
|
-
scaleY: 1 / s
|
|
68
|
-
// 反向缩放,抵消画布缩放,保持固定视觉粗细
|
|
69
|
-
});
|
|
70
|
-
t.add(r), o.current.set(e, r);
|
|
71
|
-
let n = 0, f = 1;
|
|
72
|
-
const N = F, d = () => {
|
|
73
|
-
if (!o.current.has(e) || !t)
|
|
74
|
-
return;
|
|
75
|
-
const A = e.left || 0, b = e.top || 0, H = e.getScaledWidth(), T = e.getScaledHeight(), g = t.getZoom();
|
|
76
|
-
n += N * f, n >= 1 ? (n = 1, f = -1) : n <= 0 && (n = 0, f = 1);
|
|
77
|
-
const w = b + n * T;
|
|
78
|
-
r.set({
|
|
79
|
-
left: A,
|
|
80
|
-
top: w,
|
|
81
|
-
scaleX: 1 / g,
|
|
82
|
-
// 反向缩放,抵消画布缩放,保持固定视觉粗细
|
|
83
|
-
scaleY: 1 / g
|
|
84
|
-
// 反向缩放,抵消画布缩放,保持固定视觉粗细
|
|
85
|
-
});
|
|
86
|
-
const u = r.getObjects();
|
|
87
|
-
if (u && u.length > 0) {
|
|
88
|
-
const M = H * g;
|
|
89
|
-
u.forEach((R) => {
|
|
90
|
-
R instanceof l.Rect && R.set("width", M);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
t.renderAll(), c.current = requestAnimationFrame(d);
|
|
94
|
-
};
|
|
95
|
-
d();
|
|
96
|
-
}, [t]);
|
|
97
|
-
return X(() => () => {
|
|
98
|
-
c.current !== null && (cancelAnimationFrame(c.current), c.current = null);
|
|
99
|
-
}, []), {
|
|
100
|
-
updateOCRLoadingIcon: L,
|
|
101
|
-
ocrLoadingIconMapRef: o
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
export {
|
|
105
|
-
v as useOCRLoadingIcon
|
|
106
|
-
};
|