xiaodao-painter 0.1.6
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 -0
- package/README.md +201 -0
- package/dist/types/components/painter/ColorPalette.vue.d.ts +3 -0
- package/dist/types/components/painter/Painter.vue.d.ts +22 -0
- package/dist/types/components/painter/SelectionOverlay.vue.d.ts +8 -0
- package/dist/types/components/painter/StrokeRenderer.vue.d.ts +8 -0
- package/dist/types/components/painter/Toolbar.vue.d.ts +3 -0
- package/dist/types/components/painter/Whiteboard.vue.d.ts +3 -0
- package/dist/types/components/painter/composables/useDrawing.d.ts +23 -0
- package/dist/types/components/painter/composables/useI18n.d.ts +13 -0
- package/dist/types/components/painter/stores/canvas.d.ts +238 -0
- package/dist/types/components/painter/stores/tools.d.ts +6 -0
- package/dist/types/components/painter/types/index.d.ts +37 -0
- package/dist/types/components/painter/utils/geometry.d.ts +13 -0
- package/dist/types/components/painter/utils/i18n.d.ts +2 -0
- package/dist/types/components/painter/utils/svg.d.ts +7 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/xiaodao-painter.css +2 -0
- package/dist/xiaodao-painter.es.js +2522 -0
- package/dist/xiaodao-painter.umd.js +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,2522 @@
|
|
|
1
|
+
import { Fragment as e, Teleport as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createStaticVNode as s, createVNode as c, defineComponent as l, inject as u, mergeProps as d, nextTick as f, normalizeClass as p, normalizeStyle as m, onMounted as h, onUnmounted as g, openBlock as _, provide as v, ref as y, renderList as b, resolveDynamicComponent as x, toDisplayString as S, unref as C, vModelText as w, vShow as T, watch as E, withDirectives as D, withKeys as O, withModifiers as k } from "vue";
|
|
2
|
+
import { defineStore as A } from "pinia";
|
|
3
|
+
//#region src/components/painter/utils/i18n.ts
|
|
4
|
+
var j = {
|
|
5
|
+
"zh-CN": {
|
|
6
|
+
"tool.select": "选择",
|
|
7
|
+
"tool.pencil": "铅笔",
|
|
8
|
+
"tool.line": "直线",
|
|
9
|
+
"tool.circle": "圆形",
|
|
10
|
+
"tool.rect": "矩形",
|
|
11
|
+
"tool.triangle": "三角形",
|
|
12
|
+
"tool.star": "五角星",
|
|
13
|
+
"tool.pan": "移动画布",
|
|
14
|
+
"tool.zoom": "缩放",
|
|
15
|
+
"tool.text": "文本框",
|
|
16
|
+
"color.foreground": "前景色(描边)",
|
|
17
|
+
"color.background": "背景色(填充)",
|
|
18
|
+
"color.textColor": "文本颜色",
|
|
19
|
+
"palette.stroke": "描边颜色",
|
|
20
|
+
"palette.fill": "填充颜色",
|
|
21
|
+
"palette.custom": "自定义颜色",
|
|
22
|
+
"toolbar.undo": "撤销",
|
|
23
|
+
"toolbar.redo": "重做",
|
|
24
|
+
"toolbar.bringToFront": "上移图层",
|
|
25
|
+
"toolbar.sendToBack": "下移图层",
|
|
26
|
+
"toolbar.delete": "删除",
|
|
27
|
+
"zoom.label": "缩放:{percent}%",
|
|
28
|
+
"zoom.zoomIn": "放大",
|
|
29
|
+
"zoom.zoomOut": "缩小",
|
|
30
|
+
"canvasSize.title": "画布设置",
|
|
31
|
+
"canvasSize.width": "宽度",
|
|
32
|
+
"canvasSize.height": "高度",
|
|
33
|
+
"canvasSize.confirm": "确定",
|
|
34
|
+
"canvasSize.cancel": "取消",
|
|
35
|
+
"canvasSize.background": "背景",
|
|
36
|
+
"canvasSize.transparent": "透明",
|
|
37
|
+
"canvasSize.solidColor": "纯色",
|
|
38
|
+
"textAlign.left": "左对齐",
|
|
39
|
+
"textAlign.center": "居中",
|
|
40
|
+
"textAlign.right": "右对齐"
|
|
41
|
+
},
|
|
42
|
+
"en-US": {
|
|
43
|
+
"tool.select": "Select",
|
|
44
|
+
"tool.pencil": "Pencil",
|
|
45
|
+
"tool.line": "Line",
|
|
46
|
+
"tool.circle": "Circle",
|
|
47
|
+
"tool.rect": "Rectangle",
|
|
48
|
+
"tool.triangle": "Triangle",
|
|
49
|
+
"tool.star": "Star",
|
|
50
|
+
"tool.pan": "Pan Canvas",
|
|
51
|
+
"tool.zoom": "Zoom",
|
|
52
|
+
"tool.text": "Text",
|
|
53
|
+
"color.foreground": "Stroke Color",
|
|
54
|
+
"color.background": "Fill Color",
|
|
55
|
+
"color.textColor": "Text Color",
|
|
56
|
+
"palette.stroke": "Stroke Color",
|
|
57
|
+
"palette.fill": "Fill Color",
|
|
58
|
+
"palette.custom": "Custom Color",
|
|
59
|
+
"toolbar.undo": "Undo",
|
|
60
|
+
"toolbar.redo": "Redo",
|
|
61
|
+
"toolbar.bringToFront": "Bring to Front",
|
|
62
|
+
"toolbar.sendToBack": "Send to Back",
|
|
63
|
+
"toolbar.delete": "Delete",
|
|
64
|
+
"zoom.label": "Zoom: {percent}%",
|
|
65
|
+
"zoom.zoomIn": "Zoom In",
|
|
66
|
+
"zoom.zoomOut": "Zoom Out",
|
|
67
|
+
"canvasSize.title": "Canvas Settings",
|
|
68
|
+
"canvasSize.width": "Width",
|
|
69
|
+
"canvasSize.height": "Height",
|
|
70
|
+
"canvasSize.confirm": "OK",
|
|
71
|
+
"canvasSize.cancel": "Cancel",
|
|
72
|
+
"canvasSize.background": "Background",
|
|
73
|
+
"canvasSize.transparent": "Transparent",
|
|
74
|
+
"canvasSize.solidColor": "Solid Color",
|
|
75
|
+
"textAlign.left": "Align Left",
|
|
76
|
+
"textAlign.center": "Align Center",
|
|
77
|
+
"textAlign.right": "Align Right"
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
function M(e, t) {
|
|
81
|
+
return j[e]?.[t] ?? t;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/components/painter/composables/useI18n.ts
|
|
85
|
+
var N = Symbol("wb-locale");
|
|
86
|
+
function P(e) {
|
|
87
|
+
v(N, e);
|
|
88
|
+
}
|
|
89
|
+
function ee() {
|
|
90
|
+
let e = u(N, "zh-CN");
|
|
91
|
+
return {
|
|
92
|
+
locale: e,
|
|
93
|
+
t: (t) => M(e, t)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
var F = Symbol("wb-root-el");
|
|
97
|
+
function I(e) {
|
|
98
|
+
v(F, e);
|
|
99
|
+
}
|
|
100
|
+
function L() {
|
|
101
|
+
return u(F, null);
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/components/painter/types/index.ts
|
|
105
|
+
var te = 800, R = 600, ne = 3, z = 16, re = 8, B = A("canvas", () => {
|
|
106
|
+
let e = y([]), t = y(/* @__PURE__ */ new Set()), r = y("#000000"), i = y("transparent"), a = y("foreground"), o = y(!1), s = y(3), c = y("transparent"), l = y("light"), u = y(0), d = y("#000000"), f = y(null), p = y(null), m = y(800), h = y(600), g = y(0), _ = y(0), v = y(1), b = y(!1), x = null, S = n(() => `0 0 ${m.value} ${h.value}`), C = n(() => `translate(${g.value}px, ${_.value}px) scale(${v.value})`);
|
|
107
|
+
function w(e, t) {
|
|
108
|
+
g.value = e, _.value = t;
|
|
109
|
+
}
|
|
110
|
+
function T(e, t) {
|
|
111
|
+
m.value = e, h.value = t, u.value++;
|
|
112
|
+
}
|
|
113
|
+
let E = [
|
|
114
|
+
.1,
|
|
115
|
+
.25,
|
|
116
|
+
.33,
|
|
117
|
+
.5,
|
|
118
|
+
.67,
|
|
119
|
+
.75,
|
|
120
|
+
1,
|
|
121
|
+
1.25,
|
|
122
|
+
1.5,
|
|
123
|
+
2,
|
|
124
|
+
3,
|
|
125
|
+
4,
|
|
126
|
+
5,
|
|
127
|
+
6,
|
|
128
|
+
8,
|
|
129
|
+
10
|
|
130
|
+
];
|
|
131
|
+
function D(e, t, n) {
|
|
132
|
+
let r = v.value, i = n > 1, a = null;
|
|
133
|
+
for (let e of E) if (i) {
|
|
134
|
+
if (e > r + .001) {
|
|
135
|
+
a = e;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
} else e < r - .001 && (a = e);
|
|
139
|
+
if (a === null) return;
|
|
140
|
+
let o = (e - g.value) / r, s = (t - _.value) / r;
|
|
141
|
+
g.value = e - o * a, _.value = t - s * a, v.value = a, b.value = !0, x && clearTimeout(x), x = setTimeout(() => {
|
|
142
|
+
b.value = !1;
|
|
143
|
+
}, 1500);
|
|
144
|
+
}
|
|
145
|
+
function O(e, t, n) {
|
|
146
|
+
let r = E[0], i = E[E.length - 1];
|
|
147
|
+
n = Math.max(r, Math.min(i, n));
|
|
148
|
+
let a = v.value, o = (e - g.value) / a, s = (t - _.value) / a;
|
|
149
|
+
g.value = e - o * n, _.value = t - s * n, v.value = n, b.value = !0, x && clearTimeout(x), x = setTimeout(() => {
|
|
150
|
+
b.value = !1;
|
|
151
|
+
}, 1500);
|
|
152
|
+
}
|
|
153
|
+
function k() {
|
|
154
|
+
return Math.round(v.value * 100);
|
|
155
|
+
}
|
|
156
|
+
let A = y([]), j = y([]), M = y(!1), N = y(null);
|
|
157
|
+
function P(e) {
|
|
158
|
+
s.value = e;
|
|
159
|
+
}
|
|
160
|
+
function ee(e) {
|
|
161
|
+
c.value = e, u.value++;
|
|
162
|
+
}
|
|
163
|
+
function F() {
|
|
164
|
+
o.value = !o.value;
|
|
165
|
+
}
|
|
166
|
+
function I() {
|
|
167
|
+
o.value = !1;
|
|
168
|
+
}
|
|
169
|
+
let L = n(() => e.value.filter((e) => t.value.has(e.id))), te = n(() => {
|
|
170
|
+
let e = L.value.filter((e) => e.type !== "text");
|
|
171
|
+
if (e.length === 0) return null;
|
|
172
|
+
let t = e[0].strokeColor;
|
|
173
|
+
return e.every((e) => e.strokeColor === t) ? t : null;
|
|
174
|
+
}), R = n(() => {
|
|
175
|
+
let e = L.value.filter((e) => e.type !== "line" && e.type !== "pencil" && e.type !== "text");
|
|
176
|
+
if (e.length === 0) return null;
|
|
177
|
+
let t = e[0].fillColor;
|
|
178
|
+
return e.every((e) => e.fillColor === t) ? t : null;
|
|
179
|
+
}), ne = n(() => {
|
|
180
|
+
let e = L.value.filter((e) => e.type === "text");
|
|
181
|
+
if (e.length === 0) return null;
|
|
182
|
+
let t = e[0].textColor ?? r.value;
|
|
183
|
+
return e.every((e) => (e.textColor ?? r.value) === t) ? t : null;
|
|
184
|
+
}), z = n(() => {
|
|
185
|
+
let e = L.value;
|
|
186
|
+
return e.length === 1 ? e[0] : null;
|
|
187
|
+
}), re = n(() => z.value?.id ?? null);
|
|
188
|
+
function B(e) {
|
|
189
|
+
return t.value.has(e);
|
|
190
|
+
}
|
|
191
|
+
function ie(e) {
|
|
192
|
+
t.value = e ? /* @__PURE__ */ new Set([e]) : /* @__PURE__ */ new Set();
|
|
193
|
+
}
|
|
194
|
+
function V(e) {
|
|
195
|
+
t.value = new Set(e);
|
|
196
|
+
}
|
|
197
|
+
function H() {
|
|
198
|
+
t.value = /* @__PURE__ */ new Set();
|
|
199
|
+
}
|
|
200
|
+
function U(t) {
|
|
201
|
+
q(), e.value.push(t);
|
|
202
|
+
}
|
|
203
|
+
function W(t, n) {
|
|
204
|
+
let r = e.value.findIndex((e) => e.id === t);
|
|
205
|
+
if (r === -1) return;
|
|
206
|
+
let i = { ...n };
|
|
207
|
+
i.x !== void 0 && (i.x = Math.round(i.x)), i.y !== void 0 && (i.y = Math.round(i.y)), i.width !== void 0 && (i.width = Math.round(i.width)), i.height !== void 0 && (i.height = Math.round(i.height)), i.points &&= i.points.map((e) => ({
|
|
208
|
+
x: Math.round(e.x),
|
|
209
|
+
y: Math.round(e.y)
|
|
210
|
+
})), e.value[r] = {
|
|
211
|
+
...e.value[r],
|
|
212
|
+
...i
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function ae() {
|
|
216
|
+
let n = t.value;
|
|
217
|
+
n.size !== 0 && (q(), e.value = e.value.filter((e) => !n.has(e.id)), t.value = /* @__PURE__ */ new Set());
|
|
218
|
+
}
|
|
219
|
+
let oe = n(() => A.value.length > 0), se = n(() => j.value.length > 0), G = y([]);
|
|
220
|
+
function ce() {
|
|
221
|
+
t.value.size !== 0 && (G.value = L.value.map((e) => K(e)), ae());
|
|
222
|
+
}
|
|
223
|
+
function le() {
|
|
224
|
+
t.value.size !== 0 && (G.value = L.value.map((e) => K(e)));
|
|
225
|
+
}
|
|
226
|
+
function ue() {
|
|
227
|
+
if (G.value.length === 0) return;
|
|
228
|
+
q(), H();
|
|
229
|
+
let t = [];
|
|
230
|
+
for (let n of G.value) {
|
|
231
|
+
let r = {
|
|
232
|
+
...K(n),
|
|
233
|
+
id: J(),
|
|
234
|
+
x: n.x + 20,
|
|
235
|
+
y: n.y + 20,
|
|
236
|
+
points: n.points.map((e) => ({
|
|
237
|
+
x: e.x + 20,
|
|
238
|
+
y: e.y + 20
|
|
239
|
+
}))
|
|
240
|
+
};
|
|
241
|
+
e.value.push(r), t.push(r.id);
|
|
242
|
+
}
|
|
243
|
+
V(t);
|
|
244
|
+
}
|
|
245
|
+
function K(e) {
|
|
246
|
+
return {
|
|
247
|
+
...e,
|
|
248
|
+
points: e.points.map((e) => ({ ...e }))
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function q() {
|
|
252
|
+
A.value.push(e.value.map((e) => ({
|
|
253
|
+
...e,
|
|
254
|
+
points: e.points.map((e) => ({ ...e }))
|
|
255
|
+
}))), j.value = [];
|
|
256
|
+
}
|
|
257
|
+
function de() {
|
|
258
|
+
A.value.length !== 0 && (j.value.push(e.value.map((e) => ({
|
|
259
|
+
...e,
|
|
260
|
+
points: e.points.map((e) => ({ ...e }))
|
|
261
|
+
}))), e.value = A.value.pop(), t.value = /* @__PURE__ */ new Set());
|
|
262
|
+
}
|
|
263
|
+
function fe() {
|
|
264
|
+
j.value.length !== 0 && (A.value.push(e.value.map((e) => ({
|
|
265
|
+
...e,
|
|
266
|
+
points: e.points.map((e) => ({ ...e }))
|
|
267
|
+
}))), e.value = j.value.pop(), t.value = /* @__PURE__ */ new Set());
|
|
268
|
+
}
|
|
269
|
+
function pe() {
|
|
270
|
+
let n = t.value;
|
|
271
|
+
if (n.size === 0) return;
|
|
272
|
+
q();
|
|
273
|
+
let r = e.value.map((e, t) => n.has(e.id) ? t : -1).filter((e) => e >= 0).sort((e, t) => t - e);
|
|
274
|
+
for (let t of r) t < e.value.length - 1 && ([e.value[t], e.value[t + 1]] = [e.value[t + 1], e.value[t]]);
|
|
275
|
+
}
|
|
276
|
+
function me() {
|
|
277
|
+
let n = t.value;
|
|
278
|
+
if (n.size === 0) return;
|
|
279
|
+
q();
|
|
280
|
+
let r = e.value.map((e, t) => n.has(e.id) ? t : -1).filter((e) => e >= 0).sort((e, t) => e - t);
|
|
281
|
+
for (let t of r) t > 0 && ([e.value[t], e.value[t - 1]] = [e.value[t - 1], e.value[t]]);
|
|
282
|
+
}
|
|
283
|
+
let he = !1;
|
|
284
|
+
function ge(n) {
|
|
285
|
+
if (he) return;
|
|
286
|
+
he = !0, e.value = Array.isArray(n) ? n.map((e) => ({
|
|
287
|
+
...e,
|
|
288
|
+
points: e.points.map((e) => ({ ...e }))
|
|
289
|
+
})) : [];
|
|
290
|
+
let r = new Set(e.value.map((e) => e.id));
|
|
291
|
+
t.value = new Set([...t.value].filter((e) => r.has(e))), setTimeout(() => {
|
|
292
|
+
he = !1;
|
|
293
|
+
}, 0);
|
|
294
|
+
}
|
|
295
|
+
function _e(e) {
|
|
296
|
+
let { x: t, y: n, width: r, height: i, type: a } = e;
|
|
297
|
+
return a === "line" || a === "triangle" || a === "star" ? {
|
|
298
|
+
x: r >= 0 ? t : t + r,
|
|
299
|
+
y: i >= 0 ? n : n + i,
|
|
300
|
+
width: Math.abs(r),
|
|
301
|
+
height: Math.abs(i)
|
|
302
|
+
} : {
|
|
303
|
+
x: t,
|
|
304
|
+
y: n,
|
|
305
|
+
width: r,
|
|
306
|
+
height: i
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function ve(e) {
|
|
310
|
+
a.value = e;
|
|
311
|
+
}
|
|
312
|
+
function ye(n) {
|
|
313
|
+
if (t.value.size > 0) {
|
|
314
|
+
q();
|
|
315
|
+
for (let r of t.value) {
|
|
316
|
+
let t = e.value.find((e) => e.id === r);
|
|
317
|
+
if (a.value === "foreground") {
|
|
318
|
+
if (n === "transparent" || t?.type === "text") continue;
|
|
319
|
+
W(r, { strokeColor: n });
|
|
320
|
+
} else if (a.value === "textColor") {
|
|
321
|
+
if (n === "transparent") return;
|
|
322
|
+
W(r, { textColor: n });
|
|
323
|
+
} else {
|
|
324
|
+
if (t?.type === "text") continue;
|
|
325
|
+
W(r, { fillColor: n });
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
u.value++;
|
|
329
|
+
} else if (a.value === "foreground") {
|
|
330
|
+
if (n === "transparent") return;
|
|
331
|
+
r.value = n;
|
|
332
|
+
} else if (a.value === "textColor") {
|
|
333
|
+
if (n === "transparent") return;
|
|
334
|
+
d.value = n;
|
|
335
|
+
} else i.value = n;
|
|
336
|
+
}
|
|
337
|
+
function J() {
|
|
338
|
+
return crypto.randomUUID();
|
|
339
|
+
}
|
|
340
|
+
function Y(e, t, n, a, o, c) {
|
|
341
|
+
return {
|
|
342
|
+
id: J(),
|
|
343
|
+
type: e,
|
|
344
|
+
x: Math.round(t),
|
|
345
|
+
y: Math.round(n),
|
|
346
|
+
width: Math.round(a),
|
|
347
|
+
height: Math.round(o),
|
|
348
|
+
points: c.map((e) => ({
|
|
349
|
+
x: Math.round(e.x),
|
|
350
|
+
y: Math.round(e.y)
|
|
351
|
+
})),
|
|
352
|
+
strokeColor: r.value,
|
|
353
|
+
fillColor: e === "pencil" || e === "line" ? "none" : i.value,
|
|
354
|
+
strokeWidth: s.value,
|
|
355
|
+
...e === "text" ? {
|
|
356
|
+
text: "",
|
|
357
|
+
fontSize: 16,
|
|
358
|
+
textAlign: "left",
|
|
359
|
+
textColor: r.value,
|
|
360
|
+
textAutoWidth: !0,
|
|
361
|
+
fillColor: "transparent",
|
|
362
|
+
strokeColor: "transparent",
|
|
363
|
+
width: 0,
|
|
364
|
+
height: 0
|
|
365
|
+
} : {}
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function be() {
|
|
369
|
+
e.value = [], t.value = /* @__PURE__ */ new Set(), r.value = "#000000", i.value = "transparent", a.value = "foreground", o.value = !1, s.value = 3, c.value = "transparent", l.value = "light", u.value = 0, d.value = "#000000", f.value = null, p.value = null, m.value = 800, h.value = 600, g.value = 0, _.value = 0, v.value = 1, b.value = !1, x &&= (clearTimeout(x), null), A.value = [], j.value = [], M.value = !1, N.value = null, G.value = [];
|
|
370
|
+
}
|
|
371
|
+
return {
|
|
372
|
+
strokes: e,
|
|
373
|
+
selectedStrokeIds: t,
|
|
374
|
+
selectedStrokeId: re,
|
|
375
|
+
selectedStroke: z,
|
|
376
|
+
selectedStrokes: L,
|
|
377
|
+
selectedStrokeColor: te,
|
|
378
|
+
selectedFillColor: R,
|
|
379
|
+
selectedTextColor: ne,
|
|
380
|
+
foregroundColor: r,
|
|
381
|
+
backgroundColor: i,
|
|
382
|
+
activeColorSlot: a,
|
|
383
|
+
showColorPalette: o,
|
|
384
|
+
isSelecting: M,
|
|
385
|
+
selectionBox: N,
|
|
386
|
+
toggleColorPalette: F,
|
|
387
|
+
hideColorPalette: I,
|
|
388
|
+
addStroke: U,
|
|
389
|
+
updateStroke: W,
|
|
390
|
+
selectStroke: ie,
|
|
391
|
+
selectStrokes: V,
|
|
392
|
+
clearSelection: H,
|
|
393
|
+
isSelected: B,
|
|
394
|
+
deleteSelectedStrokes: ae,
|
|
395
|
+
setColorSlot: ve,
|
|
396
|
+
setColor: ye,
|
|
397
|
+
buildStroke: Y,
|
|
398
|
+
strokeWidth: s,
|
|
399
|
+
setStrokeWidth: P,
|
|
400
|
+
canvasBackgroundColor: c,
|
|
401
|
+
setCanvasBackgroundColor: ee,
|
|
402
|
+
canUndo: oe,
|
|
403
|
+
canRedo: se,
|
|
404
|
+
undoStack: A,
|
|
405
|
+
pushUndo: q,
|
|
406
|
+
undo: de,
|
|
407
|
+
redo: fe,
|
|
408
|
+
moveSelectedUp: pe,
|
|
409
|
+
moveSelectedDown: me,
|
|
410
|
+
syncFromParent: ge,
|
|
411
|
+
getStrokeDisplayBounds: _e,
|
|
412
|
+
clipboard: G,
|
|
413
|
+
cutSelectedStrokes: ce,
|
|
414
|
+
copySelectedStrokes: le,
|
|
415
|
+
pasteStrokes: ue,
|
|
416
|
+
canvasWidth: m,
|
|
417
|
+
canvasHeight: h,
|
|
418
|
+
panX: g,
|
|
419
|
+
panY: _,
|
|
420
|
+
zoomLevel: v,
|
|
421
|
+
showZoomIndicator: b,
|
|
422
|
+
viewBox: S,
|
|
423
|
+
canvasTransform: C,
|
|
424
|
+
setPan: w,
|
|
425
|
+
setCanvasSize: T,
|
|
426
|
+
zoomAt: D,
|
|
427
|
+
continuousZoomAt: O,
|
|
428
|
+
getZoomPercent: k,
|
|
429
|
+
dataVersion: u,
|
|
430
|
+
theme: l,
|
|
431
|
+
textColor: d,
|
|
432
|
+
editingTextId: f,
|
|
433
|
+
hoveredTextId: p,
|
|
434
|
+
reset: be
|
|
435
|
+
};
|
|
436
|
+
}), ie = A("tools", () => {
|
|
437
|
+
let e = y("select");
|
|
438
|
+
function t(t) {
|
|
439
|
+
if (e.value === "select" && t !== "select") {
|
|
440
|
+
let e = B();
|
|
441
|
+
e.selectedStrokeIds.size > 0 && e.clearSelection();
|
|
442
|
+
}
|
|
443
|
+
e.value = t;
|
|
444
|
+
}
|
|
445
|
+
function n() {
|
|
446
|
+
e.value = "select";
|
|
447
|
+
}
|
|
448
|
+
return {
|
|
449
|
+
activeTool: e,
|
|
450
|
+
setTool: t,
|
|
451
|
+
reset: n
|
|
452
|
+
};
|
|
453
|
+
}), V = { class: "toolbar" }, H = ["disabled"], U = { class: "tool-group" }, W = ["title", "onClick"], ae = {
|
|
454
|
+
key: 0,
|
|
455
|
+
class: "tool-icon",
|
|
456
|
+
viewBox: "0 0 24 24",
|
|
457
|
+
fill: "none",
|
|
458
|
+
stroke: "currentColor",
|
|
459
|
+
"stroke-width": "1.6",
|
|
460
|
+
"stroke-linecap": "round",
|
|
461
|
+
"stroke-linejoin": "round"
|
|
462
|
+
}, oe = {
|
|
463
|
+
key: 1,
|
|
464
|
+
class: "tool-icon",
|
|
465
|
+
viewBox: "0 0 24 24",
|
|
466
|
+
fill: "none",
|
|
467
|
+
stroke: "currentColor",
|
|
468
|
+
"stroke-width": "1.8",
|
|
469
|
+
"stroke-linecap": "round"
|
|
470
|
+
}, se = {
|
|
471
|
+
key: 2,
|
|
472
|
+
class: "tool-icon",
|
|
473
|
+
viewBox: "0 0 24 24",
|
|
474
|
+
fill: "none",
|
|
475
|
+
stroke: "currentColor",
|
|
476
|
+
"stroke-width": "1.8",
|
|
477
|
+
"stroke-linecap": "round",
|
|
478
|
+
"stroke-linejoin": "round"
|
|
479
|
+
}, G = {
|
|
480
|
+
key: 3,
|
|
481
|
+
class: "tool-icon",
|
|
482
|
+
viewBox: "0 0 24 24",
|
|
483
|
+
fill: "none",
|
|
484
|
+
stroke: "currentColor",
|
|
485
|
+
"stroke-width": "1.8",
|
|
486
|
+
"stroke-linecap": "round"
|
|
487
|
+
}, ce = {
|
|
488
|
+
key: 4,
|
|
489
|
+
class: "tool-icon",
|
|
490
|
+
viewBox: "0 0 24 24",
|
|
491
|
+
fill: "none",
|
|
492
|
+
stroke: "currentColor",
|
|
493
|
+
"stroke-width": "1.8"
|
|
494
|
+
}, le = {
|
|
495
|
+
key: 5,
|
|
496
|
+
class: "tool-icon",
|
|
497
|
+
viewBox: "0 0 24 24",
|
|
498
|
+
fill: "none",
|
|
499
|
+
stroke: "currentColor",
|
|
500
|
+
"stroke-width": "1.8",
|
|
501
|
+
"stroke-linejoin": "round"
|
|
502
|
+
}, ue = {
|
|
503
|
+
key: 6,
|
|
504
|
+
class: "tool-icon",
|
|
505
|
+
viewBox: "0 0 24 24",
|
|
506
|
+
fill: "none",
|
|
507
|
+
stroke: "currentColor",
|
|
508
|
+
"stroke-width": "1.8",
|
|
509
|
+
"stroke-linejoin": "round"
|
|
510
|
+
}, K = {
|
|
511
|
+
key: 7,
|
|
512
|
+
class: "tool-icon",
|
|
513
|
+
viewBox: "0 0 24 24",
|
|
514
|
+
fill: "none",
|
|
515
|
+
stroke: "currentColor",
|
|
516
|
+
"stroke-width": "1.8",
|
|
517
|
+
"stroke-linejoin": "round"
|
|
518
|
+
}, q = {
|
|
519
|
+
key: 8,
|
|
520
|
+
class: "tool-icon",
|
|
521
|
+
viewBox: "0 0 24 24",
|
|
522
|
+
fill: "none",
|
|
523
|
+
stroke: "currentColor",
|
|
524
|
+
"stroke-width": "1.8",
|
|
525
|
+
"stroke-linecap": "round",
|
|
526
|
+
"stroke-linejoin": "round"
|
|
527
|
+
}, de = { class: "tool-group nav-group" }, fe = ["title"], pe = ["disabled"], me = { class: "canvas-size-wrapper" }, he = ["title"], ge = { class: "popover-title" }, _e = { class: "popover-field" }, ve = { class: "popover-label" }, ye = { class: "popover-field" }, J = { class: "popover-label" }, Y = { class: "popover-field" }, be = { class: "popover-label" }, xe = { class: "bg-color-row" }, Se = ["title"], Ce = ["value"], we = ["title"], Te = { class: "popover-actions" }, Ee = { class: "color-section" }, De = ["title"], Oe = { class: "color-swatch text-color-swatch" }, ke = {
|
|
528
|
+
key: 0,
|
|
529
|
+
class: "mixed-icon",
|
|
530
|
+
viewBox: "0 0 24 24",
|
|
531
|
+
fill: "none",
|
|
532
|
+
stroke: "currentColor",
|
|
533
|
+
"stroke-width": "2",
|
|
534
|
+
"stroke-linecap": "round"
|
|
535
|
+
}, Ae = ["title"], je = {
|
|
536
|
+
key: 0,
|
|
537
|
+
class: "mixed-icon",
|
|
538
|
+
viewBox: "0 0 24 24",
|
|
539
|
+
fill: "none",
|
|
540
|
+
stroke: "currentColor",
|
|
541
|
+
"stroke-width": "2",
|
|
542
|
+
"stroke-linecap": "round"
|
|
543
|
+
}, Me = ["title"], Ne = {
|
|
544
|
+
key: 0,
|
|
545
|
+
class: "mixed-icon",
|
|
546
|
+
viewBox: "0 0 24 24",
|
|
547
|
+
fill: "none",
|
|
548
|
+
stroke: "currentColor",
|
|
549
|
+
"stroke-width": "2",
|
|
550
|
+
"stroke-linecap": "round"
|
|
551
|
+
}, Pe = {
|
|
552
|
+
key: 1,
|
|
553
|
+
class: "mixed-icon",
|
|
554
|
+
viewBox: "0 0 24 24",
|
|
555
|
+
fill: "none",
|
|
556
|
+
stroke: "currentColor",
|
|
557
|
+
"stroke-width": "2",
|
|
558
|
+
"stroke-linecap": "round"
|
|
559
|
+
}, Fe = 42, Ie = /*@__PURE__*/ l({
|
|
560
|
+
__name: "Toolbar",
|
|
561
|
+
setup(c) {
|
|
562
|
+
let l = ie(), u = B(), { t: d } = ee(), f = L(), v = y(null), x = y(!1), T = y(!1);
|
|
563
|
+
function E() {
|
|
564
|
+
let e = v.value;
|
|
565
|
+
e && (x.value = e.scrollTop > 0, T.value = e.scrollTop + e.clientHeight < e.scrollHeight - 1);
|
|
566
|
+
}
|
|
567
|
+
function k() {
|
|
568
|
+
let e = v.value;
|
|
569
|
+
e && e.scrollBy({
|
|
570
|
+
top: -42,
|
|
571
|
+
behavior: "smooth"
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
function A() {
|
|
575
|
+
let e = v.value;
|
|
576
|
+
e && e.scrollBy({
|
|
577
|
+
top: Fe,
|
|
578
|
+
behavior: "smooth"
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
let j = null;
|
|
582
|
+
h(() => {
|
|
583
|
+
j = new ResizeObserver(() => E()), v.value && j.observe(v.value), E();
|
|
584
|
+
}), g(() => {
|
|
585
|
+
j?.disconnect();
|
|
586
|
+
});
|
|
587
|
+
let M = [
|
|
588
|
+
"select",
|
|
589
|
+
"pan",
|
|
590
|
+
"pencil",
|
|
591
|
+
"line",
|
|
592
|
+
"circle",
|
|
593
|
+
"rect",
|
|
594
|
+
"triangle",
|
|
595
|
+
"star",
|
|
596
|
+
"text"
|
|
597
|
+
], N = n(() => u.selectedStrokeIds.size > 0), P = y(!1), F = y({
|
|
598
|
+
width: u.canvasWidth,
|
|
599
|
+
height: u.canvasHeight
|
|
600
|
+
}), I = y(u.canvasBackgroundColor);
|
|
601
|
+
function te() {
|
|
602
|
+
F.value = {
|
|
603
|
+
width: u.canvasWidth,
|
|
604
|
+
height: u.canvasHeight
|
|
605
|
+
}, I.value = u.canvasBackgroundColor, P.value = !0;
|
|
606
|
+
}
|
|
607
|
+
let R = y(null);
|
|
608
|
+
function ne() {
|
|
609
|
+
R.value?.click();
|
|
610
|
+
}
|
|
611
|
+
function z(e) {
|
|
612
|
+
let t = e.target;
|
|
613
|
+
I.value = t.value;
|
|
614
|
+
}
|
|
615
|
+
function re() {
|
|
616
|
+
I.value = "transparent";
|
|
617
|
+
}
|
|
618
|
+
function Ie() {
|
|
619
|
+
let e = Math.max(1, Math.round(F.value.width)), t = Math.max(1, Math.round(F.value.height));
|
|
620
|
+
u.setCanvasSize(e, t), u.setCanvasBackgroundColor(I.value), P.value = !1;
|
|
621
|
+
}
|
|
622
|
+
function Le() {
|
|
623
|
+
P.value = !1;
|
|
624
|
+
}
|
|
625
|
+
let Re = n(() => {
|
|
626
|
+
if (!f?.value) return {};
|
|
627
|
+
let e = f.value.getBoundingClientRect();
|
|
628
|
+
return {
|
|
629
|
+
left: e.left + 52 + 12 + "px",
|
|
630
|
+
bottom: window.innerHeight - e.bottom + 80 + "px",
|
|
631
|
+
position: "fixed"
|
|
632
|
+
};
|
|
633
|
+
});
|
|
634
|
+
function ze(e) {
|
|
635
|
+
e.target.classList.contains("canvas-size-backdrop") && (P.value = !1);
|
|
636
|
+
}
|
|
637
|
+
function Be(e) {
|
|
638
|
+
e.key === "Escape" && (P.value = !1);
|
|
639
|
+
}
|
|
640
|
+
let Ve = n(() => N.value && u.selectedStrokeColor !== null ? u.selectedStrokeColor : u.foregroundColor), X = n(() => !Ue.value && N.value && u.selectedStrokeColor === null), Z = n(() => N.value && u.selectedFillColor !== null ? u.selectedFillColor : u.backgroundColor), He = n(() => !Ue.value && N.value && u.selectedFillColor === null), Q = n(() => u.selectedStrokes.some((e) => e.type === "text")), Ue = n(() => N.value && u.selectedStrokes.every((e) => e.type === "text")), We = n(() => Ue.value), Ge = n(() => Ue.value), Ke = n(() => N.value && u.selectedTextColor !== null ? u.selectedTextColor : u.textColor), qe = n(() => Q.value && u.selectedTextColor === null);
|
|
641
|
+
function Je() {
|
|
642
|
+
u.setColorSlot("textColor"), u.toggleColorPalette();
|
|
643
|
+
}
|
|
644
|
+
function Ye() {
|
|
645
|
+
We.value || (u.setColorSlot("foreground"), u.toggleColorPalette());
|
|
646
|
+
}
|
|
647
|
+
function Xe() {
|
|
648
|
+
Ge.value || (u.setColorSlot("background"), u.toggleColorPalette());
|
|
649
|
+
}
|
|
650
|
+
return (n, c) => (_(), a("div", V, [
|
|
651
|
+
x.value || T.value ? (_(), a("button", {
|
|
652
|
+
key: 0,
|
|
653
|
+
class: "scroll-btn scroll-up",
|
|
654
|
+
disabled: !x.value,
|
|
655
|
+
onClick: k
|
|
656
|
+
}, [...c[3] ||= [o("svg", {
|
|
657
|
+
class: "scroll-icon",
|
|
658
|
+
viewBox: "0 0 24 24",
|
|
659
|
+
fill: "none",
|
|
660
|
+
stroke: "currentColor",
|
|
661
|
+
"stroke-width": "2",
|
|
662
|
+
"stroke-linecap": "round",
|
|
663
|
+
"stroke-linejoin": "round"
|
|
664
|
+
}, [o("polyline", { points: "18 15 12 9 6 15" })], -1)]], 8, H)) : i("", !0),
|
|
665
|
+
o("div", {
|
|
666
|
+
ref_key: "toolsScrollRef",
|
|
667
|
+
ref: v,
|
|
668
|
+
class: "tools-scroll",
|
|
669
|
+
onScroll: E
|
|
670
|
+
}, [o("div", U, [(_(), a(e, null, b(M, (e) => o("button", {
|
|
671
|
+
key: e,
|
|
672
|
+
class: p(["tool-btn", { active: C(l).activeTool === e }]),
|
|
673
|
+
title: C(d)(`tool.${e}`),
|
|
674
|
+
onClick: (t) => C(l).setTool(e)
|
|
675
|
+
}, [e === "select" ? (_(), a("svg", ae, [...c[4] ||= [o("path", { d: "M4.5 3.5l5.5 15 2.5-6 6-2.5z" }, null, -1)]])) : e === "pan" ? (_(), a("svg", oe, [...c[5] ||= [s("<line x1=\"12\" y1=\"4\" x2=\"12\" y2=\"20\" data-v-9532ade7></line><line x1=\"4\" y1=\"12\" x2=\"20\" y2=\"12\" data-v-9532ade7></line><polygon points=\"12,4 9,8 15,8\" fill=\"currentColor\" stroke=\"none\" data-v-9532ade7></polygon><polygon points=\"12,20 9,16 15,16\" fill=\"currentColor\" stroke=\"none\" data-v-9532ade7></polygon><polygon points=\"4,12 8,9 8,15\" fill=\"currentColor\" stroke=\"none\" data-v-9532ade7></polygon><polygon points=\"20,12 16,9 16,15\" fill=\"currentColor\" stroke=\"none\" data-v-9532ade7></polygon>", 6)]])) : e === "pencil" ? (_(), a("svg", se, [...c[6] ||= [o("path", { d: "M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z" }, null, -1), o("path", { d: "m15 5 4 4" }, null, -1)]])) : e === "line" ? (_(), a("svg", G, [...c[7] ||= [o("line", {
|
|
676
|
+
x1: "5",
|
|
677
|
+
y1: "19",
|
|
678
|
+
x2: "19",
|
|
679
|
+
y2: "5"
|
|
680
|
+
}, null, -1)]])) : e === "circle" ? (_(), a("svg", ce, [...c[8] ||= [o("circle", {
|
|
681
|
+
cx: "12",
|
|
682
|
+
cy: "12",
|
|
683
|
+
r: "9"
|
|
684
|
+
}, null, -1)]])) : e === "rect" ? (_(), a("svg", le, [...c[9] ||= [o("rect", {
|
|
685
|
+
x: "3",
|
|
686
|
+
y: "3",
|
|
687
|
+
width: "18",
|
|
688
|
+
height: "18",
|
|
689
|
+
rx: "2"
|
|
690
|
+
}, null, -1)]])) : e === "triangle" ? (_(), a("svg", ue, [...c[10] ||= [o("polygon", { points: "12,3 22,21 2,21" }, null, -1)]])) : e === "star" ? (_(), a("svg", K, [...c[11] ||= [o("polygon", { points: "12,2 15.09,8.26 22,9.27 17,14.14 18.18,21.02 12,17.77 5.82,21.02 7,14.14 2,9.27 8.91,8.26" }, null, -1)]])) : e === "text" ? (_(), a("svg", q, [...c[12] ||= [
|
|
691
|
+
o("polyline", { points: "4 7 4 4 20 4 20 7" }, null, -1),
|
|
692
|
+
o("line", {
|
|
693
|
+
x1: "9",
|
|
694
|
+
y1: "20",
|
|
695
|
+
x2: "15",
|
|
696
|
+
y2: "20"
|
|
697
|
+
}, null, -1),
|
|
698
|
+
o("line", {
|
|
699
|
+
x1: "12",
|
|
700
|
+
y1: "4",
|
|
701
|
+
x2: "12",
|
|
702
|
+
y2: "20"
|
|
703
|
+
}, null, -1)
|
|
704
|
+
]])) : i("", !0)], 10, W)), 64))]), o("div", de, [o("button", {
|
|
705
|
+
class: p(["tool-btn", { active: C(l).activeTool === "zoom" }]),
|
|
706
|
+
title: C(d)("tool.zoom"),
|
|
707
|
+
onClick: c[0] ||= (e) => C(l).setTool("zoom")
|
|
708
|
+
}, [...c[13] ||= [s("<svg class=\"tool-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" data-v-9532ade7><circle cx=\"11\" cy=\"11\" r=\"8\" data-v-9532ade7></circle><line x1=\"21\" y1=\"21\" x2=\"16.65\" y2=\"16.65\" data-v-9532ade7></line><line x1=\"11\" y1=\"8\" x2=\"11\" y2=\"14\" data-v-9532ade7></line><line x1=\"8\" y1=\"11\" x2=\"14\" y2=\"11\" data-v-9532ade7></line></svg>", 1)]], 10, fe)])], 544),
|
|
709
|
+
x.value || T.value ? (_(), a("button", {
|
|
710
|
+
key: 1,
|
|
711
|
+
class: "scroll-btn scroll-down",
|
|
712
|
+
disabled: !T.value,
|
|
713
|
+
onClick: A
|
|
714
|
+
}, [...c[14] ||= [o("svg", {
|
|
715
|
+
class: "scroll-icon",
|
|
716
|
+
viewBox: "0 0 24 24",
|
|
717
|
+
fill: "none",
|
|
718
|
+
stroke: "currentColor",
|
|
719
|
+
"stroke-width": "2",
|
|
720
|
+
"stroke-linecap": "round",
|
|
721
|
+
"stroke-linejoin": "round"
|
|
722
|
+
}, [o("polyline", { points: "6 9 12 15 18 9" })], -1)]], 8, pe)) : i("", !0),
|
|
723
|
+
c[24] ||= o("div", { class: "spacer" }, null, -1),
|
|
724
|
+
o("div", me, [o("button", {
|
|
725
|
+
class: "tool-btn",
|
|
726
|
+
title: C(d)("canvasSize.title"),
|
|
727
|
+
onClick: te
|
|
728
|
+
}, [...c[15] ||= [o("svg", {
|
|
729
|
+
class: "tool-icon",
|
|
730
|
+
viewBox: "0 0 24 24",
|
|
731
|
+
fill: "none",
|
|
732
|
+
stroke: "currentColor",
|
|
733
|
+
"stroke-width": "1.8",
|
|
734
|
+
"stroke-linecap": "round",
|
|
735
|
+
"stroke-linejoin": "round"
|
|
736
|
+
}, [
|
|
737
|
+
o("rect", {
|
|
738
|
+
x: "2",
|
|
739
|
+
y: "2",
|
|
740
|
+
width: "20",
|
|
741
|
+
height: "14",
|
|
742
|
+
rx: "1.5"
|
|
743
|
+
}),
|
|
744
|
+
o("line", {
|
|
745
|
+
x1: "7",
|
|
746
|
+
y1: "16",
|
|
747
|
+
x2: "5",
|
|
748
|
+
y2: "22"
|
|
749
|
+
}),
|
|
750
|
+
o("line", {
|
|
751
|
+
x1: "17",
|
|
752
|
+
y1: "16",
|
|
753
|
+
x2: "19",
|
|
754
|
+
y2: "22"
|
|
755
|
+
})
|
|
756
|
+
], -1)]], 8, he), (_(), r(t, { to: "body" }, [P.value ? (_(), a("div", {
|
|
757
|
+
key: 0,
|
|
758
|
+
class: "canvas-size-backdrop",
|
|
759
|
+
onMousedown: ze
|
|
760
|
+
}, [o("div", {
|
|
761
|
+
class: "canvas-size-popover",
|
|
762
|
+
style: m(Re.value),
|
|
763
|
+
onKeydown: Be
|
|
764
|
+
}, [
|
|
765
|
+
o("div", ge, S(C(d)("canvasSize.title")), 1),
|
|
766
|
+
o("div", _e, [
|
|
767
|
+
o("label", ve, S(C(d)("canvasSize.width")), 1),
|
|
768
|
+
D(o("input", {
|
|
769
|
+
ref: "widthInput",
|
|
770
|
+
"onUpdate:modelValue": c[1] ||= (e) => F.value.width = e,
|
|
771
|
+
type: "number",
|
|
772
|
+
min: "1",
|
|
773
|
+
class: "popover-input",
|
|
774
|
+
onKeydown: O(Ie, ["enter"])
|
|
775
|
+
}, null, 544), [[
|
|
776
|
+
w,
|
|
777
|
+
F.value.width,
|
|
778
|
+
void 0,
|
|
779
|
+
{ number: !0 }
|
|
780
|
+
]]),
|
|
781
|
+
c[16] ||= o("span", { class: "popover-unit" }, "px", -1)
|
|
782
|
+
]),
|
|
783
|
+
o("div", ye, [
|
|
784
|
+
o("label", J, S(C(d)("canvasSize.height")), 1),
|
|
785
|
+
D(o("input", {
|
|
786
|
+
"onUpdate:modelValue": c[2] ||= (e) => F.value.height = e,
|
|
787
|
+
type: "number",
|
|
788
|
+
min: "1",
|
|
789
|
+
class: "popover-input",
|
|
790
|
+
onKeydown: O(Ie, ["enter"])
|
|
791
|
+
}, null, 544), [[
|
|
792
|
+
w,
|
|
793
|
+
F.value.height,
|
|
794
|
+
void 0,
|
|
795
|
+
{ number: !0 }
|
|
796
|
+
]]),
|
|
797
|
+
c[17] ||= o("span", { class: "popover-unit" }, "px", -1)
|
|
798
|
+
]),
|
|
799
|
+
o("div", Y, [o("label", be, S(C(d)("canvasSize.background")), 1), o("div", xe, [o("button", {
|
|
800
|
+
class: p(["bg-radio-btn", { active: I.value !== "transparent" }]),
|
|
801
|
+
title: C(d)("canvasSize.solidColor"),
|
|
802
|
+
onClick: ne
|
|
803
|
+
}, [o("span", {
|
|
804
|
+
class: "bg-color-fill",
|
|
805
|
+
style: m({ background: I.value === "transparent" ? "#ffffff" : I.value })
|
|
806
|
+
}, null, 4), o("input", {
|
|
807
|
+
ref_key: "hiddenColorInput",
|
|
808
|
+
ref: R,
|
|
809
|
+
type: "color",
|
|
810
|
+
class: "hidden-color-input",
|
|
811
|
+
value: I.value === "transparent" ? "#ffffff" : I.value,
|
|
812
|
+
onChange: z
|
|
813
|
+
}, null, 40, Ce)], 10, Se), o("button", {
|
|
814
|
+
class: p([
|
|
815
|
+
"bg-radio-btn",
|
|
816
|
+
"bg-radio-btn--transparent",
|
|
817
|
+
{ active: I.value === "transparent" }
|
|
818
|
+
]),
|
|
819
|
+
title: C(d)("canvasSize.transparent"),
|
|
820
|
+
onClick: re
|
|
821
|
+
}, [...c[18] ||= [o("svg", {
|
|
822
|
+
width: "14",
|
|
823
|
+
height: "14",
|
|
824
|
+
viewBox: "0 0 24 24",
|
|
825
|
+
fill: "none",
|
|
826
|
+
stroke: "currentColor",
|
|
827
|
+
"stroke-width": "2",
|
|
828
|
+
"stroke-linecap": "round"
|
|
829
|
+
}, [o("line", {
|
|
830
|
+
x1: "5",
|
|
831
|
+
y1: "5",
|
|
832
|
+
x2: "19",
|
|
833
|
+
y2: "19"
|
|
834
|
+
})], -1)]], 10, we)])]),
|
|
835
|
+
o("div", Te, [o("button", {
|
|
836
|
+
class: "popover-btn cancel",
|
|
837
|
+
onClick: Le
|
|
838
|
+
}, S(C(d)("canvasSize.cancel")), 1), o("button", {
|
|
839
|
+
class: "popover-btn confirm",
|
|
840
|
+
onClick: Ie
|
|
841
|
+
}, S(C(d)("canvasSize.confirm")), 1)])
|
|
842
|
+
], 36)], 32)) : i("", !0)]))]),
|
|
843
|
+
o("div", Ee, [
|
|
844
|
+
Q.value ? (_(), a("div", {
|
|
845
|
+
key: 0,
|
|
846
|
+
class: p(["color-indicator", { active: C(u).showColorPalette && C(u).activeColorSlot === "textColor" }]),
|
|
847
|
+
title: C(d)("color.textColor"),
|
|
848
|
+
onClick: Je
|
|
849
|
+
}, [o("div", Oe, [(_(), a("svg", {
|
|
850
|
+
class: "text-color-icon",
|
|
851
|
+
style: m({ color: qe.value ? "var(--wb-text-secondary)" : Ke.value }),
|
|
852
|
+
viewBox: "0 0 24 24",
|
|
853
|
+
fill: "none",
|
|
854
|
+
stroke: "currentColor",
|
|
855
|
+
"stroke-width": "1.8",
|
|
856
|
+
"stroke-linecap": "round",
|
|
857
|
+
"stroke-linejoin": "round"
|
|
858
|
+
}, [...c[19] ||= [
|
|
859
|
+
o("polyline", { points: "4 7 4 4 20 4 20 7" }, null, -1),
|
|
860
|
+
o("line", {
|
|
861
|
+
x1: "9",
|
|
862
|
+
y1: "20",
|
|
863
|
+
x2: "15",
|
|
864
|
+
y2: "20"
|
|
865
|
+
}, null, -1),
|
|
866
|
+
o("line", {
|
|
867
|
+
x1: "12",
|
|
868
|
+
y1: "4",
|
|
869
|
+
x2: "12",
|
|
870
|
+
y2: "20"
|
|
871
|
+
}, null, -1)
|
|
872
|
+
]], 4)), qe.value ? (_(), a("svg", ke, [...c[20] ||= [o("line", {
|
|
873
|
+
x1: "5",
|
|
874
|
+
y1: "12",
|
|
875
|
+
x2: "19",
|
|
876
|
+
y2: "12"
|
|
877
|
+
}, null, -1), o("line", {
|
|
878
|
+
x1: "12",
|
|
879
|
+
y1: "5",
|
|
880
|
+
x2: "12",
|
|
881
|
+
y2: "19"
|
|
882
|
+
}, null, -1)]])) : i("", !0)])], 10, De)) : i("", !0),
|
|
883
|
+
o("div", {
|
|
884
|
+
class: p(["color-indicator", {
|
|
885
|
+
active: C(u).showColorPalette && C(u).activeColorSlot === "foreground",
|
|
886
|
+
disabled: We.value
|
|
887
|
+
}]),
|
|
888
|
+
title: C(d)("color.foreground"),
|
|
889
|
+
onClick: Ye
|
|
890
|
+
}, [o("div", {
|
|
891
|
+
class: p(["color-swatch fg", { mixed: X.value }]),
|
|
892
|
+
style: m({ background: X.value ? "none" : Ve.value })
|
|
893
|
+
}, [X.value ? (_(), a("svg", je, [...c[21] ||= [o("line", {
|
|
894
|
+
x1: "5",
|
|
895
|
+
y1: "12",
|
|
896
|
+
x2: "19",
|
|
897
|
+
y2: "12"
|
|
898
|
+
}, null, -1), o("line", {
|
|
899
|
+
x1: "12",
|
|
900
|
+
y1: "5",
|
|
901
|
+
x2: "12",
|
|
902
|
+
y2: "19"
|
|
903
|
+
}, null, -1)]])) : i("", !0)], 6)], 10, Ae),
|
|
904
|
+
o("div", {
|
|
905
|
+
class: p(["color-indicator", {
|
|
906
|
+
active: C(u).showColorPalette && C(u).activeColorSlot === "background",
|
|
907
|
+
disabled: Ge.value
|
|
908
|
+
}]),
|
|
909
|
+
title: C(d)("color.background"),
|
|
910
|
+
onClick: Xe
|
|
911
|
+
}, [o("div", {
|
|
912
|
+
class: p(["color-swatch bg", {
|
|
913
|
+
mixed: He.value,
|
|
914
|
+
transparent: !He.value && Z.value === "transparent"
|
|
915
|
+
}]),
|
|
916
|
+
style: m({ background: He.value || Z.value === "transparent" ? "none" : Z.value })
|
|
917
|
+
}, [He.value ? (_(), a("svg", Ne, [...c[22] ||= [o("line", {
|
|
918
|
+
x1: "5",
|
|
919
|
+
y1: "12",
|
|
920
|
+
x2: "19",
|
|
921
|
+
y2: "12"
|
|
922
|
+
}, null, -1), o("line", {
|
|
923
|
+
x1: "12",
|
|
924
|
+
y1: "5",
|
|
925
|
+
x2: "12",
|
|
926
|
+
y2: "19"
|
|
927
|
+
}, null, -1)]])) : Z.value === "transparent" ? (_(), a("svg", Pe, [...c[23] ||= [o("line", {
|
|
928
|
+
x1: "5",
|
|
929
|
+
y1: "5",
|
|
930
|
+
x2: "19",
|
|
931
|
+
y2: "19"
|
|
932
|
+
}, null, -1)]])) : i("", !0)], 6)], 10, Me)
|
|
933
|
+
])
|
|
934
|
+
]));
|
|
935
|
+
}
|
|
936
|
+
}), Le = (e, t) => {
|
|
937
|
+
let n = e.__vccOpts || e;
|
|
938
|
+
for (let [e, r] of t) n[e] = r;
|
|
939
|
+
return n;
|
|
940
|
+
}, Re = /*#__PURE__*/ Le(Ie, [["__scopeId", "data-v-9532ade7"]]);
|
|
941
|
+
//#endregion
|
|
942
|
+
//#region src/components/painter/utils/geometry.ts
|
|
943
|
+
function ze(e, t, n, r, i = !1, a = .382) {
|
|
944
|
+
let o = i ? -1 : 1, s = [];
|
|
945
|
+
for (let i = 0; i < 5; i++) {
|
|
946
|
+
let c = Math.PI / 2 * -1 + Math.PI * 2 * i / 5, l = c + Math.PI / 5;
|
|
947
|
+
s.push({
|
|
948
|
+
x: e + n * Math.cos(c),
|
|
949
|
+
y: t - o * r * Math.sin(c)
|
|
950
|
+
}), s.push({
|
|
951
|
+
x: e + n * a * Math.cos(l),
|
|
952
|
+
y: t - o * r * a * Math.sin(l)
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
return s;
|
|
956
|
+
}
|
|
957
|
+
function Be(e, t, n, r) {
|
|
958
|
+
let i = n >= 0 ? e : e + n, a = r >= 0 ? t : t + r, o = Math.abs(n), s = Math.abs(r);
|
|
959
|
+
return r >= 0 ? [
|
|
960
|
+
{
|
|
961
|
+
x: i + o / 2,
|
|
962
|
+
y: a
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
x: i + o,
|
|
966
|
+
y: a + s
|
|
967
|
+
},
|
|
968
|
+
{
|
|
969
|
+
x: i,
|
|
970
|
+
y: a + s
|
|
971
|
+
}
|
|
972
|
+
] : [
|
|
973
|
+
{
|
|
974
|
+
x: i + o / 2,
|
|
975
|
+
y: a + s
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
x: i,
|
|
979
|
+
y: a
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
x: i + o,
|
|
983
|
+
y: a
|
|
984
|
+
}
|
|
985
|
+
];
|
|
986
|
+
}
|
|
987
|
+
function Ve(e, t, n) {
|
|
988
|
+
let r = n.x - t.x, i = n.y - t.y, a = r * r + i * i;
|
|
989
|
+
if (a === 0) return Math.hypot(e.x - t.x, e.y - t.y);
|
|
990
|
+
let o = ((e.x - t.x) * r + (e.y - t.y) * i) / a;
|
|
991
|
+
return o = Math.max(0, Math.min(1, o)), Math.hypot(e.x - (t.x + o * r), e.y - (t.y + o * i));
|
|
992
|
+
}
|
|
993
|
+
function X(e, t) {
|
|
994
|
+
let n = !1;
|
|
995
|
+
for (let r = 0, i = t.length - 1; r < t.length; i = r++) {
|
|
996
|
+
let a = t[r].x, o = t[r].y, s = t[i].x, c = t[i].y;
|
|
997
|
+
o > e.y != c > e.y && e.x < (s - a) * (e.y - o) / (c - o) + a && (n = !n);
|
|
998
|
+
}
|
|
999
|
+
return n;
|
|
1000
|
+
}
|
|
1001
|
+
function Z(e, t, n, r, i) {
|
|
1002
|
+
if (r <= 0 || i <= 0) return !1;
|
|
1003
|
+
let a = (e.x - t) / r, o = (e.y - n) / i;
|
|
1004
|
+
return a * a + o * o <= 1;
|
|
1005
|
+
}
|
|
1006
|
+
function He(e) {
|
|
1007
|
+
if (e.length === 0) return {
|
|
1008
|
+
x: 0,
|
|
1009
|
+
y: 0,
|
|
1010
|
+
width: 0,
|
|
1011
|
+
height: 0
|
|
1012
|
+
};
|
|
1013
|
+
let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity;
|
|
1014
|
+
for (let a of e) a.x < t && (t = a.x), a.y < n && (n = a.y), a.x > r && (r = a.x), a.y > i && (i = a.y);
|
|
1015
|
+
return {
|
|
1016
|
+
x: t,
|
|
1017
|
+
y: n,
|
|
1018
|
+
width: r - t,
|
|
1019
|
+
height: i - n
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
function Q(e, t) {
|
|
1023
|
+
let { x: n, y: r, width: i, height: a, type: o, points: s, fillColor: c } = t, l = c !== "none" && c !== "transparent";
|
|
1024
|
+
switch (o) {
|
|
1025
|
+
case "pencil":
|
|
1026
|
+
if (s.length < 2) return !1;
|
|
1027
|
+
for (let t = 0; t < s.length - 1; t++) if (Ve(e, s[t], s[t + 1]) < 8) return !0;
|
|
1028
|
+
return !1;
|
|
1029
|
+
case "line": return Ve(e, {
|
|
1030
|
+
x: n,
|
|
1031
|
+
y: r
|
|
1032
|
+
}, {
|
|
1033
|
+
x: n + i,
|
|
1034
|
+
y: r + a
|
|
1035
|
+
}) < 8;
|
|
1036
|
+
case "circle": {
|
|
1037
|
+
let t = n + i / 2, o = r + a / 2, s = Math.abs(i) / 2, c = Math.abs(a) / 2;
|
|
1038
|
+
return l && Z(e, t, o, s, c) ? !0 : Z(e, t, o, s + 8, c + 8) && !Z(e, t, o, s - 8, c - 8);
|
|
1039
|
+
}
|
|
1040
|
+
case "rect": {
|
|
1041
|
+
if (l && e.x >= n && e.x <= n + i && e.y >= r && e.y <= r + a) return !0;
|
|
1042
|
+
let t = e.x >= n - 8 && e.x <= n + i + 8 && e.y >= r - 8 && e.y <= r + a + 8, o = e.x >= n + 8 && e.x <= n + i - 8 && e.y >= r + 8 && e.y <= r + a - 8;
|
|
1043
|
+
return t && !o;
|
|
1044
|
+
}
|
|
1045
|
+
case "triangle": {
|
|
1046
|
+
let t = Be(n, r, i, a);
|
|
1047
|
+
return l && X(e, t) ? !0 : X(e, t);
|
|
1048
|
+
}
|
|
1049
|
+
case "star": {
|
|
1050
|
+
let t = ze(n + i / 2, r + a / 2, Math.abs(i) / 2, Math.abs(a) / 2, a >= 0);
|
|
1051
|
+
return l && X(e, t) ? !0 : X(e, t);
|
|
1052
|
+
}
|
|
1053
|
+
case "text": return e.x >= n - 8 && e.x <= n + Math.max(i, 32) + 8 && e.y >= r - 8 && e.y <= r + Math.max(a, 16) + 8;
|
|
1054
|
+
default: return !1;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
//#endregion
|
|
1058
|
+
//#region src/components/painter/composables/useDrawing.ts
|
|
1059
|
+
function Ue(e) {
|
|
1060
|
+
let t = B(), r = ie(), i = y(!1), a = y({
|
|
1061
|
+
x: 0,
|
|
1062
|
+
y: 0
|
|
1063
|
+
}), o = y({
|
|
1064
|
+
x: 0,
|
|
1065
|
+
y: 0
|
|
1066
|
+
}), s = y([]), c = y(!1), l = y(!1), u = y(!1), d = y(!1), f = y(/* @__PURE__ */ new Map()), p = y(!1), m = y(null), h = y(""), g = y(""), _ = y(null), v = y(!1), b = y(0), x = y(0), S = y(0), C = y(0), w = y(!1), T = null;
|
|
1067
|
+
function E(e) {
|
|
1068
|
+
T = e;
|
|
1069
|
+
}
|
|
1070
|
+
function D() {
|
|
1071
|
+
let e = t.editingTextId;
|
|
1072
|
+
if (!e || !t.strokes.find((t) => t.id === e)) return;
|
|
1073
|
+
let n = T?.() ?? null;
|
|
1074
|
+
n !== null && (n.trim() ? t.updateStroke(e, { text: n }) : (t.strokes = t.strokes.filter((t) => t.id !== e), t.undoStack.length > 0 && t.undoStack.pop()), t.editingTextId = null);
|
|
1075
|
+
}
|
|
1076
|
+
function O(e) {
|
|
1077
|
+
if (!v.value) return;
|
|
1078
|
+
let n = e.clientX - b.value, r = e.clientY - x.value;
|
|
1079
|
+
t.setPan(S.value + n, C.value + r);
|
|
1080
|
+
}
|
|
1081
|
+
function k() {
|
|
1082
|
+
v.value && (v.value = !1, window.removeEventListener("mousemove", O), window.removeEventListener("mouseup", k), window.removeEventListener("touchmove", ne), window.removeEventListener("touchend", z));
|
|
1083
|
+
}
|
|
1084
|
+
function A(e, t, n, r, i) {
|
|
1085
|
+
let a = r - t, o = i - n, s = e === "circle" || e === "rect" || e === "triangle" || e === "star";
|
|
1086
|
+
if (e === "line" && u.value) {
|
|
1087
|
+
let e = Math.round(Math.atan2(o, a) / (Math.PI / 4)) * (Math.PI / 4), t = Math.hypot(a, o);
|
|
1088
|
+
a = Math.cos(e) * t, o = Math.sin(e) * t;
|
|
1089
|
+
}
|
|
1090
|
+
if (s) {
|
|
1091
|
+
if (c.value) {
|
|
1092
|
+
let e = Math.max(Math.abs(a), Math.abs(o));
|
|
1093
|
+
a = a >= 0 ? e : -e, o = o >= 0 ? e : -e;
|
|
1094
|
+
}
|
|
1095
|
+
if (l.value) {
|
|
1096
|
+
let e = j(t, n, t + a, n + o), r = e.width, i = e.height;
|
|
1097
|
+
return {
|
|
1098
|
+
x: t - r,
|
|
1099
|
+
y: n - i,
|
|
1100
|
+
width: r * 2,
|
|
1101
|
+
height: i * 2
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
return e === "line" || e === "triangle" || e === "star" ? {
|
|
1106
|
+
x: t,
|
|
1107
|
+
y: n,
|
|
1108
|
+
width: a,
|
|
1109
|
+
height: o
|
|
1110
|
+
} : j(t, n, t + a, n + o);
|
|
1111
|
+
}
|
|
1112
|
+
function j(e, t, n, r) {
|
|
1113
|
+
return {
|
|
1114
|
+
x: Math.min(e, n),
|
|
1115
|
+
y: Math.min(t, r),
|
|
1116
|
+
width: Math.abs(n - e),
|
|
1117
|
+
height: Math.abs(r - t)
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
let M = n(() => {
|
|
1121
|
+
if (!i.value) return null;
|
|
1122
|
+
let e = r.activeTool;
|
|
1123
|
+
if (e === "select" || e === "pan" || e === "zoom" || e === "text") return null;
|
|
1124
|
+
let { x: n, y: c } = a.value, { x: l, y: u } = o.value;
|
|
1125
|
+
return e === "pencil" ? {
|
|
1126
|
+
id: "__preview__",
|
|
1127
|
+
type: "pencil",
|
|
1128
|
+
...He(s.value),
|
|
1129
|
+
points: [...s.value],
|
|
1130
|
+
strokeColor: t.foregroundColor,
|
|
1131
|
+
fillColor: "none",
|
|
1132
|
+
strokeWidth: t.strokeWidth
|
|
1133
|
+
} : {
|
|
1134
|
+
id: "__preview__",
|
|
1135
|
+
type: e,
|
|
1136
|
+
...A(e, n, c, l, u),
|
|
1137
|
+
points: [],
|
|
1138
|
+
strokeColor: t.foregroundColor,
|
|
1139
|
+
fillColor: e === "line" ? "none" : t.backgroundColor,
|
|
1140
|
+
strokeWidth: t.strokeWidth
|
|
1141
|
+
};
|
|
1142
|
+
});
|
|
1143
|
+
function N(e) {
|
|
1144
|
+
return P(e.clientX, e.clientY);
|
|
1145
|
+
}
|
|
1146
|
+
function P(n, r) {
|
|
1147
|
+
let i = e.value;
|
|
1148
|
+
if (!i) return {
|
|
1149
|
+
x: 0,
|
|
1150
|
+
y: 0
|
|
1151
|
+
};
|
|
1152
|
+
let a = i.getBoundingClientRect();
|
|
1153
|
+
return {
|
|
1154
|
+
x: (n - a.left) / t.zoomLevel,
|
|
1155
|
+
y: (r - a.top) / t.zoomLevel
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
function ee(e) {
|
|
1159
|
+
I(e.clientX, e.clientY, e.type === "mousedown" ? e : void 0);
|
|
1160
|
+
}
|
|
1161
|
+
function F(e) {
|
|
1162
|
+
if (e.touches.length !== 1) return;
|
|
1163
|
+
e.preventDefault();
|
|
1164
|
+
let t = e.touches[0];
|
|
1165
|
+
I(t.clientX, t.clientY);
|
|
1166
|
+
}
|
|
1167
|
+
function I(n, c, l) {
|
|
1168
|
+
let u = P(n, c);
|
|
1169
|
+
if (t.editingTextId && r.activeTool !== "text" && D(), r.activeTool === "pan") {
|
|
1170
|
+
v.value = !0, b.value = n, x.value = c, S.value = t.panX, C.value = t.panY, window.addEventListener("mousemove", O), window.addEventListener("mouseup", k), window.addEventListener("touchmove", ne, { passive: !1 }), window.addEventListener("touchend", z);
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
if (r.activeTool === "zoom" && l) {
|
|
1174
|
+
let r = l.button === 2 ? .8 : 1.25, i = e.value;
|
|
1175
|
+
if (i) {
|
|
1176
|
+
let e = i.getBoundingClientRect();
|
|
1177
|
+
t.zoomAt(n - e.left, c - e.top, r);
|
|
1178
|
+
}
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
if (r.activeTool === "text") {
|
|
1182
|
+
let e = t.editingTextId;
|
|
1183
|
+
if (e) {
|
|
1184
|
+
let n = t.strokes.find((t) => t.id === e);
|
|
1185
|
+
if (n && Q(u, n)) return;
|
|
1186
|
+
} else {
|
|
1187
|
+
let e = [...t.strokes].reverse().find((e) => Q(u, e));
|
|
1188
|
+
if (e && e.type === "text") {
|
|
1189
|
+
t.hoveredTextId = null, D(), t.pushUndo(), t.editingTextId = e.id;
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
w.value = !0, a.value = u;
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
if (a.value = u, o.value = u, i.value = !0, r.activeTool === "pencil" && (s.value = [u]), r.activeTool === "select") {
|
|
1197
|
+
let e = [...t.strokes].reverse().find((e) => Q(u, e));
|
|
1198
|
+
if (e && t.isSelected(e.id)) {
|
|
1199
|
+
t.pushUndo(), d.value = !0, f.value.clear();
|
|
1200
|
+
for (let e of t.selectedStrokes) f.value.set(e.id, {
|
|
1201
|
+
x: e.x,
|
|
1202
|
+
y: e.y,
|
|
1203
|
+
width: e.width,
|
|
1204
|
+
height: e.height,
|
|
1205
|
+
points: e.points.map((e) => ({ ...e }))
|
|
1206
|
+
});
|
|
1207
|
+
t.isSelecting = !1, t.selectionBox = null;
|
|
1208
|
+
} else d.value = !1, t.isSelecting = !0, t.selectionBox = {
|
|
1209
|
+
x: u.x,
|
|
1210
|
+
y: u.y,
|
|
1211
|
+
width: 0,
|
|
1212
|
+
height: 0
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
function L(e) {
|
|
1217
|
+
R(e.clientX, e.clientY);
|
|
1218
|
+
}
|
|
1219
|
+
function te(e) {
|
|
1220
|
+
if (e.touches.length !== 1) return;
|
|
1221
|
+
e.preventDefault();
|
|
1222
|
+
let t = e.touches[0];
|
|
1223
|
+
R(t.clientX, t.clientY);
|
|
1224
|
+
}
|
|
1225
|
+
function R(e, n) {
|
|
1226
|
+
let c = P(e, n);
|
|
1227
|
+
if (r.activeTool === "text" && !i.value && !t.editingTextId) {
|
|
1228
|
+
let e = [...t.strokes].reverse().find((e) => Q(c, e));
|
|
1229
|
+
t.hoveredTextId = e && e.type === "text" ? e.id : null;
|
|
1230
|
+
} else i.value || (t.hoveredTextId = null);
|
|
1231
|
+
if (i.value && (o.value = c, r.activeTool === "pencil" && s.value.push(c), r.activeTool === "select")) if (d.value) {
|
|
1232
|
+
let e = c.x - a.value.x, n = c.y - a.value.y;
|
|
1233
|
+
for (let r of t.selectedStrokes) {
|
|
1234
|
+
let i = f.value.get(r.id);
|
|
1235
|
+
i && t.updateStroke(r.id, {
|
|
1236
|
+
x: i.x + e,
|
|
1237
|
+
y: i.y + n,
|
|
1238
|
+
points: i.points.map((t) => ({
|
|
1239
|
+
x: t.x + e,
|
|
1240
|
+
y: t.y + n
|
|
1241
|
+
}))
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
} else t.selectionBox = {
|
|
1245
|
+
x: Math.min(a.value.x, c.x),
|
|
1246
|
+
y: Math.min(a.value.y, c.y),
|
|
1247
|
+
width: Math.abs(c.x - a.value.x),
|
|
1248
|
+
height: Math.abs(c.y - a.value.y)
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
function ne(e) {
|
|
1252
|
+
if (!v.value || e.touches.length !== 1) return;
|
|
1253
|
+
e.preventDefault();
|
|
1254
|
+
let n = e.touches[0], r = n.clientX - b.value, i = n.clientY - x.value;
|
|
1255
|
+
t.setPan(S.value + r, C.value + i);
|
|
1256
|
+
}
|
|
1257
|
+
function z() {
|
|
1258
|
+
v.value && (v.value = !1, window.removeEventListener("mousemove", O), window.removeEventListener("mouseup", k), window.removeEventListener("touchmove", ne), window.removeEventListener("touchend", z));
|
|
1259
|
+
}
|
|
1260
|
+
function re(e) {
|
|
1261
|
+
H(e.clientX, e.clientY);
|
|
1262
|
+
}
|
|
1263
|
+
function V(e) {
|
|
1264
|
+
let t = e.changedTouches[0];
|
|
1265
|
+
t && H(t.clientX, t.clientY);
|
|
1266
|
+
}
|
|
1267
|
+
function H(e, n) {
|
|
1268
|
+
if (r.activeTool === "zoom") return;
|
|
1269
|
+
if (r.activeTool === "text") {
|
|
1270
|
+
if (w.value) {
|
|
1271
|
+
w.value = !1, D();
|
|
1272
|
+
let e = t.buildStroke("text", a.value.x, a.value.y, 0, 0, []);
|
|
1273
|
+
t.addStroke(e), t.editingTextId = e.id;
|
|
1274
|
+
}
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
if (!i.value) return;
|
|
1278
|
+
i.value = !1;
|
|
1279
|
+
let o = P(e, n), c = o.x - a.value.x, l = o.y - a.value.y, u = Math.hypot(c, l);
|
|
1280
|
+
if (r.activeTool === "select") {
|
|
1281
|
+
if (d.value) d.value = !1, f.value.clear(), t.dataVersion++;
|
|
1282
|
+
else {
|
|
1283
|
+
if (t.isSelecting = !1, u < 3) {
|
|
1284
|
+
let e = [...t.strokes].reverse().find((e) => Q(o, e));
|
|
1285
|
+
t.selectStroke(e?.id ?? null);
|
|
1286
|
+
} else {
|
|
1287
|
+
let e = t.selectionBox, n = [];
|
|
1288
|
+
for (let r of [...t.strokes].reverse()) {
|
|
1289
|
+
let i = t.getStrokeDisplayBounds(r);
|
|
1290
|
+
i.x >= e.x && i.x + i.width <= e.x + e.width && i.y >= e.y && i.y + i.height <= e.y + e.height && n.push(r.id);
|
|
1291
|
+
}
|
|
1292
|
+
t.selectStrokes(n);
|
|
1293
|
+
}
|
|
1294
|
+
t.selectionBox = null;
|
|
1295
|
+
}
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
if (u < 3) {
|
|
1299
|
+
t.clearSelection();
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
let p = r.activeTool, { x: m, y: h } = a.value;
|
|
1303
|
+
if (p === "pencil") {
|
|
1304
|
+
if (s.value.length < 2) {
|
|
1305
|
+
t.clearSelection();
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
let e = s.value.map((e) => ({
|
|
1309
|
+
x: Math.round(e.x),
|
|
1310
|
+
y: Math.round(e.y)
|
|
1311
|
+
})), n = He(e);
|
|
1312
|
+
if (n.width < 3 && n.height < 3) {
|
|
1313
|
+
t.clearSelection();
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
let i = t.buildStroke("pencil", n.x, n.y, n.width, n.height, e);
|
|
1317
|
+
t.addStroke(i), r.setTool("select");
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
let g = o.x - m, _ = o.y - h;
|
|
1321
|
+
if (Math.abs(g) < 3 && Math.abs(_) < 3) {
|
|
1322
|
+
t.clearSelection();
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
let v = A(p, m, h, o.x, o.y), y = t.buildStroke(p, v.x, v.y, v.width, v.height, []);
|
|
1326
|
+
t.addStroke(y), r.setTool("select");
|
|
1327
|
+
}
|
|
1328
|
+
function U(e, n) {
|
|
1329
|
+
t.strokes.find((t) => t.id === e) && (n.trim() ? t.updateStroke(e, { text: n }) : (t.strokes = t.strokes.filter((t) => t.id !== e), t.undoStack.length > 0 && t.undoStack.pop()), t.editingTextId = null, r.activeTool === "text" && r.setTool("select"));
|
|
1330
|
+
}
|
|
1331
|
+
function W(e) {
|
|
1332
|
+
let n = t.strokes.find((t) => t.id === e);
|
|
1333
|
+
n && ((!n.text || !n.text.trim()) && (t.strokes = t.strokes.filter((t) => t.id !== e), t.undoStack.length > 0 && t.undoStack.pop()), t.editingTextId = null, r.activeTool === "text" && r.setTool("select"));
|
|
1334
|
+
}
|
|
1335
|
+
function ae(e) {
|
|
1336
|
+
t.pushUndo(), t.editingTextId = e;
|
|
1337
|
+
}
|
|
1338
|
+
function oe(e) {
|
|
1339
|
+
let t = e.ctrlKey || e.metaKey;
|
|
1340
|
+
c.value = t, l.value = e.shiftKey, u.value = e.shiftKey;
|
|
1341
|
+
}
|
|
1342
|
+
function se() {
|
|
1343
|
+
c.value = !1, l.value = !1, u.value = !1;
|
|
1344
|
+
}
|
|
1345
|
+
function G(e, t) {
|
|
1346
|
+
let { x: n, y: r, w: i, h: a } = e;
|
|
1347
|
+
switch (t) {
|
|
1348
|
+
case "nw": return {
|
|
1349
|
+
x: n + i,
|
|
1350
|
+
y: r + a
|
|
1351
|
+
};
|
|
1352
|
+
case "n": return {
|
|
1353
|
+
x: n + i / 2,
|
|
1354
|
+
y: r + a
|
|
1355
|
+
};
|
|
1356
|
+
case "ne": return {
|
|
1357
|
+
x: n,
|
|
1358
|
+
y: r + a
|
|
1359
|
+
};
|
|
1360
|
+
case "e": return {
|
|
1361
|
+
x: n,
|
|
1362
|
+
y: r + a / 2
|
|
1363
|
+
};
|
|
1364
|
+
case "se": return {
|
|
1365
|
+
x: n,
|
|
1366
|
+
y: r
|
|
1367
|
+
};
|
|
1368
|
+
case "s": return {
|
|
1369
|
+
x: n + i / 2,
|
|
1370
|
+
y: r
|
|
1371
|
+
};
|
|
1372
|
+
case "sw": return {
|
|
1373
|
+
x: n + i,
|
|
1374
|
+
y: r
|
|
1375
|
+
};
|
|
1376
|
+
case "w": return {
|
|
1377
|
+
x: n + i,
|
|
1378
|
+
y: r + a / 2
|
|
1379
|
+
};
|
|
1380
|
+
case "line-start": return {
|
|
1381
|
+
x: n + i,
|
|
1382
|
+
y: r + a
|
|
1383
|
+
};
|
|
1384
|
+
case "line-end": return {
|
|
1385
|
+
x: n,
|
|
1386
|
+
y: r
|
|
1387
|
+
};
|
|
1388
|
+
default: return {
|
|
1389
|
+
x: n + i,
|
|
1390
|
+
y: r + a
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
function ce(e) {
|
|
1395
|
+
return e === "n" || e === "s" || e === "e" || e === "w";
|
|
1396
|
+
}
|
|
1397
|
+
function le(e, n, r, i) {
|
|
1398
|
+
let s = t.strokes.find((t) => t.id === e);
|
|
1399
|
+
if (!s) return;
|
|
1400
|
+
t.pushUndo();
|
|
1401
|
+
let c = me(s);
|
|
1402
|
+
_.value = {
|
|
1403
|
+
x: c.x,
|
|
1404
|
+
y: c.y,
|
|
1405
|
+
width: c.width,
|
|
1406
|
+
height: c.height,
|
|
1407
|
+
type: s.type
|
|
1408
|
+
}, m.value = e, h.value = n, g.value = r, p.value = !0;
|
|
1409
|
+
let l, u;
|
|
1410
|
+
if ("touches" in i) {
|
|
1411
|
+
let e = i.touches[0] || i.changedTouches[0];
|
|
1412
|
+
l = e.clientX, u = e.clientY, i.preventDefault();
|
|
1413
|
+
} else l = i.clientX, u = i.clientY;
|
|
1414
|
+
let d = P(l, u);
|
|
1415
|
+
a.value = d, o.value = d, window.addEventListener("mousemove", ue), window.addEventListener("mouseup", de), window.addEventListener("touchmove", K, { passive: !1 }), window.addEventListener("touchend", fe);
|
|
1416
|
+
}
|
|
1417
|
+
function ue(e) {
|
|
1418
|
+
q(e.clientX, e.clientY);
|
|
1419
|
+
}
|
|
1420
|
+
function K(e) {
|
|
1421
|
+
if (e.touches.length !== 1) return;
|
|
1422
|
+
e.preventDefault();
|
|
1423
|
+
let t = e.touches[0];
|
|
1424
|
+
q(t.clientX, t.clientY);
|
|
1425
|
+
}
|
|
1426
|
+
function q(e, n) {
|
|
1427
|
+
if (!p.value || !_.value || !m.value) return;
|
|
1428
|
+
let r = P(e, n);
|
|
1429
|
+
o.value = r;
|
|
1430
|
+
let i = _.value, a = i.x + i.width / 2, s = i.y + i.height / 2, c;
|
|
1431
|
+
if (l.value && ce(h.value)) {
|
|
1432
|
+
let { x: e, y: n, width: o, height: l } = i;
|
|
1433
|
+
switch (h.value) {
|
|
1434
|
+
case "n": {
|
|
1435
|
+
let t = Math.abs(r.y - s);
|
|
1436
|
+
c = {
|
|
1437
|
+
x: e,
|
|
1438
|
+
y: s - t,
|
|
1439
|
+
width: o,
|
|
1440
|
+
height: t * 2
|
|
1441
|
+
};
|
|
1442
|
+
break;
|
|
1443
|
+
}
|
|
1444
|
+
case "s": {
|
|
1445
|
+
let t = Math.abs(r.y - s);
|
|
1446
|
+
c = {
|
|
1447
|
+
x: e,
|
|
1448
|
+
y: s - t,
|
|
1449
|
+
width: o,
|
|
1450
|
+
height: t * 2
|
|
1451
|
+
};
|
|
1452
|
+
break;
|
|
1453
|
+
}
|
|
1454
|
+
case "e": {
|
|
1455
|
+
let e = Math.abs(r.x - a);
|
|
1456
|
+
c = {
|
|
1457
|
+
x: a - e,
|
|
1458
|
+
y: n,
|
|
1459
|
+
width: e * 2,
|
|
1460
|
+
height: l
|
|
1461
|
+
};
|
|
1462
|
+
break;
|
|
1463
|
+
}
|
|
1464
|
+
case "w": {
|
|
1465
|
+
let e = Math.abs(r.x - a);
|
|
1466
|
+
c = {
|
|
1467
|
+
x: a - e,
|
|
1468
|
+
y: n,
|
|
1469
|
+
width: e * 2,
|
|
1470
|
+
height: l
|
|
1471
|
+
};
|
|
1472
|
+
break;
|
|
1473
|
+
}
|
|
1474
|
+
default: c = {
|
|
1475
|
+
x: e,
|
|
1476
|
+
y: n,
|
|
1477
|
+
width: o,
|
|
1478
|
+
height: l
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
t.updateStroke(m.value, c);
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
1484
|
+
if (l.value) {
|
|
1485
|
+
c = A(i.type, a, s, r.x, r.y), t.updateStroke(m.value, c);
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
if (ce(h.value)) {
|
|
1489
|
+
let { x: e, y: t, width: n, height: a } = i;
|
|
1490
|
+
switch (h.value) {
|
|
1491
|
+
case "n": {
|
|
1492
|
+
let i = t + a;
|
|
1493
|
+
c = {
|
|
1494
|
+
x: e,
|
|
1495
|
+
y: Math.min(r.y, i),
|
|
1496
|
+
width: n,
|
|
1497
|
+
height: Math.abs(r.y - i)
|
|
1498
|
+
};
|
|
1499
|
+
break;
|
|
1500
|
+
}
|
|
1501
|
+
case "s":
|
|
1502
|
+
c = {
|
|
1503
|
+
x: e,
|
|
1504
|
+
y: t,
|
|
1505
|
+
width: n,
|
|
1506
|
+
height: Math.abs(r.y - t)
|
|
1507
|
+
};
|
|
1508
|
+
break;
|
|
1509
|
+
case "e":
|
|
1510
|
+
c = {
|
|
1511
|
+
x: e,
|
|
1512
|
+
y: t,
|
|
1513
|
+
width: Math.abs(r.x - e),
|
|
1514
|
+
height: a
|
|
1515
|
+
};
|
|
1516
|
+
break;
|
|
1517
|
+
case "w": {
|
|
1518
|
+
let i = e + n;
|
|
1519
|
+
c = {
|
|
1520
|
+
x: Math.min(r.x, i),
|
|
1521
|
+
y: t,
|
|
1522
|
+
width: Math.abs(r.x - i),
|
|
1523
|
+
height: a
|
|
1524
|
+
};
|
|
1525
|
+
break;
|
|
1526
|
+
}
|
|
1527
|
+
default: c = {
|
|
1528
|
+
x: e,
|
|
1529
|
+
y: t,
|
|
1530
|
+
width: n,
|
|
1531
|
+
height: a
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
} else {
|
|
1535
|
+
let e = G({
|
|
1536
|
+
x: i.x,
|
|
1537
|
+
y: i.y,
|
|
1538
|
+
w: i.width,
|
|
1539
|
+
h: i.height
|
|
1540
|
+
}, h.value);
|
|
1541
|
+
c = A(i.type, e.x, e.y, r.x, r.y);
|
|
1542
|
+
}
|
|
1543
|
+
if (_.value?.type === "text") {
|
|
1544
|
+
c.width < 1 && (c.width = 1), t.updateStroke(m.value, {
|
|
1545
|
+
x: c.x,
|
|
1546
|
+
width: c.width,
|
|
1547
|
+
textAutoWidth: !1
|
|
1548
|
+
});
|
|
1549
|
+
return;
|
|
1550
|
+
}
|
|
1551
|
+
t.updateStroke(m.value, c);
|
|
1552
|
+
}
|
|
1553
|
+
function de() {
|
|
1554
|
+
pe();
|
|
1555
|
+
}
|
|
1556
|
+
function fe(e) {
|
|
1557
|
+
e.touches.length === 0 && pe();
|
|
1558
|
+
}
|
|
1559
|
+
function pe() {
|
|
1560
|
+
p.value = !1, m.value = null, h.value = "", g.value = "", _.value = null, t.dataVersion++, window.removeEventListener("mousemove", ue), window.removeEventListener("mouseup", de), window.removeEventListener("touchmove", K), window.removeEventListener("touchend", fe);
|
|
1561
|
+
}
|
|
1562
|
+
function me(e) {
|
|
1563
|
+
let { type: t } = e;
|
|
1564
|
+
if (t === "line" || t === "triangle" || t === "star") {
|
|
1565
|
+
let { x: t, y: n, width: r, height: i } = e;
|
|
1566
|
+
return {
|
|
1567
|
+
x: r >= 0 ? t : t + r,
|
|
1568
|
+
y: i >= 0 ? n : n + i,
|
|
1569
|
+
width: Math.abs(r),
|
|
1570
|
+
height: Math.abs(i)
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
return {
|
|
1574
|
+
x: e.x,
|
|
1575
|
+
y: e.y,
|
|
1576
|
+
width: e.width,
|
|
1577
|
+
height: e.height
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
return {
|
|
1581
|
+
isDrawing: i,
|
|
1582
|
+
previewStroke: M,
|
|
1583
|
+
onMouseDown: ee,
|
|
1584
|
+
onMouseMove: L,
|
|
1585
|
+
onMouseUp: re,
|
|
1586
|
+
onTouchStart: F,
|
|
1587
|
+
onTouchMove: te,
|
|
1588
|
+
onTouchEnd: V,
|
|
1589
|
+
getSVGPoint: N,
|
|
1590
|
+
updateModifiers: oe,
|
|
1591
|
+
clearModifiers: se,
|
|
1592
|
+
isResizing: p,
|
|
1593
|
+
resizeCursor: g,
|
|
1594
|
+
startResize: le,
|
|
1595
|
+
commitTextEdit: U,
|
|
1596
|
+
cancelTextEdit: W,
|
|
1597
|
+
startEditText: ae,
|
|
1598
|
+
saveCurrentTextEdit: D,
|
|
1599
|
+
setTextContentGetter: E
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
//#endregion
|
|
1603
|
+
//#region src/components/painter/utils/svg.ts
|
|
1604
|
+
function We(e) {
|
|
1605
|
+
if (e.length === 0) return "";
|
|
1606
|
+
if (e.length === 1) return `M ${e[0].x} ${e[0].y}`;
|
|
1607
|
+
if (e.length === 2) return `M ${e[0].x} ${e[0].y} L ${e[1].x} ${e[1].y}`;
|
|
1608
|
+
let t = `M ${e[0].x} ${e[0].y}`;
|
|
1609
|
+
for (let n = 1; n < e.length - 1; n++) {
|
|
1610
|
+
let r = (e[n].x + e[n + 1].x) / 2, i = (e[n].y + e[n + 1].y) / 2;
|
|
1611
|
+
t += ` Q ${e[n].x} ${e[n].y} ${r} ${i}`;
|
|
1612
|
+
}
|
|
1613
|
+
return t += ` L ${e[e.length - 1].x} ${e[e.length - 1].y}`, t;
|
|
1614
|
+
}
|
|
1615
|
+
function Ge(e) {
|
|
1616
|
+
let { type: t, x: n, y: r, width: i, height: a, points: o, strokeColor: s, fillColor: c, strokeWidth: l } = e, u = {
|
|
1617
|
+
stroke: s,
|
|
1618
|
+
fill: c,
|
|
1619
|
+
"stroke-width": l,
|
|
1620
|
+
"stroke-linecap": "round",
|
|
1621
|
+
"stroke-linejoin": "round"
|
|
1622
|
+
};
|
|
1623
|
+
switch (t) {
|
|
1624
|
+
case "pencil": return {
|
|
1625
|
+
tag: "path",
|
|
1626
|
+
attrs: {
|
|
1627
|
+
...u,
|
|
1628
|
+
fill: "none",
|
|
1629
|
+
d: We(o)
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
case "line": return {
|
|
1633
|
+
tag: "line",
|
|
1634
|
+
attrs: {
|
|
1635
|
+
...u,
|
|
1636
|
+
fill: "none",
|
|
1637
|
+
x1: n,
|
|
1638
|
+
y1: r,
|
|
1639
|
+
x2: n + i,
|
|
1640
|
+
y2: r + a
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
case "circle": {
|
|
1644
|
+
let e = n + i / 2, t = r + a / 2, o = Math.abs(i) / 2, s = Math.abs(a) / 2;
|
|
1645
|
+
return {
|
|
1646
|
+
tag: "ellipse",
|
|
1647
|
+
attrs: {
|
|
1648
|
+
...u,
|
|
1649
|
+
cx: e,
|
|
1650
|
+
cy: t,
|
|
1651
|
+
rx: o,
|
|
1652
|
+
ry: s
|
|
1653
|
+
}
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1656
|
+
case "rect": return {
|
|
1657
|
+
tag: "rect",
|
|
1658
|
+
attrs: {
|
|
1659
|
+
...u,
|
|
1660
|
+
x: i >= 0 ? n : n + i,
|
|
1661
|
+
y: a >= 0 ? r : r + a,
|
|
1662
|
+
width: Math.abs(i),
|
|
1663
|
+
height: Math.abs(a)
|
|
1664
|
+
}
|
|
1665
|
+
};
|
|
1666
|
+
case "triangle": {
|
|
1667
|
+
let e = Be(n, r, i, a).map((e) => `${e.x},${e.y}`).join(" ");
|
|
1668
|
+
return {
|
|
1669
|
+
tag: "polygon",
|
|
1670
|
+
attrs: {
|
|
1671
|
+
...u,
|
|
1672
|
+
points: e
|
|
1673
|
+
}
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
case "star": {
|
|
1677
|
+
let e = ze(n + i / 2, r + a / 2, Math.abs(i) / 2, Math.abs(a) / 2, a >= 0).map((e) => `${e.x},${e.y}`).join(" ");
|
|
1678
|
+
return {
|
|
1679
|
+
tag: "polygon",
|
|
1680
|
+
attrs: {
|
|
1681
|
+
...u,
|
|
1682
|
+
points: e
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
case "text": return {
|
|
1687
|
+
tag: "g",
|
|
1688
|
+
attrs: {}
|
|
1689
|
+
};
|
|
1690
|
+
default: return {
|
|
1691
|
+
tag: "g",
|
|
1692
|
+
attrs: {}
|
|
1693
|
+
};
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
//#endregion
|
|
1697
|
+
//#region src/components/painter/StrokeRenderer.vue
|
|
1698
|
+
var Ke = /*#__PURE__*/ Le(/* @__PURE__ */ l({
|
|
1699
|
+
__name: "StrokeRenderer",
|
|
1700
|
+
props: {
|
|
1701
|
+
stroke: {},
|
|
1702
|
+
isSelected: { type: Boolean }
|
|
1703
|
+
},
|
|
1704
|
+
setup(e) {
|
|
1705
|
+
return (t, n) => (_(), r(x(C(Ge)(e.stroke).tag), d(C(Ge)(e.stroke).attrs, {
|
|
1706
|
+
class: { selected: e.isSelected },
|
|
1707
|
+
"data-stroke-id": e.stroke.id
|
|
1708
|
+
}), null, 16, ["class", "data-stroke-id"]));
|
|
1709
|
+
}
|
|
1710
|
+
}), [["__scopeId", "data-v-d3706fa4"]]), qe = { key: 0 }, Je = [
|
|
1711
|
+
"x",
|
|
1712
|
+
"y",
|
|
1713
|
+
"width",
|
|
1714
|
+
"height"
|
|
1715
|
+
], Ye = [
|
|
1716
|
+
"x",
|
|
1717
|
+
"y",
|
|
1718
|
+
"onMousedown",
|
|
1719
|
+
"onTouchstart"
|
|
1720
|
+
], Xe = [
|
|
1721
|
+
"x",
|
|
1722
|
+
"y",
|
|
1723
|
+
"onMousedown",
|
|
1724
|
+
"onTouchstart"
|
|
1725
|
+
], Ze = 6, $ = 8, Qe = /* @__PURE__ */ l({
|
|
1726
|
+
__name: "SelectionOverlay",
|
|
1727
|
+
props: {
|
|
1728
|
+
stroke: {},
|
|
1729
|
+
startResize: { type: Function }
|
|
1730
|
+
},
|
|
1731
|
+
setup(t) {
|
|
1732
|
+
let r = t, s = B(), c = n(() => {
|
|
1733
|
+
let e = s.getStrokeDisplayBounds(r.stroke);
|
|
1734
|
+
return {
|
|
1735
|
+
x: e.x - Ze,
|
|
1736
|
+
y: e.y - Ze,
|
|
1737
|
+
w: e.width + 12,
|
|
1738
|
+
h: e.height + 12
|
|
1739
|
+
};
|
|
1740
|
+
}), l = n(() => r.stroke.type === "line"), u = n(() => {
|
|
1741
|
+
let e = r.stroke;
|
|
1742
|
+
return [{
|
|
1743
|
+
name: "line-start",
|
|
1744
|
+
cx: e.x,
|
|
1745
|
+
cy: e.y,
|
|
1746
|
+
cursor: "move"
|
|
1747
|
+
}, {
|
|
1748
|
+
name: "line-end",
|
|
1749
|
+
cx: e.x + e.width,
|
|
1750
|
+
cy: e.y + e.height,
|
|
1751
|
+
cursor: "move"
|
|
1752
|
+
}];
|
|
1753
|
+
}), d = n(() => r.stroke.type === "text"), f = n(() => {
|
|
1754
|
+
let e = c.value, t = [
|
|
1755
|
+
{
|
|
1756
|
+
name: "nw",
|
|
1757
|
+
cx: e.x,
|
|
1758
|
+
cy: e.y,
|
|
1759
|
+
cursor: "nwse-resize"
|
|
1760
|
+
},
|
|
1761
|
+
{
|
|
1762
|
+
name: "n",
|
|
1763
|
+
cx: e.x + e.w / 2,
|
|
1764
|
+
cy: e.y,
|
|
1765
|
+
cursor: "ns-resize"
|
|
1766
|
+
},
|
|
1767
|
+
{
|
|
1768
|
+
name: "ne",
|
|
1769
|
+
cx: e.x + e.w,
|
|
1770
|
+
cy: e.y,
|
|
1771
|
+
cursor: "nesw-resize"
|
|
1772
|
+
},
|
|
1773
|
+
{
|
|
1774
|
+
name: "e",
|
|
1775
|
+
cx: e.x + e.w,
|
|
1776
|
+
cy: e.y + e.h / 2,
|
|
1777
|
+
cursor: "ew-resize"
|
|
1778
|
+
},
|
|
1779
|
+
{
|
|
1780
|
+
name: "se",
|
|
1781
|
+
cx: e.x + e.w,
|
|
1782
|
+
cy: e.y + e.h,
|
|
1783
|
+
cursor: "nwse-resize"
|
|
1784
|
+
},
|
|
1785
|
+
{
|
|
1786
|
+
name: "s",
|
|
1787
|
+
cx: e.x + e.w / 2,
|
|
1788
|
+
cy: e.y + e.h,
|
|
1789
|
+
cursor: "ns-resize"
|
|
1790
|
+
},
|
|
1791
|
+
{
|
|
1792
|
+
name: "sw",
|
|
1793
|
+
cx: e.x,
|
|
1794
|
+
cy: e.y + e.h,
|
|
1795
|
+
cursor: "nesw-resize"
|
|
1796
|
+
},
|
|
1797
|
+
{
|
|
1798
|
+
name: "w",
|
|
1799
|
+
cx: e.x,
|
|
1800
|
+
cy: e.y + e.h / 2,
|
|
1801
|
+
cursor: "ew-resize"
|
|
1802
|
+
}
|
|
1803
|
+
];
|
|
1804
|
+
return d.value ? t.filter((e) => e.name !== "n" && e.name !== "s") : t;
|
|
1805
|
+
});
|
|
1806
|
+
function p(e, t, n) {
|
|
1807
|
+
n.preventDefault(), n.stopPropagation(), r.startResize(r.stroke.id, e, t, n);
|
|
1808
|
+
}
|
|
1809
|
+
return (n, r) => t.stroke ? (_(), a("g", qe, [
|
|
1810
|
+
o("rect", {
|
|
1811
|
+
x: c.value.x,
|
|
1812
|
+
y: c.value.y,
|
|
1813
|
+
width: c.value.w,
|
|
1814
|
+
height: c.value.h,
|
|
1815
|
+
fill: "none",
|
|
1816
|
+
stroke: "#6366f1",
|
|
1817
|
+
"stroke-width": "2",
|
|
1818
|
+
"stroke-dasharray": "6 4",
|
|
1819
|
+
rx: "4"
|
|
1820
|
+
}, null, 8, Je),
|
|
1821
|
+
(_(!0), a(e, null, b(u.value, (e) => D((_(), a("rect", {
|
|
1822
|
+
key: e.name,
|
|
1823
|
+
x: e.cx - $ / 2,
|
|
1824
|
+
y: e.cy - $ / 2,
|
|
1825
|
+
width: $,
|
|
1826
|
+
height: $,
|
|
1827
|
+
fill: "white",
|
|
1828
|
+
stroke: "#6366f1",
|
|
1829
|
+
"stroke-width": "1.5",
|
|
1830
|
+
rx: "1",
|
|
1831
|
+
style: m({ cursor: e.cursor }),
|
|
1832
|
+
onMousedown: k((t) => p(e.name, e.cursor, t), ["stop", "prevent"]),
|
|
1833
|
+
onTouchstart: k((t) => p(e.name, e.cursor, t), ["stop", "prevent"])
|
|
1834
|
+
}, null, 44, Ye)), [[T, l.value]])), 128)),
|
|
1835
|
+
(_(!0), a(e, null, b(f.value, (e) => D((_(), a("rect", {
|
|
1836
|
+
key: e.name,
|
|
1837
|
+
x: e.cx - $ / 2,
|
|
1838
|
+
y: e.cy - $ / 2,
|
|
1839
|
+
width: $,
|
|
1840
|
+
height: $,
|
|
1841
|
+
fill: "white",
|
|
1842
|
+
stroke: "#6366f1",
|
|
1843
|
+
"stroke-width": "1.5",
|
|
1844
|
+
rx: "1",
|
|
1845
|
+
style: m({ cursor: e.cursor }),
|
|
1846
|
+
onMousedown: k((t) => p(e.name, e.cursor, t), ["stop", "prevent"]),
|
|
1847
|
+
onTouchstart: k((t) => p(e.name, e.cursor, t), ["stop", "prevent"])
|
|
1848
|
+
}, null, 44, Xe)), [[T, !l.value]])), 128))
|
|
1849
|
+
])) : i("", !0);
|
|
1850
|
+
}
|
|
1851
|
+
}), $e = ["viewBox"], et = [
|
|
1852
|
+
"width",
|
|
1853
|
+
"height",
|
|
1854
|
+
"fill"
|
|
1855
|
+
], tt = [
|
|
1856
|
+
"width",
|
|
1857
|
+
"height",
|
|
1858
|
+
"fill"
|
|
1859
|
+
], nt = [
|
|
1860
|
+
"width",
|
|
1861
|
+
"height",
|
|
1862
|
+
"stroke"
|
|
1863
|
+
], rt = { class: "strokes-layer" }, it = [
|
|
1864
|
+
"x",
|
|
1865
|
+
"y",
|
|
1866
|
+
"width"
|
|
1867
|
+
], at = ["contenteditable", "onDblclick"], ot = [
|
|
1868
|
+
"x",
|
|
1869
|
+
"y",
|
|
1870
|
+
"width",
|
|
1871
|
+
"height"
|
|
1872
|
+
], st = [
|
|
1873
|
+
"x",
|
|
1874
|
+
"y",
|
|
1875
|
+
"width",
|
|
1876
|
+
"height"
|
|
1877
|
+
], ct = ["disabled", "title"], lt = ["disabled", "title"], ut = ["title"], dt = ["title"], ft = ["title"], pt = ["title"], mt = { class: "zoom-percent" }, ht = ["title"], gt = { class: "font-size-value" }, _t = ["title"], vt = ["title"], yt = ["title"], bt = /*#__PURE__*/ Le(/* @__PURE__ */ l({
|
|
1878
|
+
__name: "Whiteboard",
|
|
1879
|
+
setup(t) {
|
|
1880
|
+
let c = B(), l = ie(), { t: u } = ee(), d = y(null), { isDrawing: v, previewStroke: x, onMouseDown: w, onMouseMove: T, onMouseUp: D, onTouchStart: O, onTouchMove: A, onTouchEnd: j, updateModifiers: M, clearModifiers: N, isResizing: P, resizeCursor: F, startResize: I, commitTextEdit: L, cancelTextEdit: te, startEditText: R, saveCurrentTextEdit: ne, setTextContentGetter: z } = Ue(d);
|
|
1881
|
+
z(() => {
|
|
1882
|
+
let e = c.editingTextId;
|
|
1883
|
+
if (!e) return null;
|
|
1884
|
+
let t = H.value.get(e);
|
|
1885
|
+
return t ? t.innerText : null;
|
|
1886
|
+
}), E(() => l.activeTool, (e) => {
|
|
1887
|
+
e !== "text" && ne();
|
|
1888
|
+
});
|
|
1889
|
+
let re = n(() => P.value ? F.value : l.activeTool === "pan" ? "grab" : l.activeTool === "zoom" ? "zoom-in" : l.activeTool === "text" ? c.hoveredTextId ? "pointer" : "text" : l.activeTool === "select" ? "default" : "crosshair"), V = n(() => l.activeTool === "zoom"), H = y(/* @__PURE__ */ new Map()), U = n(() => {
|
|
1890
|
+
let e = c.hoveredTextId;
|
|
1891
|
+
if (!e) return null;
|
|
1892
|
+
let t = c.strokes.find((t) => t.id === e);
|
|
1893
|
+
return t ? c.getStrokeDisplayBounds(t) : null;
|
|
1894
|
+
}), W = n(() => {
|
|
1895
|
+
let e = c.selectedStrokes;
|
|
1896
|
+
return e.length === 1 && e[0].type === "text" ? e[0] : null;
|
|
1897
|
+
});
|
|
1898
|
+
function ae(e) {
|
|
1899
|
+
if (c.editingTextId) if (e.key === "Enter" && !e.shiftKey) {
|
|
1900
|
+
e.preventDefault(), e.stopPropagation();
|
|
1901
|
+
let t = H.value.get(c.editingTextId), n = t ? t.innerText : "";
|
|
1902
|
+
L(c.editingTextId, n), f(() => {});
|
|
1903
|
+
} else e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), te(c.editingTextId));
|
|
1904
|
+
}
|
|
1905
|
+
E(() => c.editingTextId, (e) => {
|
|
1906
|
+
e && f(() => {
|
|
1907
|
+
let t = H.value.get(e);
|
|
1908
|
+
if (t) {
|
|
1909
|
+
t.focus();
|
|
1910
|
+
let e = document.createRange();
|
|
1911
|
+
e.selectNodeContents(t), e.collapse(!1);
|
|
1912
|
+
let n = window.getSelection();
|
|
1913
|
+
n?.removeAllRanges(), n?.addRange(e);
|
|
1914
|
+
}
|
|
1915
|
+
});
|
|
1916
|
+
});
|
|
1917
|
+
function oe(e) {
|
|
1918
|
+
(l.activeTool === "text" || l.activeTool === "select") && R(e);
|
|
1919
|
+
}
|
|
1920
|
+
function se() {
|
|
1921
|
+
c.hoveredTextId = null;
|
|
1922
|
+
}
|
|
1923
|
+
function G() {
|
|
1924
|
+
let e = d.value?.parentElement;
|
|
1925
|
+
e && c.zoomAt(e.clientWidth / 2, e.clientHeight / 2, 1.1);
|
|
1926
|
+
}
|
|
1927
|
+
function ce() {
|
|
1928
|
+
let e = d.value?.parentElement;
|
|
1929
|
+
e && c.zoomAt(e.clientWidth / 2, e.clientHeight / 2, .9);
|
|
1930
|
+
}
|
|
1931
|
+
function le(e) {
|
|
1932
|
+
let t = e.ctrlKey || e.metaKey;
|
|
1933
|
+
c.editingTextId || ((v.value || P.value) && M(e), e.key === "Delete" || e.key === "Backspace" ? c.deleteSelectedStrokes() : e.key === "Escape" ? c.clearSelection() : t && e.key === "z" && !e.shiftKey ? (e.preventDefault(), c.undo()) : t && (e.key === "y" || e.shiftKey && e.key === "z") ? (e.preventDefault(), c.redo()) : t && e.key === "x" ? (e.preventDefault(), c.cutSelectedStrokes()) : t && e.key === "c" ? (e.preventDefault(), c.copySelectedStrokes()) : t && e.key === "v" && (e.preventDefault(), c.pasteStrokes()));
|
|
1934
|
+
}
|
|
1935
|
+
function ue(e) {
|
|
1936
|
+
(v.value || P.value) && M(e);
|
|
1937
|
+
}
|
|
1938
|
+
function K() {
|
|
1939
|
+
N();
|
|
1940
|
+
}
|
|
1941
|
+
let q = y(0), de = y(1), fe = y(0), pe = y(0);
|
|
1942
|
+
function me(e) {
|
|
1943
|
+
let t = e[0].clientX - e[1].clientX, n = e[0].clientY - e[1].clientY;
|
|
1944
|
+
return Math.hypot(t, n);
|
|
1945
|
+
}
|
|
1946
|
+
function he(e) {
|
|
1947
|
+
l.activeTool === "zoom" && e.touches.length === 2 && (q.value = me(e.touches), de.value = c.zoomLevel, fe.value = (e.touches[0].clientX + e.touches[1].clientX) / 2, pe.value = (e.touches[0].clientY + e.touches[1].clientY) / 2);
|
|
1948
|
+
}
|
|
1949
|
+
function ge(e) {
|
|
1950
|
+
if (l.activeTool === "zoom" && e.touches.length === 2 && q.value > 0) {
|
|
1951
|
+
let t = me(e.touches) / q.value, n = de.value * t, r = d.value;
|
|
1952
|
+
if (r) {
|
|
1953
|
+
let e = r.getBoundingClientRect();
|
|
1954
|
+
c.continuousZoomAt(fe.value - e.left, pe.value - e.top, n);
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
function _e(e) {
|
|
1959
|
+
l.activeTool === "zoom" && e.touches.length < 2 && (q.value = 0);
|
|
1960
|
+
}
|
|
1961
|
+
let ve = null;
|
|
1962
|
+
function ye() {
|
|
1963
|
+
let e = d.value?.parentElement;
|
|
1964
|
+
if (!e) return;
|
|
1965
|
+
let t = c.canvasWidth * c.zoomLevel, n = c.canvasHeight * c.zoomLevel, r = e.clientWidth, i = e.clientHeight;
|
|
1966
|
+
r > 0 && i > 0 && c.setPan((r - t) / 2, (i - n) / 2);
|
|
1967
|
+
}
|
|
1968
|
+
function J(e) {
|
|
1969
|
+
let t = W.value;
|
|
1970
|
+
if (!t) return;
|
|
1971
|
+
let n = t.fontSize ?? 16, r = Math.max(8, Math.min(200, n + e));
|
|
1972
|
+
c.pushUndo(), c.updateStroke(t.id, { fontSize: r }), c.dataVersion++;
|
|
1973
|
+
}
|
|
1974
|
+
function Y(e) {
|
|
1975
|
+
let t = W.value;
|
|
1976
|
+
t && (c.pushUndo(), c.updateStroke(t.id, { textAlign: e }), c.dataVersion++);
|
|
1977
|
+
}
|
|
1978
|
+
function be(e) {
|
|
1979
|
+
return (t) => {
|
|
1980
|
+
t ? (H.value.set(e, t), f(() => xe(e, t))) : H.value.delete(e);
|
|
1981
|
+
};
|
|
1982
|
+
}
|
|
1983
|
+
function xe(e, t) {
|
|
1984
|
+
let n = c.strokes.find((t) => t.id === e);
|
|
1985
|
+
if (!n) return;
|
|
1986
|
+
let r = Math.max(t.scrollWidth / c.zoomLevel, n.fontSize ?? 16), i = Math.max(t.scrollHeight / c.zoomLevel, n.fontSize ?? 16);
|
|
1987
|
+
if (n.textAutoWidth) {
|
|
1988
|
+
if (Math.abs(n.width - r) < .5 && Math.abs(n.height - i) < .5) return;
|
|
1989
|
+
c.updateStroke(e, {
|
|
1990
|
+
width: r,
|
|
1991
|
+
height: i
|
|
1992
|
+
});
|
|
1993
|
+
} else {
|
|
1994
|
+
let t = Math.max(n.width, r);
|
|
1995
|
+
if (Math.abs(n.width - t) < .5 && Math.abs(n.height - i) < .5) return;
|
|
1996
|
+
c.updateStroke(e, {
|
|
1997
|
+
width: t,
|
|
1998
|
+
height: i
|
|
1999
|
+
});
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
return h(() => {
|
|
2003
|
+
window.addEventListener("keydown", le), window.addEventListener("keydown", ae), window.addEventListener("keyup", ue), window.addEventListener("blur", K), ye(), ve = new ResizeObserver(() => ye());
|
|
2004
|
+
let e = d.value?.parentElement;
|
|
2005
|
+
e && ve.observe(e);
|
|
2006
|
+
}), g(() => {
|
|
2007
|
+
window.removeEventListener("keydown", le), window.removeEventListener("keydown", ae), window.removeEventListener("keyup", ue), window.removeEventListener("blur", K), ve?.disconnect();
|
|
2008
|
+
}), (t, n) => (_(), a("div", {
|
|
2009
|
+
class: "whiteboard",
|
|
2010
|
+
onContextmenu: n[23] ||= k(() => {}, ["prevent"]),
|
|
2011
|
+
onMousedown: n[24] ||= (...e) => C(w) && C(w)(...e),
|
|
2012
|
+
onMousemove: n[25] ||= (...e) => C(T) && C(T)(...e),
|
|
2013
|
+
onMouseup: n[26] ||= (...e) => C(D) && C(D)(...e),
|
|
2014
|
+
onTouchstart: n[27] ||= k((e) => {
|
|
2015
|
+
C(O)(e), he(e);
|
|
2016
|
+
}, ["prevent"]),
|
|
2017
|
+
onTouchmove: n[28] ||= k((e) => {
|
|
2018
|
+
C(A)(e), ge(e);
|
|
2019
|
+
}, ["prevent"]),
|
|
2020
|
+
onTouchend: n[29] ||= (e) => {
|
|
2021
|
+
C(j)(e), _e(e);
|
|
2022
|
+
}
|
|
2023
|
+
}, [
|
|
2024
|
+
o("div", {
|
|
2025
|
+
ref_key: "wrapperRef",
|
|
2026
|
+
ref: d,
|
|
2027
|
+
class: "canvas-wrapper",
|
|
2028
|
+
style: m({
|
|
2029
|
+
width: C(c).canvasWidth + "px",
|
|
2030
|
+
height: C(c).canvasHeight + "px",
|
|
2031
|
+
transform: C(c).canvasTransform,
|
|
2032
|
+
transformOrigin: "0 0"
|
|
2033
|
+
})
|
|
2034
|
+
}, [(_(), a("svg", {
|
|
2035
|
+
class: "canvas",
|
|
2036
|
+
viewBox: C(c).viewBox,
|
|
2037
|
+
width: "100%",
|
|
2038
|
+
height: "100%",
|
|
2039
|
+
style: m({ cursor: re.value }),
|
|
2040
|
+
onMouseleave: se
|
|
2041
|
+
}, [
|
|
2042
|
+
n[30] ||= s("<defs data-v-975e0b8b><pattern id=\"grid-light\" width=\"16\" height=\"16\" patternUnits=\"userSpaceOnUse\" data-v-975e0b8b><rect width=\"16\" height=\"16\" fill=\"#ffffff\" data-v-975e0b8b></rect><rect width=\"8\" height=\"8\" fill=\"#f0f0f0\" data-v-975e0b8b></rect><rect x=\"8\" y=\"8\" width=\"8\" height=\"8\" fill=\"#f0f0f0\" data-v-975e0b8b></rect></pattern><pattern id=\"grid-dark\" width=\"16\" height=\"16\" patternUnits=\"userSpaceOnUse\" data-v-975e0b8b><rect width=\"16\" height=\"16\" fill=\"#1e1e30\" data-v-975e0b8b></rect><rect width=\"8\" height=\"8\" fill=\"#2a2a3e\" data-v-975e0b8b></rect><rect x=\"8\" y=\"8\" width=\"8\" height=\"8\" fill=\"#2a2a3e\" data-v-975e0b8b></rect></pattern></defs>", 1),
|
|
2043
|
+
C(c).canvasBackgroundColor === "transparent" ? (_(), a("rect", {
|
|
2044
|
+
key: 0,
|
|
2045
|
+
x: "0",
|
|
2046
|
+
y: "0",
|
|
2047
|
+
width: C(c).canvasWidth,
|
|
2048
|
+
height: C(c).canvasHeight,
|
|
2049
|
+
fill: C(c).theme === "dark" ? "url(#grid-dark)" : "url(#grid-light)"
|
|
2050
|
+
}, null, 8, et)) : (_(), a("rect", {
|
|
2051
|
+
key: 1,
|
|
2052
|
+
x: "0",
|
|
2053
|
+
y: "0",
|
|
2054
|
+
width: C(c).canvasWidth,
|
|
2055
|
+
height: C(c).canvasHeight,
|
|
2056
|
+
fill: C(c).canvasBackgroundColor
|
|
2057
|
+
}, null, 8, tt)),
|
|
2058
|
+
o("rect", {
|
|
2059
|
+
x: "0",
|
|
2060
|
+
y: "0",
|
|
2061
|
+
width: C(c).canvasWidth,
|
|
2062
|
+
height: C(c).canvasHeight,
|
|
2063
|
+
fill: "none",
|
|
2064
|
+
stroke: C(c).theme === "dark" ? "#4a4a5a" : "#c0c0c0",
|
|
2065
|
+
"stroke-width": "2"
|
|
2066
|
+
}, null, 8, nt),
|
|
2067
|
+
o("g", rt, [(_(!0), a(e, null, b(C(c).strokes, (t) => (_(), a(e, { key: t.id }, [t.type === "text" ? (_(), a("foreignObject", {
|
|
2068
|
+
key: 0,
|
|
2069
|
+
x: t.x,
|
|
2070
|
+
y: t.y,
|
|
2071
|
+
width: t.textAutoWidth ? 1 : t.width || 1,
|
|
2072
|
+
height: 1,
|
|
2073
|
+
style: {
|
|
2074
|
+
overflow: "visible",
|
|
2075
|
+
pointerEvents: "none"
|
|
2076
|
+
}
|
|
2077
|
+
}, [o("div", {
|
|
2078
|
+
ref_for: !0,
|
|
2079
|
+
ref: be(t.id),
|
|
2080
|
+
xmlns: "http://www.w3.org/1999/xhtml",
|
|
2081
|
+
contenteditable: C(c).editingTextId === t.id,
|
|
2082
|
+
style: m({
|
|
2083
|
+
fontSize: (t.fontSize ?? 16) + "px",
|
|
2084
|
+
color: t.textColor ?? t.strokeColor,
|
|
2085
|
+
textAlign: t.textAlign ?? "left",
|
|
2086
|
+
whiteSpace: t.textAutoWidth ? "nowrap" : "pre-wrap",
|
|
2087
|
+
wordBreak: t.textAutoWidth ? "normal" : "break-word",
|
|
2088
|
+
padding: "2px 4px",
|
|
2089
|
+
minHeight: (t.fontSize ?? 16) + "px",
|
|
2090
|
+
outline: C(c).editingTextId === t.id ? "2px solid #6366f1" : "none",
|
|
2091
|
+
cursor: C(c).editingTextId === t.id ? "text" : "default",
|
|
2092
|
+
userSelect: C(c).editingTextId === t.id ? "text" : "none",
|
|
2093
|
+
pointerEvents: C(c).editingTextId === t.id ? "auto" : "none",
|
|
2094
|
+
background: C(c).editingTextId === t.id ? "rgba(255,255,255,0.9)" : "transparent",
|
|
2095
|
+
borderRadius: "2px",
|
|
2096
|
+
display: "inline-block",
|
|
2097
|
+
maxWidth: t.textAutoWidth ? "none" : "100%"
|
|
2098
|
+
}),
|
|
2099
|
+
onDblclick: k((e) => oe(t.id), ["stop"])
|
|
2100
|
+
}, S(t.text || ""), 45, at)], 8, it)) : (_(), r(Ke, {
|
|
2101
|
+
key: 1,
|
|
2102
|
+
stroke: t,
|
|
2103
|
+
"is-selected": C(c).isSelected(t.id)
|
|
2104
|
+
}, null, 8, ["stroke", "is-selected"]))], 64))), 128))]),
|
|
2105
|
+
C(x) ? (_(), r(Ke, {
|
|
2106
|
+
key: 2,
|
|
2107
|
+
stroke: C(x),
|
|
2108
|
+
"is-selected": !1
|
|
2109
|
+
}, null, 8, ["stroke"])) : i("", !0),
|
|
2110
|
+
(_(!0), a(e, null, b(C(c).selectedStrokes, (e) => (_(), r(Qe, {
|
|
2111
|
+
key: "sel-" + e.id,
|
|
2112
|
+
stroke: e,
|
|
2113
|
+
"start-resize": C(I)
|
|
2114
|
+
}, null, 8, ["stroke", "start-resize"]))), 128)),
|
|
2115
|
+
C(c).isSelecting && C(c).selectionBox ? (_(), a("rect", {
|
|
2116
|
+
key: 3,
|
|
2117
|
+
x: C(c).selectionBox.x,
|
|
2118
|
+
y: C(c).selectionBox.y,
|
|
2119
|
+
width: C(c).selectionBox.width,
|
|
2120
|
+
height: C(c).selectionBox.height,
|
|
2121
|
+
fill: "rgba(99, 102, 241, 0.08)",
|
|
2122
|
+
stroke: "#6366f1",
|
|
2123
|
+
"stroke-width": "1",
|
|
2124
|
+
"stroke-dasharray": "6 4"
|
|
2125
|
+
}, null, 8, ot)) : i("", !0),
|
|
2126
|
+
U.value ? (_(), a("rect", {
|
|
2127
|
+
key: 4,
|
|
2128
|
+
x: U.value.x - 4,
|
|
2129
|
+
y: U.value.y - 4,
|
|
2130
|
+
width: U.value.width + 8,
|
|
2131
|
+
height: U.value.height + 8,
|
|
2132
|
+
fill: "none",
|
|
2133
|
+
stroke: "#6366f1",
|
|
2134
|
+
"stroke-width": "1",
|
|
2135
|
+
"stroke-dasharray": "4 3",
|
|
2136
|
+
"pointer-events": "none"
|
|
2137
|
+
}, null, 8, st)) : i("", !0)
|
|
2138
|
+
], 44, $e))], 4),
|
|
2139
|
+
o("div", {
|
|
2140
|
+
class: "canvas-toolbar",
|
|
2141
|
+
onMousedown: n[5] ||= k(() => {}, ["stop"]),
|
|
2142
|
+
onMouseup: n[6] ||= k(() => {}, ["stop"]),
|
|
2143
|
+
onClick: n[7] ||= k(() => {}, ["stop"]),
|
|
2144
|
+
onTouchstart: n[8] ||= k(() => {}, ["stop"]),
|
|
2145
|
+
onTouchmove: n[9] ||= k(() => {}, ["stop"]),
|
|
2146
|
+
onTouchend: n[10] ||= k(() => {}, ["stop"])
|
|
2147
|
+
}, [
|
|
2148
|
+
o("button", {
|
|
2149
|
+
class: "canvas-tb-btn",
|
|
2150
|
+
disabled: !C(c).canUndo,
|
|
2151
|
+
title: C(u)("toolbar.undo"),
|
|
2152
|
+
onClick: n[0] ||= (e) => C(c).undo()
|
|
2153
|
+
}, [...n[31] ||= [o("svg", {
|
|
2154
|
+
width: "16",
|
|
2155
|
+
height: "16",
|
|
2156
|
+
viewBox: "0 0 24 24",
|
|
2157
|
+
fill: "none",
|
|
2158
|
+
stroke: "currentColor",
|
|
2159
|
+
"stroke-width": "2",
|
|
2160
|
+
"stroke-linecap": "round",
|
|
2161
|
+
"stroke-linejoin": "round"
|
|
2162
|
+
}, [o("path", { d: "M3 10h10a5 5 0 0 1 0 10H9" }), o("polyline", { points: "7 6 3 10 7 14" })], -1)]], 8, ct),
|
|
2163
|
+
o("button", {
|
|
2164
|
+
class: "canvas-tb-btn",
|
|
2165
|
+
disabled: !C(c).canRedo,
|
|
2166
|
+
title: C(u)("toolbar.redo"),
|
|
2167
|
+
onClick: n[1] ||= (e) => C(c).redo()
|
|
2168
|
+
}, [...n[32] ||= [o("svg", {
|
|
2169
|
+
width: "16",
|
|
2170
|
+
height: "16",
|
|
2171
|
+
viewBox: "0 0 24 24",
|
|
2172
|
+
fill: "none",
|
|
2173
|
+
stroke: "currentColor",
|
|
2174
|
+
"stroke-width": "2",
|
|
2175
|
+
"stroke-linecap": "round",
|
|
2176
|
+
"stroke-linejoin": "round"
|
|
2177
|
+
}, [o("path", { d: "M21 10H11a5 5 0 0 0 0 10h4" }), o("polyline", { points: "17 6 21 10 17 14" })], -1)]], 8, lt),
|
|
2178
|
+
C(c).selectedStrokeIds.size > 0 ? (_(), a("button", {
|
|
2179
|
+
key: 0,
|
|
2180
|
+
class: "canvas-tb-btn",
|
|
2181
|
+
title: C(u)("toolbar.bringToFront"),
|
|
2182
|
+
onClick: n[2] ||= (e) => C(c).moveSelectedUp()
|
|
2183
|
+
}, [...n[33] ||= [o("svg", {
|
|
2184
|
+
width: "16",
|
|
2185
|
+
height: "16",
|
|
2186
|
+
viewBox: "0 0 24 24",
|
|
2187
|
+
fill: "none",
|
|
2188
|
+
stroke: "currentColor",
|
|
2189
|
+
"stroke-width": "2",
|
|
2190
|
+
"stroke-linecap": "round",
|
|
2191
|
+
"stroke-linejoin": "round"
|
|
2192
|
+
}, [o("path", { d: "m18 15-6-6-6 6" })], -1)]], 8, ut)) : i("", !0),
|
|
2193
|
+
C(c).selectedStrokeIds.size > 0 ? (_(), a("button", {
|
|
2194
|
+
key: 1,
|
|
2195
|
+
class: "canvas-tb-btn",
|
|
2196
|
+
title: C(u)("toolbar.sendToBack"),
|
|
2197
|
+
onClick: n[3] ||= (e) => C(c).moveSelectedDown()
|
|
2198
|
+
}, [...n[34] ||= [o("svg", {
|
|
2199
|
+
width: "16",
|
|
2200
|
+
height: "16",
|
|
2201
|
+
viewBox: "0 0 24 24",
|
|
2202
|
+
fill: "none",
|
|
2203
|
+
stroke: "currentColor",
|
|
2204
|
+
"stroke-width": "2",
|
|
2205
|
+
"stroke-linecap": "round",
|
|
2206
|
+
"stroke-linejoin": "round"
|
|
2207
|
+
}, [o("path", { d: "m6 9 6 6 6-6" })], -1)]], 8, dt)) : i("", !0),
|
|
2208
|
+
C(c).selectedStrokeIds.size > 0 ? (_(), a("button", {
|
|
2209
|
+
key: 2,
|
|
2210
|
+
class: "canvas-tb-btn canvas-tb-btn--danger",
|
|
2211
|
+
title: C(u)("toolbar.delete"),
|
|
2212
|
+
onClick: n[4] ||= (e) => C(c).deleteSelectedStrokes()
|
|
2213
|
+
}, [...n[35] ||= [s("<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" data-v-975e0b8b><polyline points=\"3 6 5 6 21 6\" data-v-975e0b8b></polyline><path d=\"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6\" data-v-975e0b8b></path><path d=\"M10 11v6\" data-v-975e0b8b></path><path d=\"M14 11v6\" data-v-975e0b8b></path><path d=\"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2\" data-v-975e0b8b></path></svg>", 1)]], 8, ft)) : i("", !0)
|
|
2214
|
+
], 32),
|
|
2215
|
+
V.value || C(c).showZoomIndicator ? (_(), a("div", {
|
|
2216
|
+
key: 0,
|
|
2217
|
+
class: "zoom-control",
|
|
2218
|
+
onTouchstart: n[11] ||= k(() => {}, ["stop", "prevent"])
|
|
2219
|
+
}, [
|
|
2220
|
+
V.value ? (_(), a("button", {
|
|
2221
|
+
key: 0,
|
|
2222
|
+
class: "zoom-btn",
|
|
2223
|
+
title: C(u)("zoom.zoomOut"),
|
|
2224
|
+
onMousedown: k(ce, ["stop", "prevent"]),
|
|
2225
|
+
onTouchstart: k(ce, ["stop", "prevent"])
|
|
2226
|
+
}, [...n[36] ||= [o("svg", {
|
|
2227
|
+
width: "16",
|
|
2228
|
+
height: "16",
|
|
2229
|
+
viewBox: "0 0 24 24",
|
|
2230
|
+
fill: "none",
|
|
2231
|
+
stroke: "currentColor",
|
|
2232
|
+
"stroke-width": "2",
|
|
2233
|
+
"stroke-linecap": "round"
|
|
2234
|
+
}, [o("line", {
|
|
2235
|
+
x1: "5",
|
|
2236
|
+
y1: "12",
|
|
2237
|
+
x2: "19",
|
|
2238
|
+
y2: "12"
|
|
2239
|
+
})], -1)]], 40, pt)) : i("", !0),
|
|
2240
|
+
o("span", mt, S(C(c).getZoomPercent()) + "%", 1),
|
|
2241
|
+
V.value ? (_(), a("button", {
|
|
2242
|
+
key: 1,
|
|
2243
|
+
class: "zoom-btn",
|
|
2244
|
+
title: C(u)("zoom.zoomIn"),
|
|
2245
|
+
onMousedown: k(G, ["stop", "prevent"]),
|
|
2246
|
+
onTouchstart: k(G, ["stop", "prevent"])
|
|
2247
|
+
}, [...n[37] ||= [o("svg", {
|
|
2248
|
+
width: "16",
|
|
2249
|
+
height: "16",
|
|
2250
|
+
viewBox: "0 0 24 24",
|
|
2251
|
+
fill: "none",
|
|
2252
|
+
stroke: "currentColor",
|
|
2253
|
+
"stroke-width": "2",
|
|
2254
|
+
"stroke-linecap": "round"
|
|
2255
|
+
}, [o("line", {
|
|
2256
|
+
x1: "12",
|
|
2257
|
+
y1: "5",
|
|
2258
|
+
x2: "12",
|
|
2259
|
+
y2: "19"
|
|
2260
|
+
}), o("line", {
|
|
2261
|
+
x1: "5",
|
|
2262
|
+
y1: "12",
|
|
2263
|
+
x2: "19",
|
|
2264
|
+
y2: "12"
|
|
2265
|
+
})], -1)]], 40, ht)) : i("", !0)
|
|
2266
|
+
], 32)) : i("", !0),
|
|
2267
|
+
W.value ? (_(), a("div", {
|
|
2268
|
+
key: 1,
|
|
2269
|
+
class: "text-format-control",
|
|
2270
|
+
onTouchstart: n[22] ||= k(() => {}, ["stop", "prevent"])
|
|
2271
|
+
}, [
|
|
2272
|
+
o("button", {
|
|
2273
|
+
class: "font-size-btn",
|
|
2274
|
+
onMousedown: n[12] ||= k((e) => J(-1), ["stop", "prevent"]),
|
|
2275
|
+
onTouchstart: n[13] ||= k((e) => J(-1), ["stop", "prevent"])
|
|
2276
|
+
}, [...n[38] ||= [o("svg", {
|
|
2277
|
+
width: "12",
|
|
2278
|
+
height: "12",
|
|
2279
|
+
viewBox: "0 0 24 24",
|
|
2280
|
+
fill: "none",
|
|
2281
|
+
stroke: "currentColor",
|
|
2282
|
+
"stroke-width": "2",
|
|
2283
|
+
"stroke-linecap": "round"
|
|
2284
|
+
}, [o("line", {
|
|
2285
|
+
x1: "5",
|
|
2286
|
+
y1: "12",
|
|
2287
|
+
x2: "19",
|
|
2288
|
+
y2: "12"
|
|
2289
|
+
})], -1)]], 32),
|
|
2290
|
+
o("span", gt, S(W.value.fontSize ?? C(16)), 1),
|
|
2291
|
+
o("button", {
|
|
2292
|
+
class: "font-size-btn",
|
|
2293
|
+
onMousedown: n[14] ||= k((e) => J(1), ["stop", "prevent"]),
|
|
2294
|
+
onTouchstart: n[15] ||= k((e) => J(1), ["stop", "prevent"])
|
|
2295
|
+
}, [...n[39] ||= [o("svg", {
|
|
2296
|
+
width: "12",
|
|
2297
|
+
height: "12",
|
|
2298
|
+
viewBox: "0 0 24 24",
|
|
2299
|
+
fill: "none",
|
|
2300
|
+
stroke: "currentColor",
|
|
2301
|
+
"stroke-width": "2",
|
|
2302
|
+
"stroke-linecap": "round"
|
|
2303
|
+
}, [o("line", {
|
|
2304
|
+
x1: "12",
|
|
2305
|
+
y1: "5",
|
|
2306
|
+
x2: "12",
|
|
2307
|
+
y2: "19"
|
|
2308
|
+
}), o("line", {
|
|
2309
|
+
x1: "5",
|
|
2310
|
+
y1: "12",
|
|
2311
|
+
x2: "19",
|
|
2312
|
+
y2: "12"
|
|
2313
|
+
})], -1)]], 32),
|
|
2314
|
+
n[43] ||= o("div", { class: "text-align-separator" }, null, -1),
|
|
2315
|
+
o("button", {
|
|
2316
|
+
class: p(["text-align-btn", { active: W.value.textAlign === "left" || !W.value.textAlign }]),
|
|
2317
|
+
title: C(u)("textAlign.left"),
|
|
2318
|
+
onMousedown: n[16] ||= k((e) => Y("left"), ["stop", "prevent"]),
|
|
2319
|
+
onTouchstart: n[17] ||= k((e) => Y("left"), ["stop", "prevent"])
|
|
2320
|
+
}, [...n[40] ||= [s("<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" data-v-975e0b8b><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\" data-v-975e0b8b></line><line x1=\"3\" y1=\"10\" x2=\"17\" y2=\"10\" data-v-975e0b8b></line><line x1=\"3\" y1=\"14\" x2=\"21\" y2=\"14\" data-v-975e0b8b></line><line x1=\"3\" y1=\"18\" x2=\"15\" y2=\"18\" data-v-975e0b8b></line></svg>", 1)]], 42, _t),
|
|
2321
|
+
o("button", {
|
|
2322
|
+
class: p(["text-align-btn", { active: W.value.textAlign === "center" }]),
|
|
2323
|
+
title: C(u)("textAlign.center"),
|
|
2324
|
+
onMousedown: n[18] ||= k((e) => Y("center"), ["stop", "prevent"]),
|
|
2325
|
+
onTouchstart: n[19] ||= k((e) => Y("center"), ["stop", "prevent"])
|
|
2326
|
+
}, [...n[41] ||= [s("<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" data-v-975e0b8b><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\" data-v-975e0b8b></line><line x1=\"5\" y1=\"10\" x2=\"19\" y2=\"10\" data-v-975e0b8b></line><line x1=\"3\" y1=\"14\" x2=\"21\" y2=\"14\" data-v-975e0b8b></line><line x1=\"7\" y1=\"18\" x2=\"17\" y2=\"18\" data-v-975e0b8b></line></svg>", 1)]], 42, vt),
|
|
2327
|
+
o("button", {
|
|
2328
|
+
class: p(["text-align-btn", { active: W.value.textAlign === "right" }]),
|
|
2329
|
+
title: C(u)("textAlign.right"),
|
|
2330
|
+
onMousedown: n[20] ||= k((e) => Y("right"), ["stop", "prevent"]),
|
|
2331
|
+
onTouchstart: n[21] ||= k((e) => Y("right"), ["stop", "prevent"])
|
|
2332
|
+
}, [...n[42] ||= [s("<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" data-v-975e0b8b><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\" data-v-975e0b8b></line><line x1=\"7\" y1=\"10\" x2=\"21\" y2=\"10\" data-v-975e0b8b></line><line x1=\"3\" y1=\"14\" x2=\"21\" y2=\"14\" data-v-975e0b8b></line><line x1=\"9\" y1=\"18\" x2=\"21\" y2=\"18\" data-v-975e0b8b></line></svg>", 1)]], 42, yt)
|
|
2333
|
+
], 32)) : i("", !0)
|
|
2334
|
+
], 32));
|
|
2335
|
+
}
|
|
2336
|
+
}), [["__scopeId", "data-v-975e0b8b"]]), xt = { class: "palette-header" }, St = { class: "palette-title" }, Ct = { class: "current-color" }, wt = {
|
|
2337
|
+
key: 0,
|
|
2338
|
+
width: "14",
|
|
2339
|
+
height: "14",
|
|
2340
|
+
viewBox: "0 0 24 24",
|
|
2341
|
+
fill: "none",
|
|
2342
|
+
stroke: "currentColor",
|
|
2343
|
+
"stroke-width": "2",
|
|
2344
|
+
"stroke-linecap": "round"
|
|
2345
|
+
}, Tt = { class: "preset-grid" }, Et = ["title", "onClick"], Dt = {
|
|
2346
|
+
key: 0,
|
|
2347
|
+
class: "transparent-row"
|
|
2348
|
+
}, Ot = { class: "palette-footer" }, kt = { class: "custom-color" }, At = ["value"], jt = { class: "custom-label" }, Mt = /*#__PURE__*/ Le(/* @__PURE__ */ l({
|
|
2349
|
+
__name: "ColorPalette",
|
|
2350
|
+
setup(s) {
|
|
2351
|
+
let c = B(), { t: l } = ee(), u = L(), d = n(() => {
|
|
2352
|
+
if (!u?.value) return {};
|
|
2353
|
+
let e = u.value.getBoundingClientRect();
|
|
2354
|
+
return {
|
|
2355
|
+
left: e.left + 60 + "px",
|
|
2356
|
+
bottom: window.innerHeight - e.bottom + 9 + "px",
|
|
2357
|
+
position: "fixed"
|
|
2358
|
+
};
|
|
2359
|
+
}), f = [
|
|
2360
|
+
"#000000",
|
|
2361
|
+
"#ffffff",
|
|
2362
|
+
"#6b7280",
|
|
2363
|
+
"#d1d5db",
|
|
2364
|
+
"#dc2626",
|
|
2365
|
+
"#ef4444",
|
|
2366
|
+
"#f97316",
|
|
2367
|
+
"#f59e0b",
|
|
2368
|
+
"#16a34a",
|
|
2369
|
+
"#22c55e",
|
|
2370
|
+
"#0891b2",
|
|
2371
|
+
"#06b6d4",
|
|
2372
|
+
"#2563eb",
|
|
2373
|
+
"#3b82f6",
|
|
2374
|
+
"#7c3aed",
|
|
2375
|
+
"#8b5cf6",
|
|
2376
|
+
"#db2777",
|
|
2377
|
+
"#ec4899",
|
|
2378
|
+
"#a16207",
|
|
2379
|
+
"#84cc16",
|
|
2380
|
+
"#0d9488",
|
|
2381
|
+
"#6366f1",
|
|
2382
|
+
"#d946ef",
|
|
2383
|
+
"#f43f5e"
|
|
2384
|
+
];
|
|
2385
|
+
function h(e) {
|
|
2386
|
+
let t = e.target;
|
|
2387
|
+
c.setColor(t.value);
|
|
2388
|
+
}
|
|
2389
|
+
function g(e) {
|
|
2390
|
+
c.setColor(e), c.hideColorPalette();
|
|
2391
|
+
}
|
|
2392
|
+
function v() {
|
|
2393
|
+
c.setColor("transparent"), c.hideColorPalette();
|
|
2394
|
+
}
|
|
2395
|
+
return (n, s) => (_(), r(t, { to: "body" }, [C(c).showColorPalette ? (_(), a("div", {
|
|
2396
|
+
key: 0,
|
|
2397
|
+
class: "overlay",
|
|
2398
|
+
onClick: s[1] ||= (...e) => C(c).hideColorPalette && C(c).hideColorPalette(...e)
|
|
2399
|
+
}, [o("div", {
|
|
2400
|
+
class: "color-palette",
|
|
2401
|
+
style: m(d.value),
|
|
2402
|
+
onClick: s[0] ||= k(() => {}, ["stop"])
|
|
2403
|
+
}, [
|
|
2404
|
+
o("div", xt, [o("span", St, S(C(c).activeColorSlot === "textColor" ? C(l)("color.textColor") : C(c).activeColorSlot === "foreground" ? C(l)("palette.stroke") : C(l)("palette.fill")), 1), o("div", Ct, [o("div", {
|
|
2405
|
+
class: p(["current-swatch", {
|
|
2406
|
+
fill: C(c).activeColorSlot === "background",
|
|
2407
|
+
"current-transparent": C(c).activeColorSlot === "background" && C(c).backgroundColor === "transparent"
|
|
2408
|
+
}]),
|
|
2409
|
+
style: m({ background: C(c).activeColorSlot === "textColor" ? C(c).textColor : C(c).activeColorSlot === "foreground" ? C(c).foregroundColor : C(c).backgroundColor === "transparent" ? "none" : C(c).backgroundColor })
|
|
2410
|
+
}, [C(c).activeColorSlot === "background" && C(c).backgroundColor === "transparent" ? (_(), a("svg", wt, [...s[2] ||= [o("line", {
|
|
2411
|
+
x1: "5",
|
|
2412
|
+
y1: "5",
|
|
2413
|
+
x2: "19",
|
|
2414
|
+
y2: "19"
|
|
2415
|
+
}, null, -1)]])) : i("", !0)], 6)])]),
|
|
2416
|
+
o("div", Tt, [(_(), a(e, null, b(f, (e) => o("button", {
|
|
2417
|
+
key: e,
|
|
2418
|
+
class: "color-swatch",
|
|
2419
|
+
style: m({ background: e }),
|
|
2420
|
+
title: e,
|
|
2421
|
+
onClick: (t) => g(e)
|
|
2422
|
+
}, null, 12, Et)), 64))]),
|
|
2423
|
+
C(c).activeColorSlot === "background" ? (_(), a("div", Dt, [o("button", {
|
|
2424
|
+
class: "color-swatch transparent-swatch",
|
|
2425
|
+
title: "透明(无填充)",
|
|
2426
|
+
onClick: v
|
|
2427
|
+
}, [...s[3] ||= [o("svg", {
|
|
2428
|
+
width: "14",
|
|
2429
|
+
height: "14",
|
|
2430
|
+
viewBox: "0 0 24 24",
|
|
2431
|
+
fill: "none",
|
|
2432
|
+
stroke: "#d00",
|
|
2433
|
+
"stroke-width": "2",
|
|
2434
|
+
"stroke-linecap": "round"
|
|
2435
|
+
}, [o("line", {
|
|
2436
|
+
x1: "5",
|
|
2437
|
+
y1: "5",
|
|
2438
|
+
x2: "19",
|
|
2439
|
+
y2: "19"
|
|
2440
|
+
})], -1)]])])) : i("", !0),
|
|
2441
|
+
o("div", Ot, [o("div", kt, [o("input", {
|
|
2442
|
+
type: "color",
|
|
2443
|
+
value: C(c).activeColorSlot === "textColor" ? C(c).textColor : C(c).activeColorSlot === "foreground" ? C(c).foregroundColor : C(c).backgroundColor === "transparent" ? "#ffffff" : C(c).backgroundColor,
|
|
2444
|
+
class: "color-picker",
|
|
2445
|
+
onChange: h
|
|
2446
|
+
}, null, 40, At), o("span", jt, S(C(l)("palette.custom")), 1)])])
|
|
2447
|
+
], 4)])) : i("", !0)]));
|
|
2448
|
+
}
|
|
2449
|
+
}), [["__scopeId", "data-v-a8b8bc9c"]]), Nt = /*#__PURE__*/ Le(/* @__PURE__ */ l({
|
|
2450
|
+
__name: "Painter",
|
|
2451
|
+
props: {
|
|
2452
|
+
theme: { default: "light" },
|
|
2453
|
+
locale: { default: "zh-CN" },
|
|
2454
|
+
modelValue: { default: () => ({
|
|
2455
|
+
strokes: [],
|
|
2456
|
+
canvasWidth: 800,
|
|
2457
|
+
canvasHeight: 600
|
|
2458
|
+
}) },
|
|
2459
|
+
width: { default: "100%" },
|
|
2460
|
+
height: { default: "100%" }
|
|
2461
|
+
},
|
|
2462
|
+
emits: ["update:modelValue"],
|
|
2463
|
+
setup(e, { emit: t }) {
|
|
2464
|
+
let r = e, i = t, o = n(() => r.locale === "en-US" ? "en-US" : "zh-CN"), s = n(() => {
|
|
2465
|
+
let e = (e) => typeof e == "number" ? `${e}px` : e;
|
|
2466
|
+
return {
|
|
2467
|
+
width: e(r.width),
|
|
2468
|
+
height: e(r.height)
|
|
2469
|
+
};
|
|
2470
|
+
});
|
|
2471
|
+
P(o.value);
|
|
2472
|
+
let l = y(null);
|
|
2473
|
+
I(l);
|
|
2474
|
+
let u = B(), d = ie();
|
|
2475
|
+
u.reset(), d.reset();
|
|
2476
|
+
let f = !1;
|
|
2477
|
+
function h(e) {
|
|
2478
|
+
return e.map((e) => ({
|
|
2479
|
+
...e,
|
|
2480
|
+
points: e.points.map((e) => ({ ...e }))
|
|
2481
|
+
}));
|
|
2482
|
+
}
|
|
2483
|
+
E(() => r.theme, (e, t) => {
|
|
2484
|
+
u.theme = e || "light", e === "dark" && u.foregroundColor === "#000000" ? u.foregroundColor = "#ffffff" : e === "light" && t === "dark" && u.foregroundColor === "#ffffff" && (u.foregroundColor = "#000000");
|
|
2485
|
+
}, { immediate: !0 });
|
|
2486
|
+
let g = n(() => `wb-theme-${r.theme}`);
|
|
2487
|
+
u.setCanvasSize(r.modelValue.canvasWidth ?? 800, r.modelValue.canvasHeight ?? 600), r.modelValue.canvasBackgroundColor != null && u.setCanvasBackgroundColor(r.modelValue.canvasBackgroundColor), E(() => r.modelValue.canvasWidth, (e) => {
|
|
2488
|
+
e != null && u.setCanvasSize(e, u.canvasHeight);
|
|
2489
|
+
}), E(() => r.modelValue.canvasHeight, (e) => {
|
|
2490
|
+
e != null && u.setCanvasSize(u.canvasWidth, e);
|
|
2491
|
+
}), E(() => r.modelValue.strokes, (e) => {
|
|
2492
|
+
f || u.syncFromParent(e);
|
|
2493
|
+
}, {
|
|
2494
|
+
immediate: !0,
|
|
2495
|
+
deep: !0
|
|
2496
|
+
});
|
|
2497
|
+
function v() {
|
|
2498
|
+
f = !0, i("update:modelValue", {
|
|
2499
|
+
strokes: h(u.strokes),
|
|
2500
|
+
canvasWidth: u.canvasWidth,
|
|
2501
|
+
canvasHeight: u.canvasHeight,
|
|
2502
|
+
canvasBackgroundColor: u.canvasBackgroundColor
|
|
2503
|
+
}), setTimeout(() => {
|
|
2504
|
+
f = !1;
|
|
2505
|
+
}, 0);
|
|
2506
|
+
}
|
|
2507
|
+
return E(() => `${u.strokes.length}|${u.canvasWidth}|${u.canvasHeight}|${u.canvasBackgroundColor}|${u.dataVersion}`, () => {
|
|
2508
|
+
v();
|
|
2509
|
+
}), (e, t) => (_(), a("div", {
|
|
2510
|
+
ref_key: "rootEl",
|
|
2511
|
+
ref: l,
|
|
2512
|
+
class: p(["wb-root", g.value]),
|
|
2513
|
+
style: m(s.value)
|
|
2514
|
+
}, [
|
|
2515
|
+
c(Re),
|
|
2516
|
+
c(bt),
|
|
2517
|
+
c(Mt)
|
|
2518
|
+
], 6));
|
|
2519
|
+
}
|
|
2520
|
+
}), [["__scopeId", "data-v-40d42bb5"]]);
|
|
2521
|
+
//#endregion
|
|
2522
|
+
export { R as DEFAULT_CANVAS_HEIGHT, te as DEFAULT_CANVAS_WIDTH, z as DEFAULT_FONT_SIZE, re as HIT_THRESHOLD, Nt as Painter, Nt as default, ne as STROKE_WIDTH };
|