@hankchen/canvas-editor-vue 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{useDataSourceSchema-YV8g-lo0.js → DropdownMenu-CeUNKMDQ.js} +70 -78
- package/dist/ExpressionPathPicker-DchGsK70.js +739 -0
- package/dist/{canvas-CX1RdlFC.js → canvas-D3fFnBqG.js} +526 -527
- package/dist/canvas.js +1 -1
- package/dist/index.js +14 -15
- package/dist/layer-panel/TemplateTableForm.d.ts +1 -27
- package/dist/{layer-panel-Cd1e8xNB.js → layer-panel-BouAYiDq.js} +231 -257
- package/dist/layer-panel.js +1 -1
- package/dist/property-panel/PropertyField.d.ts +9 -2
- package/dist/property-panel/fieldSchema.d.ts +16 -10
- package/dist/property-panel/fields/RowsPathField.d.ts +17 -0
- package/dist/property-panel/fields/index.d.ts +1 -0
- package/dist/property-panel/usePropertyPanel.d.ts +11 -2
- package/dist/{property-panel-B32ZBQdf.js → property-panel-DJQJzioT.js} +403 -341
- package/dist/property-panel.js +2 -2
- package/dist/resourceTemplate-D-DKEo7Z.js +33 -0
- package/dist/shared/ExpressionPathPicker.d.ts +9 -2
- package/dist/shared/index.d.ts +13 -10
- package/dist/shared/pathPickerModel.d.ts +16 -3
- package/dist/shared/popupPosition.d.ts +2 -2
- package/dist/shared/rowsPathPickerSource.d.ts +15 -0
- package/dist/shared/useDataSourceSchema.d.ts +9 -1
- package/dist/shared/useExpressionDiagnostics.d.ts +11 -0
- package/dist/{shared-wuupBoZg.js → shared-CRDKDSpa.js} +22 -22
- package/dist/shared.js +9 -10
- package/dist/{status-bar-XMVbRLY9.js → status-bar-DBf5kIXY.js} +69 -67
- package/dist/status-bar.js +1 -1
- package/dist/style.css +1 -1
- package/dist/uploadFile-mXJVPEzm.js +653 -0
- package/dist/{useTransientFeedback-CTjmMmFF.js → useTransientFeedback-BN_O7V2w.js} +43 -28
- package/package.json +2 -2
- package/dist/popupPosition-Ck5Gsvjy.js +0 -526
- package/dist/resourceTemplate-cdcQtp9a.js +0 -246
- package/dist/shared/rowsPathCompletionSource.d.ts +0 -3
- package/dist/shared/usePathCompletion.d.ts +0 -18
- package/dist/uploadFile-D1RY-ji0.js +0 -516
- package/dist/usePathCompletion-Do17CQ6l.js +0 -220
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as e } from "./createLucideIcon-SCvtEGVf.js";
|
|
2
2
|
import { c as t, d as n, f as r, l as i, n as a, o, p as s, r as c, s as l, u } from "./dist-DGtNmLwo.js";
|
|
3
3
|
import { i as d, n as f, o as p } from "./layerPath-uy2ywyld.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { n as
|
|
8
|
-
import { Fragment as
|
|
9
|
-
var
|
|
4
|
+
import { c as m, o as h, t as g } from "./ExpressionPathPicker-DchGsK70.js";
|
|
5
|
+
import { a as _, d as v, i as y, n as b, p as x, r as S, t as C, u as w } from "./useTransientFeedback-BN_O7V2w.js";
|
|
6
|
+
import { c as T, f as E, i as D, l as O, m as k, n as ee, o as A, p as j, t as M } from "./uploadFile-mXJVPEzm.js";
|
|
7
|
+
import { n as N, t as P } from "./useViewport-D9Ipevzs.js";
|
|
8
|
+
import { Fragment as F, computed as I, createBlock as L, createCommentVNode as R, createElementBlock as z, createElementVNode as B, createVNode as V, defineComponent as H, mergeProps as te, nextTick as ne, normalizeClass as U, normalizeStyle as W, onBeforeUnmount as re, onMounted as G, onScopeDispose as K, openBlock as q, ref as J, renderList as Y, shallowRef as X, toDisplayString as Z, unref as Q, vModelText as ie, vShow as ae, watch as $, withDirectives as oe, withModifiers as se } from "vue";
|
|
9
|
+
var ce = e({
|
|
10
10
|
name: "arrow-down-left",
|
|
11
11
|
size: 24,
|
|
12
12
|
node: [["path", {
|
|
@@ -16,7 +16,7 @@ var ae = e({
|
|
|
16
16
|
d: "M17 17H7V7",
|
|
17
17
|
key: "1org7z"
|
|
18
18
|
}]]
|
|
19
|
-
}),
|
|
19
|
+
}), le = e({
|
|
20
20
|
name: "arrow-down-right",
|
|
21
21
|
size: 24,
|
|
22
22
|
node: [["path", {
|
|
@@ -26,7 +26,7 @@ var ae = e({
|
|
|
26
26
|
d: "M17 7v10H7",
|
|
27
27
|
key: "6fjiku"
|
|
28
28
|
}]]
|
|
29
|
-
}),
|
|
29
|
+
}), ue = e({
|
|
30
30
|
name: "arrow-up-left",
|
|
31
31
|
size: 24,
|
|
32
32
|
node: [["path", {
|
|
@@ -36,7 +36,7 @@ var ae = e({
|
|
|
36
36
|
d: "M17 17 7 7",
|
|
37
37
|
key: "2786uv"
|
|
38
38
|
}]]
|
|
39
|
-
}),
|
|
39
|
+
}), de = e({
|
|
40
40
|
name: "arrow-up-right",
|
|
41
41
|
size: 24,
|
|
42
42
|
node: [["path", {
|
|
@@ -46,21 +46,21 @@ var ae = e({
|
|
|
46
46
|
d: "M7 17 17 7",
|
|
47
47
|
key: "1vkiza"
|
|
48
48
|
}]]
|
|
49
|
-
}),
|
|
49
|
+
}), fe = e({
|
|
50
50
|
name: "chevron-up",
|
|
51
51
|
size: 24,
|
|
52
52
|
node: [["path", {
|
|
53
53
|
d: "m18 15-6-6-6 6",
|
|
54
54
|
key: "153udz"
|
|
55
55
|
}]]
|
|
56
|
-
}),
|
|
56
|
+
}), pe = e({
|
|
57
57
|
name: "minus",
|
|
58
58
|
size: 24,
|
|
59
59
|
node: [["path", {
|
|
60
60
|
d: "M5 12h14",
|
|
61
61
|
key: "1ays0h"
|
|
62
62
|
}]]
|
|
63
|
-
}),
|
|
63
|
+
}), me = e({
|
|
64
64
|
name: "plus",
|
|
65
65
|
size: 24,
|
|
66
66
|
node: [["path", {
|
|
@@ -70,7 +70,7 @@ var ae = e({
|
|
|
70
70
|
d: "M12 5v14",
|
|
71
71
|
key: "s699le"
|
|
72
72
|
}]]
|
|
73
|
-
}),
|
|
73
|
+
}), he = e({
|
|
74
74
|
name: "text-wrap",
|
|
75
75
|
size: 24,
|
|
76
76
|
node: [
|
|
@@ -92,7 +92,7 @@ var ae = e({
|
|
|
92
92
|
}]
|
|
93
93
|
],
|
|
94
94
|
aliases: ["wrap-text"]
|
|
95
|
-
}),
|
|
95
|
+
}), ge = e({
|
|
96
96
|
name: "x",
|
|
97
97
|
size: 24,
|
|
98
98
|
node: [["path", {
|
|
@@ -105,7 +105,7 @@ var ae = e({
|
|
|
105
105
|
});
|
|
106
106
|
//#endregion
|
|
107
107
|
//#region ../canvas-editor/src/spatial/camera.ts
|
|
108
|
-
function
|
|
108
|
+
function _e(e, t) {
|
|
109
109
|
if (!(t > 0)) return e;
|
|
110
110
|
let n = e.zoom * t;
|
|
111
111
|
return {
|
|
@@ -114,10 +114,10 @@ function me(e, t) {
|
|
|
114
114
|
zoom: e.zoom
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function ve(e) {
|
|
118
118
|
return 6 / e;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function ye(e, t, n) {
|
|
121
121
|
let r = [];
|
|
122
122
|
for (let i = 0; i < e.layers.length; i += 1) {
|
|
123
123
|
if (t !== null && i === t) continue;
|
|
@@ -126,7 +126,7 @@ function ge(e, t, n) {
|
|
|
126
126
|
}
|
|
127
127
|
return r;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function be(e, t, n, r) {
|
|
130
130
|
let i = [];
|
|
131
131
|
for (let e of n) i.push({
|
|
132
132
|
orientation: "vertical",
|
|
@@ -169,7 +169,7 @@ function _e(e, t, n, r) {
|
|
|
169
169
|
});
|
|
170
170
|
return i;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function xe(e, t, n, r) {
|
|
173
173
|
let i = null;
|
|
174
174
|
for (let a of t) if (a.orientation === n) for (let t of e) {
|
|
175
175
|
let e = a.position - t, n = Math.abs(e);
|
|
@@ -180,16 +180,16 @@ function ve(e, t, n, r) {
|
|
|
180
180
|
}
|
|
181
181
|
return i;
|
|
182
182
|
}
|
|
183
|
-
function
|
|
184
|
-
let r =
|
|
183
|
+
function Se(e, t, n) {
|
|
184
|
+
let r = xe(e.vertical, t, "vertical", n), i = xe(e.horizontal, t, "horizontal", n);
|
|
185
185
|
return {
|
|
186
186
|
dx: r ? r.delta : 0,
|
|
187
187
|
dy: i ? i.delta : 0,
|
|
188
188
|
axes: [...r ? [r.axis] : [], ...i ? [i.axis] : []]
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
|
-
function
|
|
192
|
-
return
|
|
191
|
+
function Ce(e, t, n) {
|
|
192
|
+
return Se({
|
|
193
193
|
vertical: [
|
|
194
194
|
e.x,
|
|
195
195
|
e.x + e.width / 2,
|
|
@@ -204,7 +204,7 @@ function be(e, t, n) {
|
|
|
204
204
|
}
|
|
205
205
|
//#endregion
|
|
206
206
|
//#region ../canvas-editor/src/spatial/resize.ts
|
|
207
|
-
function
|
|
207
|
+
function we(e, t) {
|
|
208
208
|
let n = e.x + e.width, r = e.y + e.height;
|
|
209
209
|
switch (t) {
|
|
210
210
|
case "nw": return {
|
|
@@ -243,38 +243,38 @@ function xe(e, t) {
|
|
|
243
243
|
}
|
|
244
244
|
//#endregion
|
|
245
245
|
//#region ../canvas-editor/src/spatial/wheel.ts
|
|
246
|
-
function
|
|
246
|
+
function Te(e) {
|
|
247
247
|
return e.ctrlKey || e.metaKey ? "zoom" : e.shiftKey ? "pan-x" : "pan";
|
|
248
248
|
}
|
|
249
249
|
//#endregion
|
|
250
250
|
//#region ../canvas-browser-renderer/src/fonts.ts
|
|
251
|
-
function
|
|
251
|
+
function Ee(e) {
|
|
252
252
|
return e === "" || /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e.trim());
|
|
253
253
|
}
|
|
254
|
-
function
|
|
255
|
-
return
|
|
254
|
+
function De(e) {
|
|
255
|
+
return Ee(e) ? "sans-serif" : `${Oe(e)}, sans-serif`;
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function Oe(e) {
|
|
258
258
|
let t = 2166136261;
|
|
259
259
|
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
260
260
|
return `canvas-font-${(t >>> 0).toString(36)}`;
|
|
261
261
|
}
|
|
262
262
|
//#endregion
|
|
263
263
|
//#region src/canvas/AlignFloatBar.vue?vue&type=script&setup=true&lang.ts
|
|
264
|
-
var
|
|
264
|
+
var ke = ["aria-disabled"], Ae = {
|
|
265
265
|
key: 0,
|
|
266
266
|
class: "cn-align-float__divider",
|
|
267
267
|
"aria-hidden": "true"
|
|
268
|
-
},
|
|
268
|
+
}, je = { class: "cn-align-float__group" }, Me = [
|
|
269
269
|
"disabled",
|
|
270
270
|
"title",
|
|
271
271
|
"aria-label",
|
|
272
272
|
"onClick"
|
|
273
|
-
],
|
|
273
|
+
], Ne = /*#__PURE__*/ x(/* @__PURE__ */ H({
|
|
274
274
|
__name: "AlignFloatBar",
|
|
275
275
|
props: { editor: {} },
|
|
276
276
|
setup(e) {
|
|
277
|
-
let a = e, o =
|
|
277
|
+
let a = e, o = N(a.editor), c = I(() => o.value !== null), l = (e) => `贴${e}角(边距 40px)`, d = [
|
|
278
278
|
{ keys: [{
|
|
279
279
|
mode: "h-center",
|
|
280
280
|
icon: r,
|
|
@@ -309,22 +309,22 @@ var Ee = ["aria-disabled"], De = {
|
|
|
309
309
|
{ keys: [
|
|
310
310
|
{
|
|
311
311
|
mode: "corner-tl",
|
|
312
|
-
icon:
|
|
312
|
+
icon: ue,
|
|
313
313
|
title: l("左上")
|
|
314
314
|
},
|
|
315
315
|
{
|
|
316
316
|
mode: "corner-tr",
|
|
317
|
-
icon:
|
|
317
|
+
icon: de,
|
|
318
318
|
title: l("右上")
|
|
319
319
|
},
|
|
320
320
|
{
|
|
321
321
|
mode: "corner-bl",
|
|
322
|
-
icon:
|
|
322
|
+
icon: ce,
|
|
323
323
|
title: l("左下")
|
|
324
324
|
},
|
|
325
325
|
{
|
|
326
326
|
mode: "corner-br",
|
|
327
|
-
icon:
|
|
327
|
+
icon: le,
|
|
328
328
|
title: l("右下")
|
|
329
329
|
}
|
|
330
330
|
] }
|
|
@@ -336,73 +336,71 @@ var Ee = ["aria-disabled"], De = {
|
|
|
336
336
|
let t = o.value;
|
|
337
337
|
t && (e.startsWith("corner-") ? a.editor.alignToCanvas(t, e, { margin: 40 }) : a.editor.alignToCanvas(t, e));
|
|
338
338
|
}
|
|
339
|
-
return (e, t) => (
|
|
340
|
-
class:
|
|
339
|
+
return (e, t) => (q(), z("div", {
|
|
340
|
+
class: U(["cn-align-float", { "cn-align-float--disabled": !c.value }]),
|
|
341
341
|
role: "toolbar",
|
|
342
342
|
"aria-label": "对齐画布",
|
|
343
343
|
"data-align-float": "",
|
|
344
344
|
"aria-disabled": c.value ? void 0 : "true"
|
|
345
|
-
}, [(
|
|
345
|
+
}, [(q(), z(F, null, Y(d, (e, t) => (q(), z(F, { key: t }, [t > 0 ? (q(), z("span", Ae)) : R("", !0), B("span", je, [(q(!0), z(F, null, Y(e.keys, (e) => (q(), z("button", te({
|
|
346
346
|
key: e.mode,
|
|
347
347
|
type: "button",
|
|
348
348
|
class: "cn-align-float__key",
|
|
349
349
|
disabled: !c.value,
|
|
350
350
|
title: e.title,
|
|
351
351
|
"aria-label": e.title
|
|
352
|
-
}, { ref_for: !0 }, f(e.mode), { onClick: (t) => p(e.mode) }), [
|
|
352
|
+
}, { ref_for: !0 }, f(e.mode), { onClick: (t) => p(e.mode) }), [V(m, { icon: e.icon }, null, 8, ["icon"])], 16, Me))), 128))])], 64))), 64))], 10, ke));
|
|
353
353
|
}
|
|
354
|
-
}), [["__scopeId", "data-v-9a761d37"]]),
|
|
354
|
+
}), [["__scopeId", "data-v-9a761d37"]]), Pe = {
|
|
355
355
|
key: 0,
|
|
356
356
|
class: "cn-context-menu__form"
|
|
357
|
-
},
|
|
358
|
-
key: 0,
|
|
359
|
-
class: "cn-context-menu__hint cn-context-menu__hint--error"
|
|
360
|
-
}, Fe = [
|
|
357
|
+
}, Fe = { class: "cn-context-menu__hint" }, Ie = { class: "cn-context-menu__form-actions" }, Le = ["disabled"], Re = [
|
|
361
358
|
"disabled",
|
|
362
359
|
"title",
|
|
363
360
|
"onClick"
|
|
364
|
-
],
|
|
361
|
+
], ze = /*#__PURE__*/ x(/* @__PURE__ */ H({
|
|
365
362
|
__name: "ContextMenu",
|
|
366
363
|
props: { editor: {} },
|
|
367
364
|
setup(e, { expose: t }) {
|
|
368
|
-
let n = e, r =
|
|
365
|
+
let n = e, r = J(null), i = J(!1), a = J({
|
|
369
366
|
x: 0,
|
|
370
367
|
y: 0
|
|
371
|
-
}), o =
|
|
368
|
+
}), o = w(), s = `先 ${v("copyStyle", o)} 复制样式`, c = `图层已锁定(${v("toggleLayerLock", o)} 解锁后可删除)`, l = N(n.editor), u = I(() => l.value !== null && f(l.value)), d = I(() => l.value !== null && n.editor.canCopySelection), m = I(() => (i.value, l.value !== null && n.editor.canCopyStyle)), b = I(() => (i.value, l.value !== null && n.editor.canPasteStyle)), x = I(() => {
|
|
372
369
|
let e = l.value, t = n.editor.store.doc;
|
|
373
370
|
return !e || !t || !f(e) ? !0 : p(t, e)?.visible ?? !0;
|
|
374
|
-
}),
|
|
371
|
+
}), S = I(() => {
|
|
375
372
|
let e = l.value, t = n.editor.store.doc;
|
|
376
373
|
return !e || !t ? null : p(t, e);
|
|
377
374
|
});
|
|
378
|
-
function
|
|
375
|
+
function C() {
|
|
379
376
|
let e = l.value;
|
|
380
377
|
return !e || typeof e[1] != "number" ? null : ["layers", e[1]];
|
|
381
378
|
}
|
|
382
|
-
let
|
|
383
|
-
let e =
|
|
379
|
+
let T = I(() => S.value?.type === "TableLayer" && S.value.template !== null), E = I(() => l.value?.[l.value.length - 1] === "template"), D = I(() => l.value !== null && n.editor.isLocked(l.value)), O = I(() => {
|
|
380
|
+
let e = S.value;
|
|
384
381
|
if (!e || e.type !== "TableLayer" || e.template !== null) return !1;
|
|
385
382
|
let t = e.rows[e.rows.length - 1];
|
|
386
383
|
return t !== void 0 && t.cells.length > 0;
|
|
387
|
-
}),
|
|
388
|
-
let e =
|
|
384
|
+
}), k = _(n.editor), ee = I(() => h(k.value)), A = I(() => {
|
|
385
|
+
let e = S.value;
|
|
389
386
|
return !e || e.type !== "TableLayer" ? "" : `模板取自末行,其余 ${Math.max(e.rows.length - 1, 0)} 行将移除(可撤销)`;
|
|
390
|
-
}),
|
|
391
|
-
|
|
392
|
-
|
|
387
|
+
}), j = I(() => {
|
|
388
|
+
if (k.value === null) return y;
|
|
389
|
+
if (O.value) return A.value;
|
|
390
|
+
let e = S.value;
|
|
391
|
+
return e !== null && e.type === "TableLayer" && e.rows.length === 0 ? "空表无可转换行" : "末行为空——先为末行加格";
|
|
392
|
+
}), M = J(!1), P = J("");
|
|
393
|
+
function L() {
|
|
394
|
+
M.value = !0, P.value = "";
|
|
393
395
|
}
|
|
394
|
-
function
|
|
395
|
-
let e =
|
|
396
|
-
|
|
397
|
-
O.value = !0;
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
n.editor.convertTableToTemplate(e, t), z();
|
|
396
|
+
function H() {
|
|
397
|
+
let e = C();
|
|
398
|
+
e && P.value !== "" && (n.editor.convertTableToTemplate(e, P.value), G());
|
|
401
399
|
}
|
|
402
|
-
let
|
|
400
|
+
let te = I(() => [
|
|
403
401
|
{
|
|
404
402
|
key: "visibility",
|
|
405
|
-
label:
|
|
403
|
+
label: x.value ? "隐藏" : "显示",
|
|
406
404
|
enabled: u.value,
|
|
407
405
|
title: u.value ? void 0 : "显示/隐藏仅作用于根图层",
|
|
408
406
|
run: () => {
|
|
@@ -421,7 +419,7 @@ var Ee = ["aria-disabled"], De = {
|
|
|
421
419
|
key: "copy-style",
|
|
422
420
|
label: "复制样式",
|
|
423
421
|
enabled: m.value,
|
|
424
|
-
title: !m.value &&
|
|
422
|
+
title: !m.value && E.value ? "行模板替身无样式可复制" : void 0,
|
|
425
423
|
run: () => {
|
|
426
424
|
let e = l.value;
|
|
427
425
|
e && n.editor.copyStyle(e);
|
|
@@ -430,8 +428,8 @@ var Ee = ["aria-disabled"], De = {
|
|
|
430
428
|
{
|
|
431
429
|
key: "paste-style",
|
|
432
430
|
label: "粘贴样式",
|
|
433
|
-
enabled:
|
|
434
|
-
title:
|
|
431
|
+
enabled: b.value,
|
|
432
|
+
title: b.value ? void 0 : s,
|
|
435
433
|
run: () => {
|
|
436
434
|
let e = l.value;
|
|
437
435
|
e && n.editor.pasteStyle(e);
|
|
@@ -465,39 +463,39 @@ var Ee = ["aria-disabled"], De = {
|
|
|
465
463
|
title: u.value ? void 0 : "置顶/置底仅对根图层生效",
|
|
466
464
|
run: () => n.editor.sendToBack()
|
|
467
465
|
},
|
|
468
|
-
...
|
|
466
|
+
...T.value ? [{
|
|
469
467
|
key: "to-rows",
|
|
470
468
|
label: "转回普通表",
|
|
471
469
|
enabled: !0,
|
|
472
470
|
title: "行模板实例化为单行,恢复普通表格编辑",
|
|
473
471
|
run: () => {
|
|
474
|
-
let e =
|
|
472
|
+
let e = C();
|
|
475
473
|
e && n.editor.convertTableToRows(e);
|
|
476
474
|
}
|
|
477
|
-
}] :
|
|
475
|
+
}] : S.value?.type === "TableLayer" ? [{
|
|
478
476
|
key: "to-template",
|
|
479
477
|
label: "转为模板表…",
|
|
480
|
-
enabled:
|
|
481
|
-
title:
|
|
478
|
+
enabled: k.value !== null && O.value,
|
|
479
|
+
title: j.value,
|
|
482
480
|
keepsOpen: !0,
|
|
483
|
-
run: () =>
|
|
481
|
+
run: () => L()
|
|
484
482
|
}] : [],
|
|
485
483
|
{
|
|
486
484
|
key: "delete",
|
|
487
485
|
label: "删除",
|
|
488
|
-
enabled: l.value !== null && !
|
|
489
|
-
title:
|
|
486
|
+
enabled: l.value !== null && !E.value && !D.value,
|
|
487
|
+
title: E.value ? "行模板由表持有——转换回普通表请用 V2 转换入口" : D.value ? c : void 0,
|
|
490
488
|
run: () => {
|
|
491
489
|
let e = l.value;
|
|
492
490
|
e && n.editor.deleteLayer(e);
|
|
493
491
|
}
|
|
494
492
|
}
|
|
495
493
|
]);
|
|
496
|
-
async function
|
|
494
|
+
async function re(e, t) {
|
|
497
495
|
a.value = {
|
|
498
496
|
x: e,
|
|
499
497
|
y: t
|
|
500
|
-
}, i.value = !0, await
|
|
498
|
+
}, i.value = !0, await ne();
|
|
501
499
|
let n = r.value, o = n?.parentElement;
|
|
502
500
|
if (!n || !o) return;
|
|
503
501
|
let s = n.getBoundingClientRect(), c = o.clientWidth - s.width - 2, l = o.clientHeight - s.height - 2;
|
|
@@ -506,69 +504,70 @@ var Ee = ["aria-disabled"], De = {
|
|
|
506
504
|
y: Math.max(2, Math.min(a.value.y, l))
|
|
507
505
|
};
|
|
508
506
|
}
|
|
509
|
-
function
|
|
510
|
-
i.value = !1,
|
|
507
|
+
function G() {
|
|
508
|
+
i.value = !1, M.value = !1, P.value = "";
|
|
511
509
|
}
|
|
512
|
-
function
|
|
513
|
-
e.run(), e.keepsOpen !== !0 &&
|
|
510
|
+
function K(e) {
|
|
511
|
+
e.run(), e.keepsOpen !== !0 && G();
|
|
514
512
|
}
|
|
515
513
|
return t({
|
|
516
|
-
openAt:
|
|
517
|
-
close:
|
|
518
|
-
}), (e, t) => i.value ? (
|
|
514
|
+
openAt: re,
|
|
515
|
+
close: G
|
|
516
|
+
}), (e, t) => i.value ? (q(), z("div", {
|
|
519
517
|
key: 0,
|
|
520
518
|
ref_key: "rootRef",
|
|
521
519
|
ref: r,
|
|
522
520
|
class: "cn-context-menu",
|
|
523
521
|
role: "menu",
|
|
524
522
|
"aria-label": "图层操作菜单",
|
|
525
|
-
style:
|
|
523
|
+
style: W({
|
|
526
524
|
left: `${a.value.x}px`,
|
|
527
525
|
top: `${a.value.y}px`
|
|
528
526
|
}),
|
|
529
|
-
onPointerdown: t[1] ||=
|
|
530
|
-
onContextmenu: t[2] ||=
|
|
531
|
-
}, [
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
527
|
+
onPointerdown: t[1] ||= se(() => {}, ["stop"]),
|
|
528
|
+
onContextmenu: t[2] ||= se(() => {}, ["prevent"])
|
|
529
|
+
}, [M.value ? (q(), z("div", Pe, [
|
|
530
|
+
B("p", Fe, Z(A.value), 1),
|
|
531
|
+
V(g, {
|
|
532
|
+
modelValue: P.value,
|
|
533
|
+
"onUpdate:modelValue": t[0] ||= (e) => P.value = e,
|
|
535
534
|
"data-convert-rows-path": "",
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
}, null,
|
|
541
|
-
|
|
542
|
-
L("div", { class: "cn-context-menu__form-actions" }, [L("button", {
|
|
535
|
+
mode: "rowsPath",
|
|
536
|
+
source: ee.value,
|
|
537
|
+
"aria-label": "取行路径",
|
|
538
|
+
placeholder: "未选择行路径"
|
|
539
|
+
}, null, 8, ["modelValue", "source"]),
|
|
540
|
+
B("div", Ie, [B("button", {
|
|
543
541
|
type: "button",
|
|
544
542
|
class: "cn-context-menu__item cn-context-menu__item--confirm",
|
|
545
|
-
|
|
546
|
-
|
|
543
|
+
disabled: P.value === "",
|
|
544
|
+
onClick: H
|
|
545
|
+
}, " 确认转换 ", 8, Le), B("button", {
|
|
547
546
|
type: "button",
|
|
548
547
|
class: "cn-context-menu__item",
|
|
549
|
-
onClick:
|
|
548
|
+
onClick: G
|
|
550
549
|
}, "取消")])
|
|
551
|
-
])) : (
|
|
550
|
+
])) : (q(!0), z(F, { key: 1 }, Y(te.value, (e) => (q(), z("button", {
|
|
552
551
|
key: e.key,
|
|
553
552
|
type: "button",
|
|
554
553
|
role: "menuitem",
|
|
555
|
-
class:
|
|
554
|
+
class: U(["cn-context-menu__item", [`cn-context-menu__item--${e.key}`]]),
|
|
556
555
|
disabled: !e.enabled,
|
|
557
556
|
title: e.title,
|
|
558
|
-
onClick: (t) =>
|
|
559
|
-
},
|
|
557
|
+
onClick: (t) => K(e)
|
|
558
|
+
}, Z(e.label), 11, Re))), 128))], 36)) : R("", !0);
|
|
560
559
|
}
|
|
561
|
-
}), [["__scopeId", "data-v-
|
|
560
|
+
}), [["__scopeId", "data-v-77744e07"]]);
|
|
562
561
|
//#endregion
|
|
563
562
|
//#region src/canvas/useFindSession.ts
|
|
564
|
-
function
|
|
565
|
-
let t =
|
|
563
|
+
function Be(e) {
|
|
564
|
+
let t = X(e.store.ui.find.open), n = X(e.store.ui.find.query), r = X(e.store.ui.find.replacement), i = X(e.listFindMatches()), a = X(e.findCursor), o = () => {
|
|
566
565
|
let o = e.store.ui.find;
|
|
567
566
|
t.value = o.open, n.value = o.query, r.value = o.replacement, i.value = e.listFindMatches(), a.value = e.findCursor;
|
|
568
567
|
}, s = e.subscribe((e) => {
|
|
569
568
|
(e.scope === "doc" || e.scope === "ui" && e.branch === "find") && o();
|
|
570
569
|
});
|
|
571
|
-
return
|
|
570
|
+
return K(s, !0), {
|
|
572
571
|
open: t,
|
|
573
572
|
query: n,
|
|
574
573
|
replacement: r,
|
|
@@ -578,21 +577,21 @@ function Le(e) {
|
|
|
578
577
|
}
|
|
579
578
|
//#endregion
|
|
580
579
|
//#region src/canvas/FindBar.vue?vue&type=script&setup=true&lang.ts
|
|
581
|
-
var
|
|
580
|
+
var Ve = ["value"], He = ["value"], Ue = {
|
|
582
581
|
class: "cn-find-bar__count",
|
|
583
582
|
"data-find-count": ""
|
|
584
|
-
},
|
|
583
|
+
}, We = {
|
|
585
584
|
key: 0,
|
|
586
585
|
class: "cn-find-bar__note",
|
|
587
586
|
"data-find-note": ""
|
|
588
|
-
},
|
|
587
|
+
}, Ge = ["disabled"], Ke = ["disabled"], qe = ["disabled"], Je = ["disabled"], Ye = /*#__PURE__*/ x(/* @__PURE__ */ H({
|
|
589
588
|
__name: "FindBar",
|
|
590
589
|
props: { editor: {} },
|
|
591
590
|
setup(e, { expose: t }) {
|
|
592
|
-
let n = e, { open: r, query: i, replacement: a, matches: o, cursor: s } =
|
|
591
|
+
let n = e, { open: r, query: i, replacement: a, matches: o, cursor: s } = Be(n.editor), c = J(null), u = J(null), d = I(() => {
|
|
593
592
|
let e = o.value.length;
|
|
594
593
|
return e === 0 ? i.value === "" ? "" : "无结果" : `第 ${s.value + 1}/${e} 处`;
|
|
595
|
-
}), f =
|
|
594
|
+
}), f = I(() => o.value.length > 0), p = I(() => f.value && s.value > 0), h = I(() => f.value && s.value < o.value.length - 1);
|
|
596
595
|
function g(e) {
|
|
597
596
|
let t = o.value[e];
|
|
598
597
|
if (!t) return;
|
|
@@ -600,16 +599,16 @@ var Re = ["value"], ze = ["value"], Be = {
|
|
|
600
599
|
let r = n.editor.layerBoxAt(t.path);
|
|
601
600
|
r && n.editor.panToBox(r);
|
|
602
601
|
}
|
|
603
|
-
function
|
|
602
|
+
function _(e) {
|
|
604
603
|
let t = o.value.length;
|
|
605
604
|
if (t === 0) return;
|
|
606
605
|
let r = Math.min(Math.max(s.value + e, 0), t - 1);
|
|
607
606
|
n.editor.setFindCursor(r), g(r);
|
|
608
607
|
}
|
|
609
|
-
function
|
|
608
|
+
function v() {
|
|
610
609
|
n.editor.replaceOne() && g(s.value);
|
|
611
610
|
}
|
|
612
|
-
function
|
|
611
|
+
function y() {
|
|
613
612
|
let e = n.editor.replaceAll();
|
|
614
613
|
e !== 0 && (u.value = `已替换 ${e} 处`, g(s.value));
|
|
615
614
|
}
|
|
@@ -622,7 +621,7 @@ var Re = ["value"], ze = ["value"], Be = {
|
|
|
622
621
|
e.preventDefault(), x();
|
|
623
622
|
return;
|
|
624
623
|
}
|
|
625
|
-
e.key === "Enter" && (e.preventDefault(),
|
|
624
|
+
e.key === "Enter" && (e.preventDefault(), _(e.shiftKey ? -1 : 1));
|
|
626
625
|
}
|
|
627
626
|
}
|
|
628
627
|
function C(e) {
|
|
@@ -631,98 +630,98 @@ var Re = ["value"], ze = ["value"], Be = {
|
|
|
631
630
|
function w(e) {
|
|
632
631
|
n.editor.setFindReplacement(e.target.value);
|
|
633
632
|
}
|
|
634
|
-
|
|
633
|
+
$(r, (e) => {
|
|
635
634
|
e && c.value?.focus({ preventScroll: !0 });
|
|
636
635
|
}, {
|
|
637
636
|
immediate: !0,
|
|
638
637
|
flush: "post"
|
|
639
638
|
});
|
|
640
639
|
function T(e) {
|
|
641
|
-
r.value && (e.key.toLowerCase() !== "f" || !(e.metaKey || e.ctrlKey) || e.shiftKey || e.altKey ||
|
|
640
|
+
r.value && (e.key.toLowerCase() !== "f" || !(e.metaKey || e.ctrlKey) || e.shiftKey || e.altKey || b(e.target) || c.value?.focus({ preventScroll: !0 }));
|
|
642
641
|
}
|
|
643
|
-
return window.addEventListener("keydown", T),
|
|
642
|
+
return window.addEventListener("keydown", T), re(() => window.removeEventListener("keydown", T)), $(i, () => {
|
|
644
643
|
u.value = null;
|
|
645
|
-
}), t({ close: x }), (e, t) =>
|
|
644
|
+
}), t({ close: x }), (e, t) => Q(r) ? (q(), z("div", {
|
|
646
645
|
key: 0,
|
|
647
646
|
class: "cn-find-bar",
|
|
648
647
|
"data-find-bar": "",
|
|
649
648
|
role: "search",
|
|
650
649
|
"aria-label": "查找替换",
|
|
651
|
-
onPointerdown: t[2] ||=
|
|
650
|
+
onPointerdown: t[2] ||= se(() => {}, ["stop"])
|
|
652
651
|
}, [
|
|
653
|
-
|
|
652
|
+
B("input", {
|
|
654
653
|
ref_key: "queryInput",
|
|
655
654
|
ref: c,
|
|
656
655
|
class: "cn-find-bar__input",
|
|
657
656
|
"data-find-query": "",
|
|
658
657
|
type: "text",
|
|
659
|
-
value:
|
|
658
|
+
value: Q(i),
|
|
660
659
|
placeholder: "查找",
|
|
661
660
|
"aria-label": "查找",
|
|
662
661
|
spellcheck: "false",
|
|
663
662
|
autocomplete: "off",
|
|
664
663
|
onInput: C,
|
|
665
664
|
onKeydown: S
|
|
666
|
-
}, null, 40,
|
|
667
|
-
|
|
665
|
+
}, null, 40, Ve),
|
|
666
|
+
B("input", {
|
|
668
667
|
class: "cn-find-bar__input",
|
|
669
668
|
"data-find-replace": "",
|
|
670
669
|
type: "text",
|
|
671
|
-
value:
|
|
670
|
+
value: Q(a),
|
|
672
671
|
placeholder: "替换",
|
|
673
672
|
"aria-label": "替换",
|
|
674
673
|
spellcheck: "false",
|
|
675
674
|
autocomplete: "off",
|
|
676
675
|
onInput: w,
|
|
677
676
|
onKeydown: S
|
|
678
|
-
}, null, 40,
|
|
679
|
-
|
|
680
|
-
u.value ? (
|
|
681
|
-
|
|
677
|
+
}, null, 40, He),
|
|
678
|
+
B("span", Ue, Z(d.value), 1),
|
|
679
|
+
u.value ? (q(), z("span", We, Z(u.value), 1)) : R("", !0),
|
|
680
|
+
B("button", {
|
|
682
681
|
type: "button",
|
|
683
682
|
class: "cn-find-bar__key",
|
|
684
683
|
"data-find-prev": "",
|
|
685
684
|
disabled: !p.value,
|
|
686
685
|
title: "上一处(Shift+Enter)",
|
|
687
686
|
"aria-label": "上一处",
|
|
688
|
-
onClick: t[0] ||= (e) =>
|
|
689
|
-
}, [
|
|
690
|
-
|
|
687
|
+
onClick: t[0] ||= (e) => _(-1)
|
|
688
|
+
}, [V(m, { icon: Q(fe) }, null, 8, ["icon"])], 8, Ge),
|
|
689
|
+
B("button", {
|
|
691
690
|
type: "button",
|
|
692
691
|
class: "cn-find-bar__key",
|
|
693
692
|
"data-find-next": "",
|
|
694
|
-
disabled: !
|
|
693
|
+
disabled: !h.value,
|
|
695
694
|
title: "下一处(Enter)",
|
|
696
695
|
"aria-label": "下一处",
|
|
697
|
-
onClick: t[1] ||= (e) =>
|
|
698
|
-
}, [
|
|
699
|
-
|
|
696
|
+
onClick: t[1] ||= (e) => _(1)
|
|
697
|
+
}, [V(m, { icon: Q(l) }, null, 8, ["icon"])], 8, Ke),
|
|
698
|
+
B("button", {
|
|
700
699
|
type: "button",
|
|
701
700
|
class: "cn-find-bar__action",
|
|
702
701
|
"data-find-replace-one": "",
|
|
703
702
|
disabled: !f.value,
|
|
704
703
|
title: "替换当前处",
|
|
705
|
-
onClick:
|
|
706
|
-
}, " 替换 ", 8,
|
|
707
|
-
|
|
704
|
+
onClick: v
|
|
705
|
+
}, " 替换 ", 8, qe),
|
|
706
|
+
B("button", {
|
|
708
707
|
type: "button",
|
|
709
708
|
class: "cn-find-bar__action",
|
|
710
709
|
"data-find-replace-all": "",
|
|
711
710
|
disabled: !f.value,
|
|
712
711
|
title: "全部替换",
|
|
713
|
-
onClick:
|
|
714
|
-
}, " 全部替换 ", 8,
|
|
715
|
-
|
|
712
|
+
onClick: y
|
|
713
|
+
}, " 全部替换 ", 8, Je),
|
|
714
|
+
B("button", {
|
|
716
715
|
type: "button",
|
|
717
716
|
class: "cn-find-bar__key",
|
|
718
717
|
"data-find-close": "",
|
|
719
718
|
title: "关闭(Esc)",
|
|
720
719
|
"aria-label": "关闭查找替换",
|
|
721
720
|
onClick: x
|
|
722
|
-
}, [
|
|
723
|
-
], 32)) :
|
|
721
|
+
}, [V(m, { icon: Q(ge) }, null, 8, ["icon"])])
|
|
722
|
+
], 32)) : R("", !0);
|
|
724
723
|
}
|
|
725
|
-
}), [["__scopeId", "data-v-71f0a3ae"]]),
|
|
724
|
+
}), [["__scopeId", "data-v-71f0a3ae"]]), Xe = {
|
|
726
725
|
nw: "nwse-resize",
|
|
727
726
|
se: "nwse-resize",
|
|
728
727
|
ne: "nesw-resize",
|
|
@@ -731,41 +730,41 @@ var Re = ["value"], ze = ["value"], Be = {
|
|
|
731
730
|
s: "ns-resize",
|
|
732
731
|
e: "ew-resize",
|
|
733
732
|
w: "ew-resize"
|
|
734
|
-
},
|
|
733
|
+
}, Ze = {
|
|
735
734
|
class: "cn-edit-toolbar__segment",
|
|
736
735
|
role: "group",
|
|
737
736
|
"aria-label": "内容类型",
|
|
738
737
|
"data-content-pill": ""
|
|
739
|
-
},
|
|
738
|
+
}, Qe = [
|
|
740
739
|
"aria-pressed",
|
|
741
740
|
"data-pill-static",
|
|
742
741
|
"data-pill-expression",
|
|
743
742
|
"onClick"
|
|
744
|
-
],
|
|
743
|
+
], $e = { class: "cn-edit-toolbar__segment" }, et = ["value"], tt = ["value"], nt = {
|
|
745
744
|
class: "cn-edit-toolbar__segment",
|
|
746
745
|
role: "group",
|
|
747
746
|
"aria-label": "字号"
|
|
748
|
-
},
|
|
747
|
+
}, rt = { class: "cn-edit-toolbar__segment" }, it = ["value"], at = {
|
|
749
748
|
class: "cn-edit-toolbar__segment",
|
|
750
749
|
role: "group",
|
|
751
750
|
"aria-label": "水平对齐",
|
|
752
751
|
"data-toolbar-align-horizontal": ""
|
|
753
|
-
},
|
|
752
|
+
}, ot = [
|
|
754
753
|
"aria-pressed",
|
|
755
754
|
"title",
|
|
756
755
|
"data-align-h",
|
|
757
756
|
"onClick"
|
|
758
|
-
],
|
|
757
|
+
], st = {
|
|
759
758
|
class: "cn-edit-toolbar__segment",
|
|
760
759
|
role: "group",
|
|
761
760
|
"aria-label": "垂直对齐",
|
|
762
761
|
"data-toolbar-align-vertical": ""
|
|
763
|
-
},
|
|
762
|
+
}, ct = [
|
|
764
763
|
"aria-pressed",
|
|
765
764
|
"title",
|
|
766
765
|
"data-align-v",
|
|
767
766
|
"onClick"
|
|
768
|
-
],
|
|
767
|
+
], lt = { class: "cn-edit-toolbar__segment" }, ut = ["aria-pressed"], dt = 1, ft = /*#__PURE__*/ x(/* @__PURE__ */ H({
|
|
769
768
|
__name: "EditOverlayToolbar",
|
|
770
769
|
props: {
|
|
771
770
|
mode: {},
|
|
@@ -778,9 +777,9 @@ var Re = ["value"], ze = ["value"], Be = {
|
|
|
778
777
|
},
|
|
779
778
|
emits: ["change", "styleWrite"],
|
|
780
779
|
setup(e, { expose: o, emit: l }) {
|
|
781
|
-
let d = e, f = l, p =
|
|
780
|
+
let d = e, f = l, p = J(null);
|
|
782
781
|
o({ rootEl: p });
|
|
783
|
-
function
|
|
782
|
+
function h(e, t, n) {
|
|
784
783
|
f("styleWrite", {
|
|
785
784
|
key: e,
|
|
786
785
|
value: t,
|
|
@@ -797,7 +796,7 @@ var Re = ["value"], ze = ["value"], Be = {
|
|
|
797
796
|
function _(e) {
|
|
798
797
|
e !== d.mode && f("change", e);
|
|
799
798
|
}
|
|
800
|
-
let v =
|
|
799
|
+
let v = D(), y = I(() => {
|
|
801
800
|
let e = [{
|
|
802
801
|
label: "内置默认字体",
|
|
803
802
|
value: ""
|
|
@@ -816,47 +815,47 @@ var Re = ["value"], ze = ["value"], Be = {
|
|
|
816
815
|
return e.startsWith("data:") ? "自定义字体(内联)" : e.split("/").pop() || e;
|
|
817
816
|
}
|
|
818
817
|
function x(e) {
|
|
819
|
-
|
|
818
|
+
h(["font"], e.target.value, !0);
|
|
820
819
|
}
|
|
821
|
-
let S =
|
|
822
|
-
|
|
820
|
+
let S = J(String(d.fontSize)), C = J(!1);
|
|
821
|
+
$(() => d.fontSize, (e) => {
|
|
823
822
|
C.value || (S.value = String(e));
|
|
824
823
|
});
|
|
825
|
-
function
|
|
826
|
-
return Math.max(
|
|
824
|
+
function w(e) {
|
|
825
|
+
return Math.max(dt, Math.trunc(e));
|
|
827
826
|
}
|
|
828
|
-
function
|
|
827
|
+
function T(e) {
|
|
829
828
|
if (e.value.trim() === "") return null;
|
|
830
829
|
let t = Number(e.value);
|
|
831
830
|
return Number.isFinite(t) ? t : null;
|
|
832
831
|
}
|
|
833
|
-
function
|
|
832
|
+
function E(e) {
|
|
834
833
|
let t = e.target;
|
|
835
834
|
S.value = t.value;
|
|
836
|
-
let n =
|
|
837
|
-
n !== null &&
|
|
835
|
+
let n = T(t);
|
|
836
|
+
n !== null && h(["fontSize"], w(n), !1);
|
|
838
837
|
}
|
|
839
838
|
function O(e) {
|
|
840
|
-
let t = e.target, n =
|
|
839
|
+
let t = e.target, n = T(t);
|
|
841
840
|
if (n === null) {
|
|
842
841
|
S.value = String(d.fontSize);
|
|
843
842
|
return;
|
|
844
843
|
}
|
|
845
|
-
let r =
|
|
846
|
-
S.value = String(r),
|
|
844
|
+
let r = w(n);
|
|
845
|
+
S.value = String(r), h(["fontSize"], r, !0);
|
|
847
846
|
}
|
|
848
847
|
function k(e) {
|
|
849
|
-
let t =
|
|
850
|
-
S.value = String(t),
|
|
848
|
+
let t = w(d.fontSize + e);
|
|
849
|
+
S.value = String(t), h(["fontSize"], t, !1);
|
|
851
850
|
}
|
|
852
|
-
let
|
|
853
|
-
function
|
|
854
|
-
|
|
851
|
+
let ee = I(() => /^#[0-9a-fA-F]{6}$/.test(d.fontColor) ? d.fontColor : "#000000");
|
|
852
|
+
function A(e) {
|
|
853
|
+
h(["fontColor"], e.target.value, !1);
|
|
855
854
|
}
|
|
856
|
-
function
|
|
857
|
-
|
|
855
|
+
function j(e) {
|
|
856
|
+
h(["fontColor"], e.target.value, !0);
|
|
858
857
|
}
|
|
859
|
-
let
|
|
858
|
+
let M = {
|
|
860
859
|
left: {
|
|
861
860
|
icon: t,
|
|
862
861
|
title: "左对齐"
|
|
@@ -869,7 +868,7 @@ var Re = ["value"], ze = ["value"], Be = {
|
|
|
869
868
|
icon: u,
|
|
870
869
|
title: "右对齐"
|
|
871
870
|
}
|
|
872
|
-
},
|
|
871
|
+
}, N = {
|
|
873
872
|
top: {
|
|
874
873
|
icon: i,
|
|
875
874
|
title: "顶对齐"
|
|
@@ -882,175 +881,175 @@ var Re = ["value"], ze = ["value"], Be = {
|
|
|
882
881
|
icon: n,
|
|
883
882
|
title: "底对齐"
|
|
884
883
|
}
|
|
885
|
-
},
|
|
884
|
+
}, P = a.map((e) => ({
|
|
886
885
|
value: e,
|
|
887
|
-
...
|
|
888
|
-
})),
|
|
886
|
+
...M[e]
|
|
887
|
+
})), L = c.map((e) => ({
|
|
889
888
|
value: e,
|
|
890
|
-
...
|
|
889
|
+
...N[e]
|
|
891
890
|
}));
|
|
892
|
-
function
|
|
893
|
-
t !== (e === "horizontal" ? d.horizontalAlign : d.verticalAlign) &&
|
|
891
|
+
function R(e, t) {
|
|
892
|
+
t !== (e === "horizontal" ? d.horizontalAlign : d.verticalAlign) && h(e === "horizontal" ? ["align", "horizontal"] : ["align", "vertical"], t, !0);
|
|
894
893
|
}
|
|
895
|
-
function
|
|
896
|
-
|
|
894
|
+
function H() {
|
|
895
|
+
h(["autowrap"], !d.autowrap, !0);
|
|
897
896
|
}
|
|
898
|
-
return (t, n) => (
|
|
897
|
+
return (t, n) => (q(), z("div", {
|
|
899
898
|
ref_key: "rootRef",
|
|
900
899
|
ref: p,
|
|
901
900
|
class: "cn-edit-toolbar",
|
|
902
901
|
role: "toolbar",
|
|
903
902
|
"aria-label": "文本编辑",
|
|
904
903
|
"data-edit-toolbar": "",
|
|
905
|
-
onPointerdown: n[7] ||=
|
|
904
|
+
onPointerdown: n[7] ||= se(() => {}, ["prevent"])
|
|
906
905
|
}, [
|
|
907
|
-
|
|
906
|
+
B("span", Ze, [(q(), z(F, null, Y(g, (t) => B("button", {
|
|
908
907
|
key: t.value,
|
|
909
908
|
type: "button",
|
|
910
|
-
class:
|
|
909
|
+
class: U(["cn-edit-toolbar__item", { "cn-edit-toolbar__item--active": t.value === e.mode }]),
|
|
911
910
|
"aria-pressed": t.value === e.mode,
|
|
912
911
|
"data-pill-static": t.value === "static" || void 0,
|
|
913
912
|
"data-pill-expression": t.value === "expression" || void 0,
|
|
914
913
|
onClick: (e) => _(t.value)
|
|
915
|
-
},
|
|
916
|
-
|
|
914
|
+
}, Z(t.label), 11, Qe)), 64))]),
|
|
915
|
+
B("span", $e, [B("select", {
|
|
917
916
|
class: "cn-edit-toolbar__font",
|
|
918
917
|
"data-toolbar-font": "",
|
|
919
918
|
value: e.font,
|
|
920
919
|
title: "字体",
|
|
921
|
-
onPointerdown: n[0] ||=
|
|
920
|
+
onPointerdown: n[0] ||= se(() => {}, ["stop"]),
|
|
922
921
|
onChange: x
|
|
923
|
-
}, [(
|
|
922
|
+
}, [(q(!0), z(F, null, Y(y.value, (e) => (q(), z("option", {
|
|
924
923
|
key: e.value,
|
|
925
924
|
value: e.value
|
|
926
|
-
},
|
|
927
|
-
|
|
928
|
-
|
|
925
|
+
}, Z(e.label), 9, tt))), 128))], 40, et)]),
|
|
926
|
+
B("span", nt, [
|
|
927
|
+
B("button", {
|
|
929
928
|
type: "button",
|
|
930
929
|
class: "cn-edit-toolbar__mini",
|
|
931
930
|
"data-toolbar-font-size-dec": "",
|
|
932
931
|
title: "字号减 1",
|
|
933
932
|
onClick: n[1] ||= (e) => k(-1)
|
|
934
|
-
}, [
|
|
935
|
-
icon:
|
|
933
|
+
}, [V(m, {
|
|
934
|
+
icon: Q(pe),
|
|
936
935
|
size: 11
|
|
937
936
|
}, null, 8, ["icon"])]),
|
|
938
|
-
|
|
937
|
+
oe(B("input", {
|
|
939
938
|
"onUpdate:modelValue": n[2] ||= (e) => S.value = e,
|
|
940
939
|
class: "cn-edit-toolbar__size",
|
|
941
940
|
"data-toolbar-font-size": "",
|
|
942
941
|
type: "number",
|
|
943
|
-
min:
|
|
942
|
+
min: dt,
|
|
944
943
|
step: 1,
|
|
945
944
|
"aria-label": "字号(场景像素)",
|
|
946
945
|
title: "字号(场景像素)",
|
|
947
|
-
onPointerdown: n[3] ||=
|
|
948
|
-
onInput:
|
|
946
|
+
onPointerdown: n[3] ||= se(() => {}, ["stop"]),
|
|
947
|
+
onInput: E,
|
|
949
948
|
onChange: O,
|
|
950
949
|
onBlur: O,
|
|
951
950
|
onFocus: n[4] ||= (e) => C.value = !0
|
|
952
|
-
}, null, 544), [[
|
|
953
|
-
|
|
951
|
+
}, null, 544), [[ie, S.value]]),
|
|
952
|
+
B("button", {
|
|
954
953
|
type: "button",
|
|
955
954
|
class: "cn-edit-toolbar__mini",
|
|
956
955
|
"data-toolbar-font-size-inc": "",
|
|
957
956
|
title: "字号加 1",
|
|
958
957
|
onClick: n[5] ||= (e) => k(1)
|
|
959
|
-
}, [
|
|
960
|
-
icon:
|
|
958
|
+
}, [V(m, {
|
|
959
|
+
icon: Q(me),
|
|
961
960
|
size: 11
|
|
962
961
|
}, null, 8, ["icon"])])
|
|
963
962
|
]),
|
|
964
|
-
|
|
963
|
+
B("span", rt, [B("input", {
|
|
965
964
|
class: "cn-edit-toolbar__color",
|
|
966
965
|
"data-toolbar-font-color": "",
|
|
967
966
|
type: "color",
|
|
968
|
-
value:
|
|
967
|
+
value: ee.value,
|
|
969
968
|
"aria-label": "字色",
|
|
970
969
|
title: "字色",
|
|
971
|
-
onPointerdown: n[6] ||=
|
|
972
|
-
onInput:
|
|
973
|
-
onChange:
|
|
974
|
-
}, null, 40,
|
|
975
|
-
|
|
970
|
+
onPointerdown: n[6] ||= se(() => {}, ["stop"]),
|
|
971
|
+
onInput: A,
|
|
972
|
+
onChange: j
|
|
973
|
+
}, null, 40, it)]),
|
|
974
|
+
B("span", at, [(q(!0), z(F, null, Y(Q(P), (t) => (q(), z("button", {
|
|
976
975
|
key: t.value,
|
|
977
976
|
type: "button",
|
|
978
|
-
class:
|
|
977
|
+
class: U(["cn-edit-toolbar__item cn-edit-toolbar__icon-item", { "cn-edit-toolbar__item--active": t.value === e.horizontalAlign }]),
|
|
979
978
|
"aria-pressed": t.value === e.horizontalAlign,
|
|
980
979
|
title: `水平对齐:${t.title}`,
|
|
981
980
|
"data-align-h": t.value,
|
|
982
|
-
onClick: (e) =>
|
|
983
|
-
}, [
|
|
981
|
+
onClick: (e) => R("horizontal", t.value)
|
|
982
|
+
}, [V(m, {
|
|
984
983
|
icon: t.icon,
|
|
985
984
|
size: 12
|
|
986
|
-
}, null, 8, ["icon"])], 10,
|
|
987
|
-
|
|
985
|
+
}, null, 8, ["icon"])], 10, ot))), 128))]),
|
|
986
|
+
B("span", st, [(q(!0), z(F, null, Y(Q(L), (t) => (q(), z("button", {
|
|
988
987
|
key: t.value,
|
|
989
988
|
type: "button",
|
|
990
|
-
class:
|
|
989
|
+
class: U(["cn-edit-toolbar__item cn-edit-toolbar__icon-item", { "cn-edit-toolbar__item--active": t.value === e.verticalAlign }]),
|
|
991
990
|
"aria-pressed": t.value === e.verticalAlign,
|
|
992
991
|
title: `垂直对齐:${t.title}`,
|
|
993
992
|
"data-align-v": t.value,
|
|
994
|
-
onClick: (e) =>
|
|
995
|
-
}, [
|
|
993
|
+
onClick: (e) => R("vertical", t.value)
|
|
994
|
+
}, [V(m, {
|
|
996
995
|
icon: t.icon,
|
|
997
996
|
size: 12
|
|
998
|
-
}, null, 8, ["icon"])], 10,
|
|
999
|
-
|
|
997
|
+
}, null, 8, ["icon"])], 10, ct))), 128))]),
|
|
998
|
+
B("span", lt, [B("button", {
|
|
1000
999
|
type: "button",
|
|
1001
|
-
class:
|
|
1000
|
+
class: U(["cn-edit-toolbar__item cn-edit-toolbar__icon-item", { "cn-edit-toolbar__item--active": e.autowrap }]),
|
|
1002
1001
|
"aria-pressed": e.autowrap,
|
|
1003
1002
|
"data-toolbar-autowrap": "",
|
|
1004
1003
|
title: "自动换行",
|
|
1005
|
-
onClick:
|
|
1006
|
-
}, [
|
|
1007
|
-
icon:
|
|
1004
|
+
onClick: H
|
|
1005
|
+
}, [V(m, {
|
|
1006
|
+
icon: Q(he),
|
|
1008
1007
|
size: 12
|
|
1009
|
-
}, null, 8, ["icon"])], 10,
|
|
1008
|
+
}, null, 8, ["icon"])], 10, ut)])
|
|
1010
1009
|
], 544));
|
|
1011
1010
|
}
|
|
1012
1011
|
}), [["__scopeId", "data-v-dcead501"]]);
|
|
1013
1012
|
//#endregion
|
|
1014
1013
|
//#region src/canvas/useDpr.ts
|
|
1015
|
-
function
|
|
1014
|
+
function pt(e) {
|
|
1016
1015
|
let t = null, n = () => {
|
|
1017
1016
|
t?.removeEventListener("change", n), e(window.devicePixelRatio || 1), t = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`), t.addEventListener("change", n);
|
|
1018
1017
|
};
|
|
1019
1018
|
return n(), () => t?.removeEventListener("change", n);
|
|
1020
1019
|
}
|
|
1021
|
-
function
|
|
1022
|
-
let e =
|
|
1020
|
+
function mt() {
|
|
1021
|
+
let e = X(window.devicePixelRatio || 1), t = pt((t) => {
|
|
1023
1022
|
e.value = t;
|
|
1024
1023
|
});
|
|
1025
|
-
return
|
|
1024
|
+
return K(t, !0), e;
|
|
1026
1025
|
}
|
|
1027
1026
|
//#endregion
|
|
1028
1027
|
//#region src/canvas/useTextEditing.ts
|
|
1029
|
-
var
|
|
1030
|
-
function
|
|
1031
|
-
let n = `${e}|${t}`, r =
|
|
1028
|
+
var ht = /* @__PURE__ */ new Map();
|
|
1029
|
+
function gt(e, t) {
|
|
1030
|
+
let n = `${e}|${t}`, r = ht.get(n);
|
|
1032
1031
|
if (r !== void 0) return r;
|
|
1033
1032
|
let i = t * 1.2;
|
|
1034
1033
|
try {
|
|
1035
1034
|
let n = document.createElement("canvas").getContext("2d");
|
|
1036
1035
|
if (n) {
|
|
1037
|
-
n.font = `${t}px ${
|
|
1036
|
+
n.font = `${t}px ${De(e)}`;
|
|
1038
1037
|
let r = n.measureText("字"), a = (r.fontBoundingBoxAscent ?? r.actualBoundingBoxAscent) + (r.fontBoundingBoxDescent ?? r.actualBoundingBoxDescent);
|
|
1039
1038
|
a > 0 && (i = a);
|
|
1040
1039
|
}
|
|
1041
1040
|
} catch {}
|
|
1042
|
-
return
|
|
1041
|
+
return ht.set(n, i), i;
|
|
1043
1042
|
}
|
|
1044
|
-
function
|
|
1045
|
-
let n =
|
|
1043
|
+
function _t(e, t) {
|
|
1044
|
+
let n = X(e.store.ui.editing), r = X(0), i = e.subscribe((t) => {
|
|
1046
1045
|
t.scope === "doc" ? (r.value += 1, n.value = e.store.ui.editing) : t.scope === "ui" && t.branch === "editing" && (n.value = e.store.ui.editing);
|
|
1047
1046
|
});
|
|
1048
|
-
|
|
1049
|
-
let a =
|
|
1047
|
+
K(i, !0);
|
|
1048
|
+
let a = I(() => n.value?.path ?? null), o = mt(), s = P(e), c = I(() => {
|
|
1050
1049
|
r.value;
|
|
1051
1050
|
let t = n.value;
|
|
1052
1051
|
return t ? e.textEditLayout(t.path) : null;
|
|
1053
|
-
}), l =
|
|
1052
|
+
}), l = I(() => _e(s.value, o.value));
|
|
1054
1053
|
function u(e, t) {
|
|
1055
1054
|
let { x: n, y: r, zoom: i } = l.value;
|
|
1056
1055
|
return {
|
|
@@ -1059,7 +1058,7 @@ function mt(e, t) {
|
|
|
1059
1058
|
zoom: i
|
|
1060
1059
|
};
|
|
1061
1060
|
}
|
|
1062
|
-
let d =
|
|
1061
|
+
let d = I(() => {
|
|
1063
1062
|
let e = c.value;
|
|
1064
1063
|
if (!e) return null;
|
|
1065
1064
|
let { left: t, top: n, zoom: r } = u(e.box.x, e.box.y);
|
|
@@ -1069,17 +1068,17 @@ function mt(e, t) {
|
|
|
1069
1068
|
width: `${e.box.width}px`,
|
|
1070
1069
|
height: `${e.box.height}px`,
|
|
1071
1070
|
color: e.fontColor,
|
|
1072
|
-
fontFamily:
|
|
1071
|
+
fontFamily: De(e.font),
|
|
1073
1072
|
fontSize: `${e.fontSize}px`,
|
|
1074
1073
|
lineHeight: `${e.lineHeightPx}px`,
|
|
1075
1074
|
...x(e),
|
|
1076
1075
|
textAlign: e.horizontalAlign,
|
|
1077
1076
|
whiteSpace: e.autowrap ? "pre-wrap" : "pre"
|
|
1078
1077
|
};
|
|
1079
|
-
}), f =
|
|
1078
|
+
}), f = X({
|
|
1080
1079
|
width: 0,
|
|
1081
1080
|
height: 0
|
|
1082
|
-
}), p =
|
|
1081
|
+
}), p = X({
|
|
1083
1082
|
width: 0,
|
|
1084
1083
|
height: 0
|
|
1085
1084
|
}), m = () => {
|
|
@@ -1098,15 +1097,15 @@ function mt(e, t) {
|
|
|
1098
1097
|
height: e.offsetHeight
|
|
1099
1098
|
};
|
|
1100
1099
|
};
|
|
1101
|
-
|
|
1100
|
+
$(a, (e) => {
|
|
1102
1101
|
e !== null && m();
|
|
1103
1102
|
}, { flush: "post" });
|
|
1104
1103
|
let g = null;
|
|
1105
|
-
|
|
1104
|
+
$(() => t.getToolbar?.() ?? null, (e) => {
|
|
1106
1105
|
g?.disconnect(), g = null, e !== null && (h(), typeof ResizeObserver == "function" && (g = new ResizeObserver(h), g.observe(e)));
|
|
1107
1106
|
}, { flush: "post" });
|
|
1108
1107
|
let _ = null;
|
|
1109
|
-
|
|
1108
|
+
G(() => {
|
|
1110
1109
|
let e = t.getHost();
|
|
1111
1110
|
e !== null && typeof ResizeObserver == "function" && (_ = new ResizeObserver(() => {
|
|
1112
1111
|
f.value = {
|
|
@@ -1114,10 +1113,10 @@ function mt(e, t) {
|
|
|
1114
1113
|
height: e.clientHeight
|
|
1115
1114
|
};
|
|
1116
1115
|
}), _.observe(e));
|
|
1117
|
-
}),
|
|
1116
|
+
}), K(() => {
|
|
1118
1117
|
_?.disconnect(), g?.disconnect();
|
|
1119
1118
|
}, !0);
|
|
1120
|
-
let v =
|
|
1119
|
+
let v = I(() => {
|
|
1121
1120
|
let e = c.value;
|
|
1122
1121
|
if (!e) return null;
|
|
1123
1122
|
let { width: t, height: n } = p.value, r = u(e.box.x + e.box.width / 2, e.box.y), i = u(e.box.x + e.box.width / 2, e.box.y + e.box.height), a = r.top - 4 - n < 0, o = a ? i.top + 4 : r.top - 4 - n;
|
|
@@ -1127,13 +1126,13 @@ function mt(e, t) {
|
|
|
1127
1126
|
height: n,
|
|
1128
1127
|
flipped: a
|
|
1129
1128
|
};
|
|
1130
|
-
}), y =
|
|
1129
|
+
}), y = I(() => {
|
|
1131
1130
|
let e = v.value;
|
|
1132
1131
|
return e ? {
|
|
1133
1132
|
left: `${e.left}px`,
|
|
1134
1133
|
top: `${e.top}px`
|
|
1135
1134
|
} : null;
|
|
1136
|
-
}), b =
|
|
1135
|
+
}), b = I(() => {
|
|
1137
1136
|
let e = v.value;
|
|
1138
1137
|
return e ? e.flipped ? {
|
|
1139
1138
|
left: `${e.left}px`,
|
|
@@ -1145,7 +1144,7 @@ function mt(e, t) {
|
|
|
1145
1144
|
} : null;
|
|
1146
1145
|
});
|
|
1147
1146
|
function x(e) {
|
|
1148
|
-
let t = e.padding.top + e.verticalAnchorY, n = e.lineHeightPx, r =
|
|
1147
|
+
let t = e.padding.top + e.verticalAnchorY, n = e.lineHeightPx, r = gt(e.font, e.fontSize), i;
|
|
1149
1148
|
return i = e.verticalAlign === "center" ? t - n / 2 : e.verticalAlign === "bottom" ? t - (n + r) / 2 : t - (n - r) / 2, {
|
|
1150
1149
|
paddingTop: `${Math.max(0, i)}px`,
|
|
1151
1150
|
paddingRight: `${e.padding.right}px`,
|
|
@@ -1165,161 +1164,161 @@ function mt(e, t) {
|
|
|
1165
1164
|
}, T = (t, n, r) => {
|
|
1166
1165
|
let i = e.store.ui.editing?.path;
|
|
1167
1166
|
if (!i) return;
|
|
1168
|
-
let a =
|
|
1167
|
+
let a = ee(i, t);
|
|
1169
1168
|
e.updateSpec(i, t, n, { mergeKey: a }), r && e.store.closeMerge(a);
|
|
1170
|
-
},
|
|
1169
|
+
}, E = null, D = !1, O = !1, k = () => {
|
|
1171
1170
|
e.commitTextEdit(t.getTextarea()?.value ?? "");
|
|
1172
|
-
},
|
|
1173
|
-
|
|
1174
|
-
},
|
|
1175
|
-
if (
|
|
1176
|
-
|
|
1171
|
+
}, A = () => {
|
|
1172
|
+
E !== null && clearTimeout(E), E = null;
|
|
1173
|
+
}, j = () => {
|
|
1174
|
+
if (A(), M.value) {
|
|
1175
|
+
O = !0;
|
|
1177
1176
|
return;
|
|
1178
1177
|
}
|
|
1179
|
-
|
|
1180
|
-
},
|
|
1181
|
-
|
|
1182
|
-
},
|
|
1178
|
+
k();
|
|
1179
|
+
}, M = X(!1), N = (e) => {
|
|
1180
|
+
M.value = e, !e && O && (O = !1, a.value !== null && k());
|
|
1181
|
+
}, F = () => {
|
|
1183
1182
|
if (a.value !== null) {
|
|
1184
|
-
if (
|
|
1185
|
-
|
|
1183
|
+
if (A(), D) {
|
|
1184
|
+
D = !1;
|
|
1186
1185
|
return;
|
|
1187
1186
|
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1187
|
+
E = setTimeout(() => {
|
|
1188
|
+
E = null;
|
|
1190
1189
|
let e = t.getTextarea();
|
|
1191
1190
|
if (e === null || document.activeElement !== e) {
|
|
1192
|
-
if (
|
|
1193
|
-
|
|
1191
|
+
if (M.value) {
|
|
1192
|
+
O = !0;
|
|
1194
1193
|
return;
|
|
1195
1194
|
}
|
|
1196
|
-
|
|
1195
|
+
k();
|
|
1197
1196
|
}
|
|
1198
1197
|
}, 0);
|
|
1199
1198
|
}
|
|
1200
|
-
},
|
|
1199
|
+
}, L = (e) => {
|
|
1201
1200
|
if (!(e instanceof Node)) return !1;
|
|
1202
1201
|
let n = t.getToolbar?.() ?? null;
|
|
1203
1202
|
if (n !== null && n.contains(e)) return !0;
|
|
1204
1203
|
let r = t.getTextarea();
|
|
1205
1204
|
return r !== null && r.contains(e);
|
|
1206
|
-
},
|
|
1205
|
+
}, R = (e) => {
|
|
1207
1206
|
if (a.value === null) return;
|
|
1208
1207
|
let n = t.getToolbar?.() ?? null;
|
|
1209
1208
|
if (n !== null && e.target instanceof Node && n.contains(e.target)) {
|
|
1210
|
-
|
|
1209
|
+
D = !0;
|
|
1211
1210
|
return;
|
|
1212
1211
|
}
|
|
1213
|
-
if (
|
|
1212
|
+
if (L(e.target)) return;
|
|
1214
1213
|
let r = t.getHost();
|
|
1215
|
-
r !== null && r.contains(e.target) || (
|
|
1216
|
-
},
|
|
1217
|
-
|
|
1214
|
+
r !== null && r.contains(e.target) || (D = !0);
|
|
1215
|
+
}, z = () => {
|
|
1216
|
+
D = !1;
|
|
1218
1217
|
};
|
|
1219
|
-
return window.addEventListener("pointerdown",
|
|
1220
|
-
window.removeEventListener("pointerdown",
|
|
1218
|
+
return window.addEventListener("pointerdown", R, !0), window.addEventListener("pointerup", z, !0), K(() => {
|
|
1219
|
+
window.removeEventListener("pointerdown", R, !0), window.removeEventListener("pointerup", z, !0), A();
|
|
1221
1220
|
}, !0), {
|
|
1222
1221
|
editing: a,
|
|
1223
1222
|
layout: c,
|
|
1224
|
-
draftSeq:
|
|
1223
|
+
draftSeq: I(() => n.value?.draftSeq),
|
|
1225
1224
|
style: d,
|
|
1226
1225
|
toolbarStyle: y,
|
|
1227
1226
|
toolbarTagStyle: b,
|
|
1228
|
-
scale:
|
|
1229
|
-
composing:
|
|
1230
|
-
setComposing:
|
|
1227
|
+
scale: I(() => l.value.zoom),
|
|
1228
|
+
composing: I(() => M.value),
|
|
1229
|
+
setComposing: N,
|
|
1231
1230
|
beginAt: S,
|
|
1232
1231
|
beginTextEdit: C,
|
|
1233
|
-
commitNow:
|
|
1232
|
+
commitNow: j,
|
|
1234
1233
|
setExpressionMode: w,
|
|
1235
1234
|
updateStyleField: T,
|
|
1236
|
-
armBlurCommit:
|
|
1237
|
-
ownsEventTarget:
|
|
1235
|
+
armBlurCommit: F,
|
|
1236
|
+
ownsEventTarget: L
|
|
1238
1237
|
};
|
|
1239
1238
|
}
|
|
1240
1239
|
//#endregion
|
|
1241
1240
|
//#region src/canvas/TextEditingOverlay.vue?vue&type=script&setup=true&lang.ts
|
|
1242
|
-
var
|
|
1241
|
+
var vt = ["wrap"], yt = /*#__PURE__*/ x(/* @__PURE__ */ H({
|
|
1243
1242
|
__name: "TextEditingOverlay",
|
|
1244
1243
|
props: { editor: {} },
|
|
1245
1244
|
setup(e, { expose: t }) {
|
|
1246
|
-
let n = e, r =
|
|
1245
|
+
let n = e, r = J(null), i = J(null), a = J(null), o = J(null), s = _t(n.editor, {
|
|
1247
1246
|
getTextarea: () => i.value,
|
|
1248
1247
|
getHost: () => r.value?.parentElement ?? null,
|
|
1249
1248
|
getToolbar: () => a.value?.rootEl ?? null
|
|
1250
|
-
}), { editing: c, style: l, composing: u, toolbarStyle: d, toolbarTagStyle: f } = s, p = s.layout,
|
|
1249
|
+
}), { editing: c, style: l, composing: u, toolbarStyle: d, toolbarTagStyle: f } = s, p = s.layout, m = I(() => p.value?.expressionMode === !0), { diagnostics: h, refresh: g } = T({
|
|
1251
1250
|
target: i,
|
|
1252
|
-
enabled:
|
|
1253
|
-
}),
|
|
1251
|
+
enabled: m
|
|
1252
|
+
}), _ = I(() => m.value ? A(h.value) : ""), { popup: v, accept: y } = O({
|
|
1254
1253
|
target: i,
|
|
1255
|
-
enabled:
|
|
1254
|
+
enabled: m,
|
|
1256
1255
|
resolve: (e) => {
|
|
1257
1256
|
let t = n.editor.store.ui.dataSourceSchema, r = c.value;
|
|
1258
1257
|
if (t === null || r === null) return null;
|
|
1259
|
-
let i =
|
|
1258
|
+
let i = E(t, j(t, n.editor.store.doc, r));
|
|
1260
1259
|
return i === null ? null : i(e);
|
|
1261
1260
|
},
|
|
1262
1261
|
popupEl: () => o.value?.rootEl ?? null,
|
|
1263
1262
|
scale: s.scale
|
|
1264
1263
|
});
|
|
1265
|
-
|
|
1264
|
+
$(c, async (e) => {
|
|
1266
1265
|
if (!e) return;
|
|
1267
|
-
await
|
|
1266
|
+
await ne();
|
|
1268
1267
|
let t = i.value, n = s.layout.value;
|
|
1269
|
-
t && n && (t.value = n.text,
|
|
1270
|
-
}),
|
|
1271
|
-
await
|
|
1268
|
+
t && n && (t.value = n.text, g(), t.focus({ preventScroll: !0 }), t.select());
|
|
1269
|
+
}), $(s.draftSeq, async () => {
|
|
1270
|
+
await ne();
|
|
1272
1271
|
let e = i.value, t = s.layout.value;
|
|
1273
|
-
e && t && (e.value = t.text,
|
|
1274
|
-
}),
|
|
1272
|
+
e && t && (e.value = t.text, g());
|
|
1273
|
+
}), $(l, async (e, t) => {
|
|
1275
1274
|
if (!t || !e) return;
|
|
1276
1275
|
let n = i.value;
|
|
1277
1276
|
if (!n || u.value) return;
|
|
1278
1277
|
let r = n.selectionStart, a = n.selectionEnd;
|
|
1279
|
-
await
|
|
1278
|
+
await ne(), i.value === n && (n.selectionStart !== r || n.selectionEnd !== a) && n.setSelectionRange(r, a);
|
|
1280
1279
|
}, { flush: "post" });
|
|
1281
|
-
let
|
|
1282
|
-
e.isComposing || e.keyCode === 229 || (e.key === "Escape" || e.key === "Enter" && (e.ctrlKey || e.metaKey)) && (e.key === "Escape" &&
|
|
1283
|
-
},
|
|
1280
|
+
let b = (e) => {
|
|
1281
|
+
e.isComposing || e.keyCode === 229 || (e.key === "Escape" || e.key === "Enter" && (e.ctrlKey || e.metaKey)) && (e.key === "Escape" && v.open || (e.preventDefault(), s.commitNow()));
|
|
1282
|
+
}, x = () => s.armBlurCommit();
|
|
1284
1283
|
return t({
|
|
1285
1284
|
beginAt: s.beginAt,
|
|
1286
1285
|
beginTextEdit: s.beginTextEdit,
|
|
1287
1286
|
commitEditing: () => s.commitNow(),
|
|
1288
1287
|
isEditing: () => c.value !== null,
|
|
1289
1288
|
ownsEventTarget: (e) => s.ownsEventTarget(e)
|
|
1290
|
-
}), (e, t) => (
|
|
1289
|
+
}), (e, t) => (q(), z("div", {
|
|
1291
1290
|
ref_key: "rootRef",
|
|
1292
1291
|
ref: r,
|
|
1293
1292
|
class: "cn-text-overlay"
|
|
1294
1293
|
}, [
|
|
1295
|
-
|
|
1296
|
-
key:
|
|
1294
|
+
Q(c) && Q(l) ? (q(), z("textarea", {
|
|
1295
|
+
key: Q(c).join(""),
|
|
1297
1296
|
ref_key: "textareaRef",
|
|
1298
1297
|
ref: i,
|
|
1299
1298
|
class: "cn-text-overlay__textarea",
|
|
1300
|
-
style:
|
|
1301
|
-
wrap:
|
|
1299
|
+
style: W(Q(l)),
|
|
1300
|
+
wrap: Q(l).whiteSpace === "pre" ? "off" : "soft",
|
|
1302
1301
|
spellcheck: "false",
|
|
1303
1302
|
autocomplete: "off",
|
|
1304
|
-
onKeydown:
|
|
1305
|
-
onBlur:
|
|
1306
|
-
onCompositionstart: t[0] ||= (e) =>
|
|
1307
|
-
onCompositionend: t[1] ||= (e) =>
|
|
1308
|
-
}, null, 44,
|
|
1309
|
-
|
|
1303
|
+
onKeydown: b,
|
|
1304
|
+
onBlur: x,
|
|
1305
|
+
onCompositionstart: t[0] ||= (e) => Q(s).setComposing(!0),
|
|
1306
|
+
onCompositionend: t[1] ||= (e) => Q(s).setComposing(!1)
|
|
1307
|
+
}, null, 44, vt)) : R("", !0),
|
|
1308
|
+
Q(c) && Q(d) ? (q(), L(ft, {
|
|
1310
1309
|
key: 1,
|
|
1311
1310
|
ref_key: "toolbarRef",
|
|
1312
1311
|
ref: a,
|
|
1313
|
-
style:
|
|
1314
|
-
mode:
|
|
1315
|
-
font:
|
|
1316
|
-
"font-size":
|
|
1317
|
-
"font-color":
|
|
1318
|
-
"horizontal-align":
|
|
1319
|
-
"vertical-align":
|
|
1320
|
-
autowrap:
|
|
1321
|
-
onChange: t[2] ||= (e) =>
|
|
1322
|
-
onStyleWrite: t[3] ||= (e) =>
|
|
1312
|
+
style: W(Q(d)),
|
|
1313
|
+
mode: m.value ? "expression" : "static",
|
|
1314
|
+
font: Q(p)?.font ?? "",
|
|
1315
|
+
"font-size": Q(p)?.fontSize ?? 16,
|
|
1316
|
+
"font-color": Q(p)?.fontColor ?? "#000000",
|
|
1317
|
+
"horizontal-align": Q(p)?.horizontalAlign ?? "left",
|
|
1318
|
+
"vertical-align": Q(p)?.verticalAlign ?? "top",
|
|
1319
|
+
autowrap: Q(p)?.autowrap ?? !1,
|
|
1320
|
+
onChange: t[2] ||= (e) => Q(s).setExpressionMode(e === "expression"),
|
|
1321
|
+
onStyleWrite: t[3] ||= (e) => Q(s).updateStyleField(e.key, e.value, e.final)
|
|
1323
1322
|
}, null, 8, [
|
|
1324
1323
|
"style",
|
|
1325
1324
|
"mode",
|
|
@@ -1329,36 +1328,36 @@ var ht = ["wrap"], gt = /*#__PURE__*/ x(/* @__PURE__ */ z({
|
|
|
1329
1328
|
"horizontal-align",
|
|
1330
1329
|
"vertical-align",
|
|
1331
1330
|
"autowrap"
|
|
1332
|
-
])) :
|
|
1333
|
-
|
|
1331
|
+
])) : R("", !0),
|
|
1332
|
+
Q(c) && _.value ? (q(), z("span", {
|
|
1334
1333
|
key: 2,
|
|
1335
1334
|
class: "cn-text-overlay__diagnostic",
|
|
1336
|
-
style:
|
|
1337
|
-
},
|
|
1338
|
-
|
|
1335
|
+
style: W(Q(f))
|
|
1336
|
+
}, Z(_.value), 5)) : R("", !0),
|
|
1337
|
+
V(k, {
|
|
1339
1338
|
ref_key: "popupRef",
|
|
1340
1339
|
ref: o,
|
|
1341
|
-
state:
|
|
1342
|
-
onSelect:
|
|
1340
|
+
state: Q(v),
|
|
1341
|
+
onSelect: Q(y)
|
|
1343
1342
|
}, null, 8, ["state", "onSelect"])
|
|
1344
1343
|
], 512));
|
|
1345
1344
|
}
|
|
1346
|
-
}), [["__scopeId", "data-v-9e96d660"]]),
|
|
1345
|
+
}), [["__scopeId", "data-v-9e96d660"]]), bt = {
|
|
1347
1346
|
key: 0,
|
|
1348
1347
|
class: "cn-surface__drop-hint",
|
|
1349
1348
|
"data-drop-hint": ""
|
|
1350
|
-
},
|
|
1349
|
+
}, xt = 16, St = /*#__PURE__*/ x(/* @__PURE__ */ H({
|
|
1351
1350
|
__name: "CanvasSurface",
|
|
1352
1351
|
props: { editor: {} },
|
|
1353
1352
|
emits: ["ready"],
|
|
1354
1353
|
setup(e, { emit: t }) {
|
|
1355
|
-
let n = e, r = t, i =
|
|
1354
|
+
let n = e, r = t, i = J(null), a = J(null), o = J(null), s = J(null), c = J(null), l = J(null), u = J(!1), d = J(!1), f = J(null), p = J(null), m = J(n.editor.store.ui.armedCreate), h = J(!1), g = I(() => d.value ? "cn-surface--panning" : u.value ? "cn-surface--pannable" : ""), _ = I(() => {
|
|
1356
1355
|
if (d.value) return;
|
|
1357
1356
|
if (m.value !== null || h.value) return u.value ? void 0 : { cursor: "crosshair" };
|
|
1358
1357
|
let e = p.value ?? f.value;
|
|
1359
|
-
return e === null ? void 0 : { cursor:
|
|
1360
|
-
}),
|
|
1361
|
-
function
|
|
1358
|
+
return e === null ? void 0 : { cursor: Xe[e] };
|
|
1359
|
+
}), v = J(!1), y = C();
|
|
1360
|
+
function x(e) {
|
|
1362
1361
|
return new Promise((t, n) => {
|
|
1363
1362
|
let r = URL.createObjectURL(e), i = new Image();
|
|
1364
1363
|
i.onload = () => {
|
|
@@ -1372,52 +1371,52 @@ var ht = ["wrap"], gt = /*#__PURE__*/ x(/* @__PURE__ */ z({
|
|
|
1372
1371
|
});
|
|
1373
1372
|
}
|
|
1374
1373
|
let w = [];
|
|
1375
|
-
return
|
|
1374
|
+
return G(() => {
|
|
1376
1375
|
let e = i.value, t = a.value, g = o.value;
|
|
1377
1376
|
if (!e || !t || !g) return;
|
|
1378
|
-
let
|
|
1377
|
+
let _ = n.editor, C = () => {
|
|
1379
1378
|
let n = window.devicePixelRatio, r = Math.max(1, Math.round(e.clientWidth * n)), i = Math.max(1, Math.round(e.clientHeight * n));
|
|
1380
1379
|
for (let e of [t, g]) e.width !== r && (e.width = r), e.height !== i && (e.height = i);
|
|
1381
|
-
|
|
1380
|
+
_.flushPendingFrames();
|
|
1382
1381
|
}, T = () => {
|
|
1383
|
-
|
|
1382
|
+
_.setSurfaceSize(e.clientWidth, e.clientHeight), C();
|
|
1384
1383
|
};
|
|
1385
|
-
|
|
1386
|
-
let E =
|
|
1387
|
-
(e.scope === "doc" || e.scope === "ui" && e.branch === "armedCreate") && (m.value =
|
|
1384
|
+
_.setDevicePixelRatio(window.devicePixelRatio), T();
|
|
1385
|
+
let E = _.subscribe((e) => {
|
|
1386
|
+
(e.scope === "doc" || e.scope === "ui" && e.branch === "armedCreate") && (m.value = _.store.ui.armedCreate);
|
|
1388
1387
|
});
|
|
1389
1388
|
w.push(E);
|
|
1390
1389
|
let D = new ResizeObserver(T);
|
|
1391
1390
|
D.observe(e), w.push(() => D.disconnect());
|
|
1392
|
-
let O =
|
|
1393
|
-
|
|
1391
|
+
let O = pt(() => {
|
|
1392
|
+
_.setDevicePixelRatio(window.devicePixelRatio), C();
|
|
1394
1393
|
});
|
|
1395
1394
|
w.push(O);
|
|
1396
|
-
let
|
|
1395
|
+
let k = (t) => {
|
|
1397
1396
|
let n = e.getBoundingClientRect();
|
|
1398
1397
|
return {
|
|
1399
1398
|
x: t.clientX - n.left,
|
|
1400
1399
|
y: t.clientY - n.top
|
|
1401
1400
|
};
|
|
1402
|
-
},
|
|
1401
|
+
}, ee = (e) => e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? 100 : 1, A = (e) => {
|
|
1403
1402
|
e.preventDefault();
|
|
1404
|
-
let t =
|
|
1405
|
-
r === "zoom" ?
|
|
1403
|
+
let t = ee(e), n = k(e), r = Te(e);
|
|
1404
|
+
r === "zoom" ? _.zoomByWheel(n.x, n.y, e.deltaY * t) : r === "pan-x" ? _.panBy(-(e.deltaY || e.deltaX) * t, 0) : _.panBy(-e.deltaX * t, -e.deltaY * t);
|
|
1406
1405
|
};
|
|
1407
|
-
e.addEventListener("wheel",
|
|
1408
|
-
let
|
|
1406
|
+
e.addEventListener("wheel", A, { passive: !1 }), w.push(() => e.removeEventListener("wheel", A));
|
|
1407
|
+
let j = null, N = {
|
|
1409
1408
|
x: 0,
|
|
1410
1409
|
y: 0
|
|
1411
|
-
},
|
|
1412
|
-
let t =
|
|
1413
|
-
return
|
|
1414
|
-
},
|
|
1415
|
-
if (c.value?.close(),
|
|
1410
|
+
}, P = (e) => {
|
|
1411
|
+
let t = k(e);
|
|
1412
|
+
return _.toScenePoint(t.x, t.y);
|
|
1413
|
+
}, F = (t) => {
|
|
1414
|
+
if (c.value?.close(), j !== null) return;
|
|
1416
1415
|
if (t.button === 1 || t.button === 0 && u.value) {
|
|
1417
|
-
t.preventDefault(),
|
|
1416
|
+
t.preventDefault(), j = {
|
|
1418
1417
|
id: t.pointerId,
|
|
1419
1418
|
mode: "pan"
|
|
1420
|
-
},
|
|
1419
|
+
}, N = {
|
|
1421
1420
|
x: t.clientX,
|
|
1422
1421
|
y: t.clientY
|
|
1423
1422
|
}, d.value = !0, e.setPointerCapture(t.pointerId);
|
|
@@ -1429,113 +1428,113 @@ var ht = ["wrap"], gt = /*#__PURE__*/ x(/* @__PURE__ */ z({
|
|
|
1429
1428
|
s.value.commitEditing();
|
|
1430
1429
|
}
|
|
1431
1430
|
t.preventDefault();
|
|
1432
|
-
let n =
|
|
1433
|
-
if (
|
|
1434
|
-
|
|
1431
|
+
let n = P(t);
|
|
1432
|
+
if (_.beginLayerCreate(n.x, n.y)) {
|
|
1433
|
+
j = {
|
|
1435
1434
|
id: t.pointerId,
|
|
1436
1435
|
mode: "create"
|
|
1437
1436
|
}, h.value = !0, f.value = null, e.setPointerCapture(t.pointerId);
|
|
1438
1437
|
return;
|
|
1439
1438
|
}
|
|
1440
|
-
let r =
|
|
1441
|
-
if (r !== null &&
|
|
1442
|
-
|
|
1439
|
+
let r = _.resizeHandleAt(n.x, n.y);
|
|
1440
|
+
if (r !== null && _.beginResize(_.store.ui.selection, r, n.x, n.y)) {
|
|
1441
|
+
j = {
|
|
1443
1442
|
id: t.pointerId,
|
|
1444
1443
|
mode: "resize"
|
|
1445
1444
|
}, p.value = r, f.value = null, e.setPointerCapture(t.pointerId);
|
|
1446
1445
|
return;
|
|
1447
1446
|
}
|
|
1448
|
-
let i =
|
|
1449
|
-
if (a &&
|
|
1450
|
-
|
|
1447
|
+
let i = P(t), a = _.selectAt(i.x, i.y);
|
|
1448
|
+
if (a && _.beginDrag(a, i.x, i.y, { copy: t.altKey && _.canCopyLayerAt(a) })) {
|
|
1449
|
+
j = {
|
|
1451
1450
|
id: t.pointerId,
|
|
1452
1451
|
mode: "drag"
|
|
1453
1452
|
}, e.setPointerCapture(t.pointerId);
|
|
1454
1453
|
return;
|
|
1455
1454
|
}
|
|
1456
|
-
a === null && (
|
|
1455
|
+
a === null && (j = {
|
|
1457
1456
|
id: t.pointerId,
|
|
1458
1457
|
mode: "pan"
|
|
1459
|
-
},
|
|
1458
|
+
}, N = {
|
|
1460
1459
|
x: t.clientX,
|
|
1461
1460
|
y: t.clientY
|
|
1462
1461
|
}, d.value = !0, e.setPointerCapture(t.pointerId));
|
|
1463
|
-
},
|
|
1464
|
-
if (
|
|
1465
|
-
if (e.pointerId !==
|
|
1466
|
-
if (
|
|
1462
|
+
}, I = (e) => {
|
|
1463
|
+
if (j !== null) {
|
|
1464
|
+
if (e.pointerId !== j.id) return;
|
|
1465
|
+
if (j.mode === "pan") _.panBy(e.clientX - N.x, e.clientY - N.y), N = {
|
|
1467
1466
|
x: e.clientX,
|
|
1468
1467
|
y: e.clientY
|
|
1469
1468
|
};
|
|
1470
|
-
else if (
|
|
1471
|
-
let t =
|
|
1472
|
-
|
|
1473
|
-
} else if (
|
|
1474
|
-
let t =
|
|
1475
|
-
|
|
1469
|
+
else if (j.mode === "resize") {
|
|
1470
|
+
let t = P(e);
|
|
1471
|
+
_.resizeTo(t.x, t.y, e.shiftKey);
|
|
1472
|
+
} else if (j.mode === "create") {
|
|
1473
|
+
let t = P(e);
|
|
1474
|
+
_.createTo(t.x, t.y, e.shiftKey);
|
|
1476
1475
|
} else {
|
|
1477
|
-
let t =
|
|
1478
|
-
|
|
1476
|
+
let t = P(e);
|
|
1477
|
+
_.dragTo(t.x, t.y);
|
|
1479
1478
|
}
|
|
1480
1479
|
return;
|
|
1481
1480
|
}
|
|
1482
|
-
let t =
|
|
1481
|
+
let t = P(e), n = _.resizeHandleAt(t.x, t.y);
|
|
1483
1482
|
if (f.value = n, n !== null) {
|
|
1484
|
-
|
|
1483
|
+
_.setHovered(null);
|
|
1485
1484
|
return;
|
|
1486
1485
|
}
|
|
1487
|
-
|
|
1488
|
-
},
|
|
1489
|
-
if (
|
|
1490
|
-
if (
|
|
1491
|
-
else if (
|
|
1492
|
-
else if (
|
|
1486
|
+
_.hoverAt(t.x, t.y);
|
|
1487
|
+
}, L = (t) => {
|
|
1488
|
+
if (j !== null && t.pointerId === j.id) {
|
|
1489
|
+
if (j.mode === "drag") _.endDrag();
|
|
1490
|
+
else if (j.mode === "resize") _.endResize(), p.value = null;
|
|
1491
|
+
else if (j.mode === "create") {
|
|
1493
1492
|
h.value = !1;
|
|
1494
|
-
let e =
|
|
1493
|
+
let e = _.endCreate();
|
|
1495
1494
|
e !== null && s.value?.beginTextEdit(e);
|
|
1496
1495
|
} else d.value = !1;
|
|
1497
|
-
|
|
1496
|
+
j = null, e.hasPointerCapture(t.pointerId) && e.releasePointerCapture(t.pointerId);
|
|
1498
1497
|
}
|
|
1499
|
-
},
|
|
1498
|
+
}, R = (e) => {
|
|
1500
1499
|
e.button === 1 && e.preventDefault();
|
|
1501
|
-
},
|
|
1502
|
-
let t =
|
|
1500
|
+
}, z = (e) => {
|
|
1501
|
+
let t = k(e), n = _.toScenePoint(t.x, t.y);
|
|
1503
1502
|
s.value?.beginAt(n.x, n.y);
|
|
1504
|
-
},
|
|
1503
|
+
}, B = (e) => {
|
|
1505
1504
|
if (s.value?.isEditing()) {
|
|
1506
1505
|
if (s.value.ownsEventTarget(e.target)) return;
|
|
1507
1506
|
s.value.commitEditing();
|
|
1508
1507
|
}
|
|
1509
1508
|
e.preventDefault();
|
|
1510
|
-
let t =
|
|
1511
|
-
if (
|
|
1509
|
+
let t = k(e), n = _.toScenePoint(t.x, t.y);
|
|
1510
|
+
if (_.selectAt(n.x, n.y) === null) {
|
|
1512
1511
|
c.value?.close();
|
|
1513
1512
|
return;
|
|
1514
1513
|
}
|
|
1515
1514
|
c.value?.openAt(t.x, t.y);
|
|
1516
|
-
},
|
|
1517
|
-
|
|
1515
|
+
}, V = () => {
|
|
1516
|
+
j === null && (_.setHovered(null), f.value = null);
|
|
1518
1517
|
};
|
|
1519
|
-
e.addEventListener("pointerdown",
|
|
1520
|
-
e.removeEventListener("pointerdown",
|
|
1518
|
+
e.addEventListener("pointerdown", F), e.addEventListener("pointermove", I), e.addEventListener("pointerup", L), e.addEventListener("pointercancel", L), e.addEventListener("pointerleave", V), e.addEventListener("mousedown", R), e.addEventListener("dblclick", z), w.push(() => {
|
|
1519
|
+
e.removeEventListener("pointerdown", F), e.removeEventListener("pointermove", I), e.removeEventListener("pointerup", L), e.removeEventListener("pointercancel", L), e.removeEventListener("pointerleave", V), e.removeEventListener("mousedown", R), e.removeEventListener("dblclick", z);
|
|
1521
1520
|
});
|
|
1522
|
-
let
|
|
1523
|
-
e.code !== "Space" || e.repeat ||
|
|
1524
|
-
},
|
|
1521
|
+
let H = b, te = (e) => {
|
|
1522
|
+
e.code !== "Space" || e.repeat || H(e.target) || (e.preventDefault(), u.value = !0);
|
|
1523
|
+
}, ne = (e) => {
|
|
1525
1524
|
e.code === "Space" && (u.value = !1);
|
|
1526
|
-
},
|
|
1527
|
-
if (!(e.key !== "Escape" ||
|
|
1528
|
-
if (
|
|
1529
|
-
|
|
1525
|
+
}, U = (e) => {
|
|
1526
|
+
if (!(e.key !== "Escape" || S(e.target))) {
|
|
1527
|
+
if (_.store.ui.armedCreate !== null || _.store.ui.create !== null) {
|
|
1528
|
+
_.cancelCreate();
|
|
1530
1529
|
return;
|
|
1531
1530
|
}
|
|
1532
|
-
c.value?.close(), l.value?.close(),
|
|
1531
|
+
c.value?.close(), l.value?.close(), _.escapeSelection();
|
|
1533
1532
|
}
|
|
1534
1533
|
};
|
|
1535
|
-
window.addEventListener("keydown",
|
|
1536
|
-
window.removeEventListener("keydown",
|
|
1537
|
-
}), e.addEventListener("contextmenu",
|
|
1538
|
-
let
|
|
1534
|
+
window.addEventListener("keydown", te), window.addEventListener("keyup", ne), window.addEventListener("keydown", U), w.push(() => {
|
|
1535
|
+
window.removeEventListener("keydown", te), window.removeEventListener("keyup", ne), window.removeEventListener("keydown", U);
|
|
1536
|
+
}), e.addEventListener("contextmenu", B), w.push(() => e.removeEventListener("contextmenu", B));
|
|
1537
|
+
let W = (e) => {
|
|
1539
1538
|
let t = e.dataTransfer?.items;
|
|
1540
1539
|
if (!t) return !1;
|
|
1541
1540
|
for (let e = 0; e < t.length; e += 1) {
|
|
@@ -1543,127 +1542,127 @@ var ht = ["wrap"], gt = /*#__PURE__*/ x(/* @__PURE__ */ z({
|
|
|
1543
1542
|
if (n !== void 0 && n.kind === "file" && n.type.startsWith("image/")) return !0;
|
|
1544
1543
|
}
|
|
1545
1544
|
return !1;
|
|
1546
|
-
},
|
|
1547
|
-
|
|
1548
|
-
},
|
|
1549
|
-
t.relatedTarget !== null && e.contains(t.relatedTarget) || (
|
|
1550
|
-
},
|
|
1551
|
-
e.preventDefault(),
|
|
1545
|
+
}, re = (e) => {
|
|
1546
|
+
W(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"), v.value = !0);
|
|
1547
|
+
}, G = (t) => {
|
|
1548
|
+
t.relatedTarget !== null && e.contains(t.relatedTarget) || (v.value = !1);
|
|
1549
|
+
}, K = (e) => {
|
|
1550
|
+
e.preventDefault(), v.value = !1;
|
|
1552
1551
|
let t = [], n = e.dataTransfer?.files;
|
|
1553
1552
|
for (let e = 0; n !== void 0 && e < n.length; e += 1) {
|
|
1554
1553
|
let r = n[e];
|
|
1555
1554
|
r !== void 0 && r.type.startsWith("image/") && t.push(r);
|
|
1556
1555
|
}
|
|
1557
1556
|
if (t.length !== 0) {
|
|
1558
|
-
if (!
|
|
1559
|
-
|
|
1557
|
+
if (!_.canUpload) {
|
|
1558
|
+
y.show("上传不可用:未接入上传实现,图片未添加");
|
|
1560
1559
|
return;
|
|
1561
1560
|
}
|
|
1562
|
-
s.value?.isEditing() && s.value.commitEditing(),
|
|
1561
|
+
s.value?.isEditing() && s.value.commitEditing(), q(t, k(e));
|
|
1563
1562
|
}
|
|
1564
|
-
},
|
|
1565
|
-
let n =
|
|
1563
|
+
}, q = async (e, t) => {
|
|
1564
|
+
let n = _.toScenePoint(t.x, t.y);
|
|
1566
1565
|
for (let t = 0; t < e.length; t += 1) {
|
|
1567
1566
|
let r = e[t];
|
|
1568
1567
|
if (r) try {
|
|
1569
|
-
let e = await
|
|
1570
|
-
await
|
|
1568
|
+
let e = await x(r);
|
|
1569
|
+
await _.uploadImageAsLayer(await M(r), {
|
|
1571
1570
|
at: {
|
|
1572
|
-
x: n.x + t *
|
|
1573
|
-
y: n.y + t *
|
|
1571
|
+
x: n.x + t * xt,
|
|
1572
|
+
y: n.y + t * xt
|
|
1574
1573
|
},
|
|
1575
1574
|
size: e
|
|
1576
1575
|
});
|
|
1577
1576
|
} catch (e) {
|
|
1578
|
-
|
|
1577
|
+
y.show(`上传失败:${e instanceof Error ? e.message : String(e)}`);
|
|
1579
1578
|
return;
|
|
1580
1579
|
}
|
|
1581
1580
|
}
|
|
1582
1581
|
};
|
|
1583
|
-
e.addEventListener("dragover",
|
|
1584
|
-
e.removeEventListener("dragover",
|
|
1582
|
+
e.addEventListener("dragover", re), e.addEventListener("dragleave", G), e.addEventListener("drop", K), w.push(() => {
|
|
1583
|
+
e.removeEventListener("dragover", re), e.removeEventListener("dragleave", G), e.removeEventListener("drop", K);
|
|
1585
1584
|
});
|
|
1586
|
-
let
|
|
1587
|
-
t.addEventListener("contextlost",
|
|
1588
|
-
t.removeEventListener("contextlost",
|
|
1585
|
+
let J = () => _.invalidate("both"), Y = (e) => e.preventDefault();
|
|
1586
|
+
t.addEventListener("contextlost", Y), t.addEventListener("contextrestored", J), g.addEventListener("contextlost", Y), g.addEventListener("contextrestored", J), w.push(() => {
|
|
1587
|
+
t.removeEventListener("contextlost", Y), t.removeEventListener("contextrestored", J), g.removeEventListener("contextlost", Y), g.removeEventListener("contextrestored", J);
|
|
1589
1588
|
}), r("ready", {
|
|
1590
1589
|
contentCanvas: t,
|
|
1591
1590
|
overlayCanvas: g
|
|
1592
1591
|
});
|
|
1593
|
-
}),
|
|
1592
|
+
}), re(() => {
|
|
1594
1593
|
w.forEach((e) => e()), w.length = 0, n.editor.detachSurfaces();
|
|
1595
|
-
}), (t, n) => (
|
|
1594
|
+
}), (t, n) => (q(), z("div", {
|
|
1596
1595
|
ref_key: "hostRef",
|
|
1597
1596
|
ref: i,
|
|
1598
|
-
class:
|
|
1599
|
-
style:
|
|
1597
|
+
class: U(["cn-surface", g.value]),
|
|
1598
|
+
style: W(_.value)
|
|
1600
1599
|
}, [
|
|
1601
|
-
|
|
1600
|
+
B("canvas", {
|
|
1602
1601
|
ref_key: "contentRef",
|
|
1603
1602
|
ref: a,
|
|
1604
1603
|
class: "cn-surface__canvas"
|
|
1605
1604
|
}, null, 512),
|
|
1606
|
-
|
|
1605
|
+
B("canvas", {
|
|
1607
1606
|
ref_key: "overlayRef",
|
|
1608
1607
|
ref: o,
|
|
1609
1608
|
class: "cn-surface__canvas cn-surface__canvas--overlay"
|
|
1610
1609
|
}, null, 512),
|
|
1611
|
-
|
|
1610
|
+
V(yt, {
|
|
1612
1611
|
ref_key: "textEditRef",
|
|
1613
1612
|
ref: s,
|
|
1614
1613
|
editor: e.editor
|
|
1615
1614
|
}, null, 8, ["editor"]),
|
|
1616
|
-
|
|
1615
|
+
V(ze, {
|
|
1617
1616
|
ref_key: "contextMenuRef",
|
|
1618
1617
|
ref: c,
|
|
1619
1618
|
editor: e.editor
|
|
1620
1619
|
}, null, 8, ["editor"]),
|
|
1621
|
-
|
|
1620
|
+
V(Ye, {
|
|
1622
1621
|
ref_key: "findBarRef",
|
|
1623
1622
|
ref: l,
|
|
1624
1623
|
editor: e.editor
|
|
1625
1624
|
}, null, 8, ["editor"]),
|
|
1626
|
-
|
|
1625
|
+
v.value ? (q(), z("div", bt, [...n[0] ||= [B("span", { class: "cn-surface__drop-hint-text" }, "松开以上传图片", -1)]])) : R("", !0)
|
|
1627
1626
|
], 6));
|
|
1628
1627
|
}
|
|
1629
1628
|
}), [["__scopeId", "data-v-2327ee46"]]);
|
|
1630
1629
|
//#endregion
|
|
1631
1630
|
//#region src/canvas/guideSnap.ts
|
|
1632
|
-
function
|
|
1631
|
+
function Ct(e, t, n, r) {
|
|
1633
1632
|
let i = e.store.doc;
|
|
1634
1633
|
if (!i) return n;
|
|
1635
|
-
let a = r === void 0 ? e.listGuides() : e.listGuides().filter((e) => e.id !== r), o =
|
|
1634
|
+
let a = r === void 0 ? e.listGuides() : e.listGuides().filter((e) => e.id !== r), o = Ce({
|
|
1636
1635
|
x: n,
|
|
1637
1636
|
y: n,
|
|
1638
1637
|
width: 0,
|
|
1639
1638
|
height: 0
|
|
1640
|
-
},
|
|
1639
|
+
}, be(i.width, i.height, ye(i, -1, e.textPolicies), a), ve(e.store.ui.viewport.zoom));
|
|
1641
1640
|
return t === "vertical" ? n + o.dx : n + o.dy;
|
|
1642
1641
|
}
|
|
1643
1642
|
//#endregion
|
|
1644
1643
|
//#region src/canvas/GuidesOverlay.vue?vue&type=script&setup=true&lang.ts
|
|
1645
|
-
var
|
|
1644
|
+
var wt = [
|
|
1646
1645
|
"data-snap-orientation",
|
|
1647
1646
|
"data-snap-position",
|
|
1648
1647
|
"data-snap-source"
|
|
1649
|
-
],
|
|
1648
|
+
], Tt = [
|
|
1650
1649
|
"data-guide-line",
|
|
1651
1650
|
"data-guide-orientation",
|
|
1652
1651
|
"data-guide-position",
|
|
1653
1652
|
"data-guide-dragging",
|
|
1654
1653
|
"onPointerdown"
|
|
1655
|
-
],
|
|
1654
|
+
], Et = ["data-guide-orientation", "data-guide-position"], Dt = /*#__PURE__*/ x(/* @__PURE__ */ H({
|
|
1656
1655
|
__name: "GuidesOverlay",
|
|
1657
1656
|
props: { editor: {} },
|
|
1658
1657
|
setup(e, { expose: t }) {
|
|
1659
|
-
let n = e, r =
|
|
1658
|
+
let n = e, r = P(n.editor), i = X(n.editor.store.doc), a = X(n.editor.listGuides()), o = X(n.editor.listSnapAxes()), s = n.editor.subscribe((e) => {
|
|
1660
1659
|
if (e.scope === "doc") {
|
|
1661
1660
|
i.value = n.editor.store.doc, a.value = n.editor.listGuides(), o.value = n.editor.listSnapAxes();
|
|
1662
1661
|
return;
|
|
1663
1662
|
}
|
|
1664
1663
|
e.branch === "guides" ? a.value = n.editor.listGuides() : e.branch === "snapAxes" && (o.value = n.editor.listSnapAxes());
|
|
1665
1664
|
});
|
|
1666
|
-
|
|
1665
|
+
K(s, !0);
|
|
1667
1666
|
function c(e, t) {
|
|
1668
1667
|
let n = i.value, a = r.value;
|
|
1669
1668
|
return n ? e === "vertical" ? {
|
|
@@ -1679,11 +1678,11 @@ var xt = [
|
|
|
1679
1678
|
function l(e) {
|
|
1680
1679
|
return String(Math.round(e * 100) / 100);
|
|
1681
1680
|
}
|
|
1682
|
-
let u =
|
|
1681
|
+
let u = J(null);
|
|
1683
1682
|
function d(e) {
|
|
1684
1683
|
return {
|
|
1685
1684
|
orientation: e.orientation,
|
|
1686
|
-
position:
|
|
1685
|
+
position: Ct(n.editor, e.orientation, e.position)
|
|
1687
1686
|
};
|
|
1688
1687
|
}
|
|
1689
1688
|
function f(e) {
|
|
@@ -1710,7 +1709,7 @@ var xt = [
|
|
|
1710
1709
|
endGuideDrag: m,
|
|
1711
1710
|
cancelGuideDrag: h
|
|
1712
1711
|
});
|
|
1713
|
-
let g =
|
|
1712
|
+
let g = J(null), _ = I(() => a.value.map((e) => {
|
|
1714
1713
|
let t = g.value;
|
|
1715
1714
|
return t !== null && t.id === e.id ? {
|
|
1716
1715
|
id: e.id,
|
|
@@ -1725,7 +1724,7 @@ var xt = [
|
|
|
1725
1724
|
dragging: !1,
|
|
1726
1725
|
overRuler: !1
|
|
1727
1726
|
};
|
|
1728
|
-
})), v =
|
|
1727
|
+
})), v = J(null);
|
|
1729
1728
|
function y(e, t) {
|
|
1730
1729
|
let n = v.value?.getBoundingClientRect(), i = r.value, a = n?.left ?? 0, o = n?.top ?? 0;
|
|
1731
1730
|
return t === "vertical" ? i.x + (e.clientX - a) / i.zoom : i.y + (e.clientY - o) / i.zoom;
|
|
@@ -1757,7 +1756,7 @@ var xt = [
|
|
|
1757
1756
|
let t = g.value;
|
|
1758
1757
|
t !== null && e.pointerId === t.pointerId && (g.value = {
|
|
1759
1758
|
...t,
|
|
1760
|
-
current:
|
|
1759
|
+
current: Ct(n.editor, t.orientation, y(e, t.orientation), t.id),
|
|
1761
1760
|
overRuler: b(e.clientX, e.clientY)
|
|
1762
1761
|
});
|
|
1763
1762
|
}
|
|
@@ -1775,24 +1774,24 @@ var xt = [
|
|
|
1775
1774
|
let t = g.value;
|
|
1776
1775
|
t !== null && e.pointerId === t.pointerId && (g.value = null, S(e));
|
|
1777
1776
|
}
|
|
1778
|
-
return (e, t) => (
|
|
1777
|
+
return (e, t) => (q(), z("div", {
|
|
1779
1778
|
ref_key: "rootRef",
|
|
1780
1779
|
ref: v,
|
|
1781
1780
|
class: "cn-guides",
|
|
1782
1781
|
"data-guide-overlay": ""
|
|
1783
1782
|
}, [
|
|
1784
|
-
(
|
|
1783
|
+
(q(!0), z(F, null, Y(o.value, (e, t) => (q(), z("div", {
|
|
1785
1784
|
key: `${e.orientation}-${e.position}-${t}`,
|
|
1786
|
-
class:
|
|
1785
|
+
class: U(["cn-guides__snap", `cn-guides__snap--${e.orientation}`]),
|
|
1787
1786
|
"data-snap-line": "",
|
|
1788
1787
|
"data-snap-orientation": e.orientation,
|
|
1789
1788
|
"data-snap-position": l(e.position),
|
|
1790
1789
|
"data-snap-source": e.source,
|
|
1791
|
-
style:
|
|
1792
|
-
}, null, 14,
|
|
1793
|
-
(
|
|
1790
|
+
style: W(c(e.orientation, e.position))
|
|
1791
|
+
}, null, 14, wt))), 128)),
|
|
1792
|
+
(q(!0), z(F, null, Y(_.value, (e) => (q(), z("div", {
|
|
1794
1793
|
key: e.id,
|
|
1795
|
-
class:
|
|
1794
|
+
class: U(["cn-guides__guide", [`cn-guides__guide--${e.orientation}`, {
|
|
1796
1795
|
"cn-guides__guide--grabbed": e.dragging,
|
|
1797
1796
|
"cn-guides__guide--will-delete": e.overRuler
|
|
1798
1797
|
}]]),
|
|
@@ -1800,32 +1799,32 @@ var xt = [
|
|
|
1800
1799
|
"data-guide-orientation": e.orientation,
|
|
1801
1800
|
"data-guide-position": l(e.position),
|
|
1802
1801
|
"data-guide-dragging": e.dragging ? "" : void 0,
|
|
1803
|
-
style:
|
|
1802
|
+
style: W(c(e.orientation, e.position)),
|
|
1804
1803
|
onPointerdown: (t) => C(t, e),
|
|
1805
1804
|
onPointermove: w,
|
|
1806
1805
|
onPointerup: T,
|
|
1807
1806
|
onPointercancel: E
|
|
1808
|
-
}, null, 46,
|
|
1809
|
-
u.value ? (
|
|
1807
|
+
}, null, 46, Tt))), 128)),
|
|
1808
|
+
u.value ? (q(), z("div", {
|
|
1810
1809
|
key: 0,
|
|
1811
|
-
class:
|
|
1810
|
+
class: U(["cn-guides__guide cn-guides__guide--preview", `cn-guides__guide--${u.value.orientation}`]),
|
|
1812
1811
|
"data-guide-preview": "",
|
|
1813
1812
|
"data-guide-orientation": u.value.orientation,
|
|
1814
1813
|
"data-guide-position": l(u.value.position),
|
|
1815
|
-
style:
|
|
1816
|
-
}, null, 14,
|
|
1814
|
+
style: W(c(u.value.orientation, u.value.position))
|
|
1815
|
+
}, null, 14, Et)) : R("", !0)
|
|
1817
1816
|
], 512));
|
|
1818
1817
|
}
|
|
1819
|
-
}), [["__scopeId", "data-v-61872121"]]),
|
|
1818
|
+
}), [["__scopeId", "data-v-61872121"]]), Ot = {
|
|
1820
1819
|
class: "cn-ruler",
|
|
1821
1820
|
"data-ruler": ""
|
|
1822
|
-
},
|
|
1821
|
+
}, kt = {
|
|
1823
1822
|
key: 0,
|
|
1824
1823
|
class: "cn-ruler__label"
|
|
1825
|
-
},
|
|
1824
|
+
}, At = {
|
|
1826
1825
|
key: 0,
|
|
1827
1826
|
class: "cn-ruler__label"
|
|
1828
|
-
},
|
|
1827
|
+
}, jt = 10, Mt = 5, Nt = /*#__PURE__*/ x(/* @__PURE__ */ H({
|
|
1829
1828
|
__name: "Ruler",
|
|
1830
1829
|
props: { editor: {} },
|
|
1831
1830
|
emits: [
|
|
@@ -1835,10 +1834,10 @@ var xt = [
|
|
|
1835
1834
|
"guide-drag-cancel"
|
|
1836
1835
|
],
|
|
1837
1836
|
setup(e, { emit: t }) {
|
|
1838
|
-
let n = e, r = t, i =
|
|
1837
|
+
let n = e, r = t, i = P(n.editor), a = X(n.editor.store.ui.rulersVisible), o = n.editor.subscribe((e) => {
|
|
1839
1838
|
e.scope === "ui" && e.branch === "rulersVisible" && (a.value = n.editor.store.ui.rulersVisible);
|
|
1840
1839
|
});
|
|
1841
|
-
|
|
1840
|
+
K(o, !0);
|
|
1842
1841
|
let s = [
|
|
1843
1842
|
1,
|
|
1844
1843
|
2,
|
|
@@ -1857,11 +1856,11 @@ var xt = [
|
|
|
1857
1856
|
function c(e, t, n) {
|
|
1858
1857
|
if (!(t > 0) || !(n > 0) || !Number.isFinite(e)) return [];
|
|
1859
1858
|
let r = s[s.length - 1];
|
|
1860
|
-
for (let e of s) if (e * n >=
|
|
1859
|
+
for (let e of s) if (e * n >= jt) {
|
|
1861
1860
|
r = e;
|
|
1862
1861
|
break;
|
|
1863
1862
|
}
|
|
1864
|
-
let i = r *
|
|
1863
|
+
let i = r * Mt, a = Math.floor(e / r) * r, o = [];
|
|
1865
1864
|
for (let s = 0;; s++) {
|
|
1866
1865
|
let c = a + s * r, l = (c - e) * n;
|
|
1867
1866
|
if (l > t) break;
|
|
@@ -1876,13 +1875,13 @@ var xt = [
|
|
|
1876
1875
|
}
|
|
1877
1876
|
return o;
|
|
1878
1877
|
}
|
|
1879
|
-
let l =
|
|
1878
|
+
let l = J(null), u = J(null), d = J(0), f = J(0), p = () => {
|
|
1880
1879
|
d.value = l.value?.clientWidth ?? 0, f.value = u.value?.clientHeight ?? 0;
|
|
1881
1880
|
}, m = null;
|
|
1882
|
-
|
|
1881
|
+
G(() => {
|
|
1883
1882
|
p(), m = new ResizeObserver(() => p()), l.value && m.observe(l.value), u.value && m.observe(u.value);
|
|
1884
|
-
}),
|
|
1885
|
-
let h =
|
|
1883
|
+
}), re(() => m?.disconnect());
|
|
1884
|
+
let h = I(() => c(i.value.x, d.value, i.value.zoom)), g = I(() => c(i.value.y, f.value, i.value.zoom)), _ = J(null);
|
|
1886
1885
|
function v(e, t, n) {
|
|
1887
1886
|
let r = e.getBoundingClientRect(), a = i.value;
|
|
1888
1887
|
return {
|
|
@@ -1917,8 +1916,8 @@ var xt = [
|
|
|
1917
1916
|
let a = v(n, i.orientation, e);
|
|
1918
1917
|
r(t === "guide-drag-end" ? "guide-drag-end" : "guide-drag-cancel", a);
|
|
1919
1918
|
}
|
|
1920
|
-
return (e, t) =>
|
|
1921
|
-
|
|
1919
|
+
return (e, t) => oe((q(), z("div", Ot, [
|
|
1920
|
+
B("div", {
|
|
1922
1921
|
ref_key: "topRef",
|
|
1923
1922
|
ref: l,
|
|
1924
1923
|
class: "cn-ruler__bar cn-ruler__bar--top",
|
|
@@ -1930,12 +1929,12 @@ var xt = [
|
|
|
1930
1929
|
onPointermove: t[1] ||= (e) => b(e),
|
|
1931
1930
|
onPointerup: t[2] ||= (e) => x(e, "guide-drag-end"),
|
|
1932
1931
|
onPointercancel: t[3] ||= (e) => x(e, "guide-drag-cancel")
|
|
1933
|
-
}, [(
|
|
1932
|
+
}, [(q(!0), z(F, null, Y(h.value, (e) => (q(), z("span", {
|
|
1934
1933
|
key: e.scene,
|
|
1935
|
-
class:
|
|
1936
|
-
style:
|
|
1937
|
-
}, [e.label === null ?
|
|
1938
|
-
|
|
1934
|
+
class: U(["cn-ruler__tick", { "cn-ruler__tick--major": e.label !== null }]),
|
|
1935
|
+
style: W({ left: `${e.position}px` })
|
|
1936
|
+
}, [e.label === null ? R("", !0) : (q(), z("span", kt, Z(e.label), 1))], 6))), 128))], 544),
|
|
1937
|
+
B("div", {
|
|
1939
1938
|
ref_key: "leftRef",
|
|
1940
1939
|
ref: u,
|
|
1941
1940
|
class: "cn-ruler__bar cn-ruler__bar--left",
|
|
@@ -1947,43 +1946,43 @@ var xt = [
|
|
|
1947
1946
|
onPointermove: t[5] ||= (e) => b(e),
|
|
1948
1947
|
onPointerup: t[6] ||= (e) => x(e, "guide-drag-end"),
|
|
1949
1948
|
onPointercancel: t[7] ||= (e) => x(e, "guide-drag-cancel")
|
|
1950
|
-
}, [(
|
|
1949
|
+
}, [(q(!0), z(F, null, Y(g.value, (e) => (q(), z("span", {
|
|
1951
1950
|
key: e.scene,
|
|
1952
|
-
class:
|
|
1953
|
-
style:
|
|
1954
|
-
}, [e.label === null ?
|
|
1955
|
-
t[8] ||=
|
|
1951
|
+
class: U(["cn-ruler__tick", { "cn-ruler__tick--major": e.label !== null }]),
|
|
1952
|
+
style: W({ top: `${e.position}px` })
|
|
1953
|
+
}, [e.label === null ? R("", !0) : (q(), z("span", At, Z(e.label), 1))], 6))), 128))], 544),
|
|
1954
|
+
t[8] ||= B("div", {
|
|
1956
1955
|
class: "cn-ruler__corner",
|
|
1957
1956
|
"data-ruler-corner": "",
|
|
1958
1957
|
"aria-hidden": "true"
|
|
1959
1958
|
}, null, -1)
|
|
1960
|
-
], 512)), [[
|
|
1959
|
+
], 512)), [[ae, a.value]]);
|
|
1961
1960
|
}
|
|
1962
|
-
}), [["__scopeId", "data-v-5bd7248c"]]),
|
|
1963
|
-
function
|
|
1961
|
+
}), [["__scopeId", "data-v-5bd7248c"]]), Pt = "#2563eb", Ft = "rgba(37, 99, 235, 0.08)", It = [4, 3], Lt = 1, Rt = "rgba(11, 18, 32, 0.9)", zt = "#ffffff", Bt = 11, Vt = 6, Ht = 3, Ut = 3, Wt = 6;
|
|
1962
|
+
function Gt(e, t, n) {
|
|
1964
1963
|
let r = t.store.ui.create;
|
|
1965
1964
|
if (!r) return;
|
|
1966
1965
|
let { x: i, y: a, width: o, height: s } = r.rect;
|
|
1967
1966
|
if (o === 0 && s === 0) return;
|
|
1968
1967
|
let c = n.viewport.zoom;
|
|
1969
|
-
e.fillStyle =
|
|
1970
|
-
let l =
|
|
1968
|
+
e.fillStyle = Ft, e.fillRect(i, a, o, s), e.strokeStyle = Pt, e.lineWidth = Lt / c, e.setLineDash(It.map((e) => e / c)), e.strokeRect(i, a, o, s), e.setLineDash([]);
|
|
1969
|
+
let l = Bt / c, u = Vt / c, d = Ht / c;
|
|
1971
1970
|
e.font = `${l}px system-ui, sans-serif`;
|
|
1972
|
-
let f = `${Math.round(o)} × ${Math.round(s)}`, p = e.measureText(f).width + u * 2, m = l + d * 2, h = i + o +
|
|
1973
|
-
e.fillStyle =
|
|
1971
|
+
let f = `${Math.round(o)} × ${Math.round(s)}`, p = e.measureText(f).width + u * 2, m = l + d * 2, h = i + o + Wt / c, g = a + s + Wt / c;
|
|
1972
|
+
e.fillStyle = Rt, e.beginPath(), e.roundRect(h, g, p, m, Ut / c), e.fill(), e.fillStyle = zt, e.textBaseline = "middle", e.fillText(f, h + u, g + m / 2);
|
|
1974
1973
|
}
|
|
1975
1974
|
//#endregion
|
|
1976
1975
|
//#region src/canvas/findHighlight.ts
|
|
1977
|
-
var
|
|
1976
|
+
var Kt = {
|
|
1978
1977
|
matchColor: "#f59e0b",
|
|
1979
1978
|
currentColor: "#38bdf8",
|
|
1980
1979
|
currentFill: "rgba(56, 189, 248, 0.12)",
|
|
1981
1980
|
lineWidth: 2
|
|
1982
1981
|
};
|
|
1983
|
-
function
|
|
1982
|
+
function qt(e, t, n, r) {
|
|
1984
1983
|
if (!n.doc || !t.store.ui.find.open) return;
|
|
1985
1984
|
let i = {
|
|
1986
|
-
...
|
|
1985
|
+
...Kt,
|
|
1987
1986
|
...r
|
|
1988
1987
|
}, a = t.listFindMatches();
|
|
1989
1988
|
if (a.length === 0) return;
|
|
@@ -1997,57 +1996,57 @@ function Wt(e, t, n, r) {
|
|
|
1997
1996
|
}
|
|
1998
1997
|
//#endregion
|
|
1999
1998
|
//#region src/canvas/gizmo.ts
|
|
2000
|
-
var
|
|
1999
|
+
var Jt = {
|
|
2001
2000
|
selectionColor: "#2563eb",
|
|
2002
2001
|
hoverColor: "rgba(37, 99, 235, 0.55)",
|
|
2003
2002
|
selectionWidth: 2,
|
|
2004
2003
|
handleSize: 8,
|
|
2005
2004
|
handleFill: "#ffffff"
|
|
2006
2005
|
};
|
|
2007
|
-
function
|
|
2006
|
+
function Yt(e, t) {
|
|
2008
2007
|
return p(e, t)?.visible === !1;
|
|
2009
2008
|
}
|
|
2010
|
-
function
|
|
2009
|
+
function Xt(e, t, n, r) {
|
|
2011
2010
|
let i = {
|
|
2012
|
-
...
|
|
2011
|
+
...Jt,
|
|
2013
2012
|
...r
|
|
2014
2013
|
}, { selection: a, hovered: o } = t.store.ui, s = n.doc;
|
|
2015
2014
|
if (s) {
|
|
2016
|
-
if (o && !d(o, a) && !
|
|
2015
|
+
if (o && !d(o, a) && !Yt(s, o) && !t.isLocked(o)) {
|
|
2017
2016
|
let r = t.layerBoxAt(o);
|
|
2018
2017
|
r && (e.strokeStyle = i.hoverColor, e.lineWidth = i.selectionWidth / 2 / n.viewport.zoom, e.strokeRect(r.x, r.y, r.width, r.height));
|
|
2019
2018
|
}
|
|
2020
|
-
if (a && !
|
|
2019
|
+
if (a && !Yt(s, a)) {
|
|
2021
2020
|
let r = t.layerBoxAt(a);
|
|
2022
|
-
r && (e.strokeStyle = i.selectionColor, e.lineWidth = i.selectionWidth / n.viewport.zoom, e.strokeRect(r.x, r.y, r.width, r.height),
|
|
2021
|
+
r && (e.strokeStyle = i.selectionColor, e.lineWidth = i.selectionWidth / n.viewport.zoom, e.strokeRect(r.x, r.y, r.width, r.height), Zt(e, t, a, r, n.viewport.zoom, i));
|
|
2023
2022
|
}
|
|
2024
2023
|
}
|
|
2025
2024
|
}
|
|
2026
|
-
function
|
|
2025
|
+
function Zt(e, t, n, r, i, a) {
|
|
2027
2026
|
let o = t.resizeHandlesAt(n);
|
|
2028
2027
|
if (o.length === 0) return;
|
|
2029
2028
|
let s = a.handleSize / i, c = s / 2;
|
|
2030
2029
|
e.fillStyle = a.handleFill, e.strokeStyle = a.selectionColor, e.lineWidth = a.selectionWidth / i;
|
|
2031
2030
|
for (let t of o) {
|
|
2032
|
-
let n =
|
|
2031
|
+
let n = we(r, t);
|
|
2033
2032
|
e.fillRect(n.x - c, n.y - c, s, s), e.strokeRect(n.x - c, n.y - c, s, s);
|
|
2034
2033
|
}
|
|
2035
2034
|
}
|
|
2036
|
-
function
|
|
2035
|
+
function Qt(e, t, n) {
|
|
2037
2036
|
return (r) => {
|
|
2038
2037
|
if (!t) return;
|
|
2039
2038
|
t.setTransform(1, 0, 0, 1, 0, 0), t.clearRect(0, 0, t.canvas.width, t.canvas.height);
|
|
2040
2039
|
let i = r.dpr * r.viewport.zoom;
|
|
2041
|
-
t.setTransform(i, 0, 0, i, -r.viewport.x * i, -r.viewport.y * i),
|
|
2040
|
+
t.setTransform(i, 0, 0, i, -r.viewport.x * i, -r.viewport.y * i), Xt(t, e, r, n);
|
|
2042
2041
|
};
|
|
2043
2042
|
}
|
|
2044
2043
|
//#endregion
|
|
2045
2044
|
//#region src/canvas/scheduler.ts
|
|
2046
|
-
function
|
|
2045
|
+
function $t() {
|
|
2047
2046
|
return (e) => {
|
|
2048
2047
|
let t = window.requestAnimationFrame(() => e());
|
|
2049
2048
|
return () => window.cancelAnimationFrame(t);
|
|
2050
2049
|
};
|
|
2051
2050
|
}
|
|
2052
2051
|
//#endregion
|
|
2053
|
-
export {
|
|
2052
|
+
export { Ne as _, Gt as a, St as c, mt as d, pt as f, ze as g, Be as h, qt as i, yt as l, Ye as m, Qt as n, Nt as o, ft as p, Xt as r, Dt as s, $t as t, _t as u };
|