react-screenshots 0.5.18 → 0.5.19
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/LICENSE +21 -21
- package/README.md +145 -145
- package/electron/assets/{index.78c5dcbf.css → electron-ed141e06.css} +1 -1
- package/electron/assets/index-73f470f6.js +53 -0
- package/electron/electron.html +14 -14
- package/lib/react-screenshots.cjs.js +4 -4
- package/lib/react-screenshots.es.js +1460 -2910
- package/lib/style.css +1 -1
- package/lib/types/ScreenshotsBackground/getBoundsByPoints.d.ts +2 -2
- package/lib/types/ScreenshotsBackground/index.d.ts +4 -4
- package/lib/types/ScreenshotsButton/index.d.ts +12 -12
- package/lib/types/ScreenshotsCanvas/getBoundsByPoints.d.ts +2 -2
- package/lib/types/ScreenshotsCanvas/getPoints.d.ts +2 -2
- package/lib/types/ScreenshotsCanvas/index.d.ts +15 -15
- package/lib/types/ScreenshotsCanvas/isPointInDraw.d.ts +2 -2
- package/lib/types/ScreenshotsColor/index.d.ts +8 -8
- package/lib/types/ScreenshotsContext.d.ts +29 -29
- package/lib/types/ScreenshotsMagnifier/index.d.ts +8 -8
- package/lib/types/ScreenshotsOperations/index.d.ts +6 -6
- package/lib/types/ScreenshotsOption/index.d.ts +15 -15
- package/lib/types/ScreenshotsSize/index.d.ts +8 -8
- package/lib/types/ScreenshotsSizeColor/index.d.ts +10 -10
- package/lib/types/ScreenshotsTextarea/calculateNodeSize.d.ts +17 -17
- package/lib/types/ScreenshotsTextarea/index.d.ts +15 -15
- package/lib/types/composeImage.d.ts +10 -10
- package/lib/types/exports.d.ts +3 -3
- package/lib/types/hooks/useBounds.d.ts +7 -7
- package/lib/types/hooks/useCall.d.ts +2 -2
- package/lib/types/hooks/useCanvasContextRef.d.ts +2 -2
- package/lib/types/hooks/useCanvasMousedown.d.ts +1 -1
- package/lib/types/hooks/useCanvasMousemove.d.ts +1 -1
- package/lib/types/hooks/useCanvasMouseup.d.ts +1 -1
- package/lib/types/hooks/useCursor.d.ts +6 -6
- package/lib/types/hooks/useDispatcher.d.ts +2 -2
- package/lib/types/hooks/useDrawSelect.d.ts +2 -2
- package/lib/types/hooks/useEmiter.d.ts +8 -8
- package/lib/types/hooks/useHistory.d.ts +16 -16
- package/lib/types/hooks/useLang.d.ts +2 -2
- package/lib/types/hooks/useOperation.d.ts +9 -6
- package/lib/types/hooks/useReset.d.ts +2 -2
- package/lib/types/hooks/useStore.d.ts +2 -2
- package/lib/types/index.d.ts +13 -13
- package/lib/types/operations/Arrow/draw.d.ts +11 -11
- package/lib/types/operations/Arrow/index.d.ts +22 -22
- package/lib/types/operations/Brush/draw.d.ts +3 -3
- package/lib/types/operations/Brush/index.d.ts +14 -14
- package/lib/types/operations/Cancel/index.d.ts +2 -2
- package/lib/types/operations/Ellipse/draw.d.ts +11 -11
- package/lib/types/operations/Ellipse/index.d.ts +28 -28
- package/lib/types/operations/Mosaic/index.d.ts +11 -11
- package/lib/types/operations/Ok/index.d.ts +2 -2
- package/lib/types/operations/Rectangle/draw.d.ts +11 -11
- package/lib/types/operations/Rectangle/index.d.ts +28 -28
- package/lib/types/operations/Redo/index.d.ts +2 -2
- package/lib/types/operations/Save/index.d.ts +2 -2
- package/lib/types/operations/Text/index.d.ts +22 -22
- package/lib/types/operations/Undo/index.d.ts +2 -2
- package/lib/types/operations/index.d.ts +3 -3
- package/lib/types/operations/utils.d.ts +4 -4
- package/lib/types/types.d.ts +39 -39
- package/lib/types/useGetLoadedImage.d.ts +1 -1
- package/lib/types/zh_CN.d.ts +16 -16
- package/package.json +22 -21
- package/electron/assets/index.0d61ff16.js +0 -222
|
@@ -1,74 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createPortal } from "react-dom";
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
const rx = image.naturalWidth / width;
|
|
20
|
-
const ry = image.naturalHeight / height;
|
|
21
|
-
ctx.imageSmoothingEnabled = true;
|
|
22
|
-
ctx.imageSmoothingQuality = "low";
|
|
23
|
-
ctx.setTransform(window.devicePixelRatio, 0, 0, window.devicePixelRatio, 0, 0);
|
|
24
|
-
ctx.clearRect(0, 0, bounds.width, bounds.height);
|
|
25
|
-
ctx.drawImage(
|
|
26
|
-
image,
|
|
27
|
-
bounds.x * rx,
|
|
28
|
-
bounds.y * ry,
|
|
29
|
-
bounds.width * rx,
|
|
30
|
-
bounds.height * ry,
|
|
1
|
+
import y, { useContext as pe, useCallback as g, memo as F, useState as $, useRef as E, useLayoutEffect as Q, useEffect as T, forwardRef as Me, useImperativeHandle as Be, cloneElement as $e } from "react";
|
|
2
|
+
import { createPortal as we } from "react-dom";
|
|
3
|
+
var _ = /* @__PURE__ */ ((e) => (e[e.Edit = 0] = "Edit", e[e.Source = 1] = "Source", e))(_ || {});
|
|
4
|
+
function fe({ image: e, width: t, height: s, history: i, bounds: r }) {
|
|
5
|
+
return new Promise((o, n) => {
|
|
6
|
+
const c = document.createElement("canvas"), f = r.width * window.devicePixelRatio, h = r.height * window.devicePixelRatio;
|
|
7
|
+
c.width = f, c.height = h;
|
|
8
|
+
const a = c.getContext("2d");
|
|
9
|
+
if (!a)
|
|
10
|
+
return n(new Error("convert image to blob fail"));
|
|
11
|
+
const l = e.naturalWidth / t, u = e.naturalHeight / s;
|
|
12
|
+
a.imageSmoothingEnabled = !0, a.imageSmoothingQuality = "low", a.setTransform(window.devicePixelRatio, 0, 0, window.devicePixelRatio, 0, 0), a.clearRect(0, 0, r.width, r.height), a.drawImage(
|
|
13
|
+
e,
|
|
14
|
+
r.x * l,
|
|
15
|
+
r.y * u,
|
|
16
|
+
r.width * l,
|
|
17
|
+
r.height * u,
|
|
31
18
|
0,
|
|
32
19
|
0,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
$canvas.toBlob((blob) => {
|
|
42
|
-
if (!blob) {
|
|
43
|
-
return reject(new Error("canvas toBlob fail"));
|
|
44
|
-
}
|
|
45
|
-
resolve(blob);
|
|
20
|
+
r.width,
|
|
21
|
+
r.height
|
|
22
|
+
), i.stack.slice(0, i.index + 1).forEach((d) => {
|
|
23
|
+
d.type === _.Source && d.draw(a, d);
|
|
24
|
+
}), c.toBlob((d) => {
|
|
25
|
+
if (!d)
|
|
26
|
+
return n(new Error("canvas toBlob fail"));
|
|
27
|
+
o(d);
|
|
46
28
|
}, "image/png");
|
|
47
29
|
});
|
|
48
30
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
operation_rectangle_title: "\u77E9\u5F62"
|
|
64
|
-
};
|
|
65
|
-
var ScreenshotsContext = React.createContext({
|
|
31
|
+
const Re = {
|
|
32
|
+
magnifier_position_label: "坐标",
|
|
33
|
+
operation_ok_title: "确定",
|
|
34
|
+
operation_cancel_title: "取消",
|
|
35
|
+
operation_save_title: "保存",
|
|
36
|
+
operation_redo_title: "重做",
|
|
37
|
+
operation_undo_title: "撤销",
|
|
38
|
+
operation_mosaic_title: "马赛克",
|
|
39
|
+
operation_text_title: "文本",
|
|
40
|
+
operation_brush_title: "画笔",
|
|
41
|
+
operation_arrow_title: "箭头",
|
|
42
|
+
operation_ellipse_title: "椭圆",
|
|
43
|
+
operation_rectangle_title: "矩形"
|
|
44
|
+
}, ye = y.createContext({
|
|
66
45
|
store: {
|
|
67
46
|
url: void 0,
|
|
68
47
|
image: null,
|
|
69
48
|
width: 0,
|
|
70
49
|
height: 0,
|
|
71
|
-
lang:
|
|
50
|
+
lang: Re,
|
|
72
51
|
emiterRef: { current: {} },
|
|
73
52
|
canvasContextRef: { current: null },
|
|
74
53
|
history: {
|
|
@@ -87,1481 +66,829 @@ var ScreenshotsContext = React.createContext({
|
|
|
87
66
|
setOperation: void 0
|
|
88
67
|
}
|
|
89
68
|
});
|
|
90
|
-
function
|
|
91
|
-
const { dispatcher } =
|
|
92
|
-
return
|
|
69
|
+
function se() {
|
|
70
|
+
const { dispatcher: e } = pe(ye);
|
|
71
|
+
return e;
|
|
93
72
|
}
|
|
94
|
-
function
|
|
95
|
-
const { store } =
|
|
96
|
-
return
|
|
73
|
+
function Y() {
|
|
74
|
+
const { store: e } = pe(ye);
|
|
75
|
+
return e;
|
|
97
76
|
}
|
|
98
|
-
function
|
|
99
|
-
const { bounds } =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
(bounds2) => {
|
|
103
|
-
setBounds == null ? void 0 : setBounds(bounds2);
|
|
77
|
+
function K() {
|
|
78
|
+
const { bounds: e } = Y(), { setBounds: t } = se(), s = g(
|
|
79
|
+
(r) => {
|
|
80
|
+
t == null || t(r);
|
|
104
81
|
},
|
|
105
|
-
[
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}, [setBounds]);
|
|
82
|
+
[t]
|
|
83
|
+
), i = g(() => {
|
|
84
|
+
t == null || t(null);
|
|
85
|
+
}, [t]);
|
|
110
86
|
return [
|
|
111
|
-
|
|
87
|
+
e,
|
|
112
88
|
{
|
|
113
|
-
set,
|
|
114
|
-
reset
|
|
89
|
+
set: s,
|
|
90
|
+
reset: i
|
|
115
91
|
}
|
|
116
92
|
];
|
|
117
93
|
}
|
|
118
|
-
function
|
|
119
|
-
const { lang } =
|
|
120
|
-
return
|
|
94
|
+
function O() {
|
|
95
|
+
const { lang: e } = Y();
|
|
96
|
+
return e;
|
|
121
97
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
var ScreenshotsMagnifier = memo(function ScreenshotsMagnifier2({
|
|
127
|
-
x,
|
|
128
|
-
y
|
|
129
|
-
}) {
|
|
130
|
-
const {
|
|
131
|
-
width,
|
|
132
|
-
height,
|
|
133
|
-
image
|
|
134
|
-
} = useStore();
|
|
135
|
-
const lang = useLang();
|
|
136
|
-
const [position, setPosition] = useState(null);
|
|
137
|
-
const elRef = useRef(null);
|
|
138
|
-
const canvasRef = useRef(null);
|
|
139
|
-
const ctxRef = useRef(null);
|
|
140
|
-
const [rgb, setRgb] = useState("000000");
|
|
141
|
-
useLayoutEffect(() => {
|
|
142
|
-
if (!elRef.current) {
|
|
98
|
+
const q = 100, G = 80, De = F(function({ x: t, y: s }) {
|
|
99
|
+
const { width: i, height: r, image: o } = Y(), n = O(), [c, f] = $(null), h = E(null), a = E(null), l = E(null), [u, d] = $("000000");
|
|
100
|
+
return Q(() => {
|
|
101
|
+
if (!h.current)
|
|
143
102
|
return;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
tx = x - elRect.width - 20;
|
|
150
|
-
}
|
|
151
|
-
if (ty + elRect.height > height) {
|
|
152
|
-
ty = y - elRect.height - 20;
|
|
153
|
-
}
|
|
154
|
-
if (tx < 0) {
|
|
155
|
-
tx = 0;
|
|
156
|
-
}
|
|
157
|
-
if (ty < 0) {
|
|
158
|
-
ty = 0;
|
|
159
|
-
}
|
|
160
|
-
setPosition({
|
|
161
|
-
x: tx,
|
|
162
|
-
y: ty
|
|
103
|
+
const p = h.current.getBoundingClientRect();
|
|
104
|
+
let w = t + 20, S = s + 20;
|
|
105
|
+
w + p.width > i && (w = t - p.width - 20), S + p.height > r && (S = s - p.height - 20), w < 0 && (w = 0), S < 0 && (S = 0), f({
|
|
106
|
+
x: w,
|
|
107
|
+
y: S
|
|
163
108
|
});
|
|
164
|
-
}, [
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
ctxRef.current = null;
|
|
109
|
+
}, [i, r, t, s]), T(() => {
|
|
110
|
+
if (!o || !a.current) {
|
|
111
|
+
l.current = null;
|
|
168
112
|
return;
|
|
169
113
|
}
|
|
170
|
-
if (!
|
|
171
|
-
ctxRef.current = canvasRef.current.getContext("2d");
|
|
172
|
-
}
|
|
173
|
-
if (!ctxRef.current) {
|
|
114
|
+
if (l.current || (l.current = a.current.getContext("2d")), !l.current)
|
|
174
115
|
return;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
116
|
+
const p = l.current;
|
|
117
|
+
p.clearRect(0, 0, q, G);
|
|
118
|
+
const w = o.naturalWidth / i, S = o.naturalHeight / r;
|
|
119
|
+
p.drawImage(
|
|
120
|
+
o,
|
|
121
|
+
t * w - q / 2,
|
|
122
|
+
s * S - G / 2,
|
|
123
|
+
q,
|
|
124
|
+
G,
|
|
125
|
+
0,
|
|
126
|
+
0,
|
|
127
|
+
q,
|
|
128
|
+
G
|
|
129
|
+
);
|
|
130
|
+
const { data: R } = p.getImageData(Math.floor(q / 2), Math.floor(G / 2), 1, 1), b = Array.from(R.slice(0, 3)).map((M) => M >= 16 ? M.toString(16) : `0${M.toString(16)}`).join("").toUpperCase();
|
|
131
|
+
d(b);
|
|
132
|
+
}, [i, r, o, t, s]), /* @__PURE__ */ y.createElement(
|
|
133
|
+
"div",
|
|
134
|
+
{
|
|
135
|
+
ref: h,
|
|
136
|
+
className: "screenshots-magnifier",
|
|
137
|
+
style: {
|
|
138
|
+
transform: `translate(${c == null ? void 0 : c.x}px, ${c == null ? void 0 : c.y}px)`
|
|
139
|
+
}
|
|
192
140
|
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
lineNumber: 96,
|
|
205
|
-
columnNumber: 7
|
|
206
|
-
}
|
|
207
|
-
}, /* @__PURE__ */ React.createElement("canvas", {
|
|
208
|
-
ref: canvasRef,
|
|
209
|
-
className: "screenshots-magnifier-body-canvas",
|
|
210
|
-
width: magnifierWidth,
|
|
211
|
-
height: magnifierHeight,
|
|
212
|
-
__self: this,
|
|
213
|
-
__source: {
|
|
214
|
-
fileName: _jsxFileName$l,
|
|
215
|
-
lineNumber: 97,
|
|
216
|
-
columnNumber: 9
|
|
217
|
-
}
|
|
218
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
219
|
-
className: "screenshots-magnifier-footer",
|
|
220
|
-
__self: this,
|
|
221
|
-
__source: {
|
|
222
|
-
fileName: _jsxFileName$l,
|
|
223
|
-
lineNumber: 104,
|
|
224
|
-
columnNumber: 7
|
|
225
|
-
}
|
|
226
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
227
|
-
className: "screenshots-magnifier-footer-item",
|
|
228
|
-
__self: this,
|
|
229
|
-
__source: {
|
|
230
|
-
fileName: _jsxFileName$l,
|
|
231
|
-
lineNumber: 105,
|
|
232
|
-
columnNumber: 9
|
|
233
|
-
}
|
|
234
|
-
}, lang.magnifier_position_label, ": (", x, ",", y, ")"), /* @__PURE__ */ React.createElement("div", {
|
|
235
|
-
className: "screenshots-magnifier-footer-item",
|
|
236
|
-
__self: this,
|
|
237
|
-
__source: {
|
|
238
|
-
fileName: _jsxFileName$l,
|
|
239
|
-
lineNumber: 108,
|
|
240
|
-
columnNumber: 9
|
|
241
|
-
}
|
|
242
|
-
}, "RGB: #", rgb)));
|
|
141
|
+
/* @__PURE__ */ y.createElement("div", { className: "screenshots-magnifier-body" }, /* @__PURE__ */ y.createElement(
|
|
142
|
+
"canvas",
|
|
143
|
+
{
|
|
144
|
+
ref: a,
|
|
145
|
+
className: "screenshots-magnifier-body-canvas",
|
|
146
|
+
width: q,
|
|
147
|
+
height: G
|
|
148
|
+
}
|
|
149
|
+
)),
|
|
150
|
+
/* @__PURE__ */ y.createElement("div", { className: "screenshots-magnifier-footer" }, /* @__PURE__ */ y.createElement("div", { className: "screenshots-magnifier-footer-item" }, n.magnifier_position_label, ": (", t, ",", s, ")"), /* @__PURE__ */ y.createElement("div", { className: "screenshots-magnifier-footer-item" }, "RGB: #", u))
|
|
151
|
+
);
|
|
243
152
|
});
|
|
244
|
-
function
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
if (x1 < 0) {
|
|
252
|
-
x1 = 0;
|
|
253
|
-
}
|
|
254
|
-
if (x2 > width) {
|
|
255
|
-
x2 = width;
|
|
256
|
-
}
|
|
257
|
-
if (y1 < 0) {
|
|
258
|
-
y1 = 0;
|
|
259
|
-
}
|
|
260
|
-
if (y2 > height) {
|
|
261
|
-
y2 = height;
|
|
262
|
-
}
|
|
263
|
-
return {
|
|
264
|
-
x: x1,
|
|
265
|
-
y: y1,
|
|
266
|
-
width: x2 - x1,
|
|
267
|
-
height: y2 - y1
|
|
153
|
+
function _e({ x: e, y: t }, { x: s, y: i }, r, o) {
|
|
154
|
+
return e > s && ([e, s] = [s, e]), t > i && ([t, i] = [i, t]), e < 0 && (e = 0), s > r && (s = r), t < 0 && (t = 0), i > o && (i = o), {
|
|
155
|
+
x: e,
|
|
156
|
+
y: t,
|
|
157
|
+
width: s - e,
|
|
158
|
+
height: i - t
|
|
268
159
|
};
|
|
269
160
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
url,
|
|
275
|
-
image,
|
|
276
|
-
width,
|
|
277
|
-
height
|
|
278
|
-
} = useStore();
|
|
279
|
-
const [bounds, boundsDispatcher] = useBounds();
|
|
280
|
-
const elRef = useRef(null);
|
|
281
|
-
const pointRef = useRef(null);
|
|
282
|
-
const isMoveRef = useRef(false);
|
|
283
|
-
const [position, setPosition] = useState(null);
|
|
284
|
-
const updateBounds = useCallback((p1, p2) => {
|
|
285
|
-
if (!elRef.current) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const {
|
|
289
|
-
x,
|
|
290
|
-
y
|
|
291
|
-
} = elRef.current.getBoundingClientRect();
|
|
292
|
-
boundsDispatcher.set(getBoundsByPoints$2({
|
|
293
|
-
x: p1.x - x,
|
|
294
|
-
y: p1.y - y
|
|
295
|
-
}, {
|
|
296
|
-
x: p2.x - x,
|
|
297
|
-
y: p2.y - y
|
|
298
|
-
}, width, height));
|
|
299
|
-
}, [width, height, boundsDispatcher]);
|
|
300
|
-
const onMouseDown = useCallback((e) => {
|
|
301
|
-
if (pointRef.current || bounds || e.button !== 0) {
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
pointRef.current = {
|
|
305
|
-
x: e.clientX,
|
|
306
|
-
y: e.clientY
|
|
307
|
-
};
|
|
308
|
-
isMoveRef.current = false;
|
|
309
|
-
}, [bounds]);
|
|
310
|
-
useEffect(() => {
|
|
311
|
-
const onMouseMove = (e) => {
|
|
312
|
-
if (elRef.current) {
|
|
313
|
-
const rect = elRef.current.getBoundingClientRect();
|
|
314
|
-
if (e.clientX < rect.left || e.clientY < rect.top || e.clientX > rect.right || e.clientY > rect.bottom) {
|
|
315
|
-
setPosition(null);
|
|
316
|
-
} else {
|
|
317
|
-
setPosition({
|
|
318
|
-
x: e.clientX - rect.x,
|
|
319
|
-
y: e.clientY - rect.y
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
if (!pointRef.current) {
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
updateBounds(pointRef.current, {
|
|
327
|
-
x: e.clientX,
|
|
328
|
-
y: e.clientY
|
|
329
|
-
});
|
|
330
|
-
isMoveRef.current = true;
|
|
331
|
-
};
|
|
332
|
-
const onMouseUp = (e) => {
|
|
333
|
-
if (!pointRef.current) {
|
|
161
|
+
const Pe = F(function() {
|
|
162
|
+
const { url: t, image: s, width: i, height: r } = Y(), [o, n] = K(), c = E(null), f = E(null), h = E(!1), [a, l] = $(null), u = g(
|
|
163
|
+
(p, w) => {
|
|
164
|
+
if (!c.current)
|
|
334
165
|
return;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
166
|
+
const { x: S, y: R } = c.current.getBoundingClientRect();
|
|
167
|
+
n.set(
|
|
168
|
+
_e(
|
|
169
|
+
{
|
|
170
|
+
x: p.x - S,
|
|
171
|
+
y: p.y - R
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
x: w.x - S,
|
|
175
|
+
y: w.y - R
|
|
176
|
+
},
|
|
177
|
+
i,
|
|
178
|
+
r
|
|
179
|
+
)
|
|
180
|
+
);
|
|
181
|
+
},
|
|
182
|
+
[i, r, n]
|
|
183
|
+
), d = g(
|
|
184
|
+
(p) => {
|
|
185
|
+
f.current || o || p.button !== 0 || (f.current = {
|
|
186
|
+
x: p.clientX,
|
|
187
|
+
y: p.clientY
|
|
188
|
+
}, h.current = !1);
|
|
189
|
+
},
|
|
190
|
+
[o]
|
|
191
|
+
);
|
|
192
|
+
return T(() => {
|
|
193
|
+
const p = (S) => {
|
|
194
|
+
if (c.current) {
|
|
195
|
+
const R = c.current.getBoundingClientRect();
|
|
196
|
+
S.clientX < R.left || S.clientY < R.top || S.clientX > R.right || S.clientY > R.bottom ? l(null) : l({
|
|
197
|
+
x: S.clientX - R.x,
|
|
198
|
+
y: S.clientY - R.y
|
|
340
199
|
});
|
|
341
200
|
}
|
|
342
|
-
|
|
343
|
-
|
|
201
|
+
f.current && (u(f.current, {
|
|
202
|
+
x: S.clientX,
|
|
203
|
+
y: S.clientY
|
|
204
|
+
}), h.current = !0);
|
|
205
|
+
}, w = (S) => {
|
|
206
|
+
f.current && (h.current && u(f.current, {
|
|
207
|
+
x: S.clientX,
|
|
208
|
+
y: S.clientY
|
|
209
|
+
}), f.current = null, h.current = !1);
|
|
344
210
|
};
|
|
345
|
-
window.addEventListener("mousemove",
|
|
346
|
-
|
|
347
|
-
return () => {
|
|
348
|
-
window.removeEventListener("mousemove", onMouseMove);
|
|
349
|
-
window.removeEventListener("mouseup", onMouseUp);
|
|
211
|
+
return window.addEventListener("mousemove", p), window.addEventListener("mouseup", w), () => {
|
|
212
|
+
window.removeEventListener("mousemove", p), window.removeEventListener("mouseup", w);
|
|
350
213
|
};
|
|
351
|
-
}, [
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
setPosition(null);
|
|
355
|
-
}
|
|
356
|
-
}, [image, bounds]);
|
|
357
|
-
if (!url || !image) {
|
|
358
|
-
return null;
|
|
359
|
-
}
|
|
360
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
361
|
-
ref: elRef,
|
|
362
|
-
className: "screenshots-background",
|
|
363
|
-
onMouseDown,
|
|
364
|
-
__self: this,
|
|
365
|
-
__source: {
|
|
366
|
-
fileName: _jsxFileName$k,
|
|
367
|
-
lineNumber: 120,
|
|
368
|
-
columnNumber: 5
|
|
369
|
-
}
|
|
370
|
-
}, /* @__PURE__ */ React.createElement("img", {
|
|
371
|
-
className: "screenshots-background-image",
|
|
372
|
-
src: url,
|
|
373
|
-
__self: this,
|
|
374
|
-
__source: {
|
|
375
|
-
fileName: _jsxFileName$k,
|
|
376
|
-
lineNumber: 121,
|
|
377
|
-
columnNumber: 7
|
|
378
|
-
}
|
|
379
|
-
}), /* @__PURE__ */ React.createElement("div", {
|
|
380
|
-
className: "screenshots-background-mask",
|
|
381
|
-
__self: this,
|
|
382
|
-
__source: {
|
|
383
|
-
fileName: _jsxFileName$k,
|
|
384
|
-
lineNumber: 122,
|
|
385
|
-
columnNumber: 7
|
|
386
|
-
}
|
|
387
|
-
}), position && !bounds && /* @__PURE__ */ React.createElement(ScreenshotsMagnifier, {
|
|
388
|
-
x: position == null ? void 0 : position.x,
|
|
389
|
-
y: position == null ? void 0 : position.y,
|
|
390
|
-
__self: this,
|
|
391
|
-
__source: {
|
|
392
|
-
fileName: _jsxFileName$k,
|
|
393
|
-
lineNumber: 123,
|
|
394
|
-
columnNumber: 31
|
|
395
|
-
}
|
|
396
|
-
}));
|
|
214
|
+
}, [u]), Q(() => {
|
|
215
|
+
(!s || o) && l(null);
|
|
216
|
+
}, [s, o]), !t || !s ? null : /* @__PURE__ */ y.createElement("div", { ref: c, className: "screenshots-background", onMouseDown: d }, /* @__PURE__ */ y.createElement("img", { className: "screenshots-background-image", src: t }), /* @__PURE__ */ y.createElement("div", { className: "screenshots-background-mask" }), a && !o && /* @__PURE__ */ y.createElement(De, { x: a == null ? void 0 : a.x, y: a == null ? void 0 : a.y }));
|
|
397
217
|
});
|
|
398
|
-
function
|
|
399
|
-
const { cursor } =
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
(cursor2) => {
|
|
403
|
-
setCursor == null ? void 0 : setCursor(cursor2);
|
|
218
|
+
function j() {
|
|
219
|
+
const { cursor: e } = Y(), { setCursor: t } = se(), s = g(
|
|
220
|
+
(r) => {
|
|
221
|
+
t == null || t(r);
|
|
404
222
|
},
|
|
405
|
-
[
|
|
406
|
-
)
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}, [setCursor]);
|
|
223
|
+
[t]
|
|
224
|
+
), i = g(() => {
|
|
225
|
+
t == null || t("move");
|
|
226
|
+
}, [t]);
|
|
410
227
|
return [
|
|
411
|
-
|
|
228
|
+
e,
|
|
412
229
|
{
|
|
413
|
-
set,
|
|
414
|
-
reset
|
|
230
|
+
set: s,
|
|
231
|
+
reset: i
|
|
415
232
|
}
|
|
416
233
|
];
|
|
417
234
|
}
|
|
418
|
-
function
|
|
419
|
-
const { emiterRef } =
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
if (Array.isArray(emiter[event])) {
|
|
424
|
-
emiter[event].push(listener);
|
|
425
|
-
} else {
|
|
426
|
-
emiter[event] = [listener];
|
|
427
|
-
}
|
|
235
|
+
function Z() {
|
|
236
|
+
const { emiterRef: e } = Y(), t = g(
|
|
237
|
+
(o, n) => {
|
|
238
|
+
const c = e.current;
|
|
239
|
+
Array.isArray(c[o]) ? c[o].push(n) : c[o] = [n];
|
|
428
240
|
},
|
|
429
|
-
[
|
|
430
|
-
)
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
if (index2 !== -1) {
|
|
437
|
-
emiter[event].splice(index2, 1);
|
|
438
|
-
}
|
|
241
|
+
[e]
|
|
242
|
+
), s = g(
|
|
243
|
+
(o, n) => {
|
|
244
|
+
const c = e.current;
|
|
245
|
+
if (Array.isArray(c[o])) {
|
|
246
|
+
const f = c[o].findIndex((h) => h === n);
|
|
247
|
+
f !== -1 && c[o].splice(f, 1);
|
|
439
248
|
}
|
|
440
249
|
},
|
|
441
|
-
[
|
|
442
|
-
)
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
if (Array.isArray(emiter[event])) {
|
|
447
|
-
emiter[event].forEach((listener) => listener(...args));
|
|
448
|
-
}
|
|
250
|
+
[e]
|
|
251
|
+
), i = g(
|
|
252
|
+
(o, ...n) => {
|
|
253
|
+
const c = e.current;
|
|
254
|
+
Array.isArray(c[o]) && c[o].forEach((f) => f(...n));
|
|
449
255
|
},
|
|
450
|
-
[
|
|
451
|
-
)
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}, [emiterRef]);
|
|
256
|
+
[e]
|
|
257
|
+
), r = g(() => {
|
|
258
|
+
e.current = {};
|
|
259
|
+
}, [e]);
|
|
455
260
|
return {
|
|
456
|
-
on,
|
|
457
|
-
off,
|
|
458
|
-
emit,
|
|
459
|
-
reset
|
|
261
|
+
on: t,
|
|
262
|
+
off: s,
|
|
263
|
+
emit: i,
|
|
264
|
+
reset: r
|
|
460
265
|
};
|
|
461
266
|
}
|
|
462
|
-
function
|
|
463
|
-
const { history } =
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
});
|
|
473
|
-
if (action.type === HistoryItemType.Source) {
|
|
474
|
-
action.isSelected = true;
|
|
475
|
-
} else if (action.type === HistoryItemType.Edit) {
|
|
476
|
-
action.source.isSelected = true;
|
|
477
|
-
}
|
|
478
|
-
stack.splice(index2 + 1);
|
|
479
|
-
stack.push(action);
|
|
480
|
-
setHistory == null ? void 0 : setHistory({
|
|
481
|
-
index: stack.length - 1,
|
|
482
|
-
stack
|
|
267
|
+
function H() {
|
|
268
|
+
const { history: e } = Y(), { setHistory: t } = se(), s = g(
|
|
269
|
+
(a) => {
|
|
270
|
+
const { index: l, stack: u } = e;
|
|
271
|
+
u.forEach((d) => {
|
|
272
|
+
d.type === _.Source && (d.isSelected = !1);
|
|
273
|
+
}), a.type === _.Source ? a.isSelected = !0 : a.type === _.Edit && (a.source.isSelected = !0), u.splice(l + 1), u.push(a), t == null || t({
|
|
274
|
+
index: u.length - 1,
|
|
275
|
+
stack: u
|
|
483
276
|
});
|
|
484
277
|
},
|
|
485
|
-
[
|
|
486
|
-
)
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
index: stack.length - 1,
|
|
492
|
-
stack
|
|
278
|
+
[e, t]
|
|
279
|
+
), i = g(() => {
|
|
280
|
+
const { stack: a } = e;
|
|
281
|
+
a.pop(), t == null || t({
|
|
282
|
+
index: a.length - 1,
|
|
283
|
+
stack: a
|
|
493
284
|
});
|
|
494
|
-
}, [
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
if (item.type === HistoryItemType.Source) {
|
|
500
|
-
item.isSelected = false;
|
|
501
|
-
} else if (item.type === HistoryItemType.Edit) {
|
|
502
|
-
item.source.editHistory.pop();
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
setHistory == null ? void 0 : setHistory({
|
|
506
|
-
index: index2 <= 0 ? -1 : index2 - 1,
|
|
507
|
-
stack
|
|
285
|
+
}, [e, t]), r = g(() => {
|
|
286
|
+
const { index: a, stack: l } = e, u = l[a];
|
|
287
|
+
u && (u.type === _.Source ? u.isSelected = !1 : u.type === _.Edit && u.source.editHistory.pop()), t == null || t({
|
|
288
|
+
index: a <= 0 ? -1 : a - 1,
|
|
289
|
+
stack: l
|
|
508
290
|
});
|
|
509
|
-
}, [
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
if (item.type === HistoryItemType.Source) {
|
|
515
|
-
item.isSelected = false;
|
|
516
|
-
} else if (item.type === HistoryItemType.Edit) {
|
|
517
|
-
item.source.editHistory.push(item);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
setHistory == null ? void 0 : setHistory({
|
|
521
|
-
index: index2 >= stack.length - 1 ? stack.length - 1 : index2 + 1,
|
|
522
|
-
stack
|
|
291
|
+
}, [e, t]), o = g(() => {
|
|
292
|
+
const { index: a, stack: l } = e, u = l[a + 1];
|
|
293
|
+
u && (u.type === _.Source ? u.isSelected = !1 : u.type === _.Edit && u.source.editHistory.push(u)), t == null || t({
|
|
294
|
+
index: a >= l.length - 1 ? l.length - 1 : a + 1,
|
|
295
|
+
stack: l
|
|
523
296
|
});
|
|
524
|
-
}, [
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
setHistory == null ? void 0 : setHistory({ ...history2 });
|
|
297
|
+
}, [e, t]), n = g(
|
|
298
|
+
(a) => {
|
|
299
|
+
t == null || t({ ...a });
|
|
528
300
|
},
|
|
529
|
-
[
|
|
530
|
-
)
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
if (item === action) {
|
|
536
|
-
item.isSelected = true;
|
|
537
|
-
} else {
|
|
538
|
-
item.isSelected = false;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
});
|
|
542
|
-
setHistory == null ? void 0 : setHistory({ ...history });
|
|
301
|
+
[t]
|
|
302
|
+
), c = g(
|
|
303
|
+
(a) => {
|
|
304
|
+
e.stack.forEach((l) => {
|
|
305
|
+
l.type === _.Source && (l === a ? l.isSelected = !0 : l.isSelected = !1);
|
|
306
|
+
}), t == null || t({ ...e });
|
|
543
307
|
},
|
|
544
|
-
[
|
|
545
|
-
)
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
});
|
|
552
|
-
setHistory == null ? void 0 : setHistory({ ...history });
|
|
553
|
-
}, [history, setHistory]);
|
|
554
|
-
const reset = useCallback(() => {
|
|
555
|
-
setHistory == null ? void 0 : setHistory({
|
|
308
|
+
[e, t]
|
|
309
|
+
), f = g(() => {
|
|
310
|
+
e.stack.forEach((a) => {
|
|
311
|
+
a.type === _.Source && (a.isSelected = !1);
|
|
312
|
+
}), t == null || t({ ...e });
|
|
313
|
+
}, [e, t]), h = g(() => {
|
|
314
|
+
t == null || t({
|
|
556
315
|
index: -1,
|
|
557
316
|
stack: []
|
|
558
317
|
});
|
|
559
|
-
}, [
|
|
318
|
+
}, [t]);
|
|
560
319
|
return [
|
|
561
320
|
{
|
|
562
|
-
index:
|
|
563
|
-
stack:
|
|
564
|
-
top:
|
|
321
|
+
index: e.index,
|
|
322
|
+
stack: e.stack,
|
|
323
|
+
top: e.stack.slice(e.index, e.index + 1)[0]
|
|
565
324
|
},
|
|
566
325
|
{
|
|
567
|
-
push,
|
|
568
|
-
pop,
|
|
569
|
-
undo,
|
|
570
|
-
redo,
|
|
571
|
-
set,
|
|
572
|
-
select,
|
|
573
|
-
clearSelect,
|
|
574
|
-
reset
|
|
326
|
+
push: s,
|
|
327
|
+
pop: i,
|
|
328
|
+
undo: r,
|
|
329
|
+
redo: o,
|
|
330
|
+
set: n,
|
|
331
|
+
select: c,
|
|
332
|
+
clearSelect: f,
|
|
333
|
+
reset: h
|
|
575
334
|
}
|
|
576
335
|
];
|
|
577
336
|
}
|
|
578
|
-
function
|
|
579
|
-
const { operation } =
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
(operation2) => {
|
|
583
|
-
setOperation == null ? void 0 : setOperation(operation2);
|
|
337
|
+
function J() {
|
|
338
|
+
const { operation: e } = Y(), { setOperation: t } = se(), s = g(
|
|
339
|
+
(r) => {
|
|
340
|
+
t == null || t(r);
|
|
584
341
|
},
|
|
585
|
-
[
|
|
586
|
-
)
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
}, [setOperation]);
|
|
342
|
+
[t]
|
|
343
|
+
), i = g(() => {
|
|
344
|
+
t == null || t(void 0);
|
|
345
|
+
}, [t]);
|
|
590
346
|
return [
|
|
591
|
-
|
|
347
|
+
e,
|
|
592
348
|
{
|
|
593
|
-
set,
|
|
594
|
-
reset
|
|
349
|
+
set: s,
|
|
350
|
+
reset: i
|
|
595
351
|
}
|
|
596
352
|
];
|
|
597
353
|
}
|
|
598
|
-
function
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
}
|
|
605
|
-
if (x1 < 0) {
|
|
606
|
-
x1 = 0;
|
|
607
|
-
if (resizeOrMove === "move") {
|
|
608
|
-
x2 = bounds.width;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
if (x2 > width) {
|
|
612
|
-
x2 = width;
|
|
613
|
-
if (resizeOrMove === "move") {
|
|
614
|
-
x1 = x2 - bounds.width;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
if (y1 < 0) {
|
|
618
|
-
y1 = 0;
|
|
619
|
-
if (resizeOrMove === "move") {
|
|
620
|
-
y2 = bounds.height;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
if (y2 > height) {
|
|
624
|
-
y2 = height;
|
|
625
|
-
if (resizeOrMove === "move") {
|
|
626
|
-
y1 = y2 - bounds.height;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
return {
|
|
630
|
-
x: x1,
|
|
631
|
-
y: y1,
|
|
632
|
-
width: Math.max(x2 - x1, 1),
|
|
633
|
-
height: Math.max(y2 - y1, 1)
|
|
354
|
+
function Xe({ x: e, y: t }, { x: s, y: i }, r, o, n, c) {
|
|
355
|
+
return e > s && ([e, s] = [s, e]), t > i && ([t, i] = [i, t]), e < 0 && (e = 0, c === "move" && (s = r.width)), s > o && (s = o, c === "move" && (e = s - r.width)), t < 0 && (t = 0, c === "move" && (i = r.height)), i > n && (i = n, c === "move" && (t = i - r.height)), {
|
|
356
|
+
x: e,
|
|
357
|
+
y: t,
|
|
358
|
+
width: Math.max(s - e, 1),
|
|
359
|
+
height: Math.max(i - t, 1)
|
|
634
360
|
};
|
|
635
361
|
}
|
|
636
|
-
function
|
|
637
|
-
const
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
let y1 = bounds.y;
|
|
641
|
-
let x2 = bounds.x + bounds.width;
|
|
642
|
-
let y2 = bounds.y + bounds.height;
|
|
643
|
-
switch (resizeOrMove) {
|
|
362
|
+
function Ne(e, t, s, i) {
|
|
363
|
+
const r = e.clientX - s.x, o = e.clientY - s.y;
|
|
364
|
+
let n = i.x, c = i.y, f = i.x + i.width, h = i.y + i.height;
|
|
365
|
+
switch (t) {
|
|
644
366
|
case "top":
|
|
645
|
-
|
|
367
|
+
c += o;
|
|
646
368
|
break;
|
|
647
369
|
case "top-right":
|
|
648
|
-
|
|
649
|
-
y1 += y;
|
|
370
|
+
f += r, c += o;
|
|
650
371
|
break;
|
|
651
372
|
case "right":
|
|
652
|
-
|
|
373
|
+
f += r;
|
|
653
374
|
break;
|
|
654
375
|
case "right-bottom":
|
|
655
|
-
|
|
656
|
-
y2 += y;
|
|
376
|
+
f += r, h += o;
|
|
657
377
|
break;
|
|
658
378
|
case "bottom":
|
|
659
|
-
|
|
379
|
+
h += o;
|
|
660
380
|
break;
|
|
661
381
|
case "bottom-left":
|
|
662
|
-
|
|
663
|
-
y2 += y;
|
|
382
|
+
n += r, h += o;
|
|
664
383
|
break;
|
|
665
384
|
case "left":
|
|
666
|
-
|
|
385
|
+
n += r;
|
|
667
386
|
break;
|
|
668
387
|
case "left-top":
|
|
669
|
-
|
|
670
|
-
y1 += y;
|
|
388
|
+
n += r, c += o;
|
|
671
389
|
break;
|
|
672
390
|
case "move":
|
|
673
|
-
|
|
674
|
-
y1 += y;
|
|
675
|
-
x2 += x;
|
|
676
|
-
y2 += y;
|
|
391
|
+
n += r, c += o, f += r, h += o;
|
|
677
392
|
break;
|
|
678
393
|
}
|
|
679
394
|
return [
|
|
680
395
|
{
|
|
681
|
-
x:
|
|
682
|
-
y:
|
|
396
|
+
x: n,
|
|
397
|
+
y: c
|
|
683
398
|
},
|
|
684
399
|
{
|
|
685
|
-
x:
|
|
686
|
-
y:
|
|
400
|
+
x: f,
|
|
401
|
+
y: h
|
|
687
402
|
}
|
|
688
403
|
];
|
|
689
404
|
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
const
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
const { left, top } = canvas.getBoundingClientRect();
|
|
703
|
-
const x = e.clientX - left;
|
|
704
|
-
const y = e.clientY - top;
|
|
705
|
-
const stack = [...history.stack.slice(0, history.index + 1)];
|
|
706
|
-
return stack.reverse().find((item) => {
|
|
707
|
-
var _a;
|
|
708
|
-
if (item.type !== HistoryItemType.Source) {
|
|
709
|
-
return false;
|
|
710
|
-
}
|
|
711
|
-
ctx.clearRect(0, 0, bounds.width, bounds.height);
|
|
712
|
-
return (_a = item.isHit) == null ? void 0 : _a.call(item, ctx, item, { x, y });
|
|
405
|
+
function Ye(e, t, s, i) {
|
|
406
|
+
if (!t)
|
|
407
|
+
return !1;
|
|
408
|
+
const r = document.createElement("canvas");
|
|
409
|
+
r.width = e.width, r.height = e.height;
|
|
410
|
+
const o = r.getContext("2d");
|
|
411
|
+
if (!o)
|
|
412
|
+
return !1;
|
|
413
|
+
const { left: n, top: c } = t.getBoundingClientRect(), f = i.clientX - n, h = i.clientY - c;
|
|
414
|
+
return [...s.stack.slice(0, s.index + 1)].reverse().find((l) => {
|
|
415
|
+
var u;
|
|
416
|
+
return l.type !== _.Source ? !1 : (o.clearRect(0, 0, e.width, e.height), (u = l.isHit) == null ? void 0 : u.call(l, o, l, { x: f, y: h }));
|
|
713
417
|
});
|
|
714
418
|
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
419
|
+
const Le = ["top", "right", "bottom", "left"], Te = [
|
|
420
|
+
"top",
|
|
421
|
+
"top-right",
|
|
422
|
+
"right",
|
|
423
|
+
"right-bottom",
|
|
424
|
+
"bottom",
|
|
425
|
+
"bottom-left",
|
|
426
|
+
"left",
|
|
427
|
+
"left-top"
|
|
428
|
+
/* ResizeLeftTop */
|
|
429
|
+
], He = F(
|
|
430
|
+
Me(function(t, s) {
|
|
431
|
+
const { url: i, image: r, width: o, height: n } = Y(), c = Z(), [f] = H(), [h] = j(), [a, l] = K(), [u] = J(), d = E(), p = E(null), w = E(null), S = E(null), R = E(null), b = a && !f.stack.length && !u, M = g(() => {
|
|
432
|
+
if (!a || !R.current)
|
|
433
|
+
return;
|
|
434
|
+
const x = R.current;
|
|
435
|
+
x.imageSmoothingEnabled = !0, x.imageSmoothingQuality = "low", x.clearRect(0, 0, a.width, a.height), f.stack.slice(0, f.index + 1).forEach((C) => {
|
|
436
|
+
C.type === _.Source && C.draw(x, C);
|
|
437
|
+
});
|
|
438
|
+
}, [a, R, f]), v = g(
|
|
439
|
+
(x, C) => {
|
|
440
|
+
if (!(x.button !== 0 || !a))
|
|
441
|
+
if (!u)
|
|
442
|
+
d.current = C, p.current = {
|
|
443
|
+
x: x.clientX,
|
|
444
|
+
y: x.clientY
|
|
445
|
+
}, w.current = {
|
|
446
|
+
x: a.x,
|
|
447
|
+
y: a.y,
|
|
448
|
+
width: a.width,
|
|
449
|
+
height: a.height
|
|
450
|
+
};
|
|
451
|
+
else {
|
|
452
|
+
const z = Ye(
|
|
453
|
+
a,
|
|
454
|
+
S.current,
|
|
455
|
+
f,
|
|
456
|
+
x.nativeEvent
|
|
457
|
+
);
|
|
458
|
+
z ? c.emit("drawselect", z, x.nativeEvent) : c.emit("mousedown", x.nativeEvent);
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
[a, u, c, f]
|
|
462
|
+
), m = g(
|
|
463
|
+
(x) => {
|
|
464
|
+
if (!d.current || !p.current || !w.current || !a)
|
|
465
|
+
return;
|
|
466
|
+
const C = Ne(
|
|
467
|
+
x,
|
|
468
|
+
d.current,
|
|
469
|
+
p.current,
|
|
470
|
+
w.current
|
|
471
|
+
);
|
|
472
|
+
l.set(
|
|
473
|
+
Xe(
|
|
474
|
+
C[0],
|
|
475
|
+
C[1],
|
|
476
|
+
a,
|
|
477
|
+
o,
|
|
478
|
+
n,
|
|
479
|
+
d.current
|
|
480
|
+
)
|
|
481
|
+
);
|
|
482
|
+
},
|
|
483
|
+
[o, n, a, l]
|
|
484
|
+
);
|
|
485
|
+
return Q(() => {
|
|
486
|
+
if (!r || !a || !S.current) {
|
|
487
|
+
R.current = null;
|
|
488
|
+
return;
|
|
746
489
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
490
|
+
R.current || (R.current = S.current.getContext("2d")), M();
|
|
491
|
+
}, [r, a, M]), T(() => {
|
|
492
|
+
const x = (z) => {
|
|
493
|
+
if (u)
|
|
494
|
+
c.emit("mousemove", z);
|
|
495
|
+
else {
|
|
496
|
+
if (!d.current || !p.current || !w.current)
|
|
497
|
+
return;
|
|
498
|
+
m(z);
|
|
499
|
+
}
|
|
500
|
+
}, C = (z) => {
|
|
501
|
+
if (u)
|
|
502
|
+
c.emit("mouseup", z);
|
|
503
|
+
else {
|
|
504
|
+
if (!d.current || !p.current || !w.current)
|
|
505
|
+
return;
|
|
506
|
+
m(z), d.current = void 0, p.current = null, w.current = null;
|
|
507
|
+
}
|
|
758
508
|
};
|
|
759
|
-
|
|
760
|
-
x
|
|
761
|
-
y: bounds.y,
|
|
762
|
-
width: bounds.width,
|
|
763
|
-
height: bounds.height
|
|
509
|
+
return window.addEventListener("mousemove", x), window.addEventListener("mouseup", C), () => {
|
|
510
|
+
window.removeEventListener("mousemove", x), window.removeEventListener("mouseup", C);
|
|
764
511
|
};
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
}, [bounds, operation, emiter, history]);
|
|
774
|
-
const updateBounds = useCallback((e) => {
|
|
775
|
-
if (!resizeOrMoveRef.current || !pointRef.current || !boundsRef.current || !bounds) {
|
|
776
|
-
return;
|
|
777
|
-
}
|
|
778
|
-
const points = getBoundsByPoints(e, resizeOrMoveRef.current, pointRef.current, boundsRef.current);
|
|
779
|
-
boundsDispatcher.set(getBoundsByPoints$1(points[0], points[1], bounds, width, height, resizeOrMoveRef.current));
|
|
780
|
-
}, [width, height, bounds, boundsDispatcher]);
|
|
781
|
-
useLayoutEffect(() => {
|
|
782
|
-
if (!image || !bounds || !canvasRef.current) {
|
|
783
|
-
ctxRef.current = null;
|
|
784
|
-
return;
|
|
785
|
-
}
|
|
786
|
-
if (!ctxRef.current) {
|
|
787
|
-
ctxRef.current = canvasRef.current.getContext("2d");
|
|
788
|
-
}
|
|
789
|
-
draw2();
|
|
790
|
-
}, [image, bounds, draw2]);
|
|
791
|
-
useEffect(() => {
|
|
792
|
-
const onMouseMove = (e) => {
|
|
793
|
-
if (!operation) {
|
|
794
|
-
if (!resizeOrMoveRef.current || !pointRef.current || !boundsRef.current) {
|
|
795
|
-
return;
|
|
512
|
+
}, [m, u, c]), Be(s, () => R.current), /* @__PURE__ */ y.createElement(
|
|
513
|
+
"div",
|
|
514
|
+
{
|
|
515
|
+
className: "screenshots-canvas",
|
|
516
|
+
style: {
|
|
517
|
+
width: (a == null ? void 0 : a.width) || 0,
|
|
518
|
+
height: (a == null ? void 0 : a.height) || 0,
|
|
519
|
+
transform: a ? `translate(${a.x}px, ${a.y}px)` : "none"
|
|
796
520
|
}
|
|
797
|
-
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
521
|
+
},
|
|
522
|
+
/* @__PURE__ */ y.createElement("div", { className: "screenshots-canvas-body" }, /* @__PURE__ */ y.createElement(
|
|
523
|
+
"img",
|
|
524
|
+
{
|
|
525
|
+
className: "screenshots-canvas-image",
|
|
526
|
+
src: i,
|
|
527
|
+
style: {
|
|
528
|
+
width: o,
|
|
529
|
+
height: n,
|
|
530
|
+
transform: a ? `translate(${-a.x}px, ${-a.y}px)` : "none"
|
|
531
|
+
}
|
|
806
532
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
},
|
|
852
|
-
__self: this,
|
|
853
|
-
__source: {
|
|
854
|
-
fileName: _jsxFileName$j,
|
|
855
|
-
lineNumber: 183,
|
|
856
|
-
columnNumber: 11
|
|
857
|
-
}
|
|
858
|
-
}), /* @__PURE__ */ React.createElement("canvas", {
|
|
859
|
-
ref: canvasRef,
|
|
860
|
-
className: "screenshots-canvas-panel",
|
|
861
|
-
width: (bounds == null ? void 0 : bounds.width) || 0,
|
|
862
|
-
height: (bounds == null ? void 0 : bounds.height) || 0,
|
|
863
|
-
__self: this,
|
|
864
|
-
__source: {
|
|
865
|
-
fileName: _jsxFileName$j,
|
|
866
|
-
lineNumber: 192,
|
|
867
|
-
columnNumber: 11
|
|
868
|
-
}
|
|
869
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
870
|
-
className: "screenshots-canvas-mask",
|
|
871
|
-
style: {
|
|
872
|
-
cursor
|
|
873
|
-
},
|
|
874
|
-
onMouseDown: (e) => onMouseDown(e, "move"),
|
|
875
|
-
__self: this,
|
|
876
|
-
__source: {
|
|
877
|
-
fileName: _jsxFileName$j,
|
|
878
|
-
lineNumber: 199,
|
|
879
|
-
columnNumber: 9
|
|
880
|
-
}
|
|
881
|
-
}), borders.map((border) => {
|
|
882
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
883
|
-
key: border,
|
|
884
|
-
className: `screenshots-canvas-border-${border}`,
|
|
885
|
-
__self: this,
|
|
886
|
-
__source: {
|
|
887
|
-
fileName: _jsxFileName$j,
|
|
888
|
-
lineNumber: 207,
|
|
889
|
-
columnNumber: 18
|
|
890
|
-
}
|
|
891
|
-
});
|
|
892
|
-
}), bounds && resizePoints.map((resizePoint) => {
|
|
893
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
894
|
-
key: resizePoint,
|
|
895
|
-
className: `screenshots-canvas-point-${resizePoint}`,
|
|
896
|
-
onMouseDown: (e) => onMouseDown(e, resizePoint),
|
|
897
|
-
__self: this,
|
|
898
|
-
__source: {
|
|
899
|
-
fileName: _jsxFileName$j,
|
|
900
|
-
lineNumber: 211,
|
|
901
|
-
columnNumber: 13
|
|
902
|
-
}
|
|
903
|
-
});
|
|
904
|
-
}));
|
|
905
|
-
}));
|
|
906
|
-
function useCall() {
|
|
907
|
-
const dispatcher = useDispatcher();
|
|
908
|
-
const call = useCallback(
|
|
909
|
-
(funcName, ...args) => {
|
|
910
|
-
var _a;
|
|
911
|
-
(_a = dispatcher.call) == null ? void 0 : _a.call(dispatcher, funcName, ...args);
|
|
533
|
+
), /* @__PURE__ */ y.createElement(
|
|
534
|
+
"canvas",
|
|
535
|
+
{
|
|
536
|
+
ref: S,
|
|
537
|
+
className: "screenshots-canvas-panel",
|
|
538
|
+
width: (a == null ? void 0 : a.width) || 0,
|
|
539
|
+
height: (a == null ? void 0 : a.height) || 0
|
|
540
|
+
}
|
|
541
|
+
)),
|
|
542
|
+
/* @__PURE__ */ y.createElement(
|
|
543
|
+
"div",
|
|
544
|
+
{
|
|
545
|
+
className: "screenshots-canvas-mask",
|
|
546
|
+
style: {
|
|
547
|
+
cursor: h
|
|
548
|
+
},
|
|
549
|
+
onMouseDown: (x) => v(x, "move")
|
|
550
|
+
},
|
|
551
|
+
b && /* @__PURE__ */ y.createElement("div", { className: "screenshots-canvas-size" }, a.width, " × ", a.height)
|
|
552
|
+
),
|
|
553
|
+
Le.map((x) => /* @__PURE__ */ y.createElement(
|
|
554
|
+
"div",
|
|
555
|
+
{
|
|
556
|
+
key: x,
|
|
557
|
+
className: `screenshots-canvas-border-${x}`
|
|
558
|
+
}
|
|
559
|
+
)),
|
|
560
|
+
b && Te.map((x) => /* @__PURE__ */ y.createElement(
|
|
561
|
+
"div",
|
|
562
|
+
{
|
|
563
|
+
key: x,
|
|
564
|
+
className: `screenshots-canvas-point-${x}`,
|
|
565
|
+
onMouseDown: (C) => v(C, x)
|
|
566
|
+
}
|
|
567
|
+
))
|
|
568
|
+
);
|
|
569
|
+
})
|
|
570
|
+
);
|
|
571
|
+
function ve() {
|
|
572
|
+
const e = se();
|
|
573
|
+
return g(
|
|
574
|
+
(s, ...i) => {
|
|
575
|
+
var r;
|
|
576
|
+
(r = e.call) == null || r.call(e, s, ...i);
|
|
912
577
|
},
|
|
913
|
-
[
|
|
578
|
+
[e]
|
|
914
579
|
);
|
|
915
|
-
return call;
|
|
916
580
|
}
|
|
917
|
-
function
|
|
918
|
-
const { canvasContextRef } =
|
|
919
|
-
return
|
|
581
|
+
function U() {
|
|
582
|
+
const { canvasContextRef: e } = Y();
|
|
583
|
+
return e;
|
|
920
584
|
}
|
|
921
|
-
function
|
|
922
|
-
const
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
const [, operatioDispatcher] = useOperation();
|
|
927
|
-
const reset = useCallback(() => {
|
|
928
|
-
emiter.reset();
|
|
929
|
-
historyDispatcher.reset();
|
|
930
|
-
boundsDispatcher.reset();
|
|
931
|
-
cursorDispatcher.reset();
|
|
932
|
-
operatioDispatcher.reset();
|
|
933
|
-
}, [emiter, historyDispatcher, boundsDispatcher, cursorDispatcher, operatioDispatcher]);
|
|
934
|
-
return reset;
|
|
585
|
+
function xe() {
|
|
586
|
+
const e = Z(), [, t] = K(), [, s] = j(), [, i] = H(), [, r] = J();
|
|
587
|
+
return g(() => {
|
|
588
|
+
e.reset(), i.reset(), t.reset(), s.reset(), r.reset();
|
|
589
|
+
}, [e, i, t, s, r]);
|
|
935
590
|
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
const popoverRef = useRef(null);
|
|
946
|
-
const contentRef = useRef(null);
|
|
947
|
-
const operationsRect = useContext(ScreenshotsOperationsCtx);
|
|
948
|
-
const [placement, setPlacement] = useState("bottom");
|
|
949
|
-
const [position, setPosition] = useState(null);
|
|
950
|
-
const [offsetX, setOffsetX] = useState(0);
|
|
951
|
-
const getPopoverEl = () => {
|
|
952
|
-
if (!popoverRef.current) {
|
|
953
|
-
popoverRef.current = document.createElement("div");
|
|
954
|
-
}
|
|
955
|
-
return popoverRef.current;
|
|
956
|
-
};
|
|
957
|
-
useEffect(() => {
|
|
958
|
-
const $el = getPopoverEl();
|
|
959
|
-
if (open) {
|
|
960
|
-
document.body.appendChild($el);
|
|
961
|
-
}
|
|
962
|
-
return () => {
|
|
963
|
-
$el.remove();
|
|
591
|
+
const Ae = F(function({ open: t, content: s, children: i }) {
|
|
592
|
+
const r = E(null), o = E(null), n = E(null), c = pe(Ee), [f, h] = $(
|
|
593
|
+
"bottom"
|
|
594
|
+
/* Bottom */
|
|
595
|
+
), [a, l] = $(null), [u, d] = $(0), p = () => (o.current || (o.current = document.createElement("div")), o.current);
|
|
596
|
+
return T(() => {
|
|
597
|
+
const w = p();
|
|
598
|
+
return t && document.body.appendChild(w), () => {
|
|
599
|
+
w.remove();
|
|
964
600
|
};
|
|
965
|
-
}, [
|
|
966
|
-
|
|
967
|
-
if (!open || !operationsRect || !childrenRef.current || !contentRef.current) {
|
|
601
|
+
}, [t]), T(() => {
|
|
602
|
+
if (!t || !c || !r.current || !n.current)
|
|
968
603
|
return;
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
setPosition({
|
|
1003
|
-
x,
|
|
1004
|
-
y
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1007
|
-
if (currentOffsetX !== offsetX) {
|
|
1008
|
-
setOffsetX(currentOffsetX);
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, cloneElement(children, {
|
|
1012
|
-
ref: childrenRef
|
|
1013
|
-
}), open && content && createPortal(/* @__PURE__ */ React.createElement("div", {
|
|
1014
|
-
ref: contentRef,
|
|
1015
|
-
className: "screenshots-option",
|
|
1016
|
-
style: {
|
|
1017
|
-
visibility: position ? "visible" : "hidden",
|
|
1018
|
-
transform: `translate(${(_a = position == null ? void 0 : position.x) != null ? _a : 0}px, ${(_b = position == null ? void 0 : position.y) != null ? _b : 0}px)`
|
|
1019
|
-
},
|
|
1020
|
-
"data-placement": placement,
|
|
1021
|
-
__self: this,
|
|
1022
|
-
__source: {
|
|
1023
|
-
fileName: _jsxFileName$i,
|
|
1024
|
-
lineNumber: 111,
|
|
1025
|
-
columnNumber: 11
|
|
1026
|
-
}
|
|
1027
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
1028
|
-
className: "screenshots-option-container",
|
|
1029
|
-
__self: this,
|
|
1030
|
-
__source: {
|
|
1031
|
-
fileName: _jsxFileName$i,
|
|
1032
|
-
lineNumber: 120,
|
|
1033
|
-
columnNumber: 13
|
|
1034
|
-
}
|
|
1035
|
-
}, content), /* @__PURE__ */ React.createElement("div", {
|
|
1036
|
-
className: "screenshots-option-arrow",
|
|
1037
|
-
style: {
|
|
1038
|
-
marginLeft: offsetX
|
|
1039
|
-
},
|
|
1040
|
-
__self: this,
|
|
1041
|
-
__source: {
|
|
1042
|
-
fileName: _jsxFileName$i,
|
|
1043
|
-
lineNumber: 121,
|
|
1044
|
-
columnNumber: 13
|
|
1045
|
-
}
|
|
1046
|
-
})), getPopoverEl()));
|
|
604
|
+
const w = r.current.getBoundingClientRect(), S = n.current.getBoundingClientRect();
|
|
605
|
+
let R = f, b = w.left + w.width / 2, M = w.top + w.height, v = u;
|
|
606
|
+
if (b + S.width / 2 > c.x + c.width) {
|
|
607
|
+
const m = b;
|
|
608
|
+
b = c.x + c.width - S.width / 2, v = m - b;
|
|
609
|
+
}
|
|
610
|
+
if (b < c.x + S.width / 2) {
|
|
611
|
+
const m = b;
|
|
612
|
+
b = c.x + S.width / 2, v = m - b;
|
|
613
|
+
}
|
|
614
|
+
M > window.innerHeight - S.height && (R === "bottom" && (R = "top"), M = w.top - S.height), M < 0 && (R === "top" && (R = "bottom"), M = w.top + w.height), R !== f && h(R), ((a == null ? void 0 : a.x) !== b || a.y !== M) && l({
|
|
615
|
+
x: b,
|
|
616
|
+
y: M
|
|
617
|
+
}), v !== u && d(v);
|
|
618
|
+
}), /* @__PURE__ */ y.createElement(y.Fragment, null, $e(i, {
|
|
619
|
+
ref: r
|
|
620
|
+
}), t && s && we(
|
|
621
|
+
/* @__PURE__ */ y.createElement(
|
|
622
|
+
"div",
|
|
623
|
+
{
|
|
624
|
+
ref: n,
|
|
625
|
+
className: "screenshots-option",
|
|
626
|
+
style: {
|
|
627
|
+
visibility: a ? "visible" : "hidden",
|
|
628
|
+
transform: `translate(${(a == null ? void 0 : a.x) ?? 0}px, ${(a == null ? void 0 : a.y) ?? 0}px)`
|
|
629
|
+
},
|
|
630
|
+
"data-placement": f
|
|
631
|
+
},
|
|
632
|
+
/* @__PURE__ */ y.createElement("div", { className: "screenshots-option-container" }, s),
|
|
633
|
+
/* @__PURE__ */ y.createElement("div", { className: "screenshots-option-arrow", style: { marginLeft: u } })
|
|
634
|
+
),
|
|
635
|
+
p()
|
|
636
|
+
));
|
|
1047
637
|
});
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
option,
|
|
1056
|
-
onClick
|
|
638
|
+
const A = F(function({
|
|
639
|
+
title: t,
|
|
640
|
+
icon: s,
|
|
641
|
+
checked: i,
|
|
642
|
+
disabled: r,
|
|
643
|
+
option: o,
|
|
644
|
+
onClick: n
|
|
1057
645
|
}) {
|
|
1058
|
-
const
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
content: option,
|
|
1074
|
-
__self: this,
|
|
1075
|
-
__source: {
|
|
1076
|
-
fileName: _jsxFileName$h,
|
|
1077
|
-
lineNumber: 42,
|
|
1078
|
-
columnNumber: 5
|
|
1079
|
-
}
|
|
1080
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
1081
|
-
className: classNames.join(" "),
|
|
1082
|
-
title,
|
|
1083
|
-
onClick: onButtonClick,
|
|
1084
|
-
__self: this,
|
|
1085
|
-
__source: {
|
|
1086
|
-
fileName: _jsxFileName$h,
|
|
1087
|
-
lineNumber: 43,
|
|
1088
|
-
columnNumber: 7
|
|
1089
|
-
}
|
|
1090
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
1091
|
-
className: icon,
|
|
1092
|
-
__self: this,
|
|
1093
|
-
__source: {
|
|
1094
|
-
fileName: _jsxFileName$h,
|
|
1095
|
-
lineNumber: 44,
|
|
1096
|
-
columnNumber: 9
|
|
1097
|
-
}
|
|
1098
|
-
})));
|
|
646
|
+
const c = ["screenshots-button"], f = g(
|
|
647
|
+
(h) => {
|
|
648
|
+
r || !n || n(h);
|
|
649
|
+
},
|
|
650
|
+
[r, n]
|
|
651
|
+
);
|
|
652
|
+
return i && c.push("screenshots-button-checked"), r && c.push("screenshots-button-disabled"), /* @__PURE__ */ y.createElement(Ae, { open: i, content: o }, /* @__PURE__ */ y.createElement(
|
|
653
|
+
"div",
|
|
654
|
+
{
|
|
655
|
+
className: c.join(" "),
|
|
656
|
+
title: t,
|
|
657
|
+
onClick: f
|
|
658
|
+
},
|
|
659
|
+
/* @__PURE__ */ y.createElement("span", { className: s })
|
|
660
|
+
));
|
|
1099
661
|
});
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
const [, historyDispatcher] = useHistory();
|
|
1112
|
-
const call = useCall();
|
|
1113
|
-
const reset = useReset();
|
|
1114
|
-
const onClick = useCallback(() => {
|
|
1115
|
-
historyDispatcher.clearSelect();
|
|
1116
|
-
setTimeout(() => {
|
|
1117
|
-
if (!canvasContextRef.current || !image || !bounds) {
|
|
1118
|
-
return;
|
|
1119
|
-
}
|
|
1120
|
-
composeImage({
|
|
1121
|
-
image,
|
|
1122
|
-
width,
|
|
1123
|
-
height,
|
|
1124
|
-
history,
|
|
1125
|
-
bounds
|
|
1126
|
-
}).then((blob) => {
|
|
1127
|
-
call("onOk", blob, bounds);
|
|
1128
|
-
reset();
|
|
662
|
+
function Ie() {
|
|
663
|
+
const { image: e, width: t, height: s, history: i, bounds: r, lang: o } = Y(), n = U(), [, c] = H(), f = ve(), h = xe(), a = g(() => {
|
|
664
|
+
c.clearSelect(), setTimeout(() => {
|
|
665
|
+
!n.current || !e || !r || fe({
|
|
666
|
+
image: e,
|
|
667
|
+
width: t,
|
|
668
|
+
height: s,
|
|
669
|
+
history: i,
|
|
670
|
+
bounds: r
|
|
671
|
+
}).then((l) => {
|
|
672
|
+
f("onOk", l, r), h();
|
|
1129
673
|
});
|
|
1130
674
|
});
|
|
1131
|
-
}, [
|
|
1132
|
-
return /* @__PURE__ */
|
|
1133
|
-
title: lang.operation_ok_title,
|
|
1134
|
-
icon: "icon-ok",
|
|
1135
|
-
onClick,
|
|
1136
|
-
__self: this,
|
|
1137
|
-
__source: {
|
|
1138
|
-
fileName: _jsxFileName$g,
|
|
1139
|
-
lineNumber: 36,
|
|
1140
|
-
columnNumber: 10
|
|
1141
|
-
}
|
|
1142
|
-
});
|
|
675
|
+
}, [n, c, e, t, s, i, r, f, h]);
|
|
676
|
+
return /* @__PURE__ */ y.createElement(A, { title: o.operation_ok_title, icon: "icon-ok", onClick: a });
|
|
1143
677
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
const onClick = useCallback(() => {
|
|
1150
|
-
call("onCancel");
|
|
1151
|
-
reset();
|
|
1152
|
-
}, [call, reset]);
|
|
1153
|
-
return /* @__PURE__ */ React.createElement(ScreenshotsButton, {
|
|
1154
|
-
title: lang.operation_cancel_title,
|
|
1155
|
-
icon: "icon-cancel",
|
|
1156
|
-
onClick,
|
|
1157
|
-
__self: this,
|
|
1158
|
-
__source: {
|
|
1159
|
-
fileName: _jsxFileName$f,
|
|
1160
|
-
lineNumber: 17,
|
|
1161
|
-
columnNumber: 10
|
|
1162
|
-
}
|
|
1163
|
-
});
|
|
678
|
+
function We() {
|
|
679
|
+
const e = ve(), t = xe(), s = O(), i = g(() => {
|
|
680
|
+
e("onCancel"), t();
|
|
681
|
+
}, [e, t]);
|
|
682
|
+
return /* @__PURE__ */ y.createElement(A, { title: s.operation_cancel_title, icon: "icon-cancel", onClick: i });
|
|
1164
683
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
const [, historyDispatcher] = useHistory();
|
|
1177
|
-
const call = useCall();
|
|
1178
|
-
const reset = useReset();
|
|
1179
|
-
const onClick = useCallback(() => {
|
|
1180
|
-
historyDispatcher.clearSelect();
|
|
1181
|
-
setTimeout(() => {
|
|
1182
|
-
if (!canvasContextRef.current || !image || !bounds) {
|
|
1183
|
-
return;
|
|
1184
|
-
}
|
|
1185
|
-
composeImage({
|
|
1186
|
-
image,
|
|
1187
|
-
width,
|
|
1188
|
-
height,
|
|
1189
|
-
history,
|
|
1190
|
-
bounds
|
|
1191
|
-
}).then((blob) => {
|
|
1192
|
-
call("onSave", blob, bounds);
|
|
1193
|
-
reset();
|
|
684
|
+
function Fe() {
|
|
685
|
+
const { image: e, width: t, height: s, history: i, bounds: r, lang: o } = Y(), n = U(), [, c] = H(), f = ve(), h = xe(), a = g(() => {
|
|
686
|
+
c.clearSelect(), setTimeout(() => {
|
|
687
|
+
!n.current || !e || !r || fe({
|
|
688
|
+
image: e,
|
|
689
|
+
width: t,
|
|
690
|
+
height: s,
|
|
691
|
+
history: i,
|
|
692
|
+
bounds: r
|
|
693
|
+
}).then((l) => {
|
|
694
|
+
f("onSave", l, r), h();
|
|
1194
695
|
});
|
|
1195
696
|
});
|
|
1196
|
-
}, [
|
|
1197
|
-
return /* @__PURE__ */
|
|
1198
|
-
title: lang.operation_save_title,
|
|
1199
|
-
icon: "icon-save",
|
|
1200
|
-
onClick,
|
|
1201
|
-
__self: this,
|
|
1202
|
-
__source: {
|
|
1203
|
-
fileName: _jsxFileName$e,
|
|
1204
|
-
lineNumber: 36,
|
|
1205
|
-
columnNumber: 10
|
|
1206
|
-
}
|
|
1207
|
-
});
|
|
697
|
+
}, [n, c, e, t, s, i, r, f, h]);
|
|
698
|
+
return /* @__PURE__ */ y.createElement(A, { title: o.operation_save_title, icon: "icon-save", onClick: a });
|
|
1208
699
|
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
onClick,
|
|
1221
|
-
__self: this,
|
|
1222
|
-
__source: {
|
|
1223
|
-
fileName: _jsxFileName$d,
|
|
1224
|
-
lineNumber: 15,
|
|
1225
|
-
columnNumber: 5
|
|
700
|
+
function Oe() {
|
|
701
|
+
const e = O(), [t, s] = H(), i = g(() => {
|
|
702
|
+
s.redo();
|
|
703
|
+
}, [s]);
|
|
704
|
+
return /* @__PURE__ */ y.createElement(
|
|
705
|
+
A,
|
|
706
|
+
{
|
|
707
|
+
title: e.operation_redo_title,
|
|
708
|
+
icon: "icon-redo",
|
|
709
|
+
disabled: !t.stack.length || t.stack.length - 1 === t.index,
|
|
710
|
+
onClick: i
|
|
1226
711
|
}
|
|
1227
|
-
|
|
712
|
+
);
|
|
1228
713
|
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
onClick,
|
|
1241
|
-
__self: this,
|
|
1242
|
-
__source: {
|
|
1243
|
-
fileName: _jsxFileName$c,
|
|
1244
|
-
lineNumber: 15,
|
|
1245
|
-
columnNumber: 5
|
|
714
|
+
function Ve() {
|
|
715
|
+
const e = O(), [t, s] = H(), i = g(() => {
|
|
716
|
+
s.undo();
|
|
717
|
+
}, [s]);
|
|
718
|
+
return /* @__PURE__ */ y.createElement(
|
|
719
|
+
A,
|
|
720
|
+
{
|
|
721
|
+
title: e.operation_undo_title,
|
|
722
|
+
icon: "icon-undo",
|
|
723
|
+
disabled: t.index === -1,
|
|
724
|
+
onClick: i
|
|
1246
725
|
}
|
|
1247
|
-
|
|
726
|
+
);
|
|
1248
727
|
}
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
lineNumber: 12,
|
|
1262
|
-
columnNumber: 5
|
|
1263
|
-
}
|
|
1264
|
-
}, sizes2.map((size) => {
|
|
1265
|
-
const classNames = ["screenshots-size-item"];
|
|
1266
|
-
if (size === value) {
|
|
1267
|
-
classNames.push("screenshots-size-active");
|
|
1268
|
-
}
|
|
1269
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
1270
|
-
key: size,
|
|
1271
|
-
className: classNames.join(" "),
|
|
1272
|
-
onClick: () => onChange && onChange(size),
|
|
1273
|
-
__self: this,
|
|
1274
|
-
__source: {
|
|
1275
|
-
fileName: _jsxFileName$b,
|
|
1276
|
-
lineNumber: 21,
|
|
1277
|
-
columnNumber: 11
|
|
1278
|
-
}
|
|
1279
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
1280
|
-
className: "screenshots-size-pointer",
|
|
1281
|
-
style: {
|
|
1282
|
-
width: size * 1.8,
|
|
1283
|
-
height: size * 1.8
|
|
1284
|
-
},
|
|
1285
|
-
__self: this,
|
|
1286
|
-
__source: {
|
|
1287
|
-
fileName: _jsxFileName$b,
|
|
1288
|
-
lineNumber: 22,
|
|
1289
|
-
columnNumber: 13
|
|
728
|
+
const Se = F(function({ value: t, onChange: s }) {
|
|
729
|
+
const i = [3, 6, 9];
|
|
730
|
+
return /* @__PURE__ */ y.createElement("div", { className: "screenshots-size" }, i.map((r) => {
|
|
731
|
+
const o = ["screenshots-size-item"];
|
|
732
|
+
return r === t && o.push("screenshots-size-active"), /* @__PURE__ */ y.createElement("div", { key: r, className: o.join(" "), onClick: () => s && s(r) }, /* @__PURE__ */ y.createElement(
|
|
733
|
+
"div",
|
|
734
|
+
{
|
|
735
|
+
className: "screenshots-size-pointer",
|
|
736
|
+
style: {
|
|
737
|
+
width: r * 1.8,
|
|
738
|
+
height: r * 1.8
|
|
739
|
+
}
|
|
1290
740
|
}
|
|
1291
|
-
|
|
741
|
+
));
|
|
1292
742
|
}));
|
|
1293
743
|
});
|
|
1294
|
-
function
|
|
1295
|
-
const
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
emiter.off("mousedown", onMousedown);
|
|
1300
|
-
};
|
|
1301
|
-
}, [onMousedown, emiter]);
|
|
744
|
+
function ee(e) {
|
|
745
|
+
const t = Z();
|
|
746
|
+
T(() => (t.on("mousedown", e), () => {
|
|
747
|
+
t.off("mousedown", e);
|
|
748
|
+
}), [e, t]);
|
|
1302
749
|
}
|
|
1303
|
-
function
|
|
1304
|
-
const
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
emiter.off("mousemove", onMousemove);
|
|
1309
|
-
};
|
|
1310
|
-
}, [onMousemove, emiter]);
|
|
750
|
+
function te(e) {
|
|
751
|
+
const t = Z();
|
|
752
|
+
T(() => (t.on("mousemove", e), () => {
|
|
753
|
+
t.off("mousemove", e);
|
|
754
|
+
}), [e, t]);
|
|
1311
755
|
}
|
|
1312
|
-
function
|
|
1313
|
-
const
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
emiter.off("mouseup", onMouseup);
|
|
1318
|
-
};
|
|
1319
|
-
}, [onMouseup, emiter]);
|
|
756
|
+
function ne(e) {
|
|
757
|
+
const t = Z();
|
|
758
|
+
T(() => (t.on("mouseup", e), () => {
|
|
759
|
+
t.off("mouseup", e);
|
|
760
|
+
}), [e, t]);
|
|
1320
761
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
if (!imageData) {
|
|
762
|
+
function le(e, t, s) {
|
|
763
|
+
if (!s)
|
|
1324
764
|
return [0, 0, 0, 0];
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
data,
|
|
1328
|
-
width
|
|
1329
|
-
} = imageData;
|
|
1330
|
-
const index2 = y * width * 4 + x * 4;
|
|
1331
|
-
return Array.from(data.slice(index2, index2 + 4));
|
|
765
|
+
const { data: i, width: r } = s, o = t * r * 4 + e * 4;
|
|
766
|
+
return Array.from(i.slice(o, o + 4));
|
|
1332
767
|
}
|
|
1333
|
-
function
|
|
1334
|
-
const {
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
tiles.forEach((tile) => {
|
|
1339
|
-
const r = Math.round(tile.color[0]);
|
|
1340
|
-
const g = Math.round(tile.color[1]);
|
|
1341
|
-
const b = Math.round(tile.color[2]);
|
|
1342
|
-
const a = tile.color[3] / 255;
|
|
1343
|
-
ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${a})`;
|
|
1344
|
-
ctx.fillRect(tile.x - size / 2, tile.y - size / 2, size, size);
|
|
768
|
+
function je(e, t) {
|
|
769
|
+
const { tiles: s, size: i } = t.data;
|
|
770
|
+
s.forEach((r) => {
|
|
771
|
+
const o = Math.round(r.color[0]), n = Math.round(r.color[1]), c = Math.round(r.color[2]), f = r.color[3] / 255;
|
|
772
|
+
e.fillStyle = `rgba(${o}, ${n}, ${c}, ${f})`, e.fillRect(r.x - i / 2, r.y - i / 2, i, i);
|
|
1345
773
|
});
|
|
1346
774
|
}
|
|
1347
|
-
function
|
|
1348
|
-
const
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
const y = e.clientY - rect.y;
|
|
1404
|
-
const mosaicSize = mosaicRef.current.data.size;
|
|
1405
|
-
const mosaicTiles = mosaicRef.current.data.tiles;
|
|
1406
|
-
let lastTile = mosaicTiles[mosaicTiles.length - 1];
|
|
1407
|
-
if (!lastTile) {
|
|
1408
|
-
mosaicTiles.push({
|
|
1409
|
-
x,
|
|
1410
|
-
y,
|
|
1411
|
-
color: getColor(x, y, imageDataRef.current)
|
|
1412
|
-
});
|
|
1413
|
-
} else {
|
|
1414
|
-
const dx = lastTile.x - x;
|
|
1415
|
-
const dy = lastTile.y - y;
|
|
1416
|
-
let length = Math.sqrt(dx ** 2 + dy ** 2);
|
|
1417
|
-
const sin = -dy / length;
|
|
1418
|
-
const cos = -dx / length;
|
|
1419
|
-
while (length > mosaicSize) {
|
|
1420
|
-
const cx = Math.floor(lastTile.x + mosaicSize * cos);
|
|
1421
|
-
const cy = Math.floor(lastTile.y + mosaicSize * sin);
|
|
1422
|
-
lastTile = {
|
|
1423
|
-
x: cx,
|
|
1424
|
-
y: cy,
|
|
1425
|
-
color: getColor(cx, cy, imageDataRef.current)
|
|
1426
|
-
};
|
|
1427
|
-
mosaicTiles.push(lastTile);
|
|
1428
|
-
length -= mosaicSize;
|
|
1429
|
-
}
|
|
1430
|
-
if (length > mosaicSize / 2) {
|
|
1431
|
-
mosaicTiles.push({
|
|
1432
|
-
x,
|
|
1433
|
-
y,
|
|
1434
|
-
color: getColor(x, y, imageDataRef.current)
|
|
775
|
+
function Je() {
|
|
776
|
+
const e = O(), { image: t, width: s, height: i } = Y(), [r, o] = J(), n = U(), [c, f] = H(), [h] = K(), [, a] = j(), [l, u] = $(3), d = E(null), p = E(null), w = r === "Mosaic", S = g(() => {
|
|
777
|
+
o.set("Mosaic"), a.set("crosshair");
|
|
778
|
+
}, [o, a]), R = g(() => {
|
|
779
|
+
w || (S(), f.clearSelect());
|
|
780
|
+
}, [w, S, f]), b = g(
|
|
781
|
+
(m) => {
|
|
782
|
+
if (!w || p.current || !d.current || !n.current)
|
|
783
|
+
return;
|
|
784
|
+
const x = n.current.canvas.getBoundingClientRect(), C = m.clientX - x.x, z = m.clientY - x.y, B = l * 2;
|
|
785
|
+
p.current = {
|
|
786
|
+
name: "Mosaic",
|
|
787
|
+
type: _.Source,
|
|
788
|
+
data: {
|
|
789
|
+
size: B,
|
|
790
|
+
tiles: [
|
|
791
|
+
{
|
|
792
|
+
x: C,
|
|
793
|
+
y: z,
|
|
794
|
+
color: le(C, z, d.current)
|
|
795
|
+
}
|
|
796
|
+
]
|
|
797
|
+
},
|
|
798
|
+
editHistory: [],
|
|
799
|
+
draw: je
|
|
800
|
+
};
|
|
801
|
+
},
|
|
802
|
+
[w, l, n]
|
|
803
|
+
), M = g(
|
|
804
|
+
(m) => {
|
|
805
|
+
if (!w || !p.current || !n.current || !d.current)
|
|
806
|
+
return;
|
|
807
|
+
const x = n.current.canvas.getBoundingClientRect(), C = m.clientX - x.x, z = m.clientY - x.y, B = p.current.data.size, D = p.current.data.tiles;
|
|
808
|
+
let k = D[D.length - 1];
|
|
809
|
+
if (!k)
|
|
810
|
+
D.push({
|
|
811
|
+
x: C,
|
|
812
|
+
y: z,
|
|
813
|
+
color: le(C, z, d.current)
|
|
814
|
+
});
|
|
815
|
+
else {
|
|
816
|
+
const ae = k.x - C, P = k.y - z;
|
|
817
|
+
let L = Math.sqrt(ae ** 2 + P ** 2);
|
|
818
|
+
const de = -P / L, me = -ae / L;
|
|
819
|
+
for (; L > B; ) {
|
|
820
|
+
const re = Math.floor(k.x + B * me), oe = Math.floor(k.y + B * de);
|
|
821
|
+
k = {
|
|
822
|
+
x: re,
|
|
823
|
+
y: oe,
|
|
824
|
+
color: le(re, oe, d.current)
|
|
825
|
+
}, D.push(k), L -= B;
|
|
826
|
+
}
|
|
827
|
+
L > B / 2 && D.push({
|
|
828
|
+
x: C,
|
|
829
|
+
y: z,
|
|
830
|
+
color: le(C, z, d.current)
|
|
1435
831
|
});
|
|
1436
832
|
}
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
if (!checked) {
|
|
1446
|
-
return;
|
|
1447
|
-
}
|
|
1448
|
-
mosaicRef.current = null;
|
|
1449
|
-
}, [checked]);
|
|
1450
|
-
useCanvasMousedown(onMousedown);
|
|
1451
|
-
useCanvasMousemove(onMousemove);
|
|
1452
|
-
useCanvasMouseup(onMouseup);
|
|
1453
|
-
useEffect(() => {
|
|
1454
|
-
if (!bounds || !image || !checked) {
|
|
833
|
+
c.top !== p.current ? f.push(p.current) : f.set(c);
|
|
834
|
+
},
|
|
835
|
+
[w, n, c, f]
|
|
836
|
+
), v = g(() => {
|
|
837
|
+
w && (p.current = null);
|
|
838
|
+
}, [w]);
|
|
839
|
+
return ee(b), te(M), ne(v), T(() => {
|
|
840
|
+
if (!h || !t || !w)
|
|
1455
841
|
return;
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
const canvasContext = $canvas.getContext("2d");
|
|
1459
|
-
if (!canvasContext) {
|
|
842
|
+
const m = document.createElement("canvas"), x = m.getContext("2d");
|
|
843
|
+
if (!x)
|
|
1460
844
|
return;
|
|
845
|
+
m.width = h.width, m.height = h.height;
|
|
846
|
+
const C = t.naturalWidth / s, z = t.naturalHeight / i;
|
|
847
|
+
x.drawImage(
|
|
848
|
+
t,
|
|
849
|
+
h.x * C,
|
|
850
|
+
h.y * z,
|
|
851
|
+
h.width * C,
|
|
852
|
+
h.height * z,
|
|
853
|
+
0,
|
|
854
|
+
0,
|
|
855
|
+
h.width,
|
|
856
|
+
h.height
|
|
857
|
+
), d.current = x.getImageData(0, 0, h.width, h.height);
|
|
858
|
+
}, [s, i, h, t, w]), /* @__PURE__ */ y.createElement(
|
|
859
|
+
A,
|
|
860
|
+
{
|
|
861
|
+
title: e.operation_mosaic_title,
|
|
862
|
+
icon: "icon-mosaic",
|
|
863
|
+
checked: w,
|
|
864
|
+
onClick: R,
|
|
865
|
+
option: /* @__PURE__ */ y.createElement(Se, { value: l, onChange: u })
|
|
1461
866
|
}
|
|
1462
|
-
|
|
1463
|
-
$canvas.height = bounds.height;
|
|
1464
|
-
const rx = image.naturalWidth / width;
|
|
1465
|
-
const ry = image.naturalHeight / height;
|
|
1466
|
-
canvasContext.drawImage(image, bounds.x * rx, bounds.y * ry, bounds.width * rx, bounds.height * ry, 0, 0, bounds.width, bounds.height);
|
|
1467
|
-
imageDataRef.current = canvasContext.getImageData(0, 0, bounds.width, bounds.height);
|
|
1468
|
-
}, [width, height, bounds, image, checked]);
|
|
1469
|
-
return /* @__PURE__ */ React.createElement(ScreenshotsButton, {
|
|
1470
|
-
title: lang.operation_mosaic_title,
|
|
1471
|
-
icon: "icon-mosaic",
|
|
1472
|
-
checked,
|
|
1473
|
-
onClick: onSelectMosaic,
|
|
1474
|
-
option: /* @__PURE__ */ React.createElement(ScreenshotsSize, {
|
|
1475
|
-
value: size,
|
|
1476
|
-
onChange: setSize,
|
|
1477
|
-
__self: this,
|
|
1478
|
-
__source: {
|
|
1479
|
-
fileName: _jsxFileName$a,
|
|
1480
|
-
lineNumber: 220,
|
|
1481
|
-
columnNumber: 15
|
|
1482
|
-
}
|
|
1483
|
-
}),
|
|
1484
|
-
__self: this,
|
|
1485
|
-
__source: {
|
|
1486
|
-
fileName: _jsxFileName$a,
|
|
1487
|
-
lineNumber: 215,
|
|
1488
|
-
columnNumber: 5
|
|
1489
|
-
}
|
|
1490
|
-
});
|
|
867
|
+
);
|
|
1491
868
|
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
fileName: _jsxFileName$9,
|
|
1504
|
-
lineNumber: 12,
|
|
1505
|
-
columnNumber: 5
|
|
1506
|
-
}
|
|
1507
|
-
}, colors.map((color) => {
|
|
1508
|
-
const classNames = ["screenshots-color-item"];
|
|
1509
|
-
if (color === value) {
|
|
1510
|
-
classNames.push("screenshots-color-active");
|
|
1511
|
-
}
|
|
1512
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
1513
|
-
key: color,
|
|
1514
|
-
className: classNames.join(" "),
|
|
1515
|
-
style: {
|
|
1516
|
-
backgroundColor: color
|
|
1517
|
-
},
|
|
1518
|
-
onClick: () => onChange && onChange(color),
|
|
1519
|
-
__self: this,
|
|
1520
|
-
__source: {
|
|
1521
|
-
fileName: _jsxFileName$9,
|
|
1522
|
-
lineNumber: 19,
|
|
1523
|
-
columnNumber: 11
|
|
869
|
+
const Ue = F(function({ value: t, onChange: s }) {
|
|
870
|
+
const i = ["#ee5126", "#fceb4d", "#90e746", "#51c0fa", "#7a7a7a", "#ffffff"];
|
|
871
|
+
return /* @__PURE__ */ y.createElement("div", { className: "screenshots-color" }, i.map((r) => {
|
|
872
|
+
const o = ["screenshots-color-item"];
|
|
873
|
+
return r === t && o.push("screenshots-color-active"), /* @__PURE__ */ y.createElement(
|
|
874
|
+
"div",
|
|
875
|
+
{
|
|
876
|
+
key: r,
|
|
877
|
+
className: o.join(" "),
|
|
878
|
+
style: { backgroundColor: r },
|
|
879
|
+
onClick: () => s && s(r)
|
|
1524
880
|
}
|
|
1525
|
-
|
|
881
|
+
);
|
|
1526
882
|
}));
|
|
1527
883
|
});
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
onSizeChange,
|
|
1534
|
-
onColorChange
|
|
884
|
+
const ce = F(function({
|
|
885
|
+
size: t,
|
|
886
|
+
color: s,
|
|
887
|
+
onSizeChange: i,
|
|
888
|
+
onColorChange: r
|
|
1535
889
|
}) {
|
|
1536
|
-
return /* @__PURE__ */
|
|
1537
|
-
|
|
1538
|
-
__self: this,
|
|
1539
|
-
__source: {
|
|
1540
|
-
fileName: _jsxFileName$8,
|
|
1541
|
-
lineNumber: 20,
|
|
1542
|
-
columnNumber: 5
|
|
1543
|
-
}
|
|
1544
|
-
}, /* @__PURE__ */ React.createElement(ScreenshotsSize, {
|
|
1545
|
-
value: size,
|
|
1546
|
-
onChange: onSizeChange,
|
|
1547
|
-
__self: this,
|
|
1548
|
-
__source: {
|
|
1549
|
-
fileName: _jsxFileName$8,
|
|
1550
|
-
lineNumber: 21,
|
|
1551
|
-
columnNumber: 7
|
|
1552
|
-
}
|
|
1553
|
-
}), /* @__PURE__ */ React.createElement(ScreenshotsColor, {
|
|
1554
|
-
value: color,
|
|
1555
|
-
onChange: onColorChange,
|
|
1556
|
-
__self: this,
|
|
1557
|
-
__source: {
|
|
1558
|
-
fileName: _jsxFileName$8,
|
|
1559
|
-
lineNumber: 22,
|
|
1560
|
-
columnNumber: 7
|
|
1561
|
-
}
|
|
1562
|
-
}));
|
|
1563
|
-
});
|
|
1564
|
-
const hiddenTextareaStyle = `
|
|
890
|
+
return /* @__PURE__ */ y.createElement("div", { className: "screenshots-sizecolor" }, /* @__PURE__ */ y.createElement(Se, { value: t, onChange: i }), /* @__PURE__ */ y.createElement(Ue, { value: s, onChange: r }));
|
|
891
|
+
}), qe = `
|
|
1565
892
|
min-width: 0 !important;
|
|
1566
893
|
width: 0 !important;
|
|
1567
894
|
min-height: 0 !important;
|
|
@@ -1572,8 +899,7 @@ position: absolute !important;
|
|
|
1572
899
|
z-index: -1000 !important;
|
|
1573
900
|
top:0 !important;
|
|
1574
901
|
right:0 !important;
|
|
1575
|
-
|
|
1576
|
-
const sizeStyle = [
|
|
902
|
+
`, Ge = [
|
|
1577
903
|
"letter-spacing",
|
|
1578
904
|
"line-height",
|
|
1579
905
|
"padding-top",
|
|
@@ -1592,1575 +918,799 @@ const sizeStyle = [
|
|
|
1592
918
|
"white-space",
|
|
1593
919
|
"word-break"
|
|
1594
920
|
];
|
|
1595
|
-
let
|
|
1596
|
-
function
|
|
1597
|
-
const
|
|
1598
|
-
const boxSizing = style.getPropertyValue("box-sizing") || style.getPropertyValue("-moz-box-sizing") || style.getPropertyValue("-webkit-box-sizing");
|
|
1599
|
-
const paddingSize = parseFloat(style.getPropertyValue("padding-bottom")) + parseFloat(style.getPropertyValue("padding-top"));
|
|
1600
|
-
const borderSize = parseFloat(style.getPropertyValue("border-bottom-width")) + parseFloat(style.getPropertyValue("border-top-width"));
|
|
1601
|
-
const sizingStyle = sizeStyle.map((name) => `${name}:${style.getPropertyValue(name)}`).join(";");
|
|
921
|
+
let V;
|
|
922
|
+
function Qe(e) {
|
|
923
|
+
const t = window.getComputedStyle(e), s = t.getPropertyValue("box-sizing") || t.getPropertyValue("-moz-box-sizing") || t.getPropertyValue("-webkit-box-sizing"), i = parseFloat(t.getPropertyValue("padding-bottom")) + parseFloat(t.getPropertyValue("padding-top")), r = parseFloat(t.getPropertyValue("border-bottom-width")) + parseFloat(t.getPropertyValue("border-top-width"));
|
|
1602
924
|
return {
|
|
1603
|
-
sizingStyle,
|
|
1604
|
-
paddingSize,
|
|
1605
|
-
borderSize,
|
|
1606
|
-
boxSizing
|
|
925
|
+
sizingStyle: Ge.map((n) => `${n}:${t.getPropertyValue(n)}`).join(";"),
|
|
926
|
+
paddingSize: i,
|
|
927
|
+
borderSize: r,
|
|
928
|
+
boxSizing: s
|
|
1607
929
|
};
|
|
1608
930
|
}
|
|
1609
|
-
function
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
document.body.appendChild(hiddenTextarea);
|
|
1614
|
-
}
|
|
1615
|
-
const { paddingSize, borderSize, boxSizing, sizingStyle } = getComputedSizeInfo(textarea);
|
|
1616
|
-
hiddenTextarea.setAttribute(
|
|
931
|
+
function Ke(e, t, s, i) {
|
|
932
|
+
V || (V = document.createElement("textarea"), V.setAttribute("tab-index", "-1"), document.body.appendChild(V));
|
|
933
|
+
const { paddingSize: r, borderSize: o, boxSizing: n, sizingStyle: c } = Qe(e);
|
|
934
|
+
V.setAttribute(
|
|
1617
935
|
"style",
|
|
1618
|
-
`${
|
|
1619
|
-
);
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
width += borderSize;
|
|
1625
|
-
height += borderSize;
|
|
1626
|
-
} else if (boxSizing === "content-box") {
|
|
1627
|
-
width -= paddingSize;
|
|
1628
|
-
height -= paddingSize;
|
|
1629
|
-
}
|
|
1630
|
-
return {
|
|
1631
|
-
width: Math.min(width, maxWidth),
|
|
1632
|
-
height: Math.min(height, maxHeight)
|
|
936
|
+
`${c};${qe};max-width:${s}px;max-height:${i}px`
|
|
937
|
+
), V.value = t || " ";
|
|
938
|
+
let f = V.scrollWidth, h = V.scrollHeight;
|
|
939
|
+
return n === "border-box" ? (f += o, h += o) : n === "content-box" && (f -= r, h -= r), {
|
|
940
|
+
width: Math.min(f, s),
|
|
941
|
+
height: Math.min(h, i)
|
|
1633
942
|
};
|
|
1634
943
|
}
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
onChange,
|
|
1646
|
-
onBlur
|
|
944
|
+
const Ze = F(function({
|
|
945
|
+
x: t,
|
|
946
|
+
y: s,
|
|
947
|
+
maxWidth: i,
|
|
948
|
+
maxHeight: r,
|
|
949
|
+
size: o,
|
|
950
|
+
color: n,
|
|
951
|
+
value: c,
|
|
952
|
+
onChange: f,
|
|
953
|
+
onBlur: h
|
|
1647
954
|
}) {
|
|
1648
|
-
const
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
};
|
|
1658
|
-
useLayoutEffect(() => {
|
|
1659
|
-
if (popoverRef.current) {
|
|
1660
|
-
document.body.appendChild(popoverRef.current);
|
|
1661
|
-
requestAnimationFrame(() => {
|
|
1662
|
-
var _a;
|
|
1663
|
-
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
1664
|
-
});
|
|
1665
|
-
}
|
|
1666
|
-
return () => {
|
|
1667
|
-
var _a;
|
|
1668
|
-
(_a = popoverRef.current) == null ? void 0 : _a.remove();
|
|
1669
|
-
};
|
|
1670
|
-
}, []);
|
|
1671
|
-
useLayoutEffect(() => {
|
|
1672
|
-
if (!textareaRef.current) {
|
|
955
|
+
const a = E(null), l = E(null), [u, d] = $(0), [p, w] = $(0), S = () => (a.current || (a.current = document.createElement("div")), a.current);
|
|
956
|
+
return Q(() => (a.current && (document.body.appendChild(a.current), requestAnimationFrame(() => {
|
|
957
|
+
var R;
|
|
958
|
+
(R = l.current) == null || R.focus();
|
|
959
|
+
})), () => {
|
|
960
|
+
var R;
|
|
961
|
+
(R = a.current) == null || R.remove();
|
|
962
|
+
}), []), Q(() => {
|
|
963
|
+
if (!l.current)
|
|
1673
964
|
return;
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
__source: {
|
|
1700
|
-
fileName: _jsxFileName$7,
|
|
1701
|
-
lineNumber: 65,
|
|
1702
|
-
columnNumber: 5
|
|
1703
|
-
}
|
|
1704
|
-
}), getPopoverEl());
|
|
965
|
+
const { width: R, height: b } = Ke(l.current, c, i, r);
|
|
966
|
+
d(R), w(b);
|
|
967
|
+
}, [c, i, r]), we(
|
|
968
|
+
/* @__PURE__ */ y.createElement(
|
|
969
|
+
"textarea",
|
|
970
|
+
{
|
|
971
|
+
ref: l,
|
|
972
|
+
className: "screenshots-textarea",
|
|
973
|
+
style: {
|
|
974
|
+
color: n,
|
|
975
|
+
width: u,
|
|
976
|
+
height: p,
|
|
977
|
+
maxWidth: i,
|
|
978
|
+
maxHeight: r,
|
|
979
|
+
fontSize: o,
|
|
980
|
+
lineHeight: `${o}px`,
|
|
981
|
+
transform: `translate(${t}px, ${s}px)`
|
|
982
|
+
},
|
|
983
|
+
value: c,
|
|
984
|
+
onChange: (R) => f && f(R.target.value),
|
|
985
|
+
onBlur: (R) => h && h(R)
|
|
986
|
+
}
|
|
987
|
+
),
|
|
988
|
+
S()
|
|
989
|
+
);
|
|
1705
990
|
});
|
|
1706
|
-
function
|
|
1707
|
-
const
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
emiter.off("drawselect", onDrawSelect);
|
|
1712
|
-
};
|
|
1713
|
-
}, [onDrawSelect, emiter]);
|
|
991
|
+
function ie(e) {
|
|
992
|
+
const t = Z();
|
|
993
|
+
T(() => (t.on("drawselect", e), () => {
|
|
994
|
+
t.off("drawselect", e);
|
|
995
|
+
}), [e, t]);
|
|
1714
996
|
}
|
|
1715
|
-
|
|
1716
|
-
const sizes = {
|
|
997
|
+
const ge = {
|
|
1717
998
|
3: 18,
|
|
1718
999
|
6: 32,
|
|
1719
1000
|
9: 46
|
|
1720
1001
|
};
|
|
1721
|
-
function
|
|
1722
|
-
const {
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
const distance = action.editHistory.reduce((distance2, {
|
|
1735
|
-
data
|
|
1736
|
-
}) => ({
|
|
1737
|
-
x: distance2.x + data.x2 - data.x1,
|
|
1738
|
-
y: distance2.y + data.y2 - data.y1
|
|
1739
|
-
}), {
|
|
1740
|
-
x: 0,
|
|
1741
|
-
y: 0
|
|
1742
|
-
});
|
|
1743
|
-
text.split("\n").forEach((item, index2) => {
|
|
1744
|
-
ctx.fillText(item, x + distance.x, y + distance.y + index2 * size);
|
|
1002
|
+
function et(e, t) {
|
|
1003
|
+
const { size: s, color: i, fontFamily: r, x: o, y: n, text: c } = t.data;
|
|
1004
|
+
e.fillStyle = i, e.textAlign = "left", e.textBaseline = "top", e.font = `${s}px ${r}`;
|
|
1005
|
+
const f = t.editHistory.reduce(
|
|
1006
|
+
(h, { data: a }) => ({
|
|
1007
|
+
x: h.x + a.x2 - a.x1,
|
|
1008
|
+
y: h.y + a.y2 - a.y1
|
|
1009
|
+
}),
|
|
1010
|
+
{ x: 0, y: 0 }
|
|
1011
|
+
);
|
|
1012
|
+
c.split(`
|
|
1013
|
+
`).forEach((h, a) => {
|
|
1014
|
+
e.fillText(h, o + f.x, n + f.y + a * s);
|
|
1745
1015
|
});
|
|
1746
1016
|
}
|
|
1747
|
-
function
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
const measured = ctx.measureText(item);
|
|
1755
|
-
if (width < measured.width) {
|
|
1756
|
-
width = measured.width;
|
|
1757
|
-
}
|
|
1758
|
-
height += action.data.size;
|
|
1759
|
-
});
|
|
1760
|
-
const {
|
|
1761
|
-
x,
|
|
1762
|
-
y
|
|
1763
|
-
} = action.editHistory.reduce((distance, {
|
|
1764
|
-
data
|
|
1765
|
-
}) => ({
|
|
1766
|
-
x: distance.x + data.x2 - data.x1,
|
|
1767
|
-
y: distance.y + data.y2 - data.y1
|
|
1768
|
-
}), {
|
|
1769
|
-
x: 0,
|
|
1770
|
-
y: 0
|
|
1017
|
+
function tt(e, t, s) {
|
|
1018
|
+
e.textAlign = "left", e.textBaseline = "top", e.font = `${t.data.size}px ${t.data.fontFamily}`;
|
|
1019
|
+
let i = 0, r = 0;
|
|
1020
|
+
t.data.text.split(`
|
|
1021
|
+
`).forEach((l) => {
|
|
1022
|
+
const u = e.measureText(l);
|
|
1023
|
+
i < u.width && (i = u.width), r += t.data.size;
|
|
1771
1024
|
});
|
|
1772
|
-
const
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
return point.x >= left && point.x <= right && point.y >= top && point.y <= bottom;
|
|
1777
|
-
}
|
|
1778
|
-
function Text() {
|
|
1779
|
-
const lang = useLang();
|
|
1780
|
-
const [history, historyDispatcher] = useHistory();
|
|
1781
|
-
const [bounds] = useBounds();
|
|
1782
|
-
const [operation, operationDispatcher] = useOperation();
|
|
1783
|
-
const [, cursorDispatcher] = useCursor();
|
|
1784
|
-
const canvasContextRef = useCanvasContextRef();
|
|
1785
|
-
const [size, setSize] = useState(3);
|
|
1786
|
-
const [color, setColor] = useState("#ee5126");
|
|
1787
|
-
const textRef = useRef(null);
|
|
1788
|
-
const textEditRef = useRef(null);
|
|
1789
|
-
const [textareaBounds, setTextareaBounds] = useState(null);
|
|
1790
|
-
const [text, setText] = useState("");
|
|
1791
|
-
const checked = operation === "Text";
|
|
1792
|
-
const selectText = useCallback(() => {
|
|
1793
|
-
operationDispatcher.set("Text");
|
|
1794
|
-
cursorDispatcher.set("default");
|
|
1795
|
-
}, [operationDispatcher, cursorDispatcher]);
|
|
1796
|
-
const onSelectText = useCallback(() => {
|
|
1797
|
-
if (checked) {
|
|
1798
|
-
return;
|
|
1799
|
-
}
|
|
1800
|
-
selectText();
|
|
1801
|
-
historyDispatcher.clearSelect();
|
|
1802
|
-
}, [checked, selectText, historyDispatcher]);
|
|
1803
|
-
const onSizeChange = useCallback((size2) => {
|
|
1804
|
-
if (textRef.current) {
|
|
1805
|
-
textRef.current.data.size = sizes[size2];
|
|
1806
|
-
}
|
|
1807
|
-
setSize(size2);
|
|
1808
|
-
}, []);
|
|
1809
|
-
const onColorChange = useCallback((color2) => {
|
|
1810
|
-
if (textRef.current) {
|
|
1811
|
-
textRef.current.data.color = color2;
|
|
1812
|
-
}
|
|
1813
|
-
setColor(color2);
|
|
1814
|
-
}, []);
|
|
1815
|
-
const onTextareaChange = useCallback((value) => {
|
|
1816
|
-
setText(value);
|
|
1817
|
-
if (checked && textRef.current) {
|
|
1818
|
-
textRef.current.data.text = value;
|
|
1819
|
-
}
|
|
1820
|
-
}, [checked]);
|
|
1821
|
-
const onTextareaBlur = useCallback(() => {
|
|
1822
|
-
if (textRef.current && textRef.current.data.text) {
|
|
1823
|
-
historyDispatcher.push(textRef.current);
|
|
1824
|
-
}
|
|
1825
|
-
textRef.current = null;
|
|
1826
|
-
setText("");
|
|
1827
|
-
setTextareaBounds(null);
|
|
1828
|
-
}, [historyDispatcher]);
|
|
1829
|
-
const onDrawSelect = useCallback((action, e) => {
|
|
1830
|
-
if (action.name !== "Text") {
|
|
1831
|
-
return;
|
|
1832
|
-
}
|
|
1833
|
-
selectText();
|
|
1834
|
-
textEditRef.current = {
|
|
1835
|
-
type: HistoryItemType.Edit,
|
|
1836
|
-
data: {
|
|
1837
|
-
x1: e.clientX,
|
|
1838
|
-
y1: e.clientY,
|
|
1839
|
-
x2: e.clientX,
|
|
1840
|
-
y2: e.clientY
|
|
1841
|
-
},
|
|
1842
|
-
source: action
|
|
1843
|
-
};
|
|
1844
|
-
historyDispatcher.select(action);
|
|
1845
|
-
}, [selectText, historyDispatcher]);
|
|
1846
|
-
const onMousedown = useCallback((e) => {
|
|
1847
|
-
if (!checked || !canvasContextRef.current || textRef.current || !bounds) {
|
|
1848
|
-
return;
|
|
1849
|
-
}
|
|
1850
|
-
const {
|
|
1851
|
-
left,
|
|
1852
|
-
top
|
|
1853
|
-
} = canvasContextRef.current.canvas.getBoundingClientRect();
|
|
1854
|
-
const fontFamily = window.getComputedStyle(canvasContextRef.current.canvas).fontFamily;
|
|
1855
|
-
const x = e.clientX - left;
|
|
1856
|
-
const y = e.clientY - top;
|
|
1857
|
-
textRef.current = {
|
|
1858
|
-
name: "Text",
|
|
1859
|
-
type: HistoryItemType.Source,
|
|
1860
|
-
data: {
|
|
1861
|
-
size: sizes[size],
|
|
1862
|
-
color,
|
|
1863
|
-
fontFamily,
|
|
1864
|
-
x,
|
|
1865
|
-
y,
|
|
1866
|
-
text: ""
|
|
1867
|
-
},
|
|
1868
|
-
editHistory: [],
|
|
1869
|
-
draw: draw$4,
|
|
1870
|
-
isHit: isHit$1
|
|
1871
|
-
};
|
|
1872
|
-
setTextareaBounds({
|
|
1873
|
-
x: e.clientX,
|
|
1874
|
-
y: e.clientY,
|
|
1875
|
-
maxWidth: bounds.width - x,
|
|
1876
|
-
maxHeight: bounds.height - y
|
|
1877
|
-
});
|
|
1878
|
-
}, [checked, size, color, bounds, canvasContextRef]);
|
|
1879
|
-
const onMousemove = useCallback((e) => {
|
|
1880
|
-
if (!checked) {
|
|
1881
|
-
return;
|
|
1882
|
-
}
|
|
1883
|
-
if (textEditRef.current) {
|
|
1884
|
-
textEditRef.current.data.x2 = e.clientX;
|
|
1885
|
-
textEditRef.current.data.y2 = e.clientY;
|
|
1886
|
-
if (history.top !== textEditRef.current) {
|
|
1887
|
-
textEditRef.current.source.editHistory.push(textEditRef.current);
|
|
1888
|
-
historyDispatcher.push(textEditRef.current);
|
|
1889
|
-
} else {
|
|
1890
|
-
historyDispatcher.set(history);
|
|
1891
|
-
}
|
|
1892
|
-
}
|
|
1893
|
-
}, [checked, history, historyDispatcher]);
|
|
1894
|
-
const onMouseup = useCallback(() => {
|
|
1895
|
-
if (!checked) {
|
|
1896
|
-
return;
|
|
1897
|
-
}
|
|
1898
|
-
textEditRef.current = null;
|
|
1899
|
-
}, [checked]);
|
|
1900
|
-
useDrawSelect(onDrawSelect);
|
|
1901
|
-
useCanvasMousedown(onMousedown);
|
|
1902
|
-
useCanvasMousemove(onMousemove);
|
|
1903
|
-
useCanvasMouseup(onMouseup);
|
|
1904
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ScreenshotsButton, {
|
|
1905
|
-
title: lang.operation_text_title,
|
|
1906
|
-
icon: "icon-text",
|
|
1907
|
-
checked,
|
|
1908
|
-
onClick: onSelectText,
|
|
1909
|
-
option: /* @__PURE__ */ React.createElement(ScreenshotsSizeColor, {
|
|
1910
|
-
size,
|
|
1911
|
-
color,
|
|
1912
|
-
onSizeChange,
|
|
1913
|
-
onColorChange,
|
|
1914
|
-
__self: this,
|
|
1915
|
-
__source: {
|
|
1916
|
-
fileName: _jsxFileName$6,
|
|
1917
|
-
lineNumber: 261,
|
|
1918
|
-
columnNumber: 11
|
|
1919
|
-
}
|
|
1025
|
+
const { x: o, y: n } = t.editHistory.reduce(
|
|
1026
|
+
(l, { data: u }) => ({
|
|
1027
|
+
x: l.x + u.x2 - u.x1,
|
|
1028
|
+
y: l.y + u.y2 - u.y1
|
|
1920
1029
|
}),
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1030
|
+
{ x: 0, y: 0 }
|
|
1031
|
+
), c = t.data.x + o, f = t.data.y + n, h = c + i, a = f + r;
|
|
1032
|
+
return s.x >= c && s.x <= h && s.y >= f && s.y <= a;
|
|
1033
|
+
}
|
|
1034
|
+
function nt() {
|
|
1035
|
+
const e = O(), [t, s] = H(), [i] = K(), [r, o] = J(), [, n] = j(), c = U(), [f, h] = $(3), [a, l] = $("#ee5126"), u = E(
|
|
1036
|
+
null
|
|
1037
|
+
), d = E(
|
|
1038
|
+
null
|
|
1039
|
+
), [p, w] = $(
|
|
1040
|
+
null
|
|
1041
|
+
), [S, R] = $(""), b = r === "Text", M = g(() => {
|
|
1042
|
+
o.set("Text"), n.set("default");
|
|
1043
|
+
}, [o, n]), v = g(() => {
|
|
1044
|
+
b || (M(), s.clearSelect());
|
|
1045
|
+
}, [b, M, s]), m = g((P) => {
|
|
1046
|
+
u.current && (u.current.data.size = ge[P]), h(P);
|
|
1047
|
+
}, []), x = g((P) => {
|
|
1048
|
+
u.current && (u.current.data.color = P), l(P);
|
|
1049
|
+
}, []), C = g(
|
|
1050
|
+
(P) => {
|
|
1051
|
+
R(P), b && u.current && (u.current.data.text = P);
|
|
1052
|
+
},
|
|
1053
|
+
[b]
|
|
1054
|
+
), z = g(() => {
|
|
1055
|
+
u.current && u.current.data.text && s.push(u.current), u.current = null, R(""), w(null);
|
|
1056
|
+
}, [s]), B = g(
|
|
1057
|
+
(P, L) => {
|
|
1058
|
+
P.name === "Text" && (M(), d.current = {
|
|
1059
|
+
type: _.Edit,
|
|
1060
|
+
data: {
|
|
1061
|
+
x1: L.clientX,
|
|
1062
|
+
y1: L.clientY,
|
|
1063
|
+
x2: L.clientX,
|
|
1064
|
+
y2: L.clientY
|
|
1065
|
+
},
|
|
1066
|
+
source: P
|
|
1067
|
+
}, s.select(P));
|
|
1068
|
+
},
|
|
1069
|
+
[M, s]
|
|
1070
|
+
), D = g(
|
|
1071
|
+
(P) => {
|
|
1072
|
+
if (!b || !c.current || u.current || !i)
|
|
1073
|
+
return;
|
|
1074
|
+
const { left: L, top: de } = c.current.canvas.getBoundingClientRect(), me = window.getComputedStyle(
|
|
1075
|
+
c.current.canvas
|
|
1076
|
+
).fontFamily, re = P.clientX - L, oe = P.clientY - de;
|
|
1077
|
+
u.current = {
|
|
1078
|
+
name: "Text",
|
|
1079
|
+
type: _.Source,
|
|
1080
|
+
data: {
|
|
1081
|
+
size: ge[f],
|
|
1082
|
+
color: a,
|
|
1083
|
+
fontFamily: me,
|
|
1084
|
+
x: re,
|
|
1085
|
+
y: oe,
|
|
1086
|
+
text: ""
|
|
1087
|
+
},
|
|
1088
|
+
editHistory: [],
|
|
1089
|
+
draw: et,
|
|
1090
|
+
isHit: tt
|
|
1091
|
+
}, w({
|
|
1092
|
+
x: P.clientX,
|
|
1093
|
+
y: P.clientY,
|
|
1094
|
+
maxWidth: i.width - re,
|
|
1095
|
+
maxHeight: i.height - oe
|
|
1096
|
+
});
|
|
1097
|
+
},
|
|
1098
|
+
[b, f, a, i, c]
|
|
1099
|
+
), k = g(
|
|
1100
|
+
(P) => {
|
|
1101
|
+
b && d.current && (d.current.data.x2 = P.clientX, d.current.data.y2 = P.clientY, t.top !== d.current ? (d.current.source.editHistory.push(d.current), s.push(d.current)) : s.set(t));
|
|
1102
|
+
},
|
|
1103
|
+
[b, t, s]
|
|
1104
|
+
), ae = g(() => {
|
|
1105
|
+
b && (d.current = null);
|
|
1106
|
+
}, [b]);
|
|
1107
|
+
return ie(B), ee(D), te(k), ne(ae), /* @__PURE__ */ y.createElement(y.Fragment, null, /* @__PURE__ */ y.createElement(
|
|
1108
|
+
A,
|
|
1109
|
+
{
|
|
1110
|
+
title: e.operation_text_title,
|
|
1111
|
+
icon: "icon-text",
|
|
1112
|
+
checked: b,
|
|
1113
|
+
onClick: v,
|
|
1114
|
+
option: /* @__PURE__ */ y.createElement(
|
|
1115
|
+
ce,
|
|
1116
|
+
{
|
|
1117
|
+
size: f,
|
|
1118
|
+
color: a,
|
|
1119
|
+
onSizeChange: m,
|
|
1120
|
+
onColorChange: x
|
|
1121
|
+
}
|
|
1122
|
+
)
|
|
1942
1123
|
}
|
|
1943
|
-
|
|
1124
|
+
), b && p && /* @__PURE__ */ y.createElement(
|
|
1125
|
+
Ze,
|
|
1126
|
+
{
|
|
1127
|
+
x: p.x,
|
|
1128
|
+
y: p.y,
|
|
1129
|
+
maxWidth: p.maxWidth,
|
|
1130
|
+
maxHeight: p.maxHeight,
|
|
1131
|
+
size: ge[f],
|
|
1132
|
+
color: a,
|
|
1133
|
+
value: S,
|
|
1134
|
+
onChange: C,
|
|
1135
|
+
onBlur: z
|
|
1136
|
+
}
|
|
1137
|
+
));
|
|
1944
1138
|
}
|
|
1945
|
-
const
|
|
1946
|
-
function
|
|
1947
|
-
|
|
1948
|
-
ctx.strokeStyle = "#000000";
|
|
1949
|
-
ctx.fillStyle = "#ffffff";
|
|
1950
|
-
ctx.beginPath();
|
|
1951
|
-
ctx.arc(x, y, CircleRadius, 0, 2 * Math.PI);
|
|
1952
|
-
ctx.fill();
|
|
1953
|
-
ctx.stroke();
|
|
1139
|
+
const Ce = 4;
|
|
1140
|
+
function X(e, t, s) {
|
|
1141
|
+
e.lineWidth = 1, e.strokeStyle = "#000000", e.fillStyle = "#ffffff", e.beginPath(), e.arc(t, s, Ce, 0, 2 * Math.PI), e.fill(), e.stroke();
|
|
1954
1142
|
}
|
|
1955
|
-
function
|
|
1956
|
-
|
|
1957
|
-
const { data } =
|
|
1958
|
-
return
|
|
1143
|
+
function he(e, t, s) {
|
|
1144
|
+
t.draw(e, t);
|
|
1145
|
+
const { data: i } = e.getImageData(s.x, s.y, 1, 1);
|
|
1146
|
+
return i.some((r) => r !== 0);
|
|
1959
1147
|
}
|
|
1960
|
-
function
|
|
1961
|
-
if (!
|
|
1962
|
-
return
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
const x = e.clientX - left;
|
|
1966
|
-
const y = e.clientY - top;
|
|
1967
|
-
return (point.x - x) ** 2 + (point.y - y) ** 2 < CircleRadius ** 2;
|
|
1148
|
+
function N(e, t, s) {
|
|
1149
|
+
if (!e)
|
|
1150
|
+
return !1;
|
|
1151
|
+
const { left: i, top: r } = e.getBoundingClientRect(), o = t.clientX - i, n = t.clientY - r;
|
|
1152
|
+
return (s.x - o) ** 2 + (s.y - n) ** 2 < Ce ** 2;
|
|
1968
1153
|
}
|
|
1969
|
-
function
|
|
1970
|
-
const { size, color, points } =
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
(distance2, { data }) => ({
|
|
1977
|
-
x: distance2.x + data.x2 - data.x1,
|
|
1978
|
-
y: distance2.y + data.y2 - data.y1
|
|
1154
|
+
function rt(e, t) {
|
|
1155
|
+
const { size: s, color: i, points: r } = t.data;
|
|
1156
|
+
e.lineCap = "round", e.lineJoin = "round", e.lineWidth = s, e.strokeStyle = i;
|
|
1157
|
+
const o = t.editHistory.reduce(
|
|
1158
|
+
(n, { data: c }) => ({
|
|
1159
|
+
x: n.x + c.x2 - c.x1,
|
|
1160
|
+
y: n.y + c.y2 - c.y1
|
|
1979
1161
|
}),
|
|
1980
1162
|
{ x: 0, y: 0 }
|
|
1981
1163
|
);
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
ctx.lineTo(item.x + distance.x, item.y + distance.y);
|
|
1988
|
-
}
|
|
1989
|
-
});
|
|
1990
|
-
ctx.stroke();
|
|
1991
|
-
if (action.isSelected) {
|
|
1992
|
-
ctx.lineWidth = 1;
|
|
1993
|
-
ctx.strokeStyle = "#000000";
|
|
1994
|
-
ctx.beginPath();
|
|
1995
|
-
points.forEach((item, index2) => {
|
|
1996
|
-
if (index2 === 0) {
|
|
1997
|
-
ctx.moveTo(item.x + distance.x, item.y + distance.y);
|
|
1998
|
-
} else {
|
|
1999
|
-
ctx.lineTo(item.x + distance.x, item.y + distance.y);
|
|
2000
|
-
}
|
|
2001
|
-
});
|
|
2002
|
-
ctx.stroke();
|
|
2003
|
-
}
|
|
1164
|
+
e.beginPath(), r.forEach((n, c) => {
|
|
1165
|
+
c === 0 ? e.moveTo(n.x + o.x, n.y + o.y) : e.lineTo(n.x + o.x, n.y + o.y);
|
|
1166
|
+
}), e.stroke(), t.isSelected && (e.lineWidth = 1, e.strokeStyle = "#000000", e.beginPath(), r.forEach((n, c) => {
|
|
1167
|
+
c === 0 ? e.moveTo(n.x + o.x, n.y + o.y) : e.lineTo(n.x + o.x, n.y + o.y);
|
|
1168
|
+
}), e.stroke());
|
|
2004
1169
|
}
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
x: e.clientX - left,
|
|
2061
|
-
y: e.clientY - top
|
|
2062
|
-
}]
|
|
2063
|
-
},
|
|
2064
|
-
editHistory: [],
|
|
2065
|
-
draw: draw$3,
|
|
2066
|
-
isHit
|
|
2067
|
-
};
|
|
2068
|
-
}, [checked, canvasContextRef, size, color]);
|
|
2069
|
-
const onMousemove = useCallback((e) => {
|
|
2070
|
-
if (!checked || !canvasContextRef.current) {
|
|
2071
|
-
return;
|
|
2072
|
-
}
|
|
2073
|
-
if (brushEditRef.current) {
|
|
2074
|
-
brushEditRef.current.data.x2 = e.clientX;
|
|
2075
|
-
brushEditRef.current.data.y2 = e.clientY;
|
|
2076
|
-
if (history.top !== brushEditRef.current) {
|
|
2077
|
-
brushEditRef.current.source.editHistory.push(brushEditRef.current);
|
|
2078
|
-
historyDispatcher.push(brushEditRef.current);
|
|
2079
|
-
} else {
|
|
2080
|
-
historyDispatcher.set(history);
|
|
2081
|
-
}
|
|
2082
|
-
} else if (brushRef.current) {
|
|
2083
|
-
const {
|
|
2084
|
-
left,
|
|
2085
|
-
top
|
|
2086
|
-
} = canvasContextRef.current.canvas.getBoundingClientRect();
|
|
2087
|
-
brushRef.current.data.points.push({
|
|
2088
|
-
x: e.clientX - left,
|
|
2089
|
-
y: e.clientY - top
|
|
2090
|
-
});
|
|
2091
|
-
if (history.top !== brushRef.current) {
|
|
2092
|
-
historyDispatcher.push(brushRef.current);
|
|
2093
|
-
} else {
|
|
2094
|
-
historyDispatcher.set(history);
|
|
2095
|
-
}
|
|
2096
|
-
}
|
|
2097
|
-
}, [checked, history, canvasContextRef, historyDispatcher]);
|
|
2098
|
-
const onMouseup = useCallback(() => {
|
|
2099
|
-
if (!checked) {
|
|
2100
|
-
return;
|
|
2101
|
-
}
|
|
2102
|
-
if (brushRef.current) {
|
|
2103
|
-
historyDispatcher.clearSelect();
|
|
2104
|
-
}
|
|
2105
|
-
brushRef.current = null;
|
|
2106
|
-
brushEditRef.current = null;
|
|
2107
|
-
}, [checked, historyDispatcher]);
|
|
2108
|
-
useDrawSelect(onDrawSelect);
|
|
2109
|
-
useCanvasMousedown(onMousedown);
|
|
2110
|
-
useCanvasMousemove(onMousemove);
|
|
2111
|
-
useCanvasMouseup(onMouseup);
|
|
2112
|
-
return /* @__PURE__ */ React.createElement(ScreenshotsButton, {
|
|
2113
|
-
title: lang.operation_brush_title,
|
|
2114
|
-
icon: "icon-brush",
|
|
2115
|
-
checked,
|
|
2116
|
-
onClick: onSelectBrush,
|
|
2117
|
-
option: /* @__PURE__ */ React.createElement(ScreenshotsSizeColor, {
|
|
2118
|
-
size,
|
|
2119
|
-
color,
|
|
2120
|
-
onSizeChange: setSize,
|
|
2121
|
-
onColorChange: setColor,
|
|
2122
|
-
__self: this,
|
|
2123
|
-
__source: {
|
|
2124
|
-
fileName: _jsxFileName$5,
|
|
2125
|
-
lineNumber: 166,
|
|
2126
|
-
columnNumber: 15
|
|
1170
|
+
function ot() {
|
|
1171
|
+
const e = O(), [, t] = j(), [s, i] = J(), r = U(), [o, n] = H(), [c, f] = $(3), [h, a] = $("#ee5126"), l = E(null), u = E(null), d = s === "Brush", p = g(() => {
|
|
1172
|
+
i.set("Brush"), t.set("default");
|
|
1173
|
+
}, [i, t]), w = g(() => {
|
|
1174
|
+
d || (p(), n.clearSelect());
|
|
1175
|
+
}, [d, p, n]), S = g(
|
|
1176
|
+
(v, m) => {
|
|
1177
|
+
v.name === "Brush" && (p(), u.current = {
|
|
1178
|
+
type: _.Edit,
|
|
1179
|
+
data: {
|
|
1180
|
+
x1: m.clientX,
|
|
1181
|
+
y1: m.clientY,
|
|
1182
|
+
x2: m.clientX,
|
|
1183
|
+
y2: m.clientY
|
|
1184
|
+
},
|
|
1185
|
+
source: v
|
|
1186
|
+
}, n.select(v));
|
|
1187
|
+
},
|
|
1188
|
+
[p, n]
|
|
1189
|
+
), R = g(
|
|
1190
|
+
(v) => {
|
|
1191
|
+
if (!d || l.current || !r.current)
|
|
1192
|
+
return;
|
|
1193
|
+
const { left: m, top: x } = r.current.canvas.getBoundingClientRect();
|
|
1194
|
+
l.current = {
|
|
1195
|
+
name: "Brush",
|
|
1196
|
+
type: _.Source,
|
|
1197
|
+
data: {
|
|
1198
|
+
size: c,
|
|
1199
|
+
color: h,
|
|
1200
|
+
points: [
|
|
1201
|
+
{
|
|
1202
|
+
x: v.clientX - m,
|
|
1203
|
+
y: v.clientY - x
|
|
1204
|
+
}
|
|
1205
|
+
]
|
|
1206
|
+
},
|
|
1207
|
+
editHistory: [],
|
|
1208
|
+
draw: rt,
|
|
1209
|
+
isHit: he
|
|
1210
|
+
};
|
|
1211
|
+
},
|
|
1212
|
+
[d, r, c, h]
|
|
1213
|
+
), b = g(
|
|
1214
|
+
(v) => {
|
|
1215
|
+
if (!(!d || !r.current)) {
|
|
1216
|
+
if (u.current)
|
|
1217
|
+
u.current.data.x2 = v.clientX, u.current.data.y2 = v.clientY, o.top !== u.current ? (u.current.source.editHistory.push(u.current), n.push(u.current)) : n.set(o);
|
|
1218
|
+
else if (l.current) {
|
|
1219
|
+
const { left: m, top: x } = r.current.canvas.getBoundingClientRect();
|
|
1220
|
+
l.current.data.points.push({
|
|
1221
|
+
x: v.clientX - m,
|
|
1222
|
+
y: v.clientY - x
|
|
1223
|
+
}), o.top !== l.current ? n.push(l.current) : n.set(o);
|
|
1224
|
+
}
|
|
2127
1225
|
}
|
|
2128
|
-
}
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
1226
|
+
},
|
|
1227
|
+
[d, o, r, n]
|
|
1228
|
+
), M = g(() => {
|
|
1229
|
+
d && (l.current && n.clearSelect(), l.current = null, u.current = null);
|
|
1230
|
+
}, [d, n]);
|
|
1231
|
+
return ie(S), ee(R), te(b), ne(M), /* @__PURE__ */ y.createElement(
|
|
1232
|
+
A,
|
|
1233
|
+
{
|
|
1234
|
+
title: e.operation_brush_title,
|
|
1235
|
+
icon: "icon-brush",
|
|
1236
|
+
checked: d,
|
|
1237
|
+
onClick: w,
|
|
1238
|
+
option: /* @__PURE__ */ y.createElement(ce, { size: c, color: h, onSizeChange: f, onColorChange: a })
|
|
2134
1239
|
}
|
|
2135
|
-
|
|
1240
|
+
);
|
|
2136
1241
|
}
|
|
2137
|
-
function
|
|
2138
|
-
let { x1, y1, x2, y2 } =
|
|
2139
|
-
|
|
2140
|
-
const
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
x1 += x;
|
|
2149
|
-
y1 += y;
|
|
2150
|
-
} else if (data.type === ArrowEditType.MoveEnd) {
|
|
2151
|
-
x2 += x;
|
|
2152
|
-
y2 += y;
|
|
2153
|
-
}
|
|
2154
|
-
});
|
|
2155
|
-
return {
|
|
2156
|
-
...action.data,
|
|
2157
|
-
x1,
|
|
2158
|
-
x2,
|
|
2159
|
-
y1,
|
|
2160
|
-
y2
|
|
1242
|
+
function ze(e) {
|
|
1243
|
+
let { x1: t, y1: s, x2: i, y2: r } = e.data;
|
|
1244
|
+
return e.editHistory.forEach(({ data: o }) => {
|
|
1245
|
+
const n = o.x2 - o.x1, c = o.y2 - o.y1;
|
|
1246
|
+
o.type === ue.Move ? (t += n, s += c, i += n, r += c) : o.type === ue.MoveStart ? (t += n, s += c) : o.type === ue.MoveEnd && (i += n, r += c);
|
|
1247
|
+
}), {
|
|
1248
|
+
...e.data,
|
|
1249
|
+
x1: t,
|
|
1250
|
+
x2: i,
|
|
1251
|
+
y1: s,
|
|
1252
|
+
y2: r
|
|
2161
1253
|
};
|
|
2162
1254
|
}
|
|
2163
|
-
function
|
|
2164
|
-
const { size, color, x1, x2, y1, y2 } =
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
ctx.strokeStyle = color;
|
|
2169
|
-
const dx = x2 - x1;
|
|
2170
|
-
const dy = y2 - y1;
|
|
2171
|
-
const length = size * 3;
|
|
2172
|
-
const angle = Math.atan2(dy, dx);
|
|
2173
|
-
ctx.beginPath();
|
|
2174
|
-
ctx.moveTo(x1, y1);
|
|
2175
|
-
ctx.lineTo(x2, y2);
|
|
2176
|
-
ctx.lineTo(x2 - length * Math.cos(angle - Math.PI / 6), y2 - length * Math.sin(angle - Math.PI / 6));
|
|
2177
|
-
ctx.moveTo(x2, y2);
|
|
2178
|
-
ctx.lineTo(x2 - length * Math.cos(angle + Math.PI / 6), y2 - length * Math.sin(angle + Math.PI / 6));
|
|
2179
|
-
ctx.stroke();
|
|
2180
|
-
if (action.isSelected) {
|
|
2181
|
-
drawDragCircle(ctx, x1, y1);
|
|
2182
|
-
drawDragCircle(ctx, x2, y2);
|
|
2183
|
-
}
|
|
1255
|
+
function st(e, t) {
|
|
1256
|
+
const { size: s, color: i, x1: r, x2: o, y1: n, y2: c } = ze(t);
|
|
1257
|
+
e.lineCap = "round", e.lineJoin = "bevel", e.lineWidth = s, e.strokeStyle = i;
|
|
1258
|
+
const f = o - r, h = c - n, a = s * 3, l = Math.atan2(h, f);
|
|
1259
|
+
e.beginPath(), e.moveTo(r, n), e.lineTo(o, c), e.lineTo(o - a * Math.cos(l - Math.PI / 6), c - a * Math.sin(l - Math.PI / 6)), e.moveTo(o, c), e.lineTo(o - a * Math.cos(l + Math.PI / 6), c - a * Math.sin(l + Math.PI / 6)), e.stroke(), t.isSelected && (X(e, r, n), X(e, o, c));
|
|
2184
1260
|
}
|
|
2185
|
-
var
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
})
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
historyDispatcher.select(action);
|
|
2250
|
-
}, [canvasContextRef, selectArrow, historyDispatcher]);
|
|
2251
|
-
const onMousedown = useCallback((e) => {
|
|
2252
|
-
if (!checked || arrowRef.current || !canvasContextRef.current) {
|
|
2253
|
-
return;
|
|
2254
|
-
}
|
|
2255
|
-
const {
|
|
2256
|
-
left,
|
|
2257
|
-
top
|
|
2258
|
-
} = canvasContextRef.current.canvas.getBoundingClientRect();
|
|
2259
|
-
arrowRef.current = {
|
|
2260
|
-
name: "Arrow",
|
|
2261
|
-
type: HistoryItemType.Source,
|
|
2262
|
-
data: {
|
|
2263
|
-
size,
|
|
2264
|
-
color,
|
|
2265
|
-
x1: e.clientX - left,
|
|
2266
|
-
y1: e.clientY - top,
|
|
2267
|
-
x2: e.clientX - left,
|
|
2268
|
-
y2: e.clientY - top
|
|
2269
|
-
},
|
|
2270
|
-
editHistory: [],
|
|
2271
|
-
draw: draw$2,
|
|
2272
|
-
isHit
|
|
2273
|
-
};
|
|
2274
|
-
}, [checked, color, size, canvasContextRef]);
|
|
2275
|
-
const onMousemove = useCallback((e) => {
|
|
2276
|
-
if (!checked || !canvasContextRef.current) {
|
|
2277
|
-
return;
|
|
2278
|
-
}
|
|
2279
|
-
if (arrowEditRef.current) {
|
|
2280
|
-
arrowEditRef.current.data.x2 = e.clientX;
|
|
2281
|
-
arrowEditRef.current.data.y2 = e.clientY;
|
|
2282
|
-
if (history.top !== arrowEditRef.current) {
|
|
2283
|
-
arrowEditRef.current.source.editHistory.push(arrowEditRef.current);
|
|
2284
|
-
historyDispatcher.push(arrowEditRef.current);
|
|
2285
|
-
} else {
|
|
2286
|
-
historyDispatcher.set(history);
|
|
2287
|
-
}
|
|
2288
|
-
} else if (arrowRef.current) {
|
|
2289
|
-
const {
|
|
2290
|
-
left,
|
|
2291
|
-
top
|
|
2292
|
-
} = canvasContextRef.current.canvas.getBoundingClientRect();
|
|
2293
|
-
arrowRef.current.data.x2 = e.clientX - left;
|
|
2294
|
-
arrowRef.current.data.y2 = e.clientY - top;
|
|
2295
|
-
if (history.top !== arrowRef.current) {
|
|
2296
|
-
historyDispatcher.push(arrowRef.current);
|
|
2297
|
-
} else {
|
|
2298
|
-
historyDispatcher.set(history);
|
|
2299
|
-
}
|
|
2300
|
-
}
|
|
2301
|
-
}, [checked, history, canvasContextRef, historyDispatcher]);
|
|
2302
|
-
const onMouseup = useCallback(() => {
|
|
2303
|
-
if (!checked) {
|
|
2304
|
-
return;
|
|
2305
|
-
}
|
|
2306
|
-
if (arrowRef.current) {
|
|
2307
|
-
historyDispatcher.clearSelect();
|
|
2308
|
-
}
|
|
2309
|
-
arrowRef.current = null;
|
|
2310
|
-
arrowEditRef.current = null;
|
|
2311
|
-
}, [checked, historyDispatcher]);
|
|
2312
|
-
useDrawSelect(onDrawSelect);
|
|
2313
|
-
useCanvasMousedown(onMousedown);
|
|
2314
|
-
useCanvasMousemove(onMousemove);
|
|
2315
|
-
useCanvasMouseup(onMouseup);
|
|
2316
|
-
return /* @__PURE__ */ React.createElement(ScreenshotsButton, {
|
|
2317
|
-
title: lang.operation_arrow_title,
|
|
2318
|
-
icon: "icon-arrow",
|
|
2319
|
-
checked,
|
|
2320
|
-
onClick: onSelectArrow,
|
|
2321
|
-
option: /* @__PURE__ */ React.createElement(ScreenshotsSizeColor, {
|
|
2322
|
-
size,
|
|
2323
|
-
color,
|
|
2324
|
-
onSizeChange: setSize,
|
|
2325
|
-
onColorChange: setColor,
|
|
2326
|
-
__self: this,
|
|
2327
|
-
__source: {
|
|
2328
|
-
fileName: _jsxFileName$4,
|
|
2329
|
-
lineNumber: 190,
|
|
2330
|
-
columnNumber: 15
|
|
1261
|
+
var ue = /* @__PURE__ */ ((e) => (e[e.Move = 0] = "Move", e[e.MoveStart = 1] = "MoveStart", e[e.MoveEnd = 2] = "MoveEnd", e))(ue || {});
|
|
1262
|
+
function ct() {
|
|
1263
|
+
const e = O(), [, t] = j(), [s, i] = J(), [r, o] = H(), n = U(), [c, f] = $(3), [h, a] = $("#ee5126"), l = E(null), u = E(null), d = s === "Arrow", p = g(() => {
|
|
1264
|
+
i.set("Arrow"), t.set("default");
|
|
1265
|
+
}, [i, t]), w = g(() => {
|
|
1266
|
+
d || (p(), o.clearSelect());
|
|
1267
|
+
}, [d, p, o]), S = g(
|
|
1268
|
+
(v, m) => {
|
|
1269
|
+
if (v.name !== "Arrow" || !n.current)
|
|
1270
|
+
return;
|
|
1271
|
+
const x = v;
|
|
1272
|
+
p();
|
|
1273
|
+
const { x1: C, y1: z, x2: B, y2: D } = ze(x);
|
|
1274
|
+
let k = 0;
|
|
1275
|
+
N(n.current.canvas, m, {
|
|
1276
|
+
x: C,
|
|
1277
|
+
y: z
|
|
1278
|
+
}) ? k = 1 : N(n.current.canvas, m, {
|
|
1279
|
+
x: B,
|
|
1280
|
+
y: D
|
|
1281
|
+
}) && (k = 2), u.current = {
|
|
1282
|
+
type: _.Edit,
|
|
1283
|
+
data: {
|
|
1284
|
+
type: k,
|
|
1285
|
+
x1: m.clientX,
|
|
1286
|
+
y1: m.clientY,
|
|
1287
|
+
x2: m.clientX,
|
|
1288
|
+
y2: m.clientY
|
|
1289
|
+
},
|
|
1290
|
+
source: x
|
|
1291
|
+
}, o.select(v);
|
|
1292
|
+
},
|
|
1293
|
+
[n, p, o]
|
|
1294
|
+
), R = g(
|
|
1295
|
+
(v) => {
|
|
1296
|
+
if (!d || l.current || !n.current)
|
|
1297
|
+
return;
|
|
1298
|
+
const { left: m, top: x } = n.current.canvas.getBoundingClientRect();
|
|
1299
|
+
l.current = {
|
|
1300
|
+
name: "Arrow",
|
|
1301
|
+
type: _.Source,
|
|
1302
|
+
data: {
|
|
1303
|
+
size: c,
|
|
1304
|
+
color: h,
|
|
1305
|
+
x1: v.clientX - m,
|
|
1306
|
+
y1: v.clientY - x,
|
|
1307
|
+
x2: v.clientX - m,
|
|
1308
|
+
y2: v.clientY - x
|
|
1309
|
+
},
|
|
1310
|
+
editHistory: [],
|
|
1311
|
+
draw: st,
|
|
1312
|
+
isHit: he
|
|
1313
|
+
};
|
|
1314
|
+
},
|
|
1315
|
+
[d, h, c, n]
|
|
1316
|
+
), b = g(
|
|
1317
|
+
(v) => {
|
|
1318
|
+
if (!(!d || !n.current)) {
|
|
1319
|
+
if (u.current)
|
|
1320
|
+
u.current.data.x2 = v.clientX, u.current.data.y2 = v.clientY, r.top !== u.current ? (u.current.source.editHistory.push(u.current), o.push(u.current)) : o.set(r);
|
|
1321
|
+
else if (l.current) {
|
|
1322
|
+
const { left: m, top: x } = n.current.canvas.getBoundingClientRect();
|
|
1323
|
+
l.current.data.x2 = v.clientX - m, l.current.data.y2 = v.clientY - x, r.top !== l.current ? o.push(l.current) : o.set(r);
|
|
1324
|
+
}
|
|
2331
1325
|
}
|
|
2332
|
-
}
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
1326
|
+
},
|
|
1327
|
+
[d, r, n, o]
|
|
1328
|
+
), M = g(() => {
|
|
1329
|
+
d && (l.current && o.clearSelect(), l.current = null, u.current = null);
|
|
1330
|
+
}, [d, o]);
|
|
1331
|
+
return ie(S), ee(R), te(b), ne(M), /* @__PURE__ */ y.createElement(
|
|
1332
|
+
A,
|
|
1333
|
+
{
|
|
1334
|
+
title: e.operation_arrow_title,
|
|
1335
|
+
icon: "icon-arrow",
|
|
1336
|
+
checked: d,
|
|
1337
|
+
onClick: w,
|
|
1338
|
+
option: /* @__PURE__ */ y.createElement(ce, { size: c, color: h, onSizeChange: f, onColorChange: a })
|
|
2338
1339
|
}
|
|
2339
|
-
|
|
1340
|
+
);
|
|
2340
1341
|
}
|
|
2341
|
-
function
|
|
2342
|
-
let { x1, y1, x2, y2 } =
|
|
2343
|
-
|
|
2344
|
-
const
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
y1 += y;
|
|
2353
|
-
} else if (data.type === EllipseEditType.ResizeRightTop) {
|
|
2354
|
-
x2 += x;
|
|
2355
|
-
y1 += y;
|
|
2356
|
-
} else if (data.type === EllipseEditType.ResizeRight) {
|
|
2357
|
-
x2 += x;
|
|
2358
|
-
} else if (data.type === EllipseEditType.ResizeRightBottom) {
|
|
2359
|
-
x2 += x;
|
|
2360
|
-
y2 += y;
|
|
2361
|
-
} else if (data.type === EllipseEditType.ResizeBottom) {
|
|
2362
|
-
y2 += y;
|
|
2363
|
-
} else if (data.type === EllipseEditType.ResizeLeftBottom) {
|
|
2364
|
-
x1 += x;
|
|
2365
|
-
y2 += y;
|
|
2366
|
-
} else if (data.type === EllipseEditType.ResizeLeft) {
|
|
2367
|
-
x1 += x;
|
|
2368
|
-
} else if (data.type === EllipseEditType.ResizeLeftTop) {
|
|
2369
|
-
x1 += x;
|
|
2370
|
-
y1 += y;
|
|
2371
|
-
}
|
|
2372
|
-
});
|
|
2373
|
-
return {
|
|
2374
|
-
...action.data,
|
|
2375
|
-
x1,
|
|
2376
|
-
x2,
|
|
2377
|
-
y1,
|
|
2378
|
-
y2
|
|
1342
|
+
function be(e) {
|
|
1343
|
+
let { x1: t, y1: s, x2: i, y2: r } = e.data;
|
|
1344
|
+
return e.editHistory.forEach(({ data: o }) => {
|
|
1345
|
+
const n = o.x2 - o.x1, c = o.y2 - o.y1;
|
|
1346
|
+
o.type === I.Move ? (t += n, s += c, i += n, r += c) : o.type === I.ResizeTop ? s += c : o.type === I.ResizeRightTop ? (i += n, s += c) : o.type === I.ResizeRight ? i += n : o.type === I.ResizeRightBottom ? (i += n, r += c) : o.type === I.ResizeBottom ? r += c : o.type === I.ResizeLeftBottom ? (t += n, r += c) : o.type === I.ResizeLeft ? t += n : o.type === I.ResizeLeftTop && (t += n, s += c);
|
|
1347
|
+
}), {
|
|
1348
|
+
...e.data,
|
|
1349
|
+
x1: t,
|
|
1350
|
+
x2: i,
|
|
1351
|
+
y1: s,
|
|
1352
|
+
y2: r
|
|
2379
1353
|
};
|
|
2380
1354
|
}
|
|
2381
|
-
function
|
|
2382
|
-
const { size, color, x1, y1, x2, y2 } =
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
ctx.strokeStyle = color;
|
|
2387
|
-
const x = (x1 + x2) / 2;
|
|
2388
|
-
const y = (y1 + y2) / 2;
|
|
2389
|
-
const rx = Math.abs(x2 - x1) / 2;
|
|
2390
|
-
const ry = Math.abs(y2 - y1) / 2;
|
|
2391
|
-
const k = 0.5522848;
|
|
2392
|
-
const ox = rx * k;
|
|
2393
|
-
const oy = ry * k;
|
|
2394
|
-
ctx.beginPath();
|
|
2395
|
-
ctx.moveTo(x - rx, y);
|
|
2396
|
-
ctx.bezierCurveTo(x - rx, y - oy, x - ox, y - ry, x, y - ry);
|
|
2397
|
-
ctx.bezierCurveTo(x + ox, y - ry, x + rx, y - oy, x + rx, y);
|
|
2398
|
-
ctx.bezierCurveTo(x + rx, y + oy, x + ox, y + ry, x, y + ry);
|
|
2399
|
-
ctx.bezierCurveTo(x - ox, y + ry, x - rx, y + oy, x - rx, y);
|
|
2400
|
-
ctx.closePath();
|
|
2401
|
-
ctx.stroke();
|
|
2402
|
-
if (action.isSelected) {
|
|
2403
|
-
ctx.lineWidth = 1;
|
|
2404
|
-
ctx.strokeStyle = "#000000";
|
|
2405
|
-
ctx.fillStyle = "#ffffff";
|
|
2406
|
-
ctx.beginPath();
|
|
2407
|
-
ctx.moveTo(x1, y1);
|
|
2408
|
-
ctx.lineTo(x2, y1);
|
|
2409
|
-
ctx.lineTo(x2, y2);
|
|
2410
|
-
ctx.lineTo(x1, y2);
|
|
2411
|
-
ctx.closePath();
|
|
2412
|
-
ctx.stroke();
|
|
2413
|
-
drawDragCircle(ctx, (x1 + x2) / 2, y1);
|
|
2414
|
-
drawDragCircle(ctx, x2, y1);
|
|
2415
|
-
drawDragCircle(ctx, x2, (y1 + y2) / 2);
|
|
2416
|
-
drawDragCircle(ctx, x2, y2);
|
|
2417
|
-
drawDragCircle(ctx, (x1 + x2) / 2, y2);
|
|
2418
|
-
drawDragCircle(ctx, x1, y2);
|
|
2419
|
-
drawDragCircle(ctx, x1, (y1 + y2) / 2);
|
|
2420
|
-
drawDragCircle(ctx, x1, y1);
|
|
2421
|
-
}
|
|
1355
|
+
function it(e, t) {
|
|
1356
|
+
const { size: s, color: i, x1: r, y1: o, x2: n, y2: c } = be(t);
|
|
1357
|
+
e.lineCap = "butt", e.lineJoin = "miter", e.lineWidth = s, e.strokeStyle = i;
|
|
1358
|
+
const f = (r + n) / 2, h = (o + c) / 2, a = Math.abs(n - r) / 2, l = Math.abs(c - o) / 2, u = 0.5522848, d = a * u, p = l * u;
|
|
1359
|
+
e.beginPath(), e.moveTo(f - a, h), e.bezierCurveTo(f - a, h - p, f - d, h - l, f, h - l), e.bezierCurveTo(f + d, h - l, f + a, h - p, f + a, h), e.bezierCurveTo(f + a, h + p, f + d, h + l, f, h + l), e.bezierCurveTo(f - d, h + l, f - a, h + p, f - a, h), e.closePath(), e.stroke(), t.isSelected && (e.lineWidth = 1, e.strokeStyle = "#000000", e.fillStyle = "#ffffff", e.beginPath(), e.moveTo(r, o), e.lineTo(n, o), e.lineTo(n, c), e.lineTo(r, c), e.closePath(), e.stroke(), X(e, (r + n) / 2, o), X(e, n, o), X(e, n, (o + c) / 2), X(e, n, c), X(e, (r + n) / 2, c), X(e, r, c), X(e, r, (o + c) / 2), X(e, r, o));
|
|
2422
1360
|
}
|
|
2423
|
-
var
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
}
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
}
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
type = 7;
|
|
2506
|
-
} else if (isHitCircle(canvasContextRef.current.canvas, e, {
|
|
2507
|
-
x: x1,
|
|
2508
|
-
y: y1
|
|
2509
|
-
})) {
|
|
2510
|
-
type = 8;
|
|
2511
|
-
}
|
|
2512
|
-
ellipseEditRef.current = {
|
|
2513
|
-
type: HistoryItemType.Edit,
|
|
2514
|
-
data: {
|
|
2515
|
-
type,
|
|
2516
|
-
x1: e.clientX,
|
|
2517
|
-
y1: e.clientY,
|
|
2518
|
-
x2: e.clientX,
|
|
2519
|
-
y2: e.clientY
|
|
2520
|
-
},
|
|
2521
|
-
source
|
|
2522
|
-
};
|
|
2523
|
-
historyDispatcher.select(action);
|
|
2524
|
-
}, [canvasContextRef, selectEllipse, historyDispatcher]);
|
|
2525
|
-
const onMousedown = useCallback((e) => {
|
|
2526
|
-
if (!checked || !canvasContextRef.current || ellipseRef.current) {
|
|
2527
|
-
return;
|
|
2528
|
-
}
|
|
2529
|
-
const {
|
|
2530
|
-
left,
|
|
2531
|
-
top
|
|
2532
|
-
} = canvasContextRef.current.canvas.getBoundingClientRect();
|
|
2533
|
-
const x = e.clientX - left;
|
|
2534
|
-
const y = e.clientY - top;
|
|
2535
|
-
ellipseRef.current = {
|
|
2536
|
-
name: "Ellipse",
|
|
2537
|
-
type: HistoryItemType.Source,
|
|
2538
|
-
data: {
|
|
2539
|
-
size,
|
|
2540
|
-
color,
|
|
2541
|
-
x1: x,
|
|
2542
|
-
y1: y,
|
|
2543
|
-
x2: x,
|
|
2544
|
-
y2: y
|
|
2545
|
-
},
|
|
2546
|
-
editHistory: [],
|
|
2547
|
-
draw: draw$1,
|
|
2548
|
-
isHit
|
|
2549
|
-
};
|
|
2550
|
-
}, [checked, size, color, canvasContextRef]);
|
|
2551
|
-
const onMousemove = useCallback((e) => {
|
|
2552
|
-
if (!checked || !canvasContextRef.current) {
|
|
2553
|
-
return;
|
|
2554
|
-
}
|
|
2555
|
-
if (ellipseEditRef.current) {
|
|
2556
|
-
ellipseEditRef.current.data.x2 = e.clientX;
|
|
2557
|
-
ellipseEditRef.current.data.y2 = e.clientY;
|
|
2558
|
-
if (history.top !== ellipseEditRef.current) {
|
|
2559
|
-
ellipseEditRef.current.source.editHistory.push(ellipseEditRef.current);
|
|
2560
|
-
historyDispatcher.push(ellipseEditRef.current);
|
|
2561
|
-
} else {
|
|
2562
|
-
historyDispatcher.set(history);
|
|
2563
|
-
}
|
|
2564
|
-
} else if (ellipseRef.current) {
|
|
2565
|
-
const {
|
|
2566
|
-
left,
|
|
2567
|
-
top
|
|
2568
|
-
} = canvasContextRef.current.canvas.getBoundingClientRect();
|
|
2569
|
-
ellipseRef.current.data.x2 = e.clientX - left;
|
|
2570
|
-
ellipseRef.current.data.y2 = e.clientY - top;
|
|
2571
|
-
if (history.top !== ellipseRef.current) {
|
|
2572
|
-
historyDispatcher.push(ellipseRef.current);
|
|
2573
|
-
} else {
|
|
2574
|
-
historyDispatcher.set(history);
|
|
2575
|
-
}
|
|
2576
|
-
}
|
|
2577
|
-
}, [checked, canvasContextRef, history, historyDispatcher]);
|
|
2578
|
-
const onMouseup = useCallback(() => {
|
|
2579
|
-
if (!checked) {
|
|
2580
|
-
return;
|
|
2581
|
-
}
|
|
2582
|
-
if (ellipseRef.current) {
|
|
2583
|
-
historyDispatcher.clearSelect();
|
|
2584
|
-
}
|
|
2585
|
-
ellipseRef.current = null;
|
|
2586
|
-
ellipseEditRef.current = null;
|
|
2587
|
-
}, [checked, historyDispatcher]);
|
|
2588
|
-
useDrawSelect(onDrawSelect);
|
|
2589
|
-
useCanvasMousedown(onMousedown);
|
|
2590
|
-
useCanvasMousemove(onMousemove);
|
|
2591
|
-
useCanvasMouseup(onMouseup);
|
|
2592
|
-
return /* @__PURE__ */ React.createElement(ScreenshotsButton, {
|
|
2593
|
-
title: lang.operation_ellipse_title,
|
|
2594
|
-
icon: "icon-ellipse",
|
|
2595
|
-
checked,
|
|
2596
|
-
onClick: onSelectEllipse,
|
|
2597
|
-
option: /* @__PURE__ */ React.createElement(ScreenshotsSizeColor, {
|
|
2598
|
-
size,
|
|
2599
|
-
color,
|
|
2600
|
-
onSizeChange: setSize,
|
|
2601
|
-
onColorChange: setColor,
|
|
2602
|
-
__self: this,
|
|
2603
|
-
__source: {
|
|
2604
|
-
fileName: _jsxFileName$3,
|
|
2605
|
-
lineNumber: 242,
|
|
2606
|
-
columnNumber: 15
|
|
1361
|
+
var I = /* @__PURE__ */ ((e) => (e[e.Move = 0] = "Move", e[e.ResizeTop = 1] = "ResizeTop", e[e.ResizeRightTop = 2] = "ResizeRightTop", e[e.ResizeRight = 3] = "ResizeRight", e[e.ResizeRightBottom = 4] = "ResizeRightBottom", e[e.ResizeBottom = 5] = "ResizeBottom", e[e.ResizeLeftBottom = 6] = "ResizeLeftBottom", e[e.ResizeLeft = 7] = "ResizeLeft", e[e.ResizeLeftTop = 8] = "ResizeLeftTop", e))(I || {});
|
|
1362
|
+
function at() {
|
|
1363
|
+
const e = O(), [t, s] = H(), [i, r] = J(), [, o] = j(), n = U(), [c, f] = $(3), [h, a] = $("#ee5126"), l = E(null), u = E(null), d = i === "Ellipse", p = g(() => {
|
|
1364
|
+
r.set("Ellipse"), o.set("crosshair");
|
|
1365
|
+
}, [r, o]), w = g(() => {
|
|
1366
|
+
d || (p(), s.clearSelect());
|
|
1367
|
+
}, [d, p, s]), S = g(
|
|
1368
|
+
(v, m) => {
|
|
1369
|
+
if (v.name !== "Ellipse" || !n.current)
|
|
1370
|
+
return;
|
|
1371
|
+
const x = v;
|
|
1372
|
+
p();
|
|
1373
|
+
const { x1: C, y1: z, x2: B, y2: D } = be(x);
|
|
1374
|
+
let k = 0;
|
|
1375
|
+
N(n.current.canvas, m, {
|
|
1376
|
+
x: (C + B) / 2,
|
|
1377
|
+
y: z
|
|
1378
|
+
}) ? k = 1 : N(n.current.canvas, m, {
|
|
1379
|
+
x: B,
|
|
1380
|
+
y: z
|
|
1381
|
+
}) ? k = 2 : N(n.current.canvas, m, {
|
|
1382
|
+
x: B,
|
|
1383
|
+
y: (z + D) / 2
|
|
1384
|
+
}) ? k = 3 : N(n.current.canvas, m, {
|
|
1385
|
+
x: B,
|
|
1386
|
+
y: D
|
|
1387
|
+
}) ? k = 4 : N(n.current.canvas, m, {
|
|
1388
|
+
x: (C + B) / 2,
|
|
1389
|
+
y: D
|
|
1390
|
+
}) ? k = 5 : N(n.current.canvas, m, {
|
|
1391
|
+
x: C,
|
|
1392
|
+
y: D
|
|
1393
|
+
}) ? k = 6 : N(n.current.canvas, m, {
|
|
1394
|
+
x: C,
|
|
1395
|
+
y: (z + D) / 2
|
|
1396
|
+
}) ? k = 7 : N(n.current.canvas, m, {
|
|
1397
|
+
x: C,
|
|
1398
|
+
y: z
|
|
1399
|
+
}) && (k = 8), u.current = {
|
|
1400
|
+
type: _.Edit,
|
|
1401
|
+
data: {
|
|
1402
|
+
type: k,
|
|
1403
|
+
x1: m.clientX,
|
|
1404
|
+
y1: m.clientY,
|
|
1405
|
+
x2: m.clientX,
|
|
1406
|
+
y2: m.clientY
|
|
1407
|
+
},
|
|
1408
|
+
source: x
|
|
1409
|
+
}, s.select(v);
|
|
1410
|
+
},
|
|
1411
|
+
[n, p, s]
|
|
1412
|
+
), R = g(
|
|
1413
|
+
(v) => {
|
|
1414
|
+
if (!d || !n.current || l.current)
|
|
1415
|
+
return;
|
|
1416
|
+
const { left: m, top: x } = n.current.canvas.getBoundingClientRect(), C = v.clientX - m, z = v.clientY - x;
|
|
1417
|
+
l.current = {
|
|
1418
|
+
name: "Ellipse",
|
|
1419
|
+
type: _.Source,
|
|
1420
|
+
data: {
|
|
1421
|
+
size: c,
|
|
1422
|
+
color: h,
|
|
1423
|
+
x1: C,
|
|
1424
|
+
y1: z,
|
|
1425
|
+
x2: C,
|
|
1426
|
+
y2: z
|
|
1427
|
+
},
|
|
1428
|
+
editHistory: [],
|
|
1429
|
+
draw: it,
|
|
1430
|
+
isHit: he
|
|
1431
|
+
};
|
|
1432
|
+
},
|
|
1433
|
+
[d, c, h, n]
|
|
1434
|
+
), b = g(
|
|
1435
|
+
(v) => {
|
|
1436
|
+
if (!(!d || !n.current)) {
|
|
1437
|
+
if (u.current)
|
|
1438
|
+
u.current.data.x2 = v.clientX, u.current.data.y2 = v.clientY, t.top !== u.current ? (u.current.source.editHistory.push(u.current), s.push(u.current)) : s.set(t);
|
|
1439
|
+
else if (l.current) {
|
|
1440
|
+
const { left: m, top: x } = n.current.canvas.getBoundingClientRect();
|
|
1441
|
+
l.current.data.x2 = v.clientX - m, l.current.data.y2 = v.clientY - x, t.top !== l.current ? s.push(l.current) : s.set(t);
|
|
1442
|
+
}
|
|
2607
1443
|
}
|
|
2608
|
-
}
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
1444
|
+
},
|
|
1445
|
+
[d, n, t, s]
|
|
1446
|
+
), M = g(() => {
|
|
1447
|
+
d && (l.current && s.clearSelect(), l.current = null, u.current = null);
|
|
1448
|
+
}, [d, s]);
|
|
1449
|
+
return ie(S), ee(R), te(b), ne(M), /* @__PURE__ */ y.createElement(
|
|
1450
|
+
A,
|
|
1451
|
+
{
|
|
1452
|
+
title: e.operation_ellipse_title,
|
|
1453
|
+
icon: "icon-ellipse",
|
|
1454
|
+
checked: d,
|
|
1455
|
+
onClick: w,
|
|
1456
|
+
option: /* @__PURE__ */ y.createElement(ce, { size: c, color: h, onSizeChange: f, onColorChange: a })
|
|
2614
1457
|
}
|
|
2615
|
-
|
|
1458
|
+
);
|
|
2616
1459
|
}
|
|
2617
|
-
function
|
|
2618
|
-
let { x1, y1, x2, y2 } =
|
|
2619
|
-
|
|
2620
|
-
const
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
y1 += y;
|
|
2629
|
-
} else if (data.type === RectangleEditType.ResizeRightTop) {
|
|
2630
|
-
x2 += x;
|
|
2631
|
-
y1 += y;
|
|
2632
|
-
} else if (data.type === RectangleEditType.ResizeRight) {
|
|
2633
|
-
x2 += x;
|
|
2634
|
-
} else if (data.type === RectangleEditType.ResizeRightBottom) {
|
|
2635
|
-
x2 += x;
|
|
2636
|
-
y2 += y;
|
|
2637
|
-
} else if (data.type === RectangleEditType.ResizeBottom) {
|
|
2638
|
-
y2 += y;
|
|
2639
|
-
} else if (data.type === RectangleEditType.ResizeLeftBottom) {
|
|
2640
|
-
x1 += x;
|
|
2641
|
-
y2 += y;
|
|
2642
|
-
} else if (data.type === RectangleEditType.ResizeLeft) {
|
|
2643
|
-
x1 += x;
|
|
2644
|
-
} else if (data.type === RectangleEditType.ResizeLeftTop) {
|
|
2645
|
-
x1 += x;
|
|
2646
|
-
y1 += y;
|
|
2647
|
-
}
|
|
2648
|
-
});
|
|
2649
|
-
return {
|
|
2650
|
-
...action.data,
|
|
2651
|
-
x1,
|
|
2652
|
-
x2,
|
|
2653
|
-
y1,
|
|
2654
|
-
y2
|
|
1460
|
+
function ke(e) {
|
|
1461
|
+
let { x1: t, y1: s, x2: i, y2: r } = e.data;
|
|
1462
|
+
return e.editHistory.forEach(({ data: o }) => {
|
|
1463
|
+
const n = o.x2 - o.x1, c = o.y2 - o.y1;
|
|
1464
|
+
o.type === W.Move ? (t += n, s += c, i += n, r += c) : o.type === W.ResizeTop ? s += c : o.type === W.ResizeRightTop ? (i += n, s += c) : o.type === W.ResizeRight ? i += n : o.type === W.ResizeRightBottom ? (i += n, r += c) : o.type === W.ResizeBottom ? r += c : o.type === W.ResizeLeftBottom ? (t += n, r += c) : o.type === W.ResizeLeft ? t += n : o.type === W.ResizeLeftTop && (t += n, s += c);
|
|
1465
|
+
}), {
|
|
1466
|
+
...e.data,
|
|
1467
|
+
x1: t,
|
|
1468
|
+
x2: i,
|
|
1469
|
+
y1: s,
|
|
1470
|
+
y2: r
|
|
2655
1471
|
};
|
|
2656
1472
|
}
|
|
2657
|
-
function
|
|
2658
|
-
const { size, color, x1, y1, x2, y2 } =
|
|
2659
|
-
|
|
2660
|
-
ctx.lineJoin = "miter";
|
|
2661
|
-
ctx.lineWidth = size;
|
|
2662
|
-
ctx.strokeStyle = color;
|
|
2663
|
-
ctx.beginPath();
|
|
2664
|
-
ctx.moveTo(x1, y1);
|
|
2665
|
-
ctx.lineTo(x2, y1);
|
|
2666
|
-
ctx.lineTo(x2, y2);
|
|
2667
|
-
ctx.lineTo(x1, y2);
|
|
2668
|
-
ctx.closePath();
|
|
2669
|
-
ctx.stroke();
|
|
2670
|
-
if (action.isSelected) {
|
|
2671
|
-
ctx.lineWidth = 1;
|
|
2672
|
-
ctx.strokeStyle = "#000000";
|
|
2673
|
-
ctx.fillStyle = "#ffffff";
|
|
2674
|
-
drawDragCircle(ctx, (x1 + x2) / 2, y1);
|
|
2675
|
-
drawDragCircle(ctx, x2, y1);
|
|
2676
|
-
drawDragCircle(ctx, x2, (y1 + y2) / 2);
|
|
2677
|
-
drawDragCircle(ctx, x2, y2);
|
|
2678
|
-
drawDragCircle(ctx, (x1 + x2) / 2, y2);
|
|
2679
|
-
drawDragCircle(ctx, x1, y2);
|
|
2680
|
-
drawDragCircle(ctx, x1, (y1 + y2) / 2);
|
|
2681
|
-
drawDragCircle(ctx, x1, y1);
|
|
2682
|
-
}
|
|
1473
|
+
function lt(e, t) {
|
|
1474
|
+
const { size: s, color: i, x1: r, y1: o, x2: n, y2: c } = ke(t);
|
|
1475
|
+
e.lineCap = "butt", e.lineJoin = "miter", e.lineWidth = s, e.strokeStyle = i, e.beginPath(), e.moveTo(r, o), e.lineTo(n, o), e.lineTo(n, c), e.lineTo(r, c), e.closePath(), e.stroke(), t.isSelected && (e.lineWidth = 1, e.strokeStyle = "#000000", e.fillStyle = "#ffffff", X(e, (r + n) / 2, o), X(e, n, o), X(e, n, (o + c) / 2), X(e, n, c), X(e, (r + n) / 2, c), X(e, r, c), X(e, r, (o + c) / 2), X(e, r, o));
|
|
2683
1476
|
}
|
|
2684
|
-
var
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
}
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
}
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
type = 7;
|
|
2767
|
-
} else if (isHitCircle(canvasContextRef.current.canvas, e, {
|
|
2768
|
-
x: x1,
|
|
2769
|
-
y: y1
|
|
2770
|
-
})) {
|
|
2771
|
-
type = 8;
|
|
2772
|
-
}
|
|
2773
|
-
rectangleEditRef.current = {
|
|
2774
|
-
type: HistoryItemType.Edit,
|
|
2775
|
-
data: {
|
|
2776
|
-
type,
|
|
2777
|
-
x1: e.clientX,
|
|
2778
|
-
y1: e.clientY,
|
|
2779
|
-
x2: e.clientX,
|
|
2780
|
-
y2: e.clientY
|
|
2781
|
-
},
|
|
2782
|
-
source: action
|
|
2783
|
-
};
|
|
2784
|
-
historyDispatcher.select(action);
|
|
2785
|
-
}, [canvasContextRef, selectRectangle, historyDispatcher]);
|
|
2786
|
-
const onMousedown = useCallback((e) => {
|
|
2787
|
-
if (!checked || !canvasContextRef.current || rectangleRef.current) {
|
|
2788
|
-
return;
|
|
2789
|
-
}
|
|
2790
|
-
const {
|
|
2791
|
-
left,
|
|
2792
|
-
top
|
|
2793
|
-
} = canvasContextRef.current.canvas.getBoundingClientRect();
|
|
2794
|
-
const x = e.clientX - left;
|
|
2795
|
-
const y = e.clientY - top;
|
|
2796
|
-
rectangleRef.current = {
|
|
2797
|
-
name: "Rectangle",
|
|
2798
|
-
type: HistoryItemType.Source,
|
|
2799
|
-
data: {
|
|
2800
|
-
size,
|
|
2801
|
-
color,
|
|
2802
|
-
x1: x,
|
|
2803
|
-
y1: y,
|
|
2804
|
-
x2: x,
|
|
2805
|
-
y2: y
|
|
2806
|
-
},
|
|
2807
|
-
editHistory: [],
|
|
2808
|
-
draw,
|
|
2809
|
-
isHit
|
|
2810
|
-
};
|
|
2811
|
-
}, [checked, size, color, canvasContextRef]);
|
|
2812
|
-
const onMousemove = useCallback((e) => {
|
|
2813
|
-
if (!checked || !canvasContextRef.current) {
|
|
2814
|
-
return;
|
|
2815
|
-
}
|
|
2816
|
-
if (rectangleEditRef.current) {
|
|
2817
|
-
rectangleEditRef.current.data.x2 = e.clientX;
|
|
2818
|
-
rectangleEditRef.current.data.y2 = e.clientY;
|
|
2819
|
-
if (history.top !== rectangleEditRef.current) {
|
|
2820
|
-
rectangleEditRef.current.source.editHistory.push(rectangleEditRef.current);
|
|
2821
|
-
historyDispatcher.push(rectangleEditRef.current);
|
|
2822
|
-
} else {
|
|
2823
|
-
historyDispatcher.set(history);
|
|
2824
|
-
}
|
|
2825
|
-
} else if (rectangleRef.current) {
|
|
2826
|
-
const {
|
|
2827
|
-
left,
|
|
2828
|
-
top
|
|
2829
|
-
} = canvasContextRef.current.canvas.getBoundingClientRect();
|
|
2830
|
-
const rectangleData = rectangleRef.current.data;
|
|
2831
|
-
rectangleData.x2 = e.clientX - left;
|
|
2832
|
-
rectangleData.y2 = e.clientY - top;
|
|
2833
|
-
if (history.top !== rectangleRef.current) {
|
|
2834
|
-
historyDispatcher.push(rectangleRef.current);
|
|
2835
|
-
} else {
|
|
2836
|
-
historyDispatcher.set(history);
|
|
2837
|
-
}
|
|
2838
|
-
}
|
|
2839
|
-
}, [checked, canvasContextRef, history, historyDispatcher]);
|
|
2840
|
-
const onMouseup = useCallback(() => {
|
|
2841
|
-
if (!checked) {
|
|
2842
|
-
return;
|
|
2843
|
-
}
|
|
2844
|
-
if (rectangleRef.current) {
|
|
2845
|
-
historyDispatcher.clearSelect();
|
|
2846
|
-
}
|
|
2847
|
-
rectangleRef.current = null;
|
|
2848
|
-
rectangleEditRef.current = null;
|
|
2849
|
-
}, [checked, historyDispatcher]);
|
|
2850
|
-
useDrawSelect(onDrawSelect);
|
|
2851
|
-
useCanvasMousedown(onMousedown);
|
|
2852
|
-
useCanvasMousemove(onMousemove);
|
|
2853
|
-
useCanvasMouseup(onMouseup);
|
|
2854
|
-
return /* @__PURE__ */ React.createElement(ScreenshotsButton, {
|
|
2855
|
-
title: lang.operation_rectangle_title,
|
|
2856
|
-
icon: "icon-rectangle",
|
|
2857
|
-
checked,
|
|
2858
|
-
onClick: onSelectRectangle,
|
|
2859
|
-
option: /* @__PURE__ */ React.createElement(ScreenshotsSizeColor, {
|
|
2860
|
-
size,
|
|
2861
|
-
color,
|
|
2862
|
-
onSizeChange: setSize,
|
|
2863
|
-
onColorChange: setColor,
|
|
2864
|
-
__self: this,
|
|
2865
|
-
__source: {
|
|
2866
|
-
fileName: _jsxFileName$2,
|
|
2867
|
-
lineNumber: 242,
|
|
2868
|
-
columnNumber: 15
|
|
1477
|
+
var W = /* @__PURE__ */ ((e) => (e[e.Move = 0] = "Move", e[e.ResizeTop = 1] = "ResizeTop", e[e.ResizeRightTop = 2] = "ResizeRightTop", e[e.ResizeRight = 3] = "ResizeRight", e[e.ResizeRightBottom = 4] = "ResizeRightBottom", e[e.ResizeBottom = 5] = "ResizeBottom", e[e.ResizeLeftBottom = 6] = "ResizeLeftBottom", e[e.ResizeLeft = 7] = "ResizeLeft", e[e.ResizeLeftTop = 8] = "ResizeLeftTop", e))(W || {});
|
|
1478
|
+
function ut() {
|
|
1479
|
+
const e = O(), [t, s] = H(), [i, r] = J(), [, o] = j(), n = U(), [c, f] = $(3), [h, a] = $("#ee5126"), l = E(null), u = E(null), d = i === "Rectangle", p = g(() => {
|
|
1480
|
+
r.set("Rectangle"), o.set("crosshair");
|
|
1481
|
+
}, [r, o]), w = g(() => {
|
|
1482
|
+
d || (p(), s.clearSelect());
|
|
1483
|
+
}, [d, p, s]), S = g(
|
|
1484
|
+
(v, m) => {
|
|
1485
|
+
if (v.name !== "Rectangle" || !n.current)
|
|
1486
|
+
return;
|
|
1487
|
+
const x = v;
|
|
1488
|
+
p();
|
|
1489
|
+
const { x1: C, y1: z, x2: B, y2: D } = ke(x);
|
|
1490
|
+
let k = 0;
|
|
1491
|
+
N(n.current.canvas, m, {
|
|
1492
|
+
x: (C + B) / 2,
|
|
1493
|
+
y: z
|
|
1494
|
+
}) ? k = 1 : N(n.current.canvas, m, {
|
|
1495
|
+
x: B,
|
|
1496
|
+
y: z
|
|
1497
|
+
}) ? k = 2 : N(n.current.canvas, m, {
|
|
1498
|
+
x: B,
|
|
1499
|
+
y: (z + D) / 2
|
|
1500
|
+
}) ? k = 3 : N(n.current.canvas, m, {
|
|
1501
|
+
x: B,
|
|
1502
|
+
y: D
|
|
1503
|
+
}) ? k = 4 : N(n.current.canvas, m, {
|
|
1504
|
+
x: (C + B) / 2,
|
|
1505
|
+
y: D
|
|
1506
|
+
}) ? k = 5 : N(n.current.canvas, m, {
|
|
1507
|
+
x: C,
|
|
1508
|
+
y: D
|
|
1509
|
+
}) ? k = 6 : N(n.current.canvas, m, {
|
|
1510
|
+
x: C,
|
|
1511
|
+
y: (z + D) / 2
|
|
1512
|
+
}) ? k = 7 : N(n.current.canvas, m, {
|
|
1513
|
+
x: C,
|
|
1514
|
+
y: z
|
|
1515
|
+
}) && (k = 8), u.current = {
|
|
1516
|
+
type: _.Edit,
|
|
1517
|
+
data: {
|
|
1518
|
+
type: k,
|
|
1519
|
+
x1: m.clientX,
|
|
1520
|
+
y1: m.clientY,
|
|
1521
|
+
x2: m.clientX,
|
|
1522
|
+
y2: m.clientY
|
|
1523
|
+
},
|
|
1524
|
+
source: v
|
|
1525
|
+
}, s.select(v);
|
|
1526
|
+
},
|
|
1527
|
+
[n, p, s]
|
|
1528
|
+
), R = g(
|
|
1529
|
+
(v) => {
|
|
1530
|
+
if (!d || !n.current || l.current)
|
|
1531
|
+
return;
|
|
1532
|
+
const { left: m, top: x } = n.current.canvas.getBoundingClientRect(), C = v.clientX - m, z = v.clientY - x;
|
|
1533
|
+
l.current = {
|
|
1534
|
+
name: "Rectangle",
|
|
1535
|
+
type: _.Source,
|
|
1536
|
+
data: {
|
|
1537
|
+
size: c,
|
|
1538
|
+
color: h,
|
|
1539
|
+
x1: C,
|
|
1540
|
+
y1: z,
|
|
1541
|
+
x2: C,
|
|
1542
|
+
y2: z
|
|
1543
|
+
},
|
|
1544
|
+
editHistory: [],
|
|
1545
|
+
draw: lt,
|
|
1546
|
+
isHit: he
|
|
1547
|
+
};
|
|
1548
|
+
},
|
|
1549
|
+
[d, c, h, n]
|
|
1550
|
+
), b = g(
|
|
1551
|
+
(v) => {
|
|
1552
|
+
if (!(!d || !n.current)) {
|
|
1553
|
+
if (u.current)
|
|
1554
|
+
u.current.data.x2 = v.clientX, u.current.data.y2 = v.clientY, t.top !== u.current ? (u.current.source.editHistory.push(u.current), s.push(u.current)) : s.set(t);
|
|
1555
|
+
else if (l.current) {
|
|
1556
|
+
const { left: m, top: x } = n.current.canvas.getBoundingClientRect(), C = l.current.data;
|
|
1557
|
+
C.x2 = v.clientX - m, C.y2 = v.clientY - x, t.top !== l.current ? s.push(l.current) : s.set(t);
|
|
1558
|
+
}
|
|
2869
1559
|
}
|
|
2870
|
-
}
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
1560
|
+
},
|
|
1561
|
+
[d, n, t, s]
|
|
1562
|
+
), M = g(() => {
|
|
1563
|
+
d && (l.current && s.clearSelect(), l.current = null, u.current = null);
|
|
1564
|
+
}, [d, s]);
|
|
1565
|
+
return ie(S), ee(R), te(b), ne(M), /* @__PURE__ */ y.createElement(
|
|
1566
|
+
A,
|
|
1567
|
+
{
|
|
1568
|
+
title: e.operation_rectangle_title,
|
|
1569
|
+
icon: "icon-rectangle",
|
|
1570
|
+
checked: d,
|
|
1571
|
+
onClick: w,
|
|
1572
|
+
option: /* @__PURE__ */ y.createElement(ce, { size: c, color: h, onSizeChange: f, onColorChange: a })
|
|
2876
1573
|
}
|
|
2877
|
-
|
|
1574
|
+
);
|
|
2878
1575
|
}
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
const {
|
|
2886
|
-
width,
|
|
2887
|
-
height
|
|
2888
|
-
} = useStore();
|
|
2889
|
-
const [bounds] = useBounds();
|
|
2890
|
-
const [operationsRect, setOperationsRect] = useState(null);
|
|
2891
|
-
const [position, setPosition] = useState(null);
|
|
2892
|
-
const elRef = useRef(null);
|
|
2893
|
-
const onDoubleClick = useCallback((e) => {
|
|
2894
|
-
e.stopPropagation();
|
|
1576
|
+
const ft = [ut, at, ct, ot, nt, Je, "|", Ve, Oe, "|", Fe, We, Ie];
|
|
1577
|
+
const Ee = y.createContext(null), ht = F(function() {
|
|
1578
|
+
const { width: t, height: s } = Y(), [i] = K(), [r, o] = $(null), [n, c] = $(null), f = E(null), h = g((l) => {
|
|
1579
|
+
l.stopPropagation();
|
|
1580
|
+
}, []), a = g((l) => {
|
|
1581
|
+
l.preventDefault(), l.stopPropagation();
|
|
2895
1582
|
}, []);
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
e.stopPropagation();
|
|
2899
|
-
}, []);
|
|
2900
|
-
useEffect(() => {
|
|
2901
|
-
if (!bounds || !elRef.current) {
|
|
1583
|
+
return T(() => {
|
|
1584
|
+
if (!i || !f.current)
|
|
2902
1585
|
return;
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
y: elRect.y,
|
|
2926
|
-
width: elRect.width,
|
|
2927
|
-
height: elRect.height
|
|
2928
|
-
});
|
|
2929
|
-
}
|
|
2930
|
-
});
|
|
2931
|
-
if (!bounds) {
|
|
2932
|
-
return null;
|
|
2933
|
-
}
|
|
2934
|
-
return /* @__PURE__ */ React.createElement(ScreenshotsOperationsCtx.Provider, {
|
|
2935
|
-
value: operationsRect,
|
|
2936
|
-
__self: this,
|
|
2937
|
-
__source: {
|
|
2938
|
-
fileName: _jsxFileName$1,
|
|
2939
|
-
lineNumber: 79,
|
|
2940
|
-
columnNumber: 5
|
|
2941
|
-
}
|
|
2942
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
2943
|
-
ref: elRef,
|
|
2944
|
-
className: "screenshots-operations",
|
|
2945
|
-
style: {
|
|
2946
|
-
visibility: position ? "visible" : "hidden",
|
|
2947
|
-
transform: `translate(${(_a = position == null ? void 0 : position.x) != null ? _a : 0}px, ${(_b = position == null ? void 0 : position.y) != null ? _b : 0}px)`
|
|
1586
|
+
const l = f.current.getBoundingClientRect();
|
|
1587
|
+
let u = i.x + i.width - l.width, d = i.y + i.height + 10;
|
|
1588
|
+
u < 0 && (u = 0), u > t - l.width && (u = t - l.width), d > s - l.height && (d = s - l.height - 10), (!n || Math.abs(n.x - u) > 1 || Math.abs(n.y - d) > 1) && c({
|
|
1589
|
+
x: u,
|
|
1590
|
+
y: d
|
|
1591
|
+
}), (!r || Math.abs(r.x - l.x) > 1 || Math.abs(r.y - l.y) > 1 || Math.abs(r.width - l.width) > 1 || Math.abs(r.height - l.height) > 1) && o({
|
|
1592
|
+
x: l.x,
|
|
1593
|
+
y: l.y,
|
|
1594
|
+
width: l.width,
|
|
1595
|
+
height: l.height
|
|
1596
|
+
});
|
|
1597
|
+
}), i ? /* @__PURE__ */ y.createElement(Ee.Provider, { value: r }, /* @__PURE__ */ y.createElement(
|
|
1598
|
+
"div",
|
|
1599
|
+
{
|
|
1600
|
+
ref: f,
|
|
1601
|
+
className: "screenshots-operations",
|
|
1602
|
+
style: {
|
|
1603
|
+
visibility: n ? "visible" : "hidden",
|
|
1604
|
+
transform: `translate(${(n == null ? void 0 : n.x) ?? 0}px, ${(n == null ? void 0 : n.y) ?? 0}px)`
|
|
1605
|
+
},
|
|
1606
|
+
onDoubleClick: h,
|
|
1607
|
+
onContextMenu: a
|
|
2948
1608
|
},
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
__self: this,
|
|
2952
|
-
__source: {
|
|
2953
|
-
fileName: _jsxFileName$1,
|
|
2954
|
-
lineNumber: 80,
|
|
2955
|
-
columnNumber: 7
|
|
2956
|
-
}
|
|
2957
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
2958
|
-
className: "screenshots-operations-buttons",
|
|
2959
|
-
__self: this,
|
|
2960
|
-
__source: {
|
|
2961
|
-
fileName: _jsxFileName$1,
|
|
2962
|
-
lineNumber: 90,
|
|
2963
|
-
columnNumber: 9
|
|
2964
|
-
}
|
|
2965
|
-
}, OperationButtons.map((OperationButton, index2) => {
|
|
2966
|
-
if (OperationButton === "|") {
|
|
2967
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
2968
|
-
key: index2,
|
|
2969
|
-
className: "screenshots-operations-divider",
|
|
2970
|
-
__self: this,
|
|
2971
|
-
__source: {
|
|
2972
|
-
fileName: _jsxFileName$1,
|
|
2973
|
-
lineNumber: 93,
|
|
2974
|
-
columnNumber: 22
|
|
2975
|
-
}
|
|
2976
|
-
});
|
|
2977
|
-
} else {
|
|
2978
|
-
return /* @__PURE__ */ React.createElement(OperationButton, {
|
|
2979
|
-
key: index2,
|
|
2980
|
-
__self: this,
|
|
2981
|
-
__source: {
|
|
2982
|
-
fileName: _jsxFileName$1,
|
|
2983
|
-
lineNumber: 95,
|
|
2984
|
-
columnNumber: 22
|
|
2985
|
-
}
|
|
2986
|
-
});
|
|
2987
|
-
}
|
|
2988
|
-
}))));
|
|
1609
|
+
/* @__PURE__ */ y.createElement("div", { className: "screenshots-operations-buttons" }, ft.map((l, u) => l === "|" ? /* @__PURE__ */ y.createElement("div", { key: u, className: "screenshots-operations-divider" }) : /* @__PURE__ */ y.createElement(l, { key: u })))
|
|
1610
|
+
)) : null;
|
|
2989
1611
|
});
|
|
2990
|
-
function
|
|
2991
|
-
const [
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
if (url == null) {
|
|
1612
|
+
function dt(e) {
|
|
1613
|
+
const [t, s] = $(null);
|
|
1614
|
+
return T(() => {
|
|
1615
|
+
if (s(null), e == null)
|
|
2995
1616
|
return;
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
const onError = () => setImage(null);
|
|
3000
|
-
$image.addEventListener("load", onLoad);
|
|
3001
|
-
$image.addEventListener("error", onError);
|
|
3002
|
-
$image.src = url;
|
|
3003
|
-
return () => {
|
|
3004
|
-
$image.removeEventListener("load", onLoad);
|
|
3005
|
-
$image.removeEventListener("error", onError);
|
|
1617
|
+
const i = document.createElement("img"), r = () => s(i), o = () => s(null);
|
|
1618
|
+
return i.addEventListener("load", r), i.addEventListener("error", o), i.src = e, () => {
|
|
1619
|
+
i.removeEventListener("load", r), i.removeEventListener("error", o);
|
|
3006
1620
|
};
|
|
3007
|
-
}, [
|
|
3008
|
-
return image;
|
|
1621
|
+
}, [e]), t;
|
|
3009
1622
|
}
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
url,
|
|
3013
|
-
width,
|
|
3014
|
-
height,
|
|
3015
|
-
lang,
|
|
3016
|
-
className,
|
|
3017
|
-
...props
|
|
3018
|
-
}) {
|
|
3019
|
-
const image = useGetLoadedImage(url);
|
|
3020
|
-
const canvasContextRef = useRef(null);
|
|
3021
|
-
const emiterRef = useRef({});
|
|
3022
|
-
const [history, setHistory] = useState({
|
|
1623
|
+
function pt({ url: e, width: t, height: s, lang: i, className: r, ...o }) {
|
|
1624
|
+
const n = dt(e), c = E(null), f = E({}), [h, a] = $({
|
|
3023
1625
|
index: -1,
|
|
3024
1626
|
stack: []
|
|
3025
|
-
})
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
url,
|
|
3031
|
-
width,
|
|
3032
|
-
height,
|
|
3033
|
-
image,
|
|
1627
|
+
}), [l, u] = $(null), [d, p] = $("move"), [w, S] = $(void 0), R = {
|
|
1628
|
+
url: e,
|
|
1629
|
+
width: t,
|
|
1630
|
+
height: s,
|
|
1631
|
+
image: n,
|
|
3034
1632
|
lang: {
|
|
3035
|
-
...
|
|
3036
|
-
...
|
|
1633
|
+
...Re,
|
|
1634
|
+
...i
|
|
3037
1635
|
},
|
|
3038
|
-
emiterRef,
|
|
3039
|
-
canvasContextRef,
|
|
3040
|
-
history,
|
|
3041
|
-
bounds,
|
|
3042
|
-
cursor,
|
|
3043
|
-
operation
|
|
3044
|
-
}
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
const
|
|
3059
|
-
|
|
3060
|
-
classNames.push(className);
|
|
3061
|
-
}
|
|
3062
|
-
const reset = () => {
|
|
3063
|
-
emiterRef.current = {};
|
|
3064
|
-
setHistory({
|
|
1636
|
+
emiterRef: f,
|
|
1637
|
+
canvasContextRef: c,
|
|
1638
|
+
history: h,
|
|
1639
|
+
bounds: l,
|
|
1640
|
+
cursor: d,
|
|
1641
|
+
operation: w
|
|
1642
|
+
}, b = g(
|
|
1643
|
+
(z, ...B) => {
|
|
1644
|
+
const D = o[z];
|
|
1645
|
+
typeof D == "function" && D(...B);
|
|
1646
|
+
},
|
|
1647
|
+
[o]
|
|
1648
|
+
), M = {
|
|
1649
|
+
call: b,
|
|
1650
|
+
setHistory: a,
|
|
1651
|
+
setBounds: u,
|
|
1652
|
+
setCursor: p,
|
|
1653
|
+
setOperation: S
|
|
1654
|
+
}, v = ["screenshots"];
|
|
1655
|
+
r && v.push(r);
|
|
1656
|
+
const m = () => {
|
|
1657
|
+
f.current = {}, a({
|
|
3065
1658
|
index: -1,
|
|
3066
1659
|
stack: []
|
|
3067
|
-
});
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
history,
|
|
3099
|
-
bounds: targetBounds
|
|
3100
|
-
}).then((blob) => {
|
|
3101
|
-
call("onOk", blob, targetBounds);
|
|
3102
|
-
reset();
|
|
3103
|
-
});
|
|
3104
|
-
}
|
|
3105
|
-
}, [image, history, bounds, width, height, call]);
|
|
3106
|
-
const onContextMenu = useCallback((e) => {
|
|
3107
|
-
if (e.button !== 2) {
|
|
3108
|
-
return;
|
|
3109
|
-
}
|
|
3110
|
-
e.preventDefault();
|
|
3111
|
-
call("onCancel");
|
|
3112
|
-
reset();
|
|
3113
|
-
}, [call]);
|
|
3114
|
-
useLayoutEffect(() => {
|
|
3115
|
-
reset();
|
|
3116
|
-
}, [url]);
|
|
3117
|
-
return /* @__PURE__ */ React.createElement(ScreenshotsContext.Provider, {
|
|
3118
|
-
value: {
|
|
3119
|
-
store,
|
|
3120
|
-
dispatcher
|
|
1660
|
+
}), u(null), p("move"), S(void 0);
|
|
1661
|
+
}, x = g(
|
|
1662
|
+
async (z) => {
|
|
1663
|
+
if (!(z.button !== 0 || !n))
|
|
1664
|
+
if (l && c.current)
|
|
1665
|
+
fe({
|
|
1666
|
+
image: n,
|
|
1667
|
+
width: t,
|
|
1668
|
+
height: s,
|
|
1669
|
+
history: h,
|
|
1670
|
+
bounds: l
|
|
1671
|
+
}).then((B) => {
|
|
1672
|
+
b("onOk", B, l), m();
|
|
1673
|
+
});
|
|
1674
|
+
else {
|
|
1675
|
+
const B = {
|
|
1676
|
+
x: 0,
|
|
1677
|
+
y: 0,
|
|
1678
|
+
width: t,
|
|
1679
|
+
height: s
|
|
1680
|
+
};
|
|
1681
|
+
fe({
|
|
1682
|
+
image: n,
|
|
1683
|
+
width: t,
|
|
1684
|
+
height: s,
|
|
1685
|
+
history: h,
|
|
1686
|
+
bounds: B
|
|
1687
|
+
}).then((D) => {
|
|
1688
|
+
b("onOk", D, B), m();
|
|
1689
|
+
});
|
|
1690
|
+
}
|
|
3121
1691
|
},
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
columnNumber: 5
|
|
3127
|
-
}
|
|
3128
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
3129
|
-
className: classNames.join(" "),
|
|
3130
|
-
style: {
|
|
3131
|
-
width,
|
|
3132
|
-
height
|
|
1692
|
+
[n, h, l, t, s, b]
|
|
1693
|
+
), C = g(
|
|
1694
|
+
(z) => {
|
|
1695
|
+
z.button === 2 && (z.preventDefault(), b("onCancel"), m());
|
|
3133
1696
|
},
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
ref: canvasContextRef,
|
|
3151
|
-
__self: this,
|
|
3152
|
-
__source: {
|
|
3153
|
-
fileName: _jsxFileName,
|
|
3154
|
-
lineNumber: 150,
|
|
3155
|
-
columnNumber: 9
|
|
3156
|
-
}
|
|
3157
|
-
}), /* @__PURE__ */ React.createElement(ScreenshotsOperations, {
|
|
3158
|
-
__self: this,
|
|
3159
|
-
__source: {
|
|
3160
|
-
fileName: _jsxFileName,
|
|
3161
|
-
lineNumber: 151,
|
|
3162
|
-
columnNumber: 9
|
|
3163
|
-
}
|
|
3164
|
-
})));
|
|
1697
|
+
[b]
|
|
1698
|
+
);
|
|
1699
|
+
return Q(() => {
|
|
1700
|
+
m();
|
|
1701
|
+
}, [e]), /* @__PURE__ */ y.createElement(ye.Provider, { value: { store: R, dispatcher: M } }, /* @__PURE__ */ y.createElement(
|
|
1702
|
+
"div",
|
|
1703
|
+
{
|
|
1704
|
+
className: v.join(" "),
|
|
1705
|
+
style: { width: t, height: s },
|
|
1706
|
+
onDoubleClick: x,
|
|
1707
|
+
onContextMenu: C
|
|
1708
|
+
},
|
|
1709
|
+
/* @__PURE__ */ y.createElement(Pe, null),
|
|
1710
|
+
/* @__PURE__ */ y.createElement(He, { ref: c }),
|
|
1711
|
+
/* @__PURE__ */ y.createElement(ht, null)
|
|
1712
|
+
));
|
|
3165
1713
|
}
|
|
3166
|
-
export {
|
|
1714
|
+
export {
|
|
1715
|
+
pt as default
|
|
1716
|
+
};
|