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