@hankchen/canvas-editor-vue 0.2.0 → 0.3.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/{canvas-C70NSsoF.js → canvas-ZMyaouKe.js} +2 -2
- package/dist/canvas.js +1 -1
- package/dist/completionAnchor-Da8VhzMQ.js +470 -0
- package/dist/index.js +6 -6
- package/dist/{layer-panel-BEcT9HhJ.js → layer-panel-CEyB57XM.js} +6 -6
- package/dist/layer-panel.js +1 -1
- package/dist/{property-panel-C2etsIhF.js → property-panel-DmSf_GPu.js} +3 -3
- package/dist/property-panel.js +1 -1
- package/dist/shared/completion.d.ts +26 -6
- package/dist/shared.js +3 -3
- package/dist/uploadFile-DXAEX9kG.js +455 -0
- package/dist/{usePathCompletion-uJ5c_gQ0.js → usePathCompletion-C52F4phW.js} +18 -18
- package/package.json +2 -2
- package/dist/completionAnchor-CDR5YZhu.js +0 -273
- package/dist/uploadFile-BOfv8aLG.js +0 -331
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import { a as e, r as t } from "./layerPath-uy2ywyld.js";
|
|
2
|
+
import { a as n, c as r, d as i, f as a, l as o, n as s, o as c, p as l, s as u, t as d, u as f } from "./completionAnchor-Da8VhzMQ.js";
|
|
3
|
+
import { nextTick as p, onMounted as m, onScopeDispose as h, reactive as g, toValue as _, watch as v } from "vue";
|
|
4
|
+
//#region ../canvas-editor/src/shared/expressionFunctions.ts
|
|
5
|
+
var y = [
|
|
6
|
+
{
|
|
7
|
+
name: "date",
|
|
8
|
+
signature: "date(path[, format])",
|
|
9
|
+
summary: "日期格式化(moment 风格 token,预设 date/datetime)"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "number",
|
|
13
|
+
signature: "number(path[, n])",
|
|
14
|
+
summary: "千分位分组"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "fixed",
|
|
18
|
+
signature: "fixed(path[, n])",
|
|
19
|
+
summary: "定点补零(缺省 2 位)"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "percent",
|
|
23
|
+
signature: "percent(path[, n])",
|
|
24
|
+
summary: "百分比(乘 100)"
|
|
25
|
+
}
|
|
26
|
+
], b = y.filter((e) => e.name !== "date"), x = [
|
|
27
|
+
{
|
|
28
|
+
segment: "date",
|
|
29
|
+
description: "预设 → YYYY-MM-DD"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
segment: "datetime",
|
|
33
|
+
description: "预设 → YYYY-MM-DD HH:mm:ss"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
segment: "YYYY年MM月DD日",
|
|
37
|
+
description: "中文模板(写即所得)"
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region ../canvas-editor/src/shared/expressionCandidates.ts
|
|
42
|
+
function S(e) {
|
|
43
|
+
return e.kind === "row" ? "row" : e.kind === "root" ? "$root" : e.name;
|
|
44
|
+
}
|
|
45
|
+
function C(e) {
|
|
46
|
+
let t = {};
|
|
47
|
+
return e.description !== void 0 && (t.description = e.description), e.title !== void 0 && (t.title = e.title), e.type !== void 0 && (t.type = e.type), t;
|
|
48
|
+
}
|
|
49
|
+
function w(e, t) {
|
|
50
|
+
return {
|
|
51
|
+
path: t === "" ? e.key : `${t}.${e.key}`,
|
|
52
|
+
segment: e.key,
|
|
53
|
+
...C(e.node)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function T(e, t, n) {
|
|
57
|
+
let r = [];
|
|
58
|
+
if (e.node.format === "date" || e.node.format === "date-time") r.push({
|
|
59
|
+
path: `date(${t}, '')`,
|
|
60
|
+
segment: `date(${t}, '')`,
|
|
61
|
+
cursorBack: 2,
|
|
62
|
+
replaceLen: n,
|
|
63
|
+
filterKey: e.key,
|
|
64
|
+
description: "日期格式化",
|
|
65
|
+
type: "函数"
|
|
66
|
+
});
|
|
67
|
+
else if (e.node.type === "number") for (let i of b) r.push({
|
|
68
|
+
path: `${i.name}(${t})`,
|
|
69
|
+
segment: `${i.name}(${t})`,
|
|
70
|
+
replaceLen: n,
|
|
71
|
+
filterKey: e.key,
|
|
72
|
+
description: i.summary,
|
|
73
|
+
type: "函数"
|
|
74
|
+
});
|
|
75
|
+
return r;
|
|
76
|
+
}
|
|
77
|
+
function E(e, t, n, r) {
|
|
78
|
+
let i = w(e, t);
|
|
79
|
+
return r ? [i, ...T(e, i.path, n)] : [i];
|
|
80
|
+
}
|
|
81
|
+
function D() {
|
|
82
|
+
return y.map((e) => ({
|
|
83
|
+
path: e.signature,
|
|
84
|
+
segment: `${e.name}()`,
|
|
85
|
+
cursorBack: 1,
|
|
86
|
+
description: e.summary,
|
|
87
|
+
type: "函数"
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
function O() {
|
|
91
|
+
return x.map((e) => ({
|
|
92
|
+
path: e.segment,
|
|
93
|
+
segment: e.segment,
|
|
94
|
+
description: e.description,
|
|
95
|
+
type: "格式"
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
function k(e, t, n, r, i) {
|
|
99
|
+
let o = a(e), s = o.entries.flatMap((e) => E(e, "", r, i));
|
|
100
|
+
return s.push({
|
|
101
|
+
path: "$root",
|
|
102
|
+
segment: "$root"
|
|
103
|
+
}), t === "row" && (s.push(n ? {
|
|
104
|
+
path: "row",
|
|
105
|
+
segment: "row",
|
|
106
|
+
...C(n)
|
|
107
|
+
} : {
|
|
108
|
+
path: "row",
|
|
109
|
+
segment: "row"
|
|
110
|
+
}), s.push({
|
|
111
|
+
path: "$index",
|
|
112
|
+
segment: "$index"
|
|
113
|
+
})), o.open === !0 ? {
|
|
114
|
+
candidates: s,
|
|
115
|
+
open: !0
|
|
116
|
+
} : { candidates: s };
|
|
117
|
+
}
|
|
118
|
+
function A(e, t) {
|
|
119
|
+
let n = r(t.expr);
|
|
120
|
+
if (n === null) return {
|
|
121
|
+
ok: !0,
|
|
122
|
+
prefix: "",
|
|
123
|
+
partial: "",
|
|
124
|
+
candidates: []
|
|
125
|
+
};
|
|
126
|
+
if (n.stringSlot && n.index >= 1 && n.name === "date") return {
|
|
127
|
+
ok: !0,
|
|
128
|
+
prefix: "",
|
|
129
|
+
partial: n.text,
|
|
130
|
+
candidates: O()
|
|
131
|
+
};
|
|
132
|
+
if (n.index === 0 && !o(n.text)) {
|
|
133
|
+
let r = j(e, t, n.text, !1);
|
|
134
|
+
return r.ok ? r : {
|
|
135
|
+
ok: !0,
|
|
136
|
+
prefix: "",
|
|
137
|
+
partial: "",
|
|
138
|
+
candidates: []
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
ok: !0,
|
|
143
|
+
prefix: "",
|
|
144
|
+
partial: "",
|
|
145
|
+
candidates: []
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function j(e, t, n, r) {
|
|
149
|
+
if (e === null) return {
|
|
150
|
+
ok: !0,
|
|
151
|
+
prefix: "",
|
|
152
|
+
partial: "",
|
|
153
|
+
candidates: []
|
|
154
|
+
};
|
|
155
|
+
let i = n.endsWith("."), o = i ? n.slice(0, -1) : n;
|
|
156
|
+
if (o === "") return n === "" ? {
|
|
157
|
+
ok: !0,
|
|
158
|
+
prefix: "",
|
|
159
|
+
partial: "",
|
|
160
|
+
...k(e, t.context, t.rowSchema, n.length, !1)
|
|
161
|
+
} : {
|
|
162
|
+
ok: !1,
|
|
163
|
+
reason: "expression_syntax_error"
|
|
164
|
+
};
|
|
165
|
+
let s = f(o);
|
|
166
|
+
if (!s.ok) return {
|
|
167
|
+
ok: !1,
|
|
168
|
+
reason: "expression_syntax_error"
|
|
169
|
+
};
|
|
170
|
+
let { head: c, rest: u } = s, d, p;
|
|
171
|
+
i ? (d = [S(c), ...u], p = "") : u.length > 0 ? (d = [S(c), ...u.slice(0, -1)], p = u[u.length - 1]) : (d = [], p = S(c));
|
|
172
|
+
let m = r && p !== "";
|
|
173
|
+
if (d.length === 0) {
|
|
174
|
+
let i = k(e, t.context, t.rowSchema, n.length, m), a = r && n !== "" ? D() : [];
|
|
175
|
+
return {
|
|
176
|
+
ok: !0,
|
|
177
|
+
prefix: "",
|
|
178
|
+
partial: p,
|
|
179
|
+
candidates: [...i.candidates, ...a],
|
|
180
|
+
...i.open === !0 ? { open: !0 } : {}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
let h, g;
|
|
184
|
+
if (c.kind === "row") {
|
|
185
|
+
if (t.context !== "row") return {
|
|
186
|
+
ok: !0,
|
|
187
|
+
prefix: d.join("."),
|
|
188
|
+
partial: p,
|
|
189
|
+
candidates: []
|
|
190
|
+
};
|
|
191
|
+
h = t.rowSchema ?? null, g = d.slice(1);
|
|
192
|
+
} else if (c.kind === "root") h = e, g = d.slice(1);
|
|
193
|
+
else if (c.name === "$index") return {
|
|
194
|
+
ok: !0,
|
|
195
|
+
prefix: d.join("."),
|
|
196
|
+
partial: p,
|
|
197
|
+
candidates: []
|
|
198
|
+
};
|
|
199
|
+
else h = e, g = d;
|
|
200
|
+
let _ = h === null ? null : l(h, g), v = d.join(".");
|
|
201
|
+
if (_ === null) return {
|
|
202
|
+
ok: !0,
|
|
203
|
+
prefix: v,
|
|
204
|
+
partial: p,
|
|
205
|
+
candidates: []
|
|
206
|
+
};
|
|
207
|
+
let y = a(_);
|
|
208
|
+
return {
|
|
209
|
+
ok: !0,
|
|
210
|
+
prefix: v,
|
|
211
|
+
partial: p,
|
|
212
|
+
candidates: y.entries.flatMap((e) => E(e, v, n.length, m)),
|
|
213
|
+
...y.open === !0 ? { open: !0 } : {}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function M(e, t) {
|
|
217
|
+
return e === null ? {
|
|
218
|
+
ok: !0,
|
|
219
|
+
prefix: "",
|
|
220
|
+
partial: "",
|
|
221
|
+
candidates: []
|
|
222
|
+
} : o(t.expr) ? A(e, t) : j(e, t, t.expr, !0);
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/shared/expressionContext.ts
|
|
226
|
+
function N(t, n, r) {
|
|
227
|
+
let a = null;
|
|
228
|
+
for (let o = 0; o < n.length; o += 1) {
|
|
229
|
+
if (n[o] !== "template") continue;
|
|
230
|
+
let s = e(t, n.slice(0, o));
|
|
231
|
+
if (s === null || s.type !== "TableLayer" || (a = i(a ?? r, s.rowsPath), a === null)) return null;
|
|
232
|
+
}
|
|
233
|
+
return a;
|
|
234
|
+
}
|
|
235
|
+
function P(e) {
|
|
236
|
+
return e[e.length - 1] === "content" && t(e);
|
|
237
|
+
}
|
|
238
|
+
function F(e, t, n) {
|
|
239
|
+
return e === null || t === null || n === null || !P(n) ? {
|
|
240
|
+
kind: "root",
|
|
241
|
+
rowSchema: null
|
|
242
|
+
} : {
|
|
243
|
+
kind: "row",
|
|
244
|
+
rowSchema: N(t, n, e)
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function I(e, t) {
|
|
248
|
+
return e === null ? null : (n) => {
|
|
249
|
+
let r = M(e, {
|
|
250
|
+
context: t.kind,
|
|
251
|
+
expr: n,
|
|
252
|
+
rowSchema: t.rowSchema
|
|
253
|
+
});
|
|
254
|
+
return r.ok ? {
|
|
255
|
+
partial: r.partial,
|
|
256
|
+
candidates: r.candidates,
|
|
257
|
+
...r.open === !0 ? { open: !0 } : {}
|
|
258
|
+
} : null;
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/shared/useExpressionCompletion.ts
|
|
263
|
+
var L = 4, R = [
|
|
264
|
+
"ArrowLeft",
|
|
265
|
+
"ArrowRight",
|
|
266
|
+
"Home",
|
|
267
|
+
"End",
|
|
268
|
+
"PageUp",
|
|
269
|
+
"PageDown"
|
|
270
|
+
];
|
|
271
|
+
function z(e) {
|
|
272
|
+
let t = g({
|
|
273
|
+
open: !1,
|
|
274
|
+
items: [],
|
|
275
|
+
activeIndex: 0,
|
|
276
|
+
top: 0,
|
|
277
|
+
left: 0,
|
|
278
|
+
openMapping: !1
|
|
279
|
+
}), r = null, i = !1, a = null;
|
|
280
|
+
function o() {
|
|
281
|
+
t.open = !1, t.items = [], t.activeIndex = 0, t.openMapping = !1, a = null;
|
|
282
|
+
}
|
|
283
|
+
function l() {
|
|
284
|
+
if (!t.open || !r) return;
|
|
285
|
+
let n = d(r, _(e.scale ?? 1));
|
|
286
|
+
t.top = n.bottom + L, t.left = f(n.left);
|
|
287
|
+
}
|
|
288
|
+
function f(t) {
|
|
289
|
+
let n = (e.popupEl ? _(e.popupEl) : null)?.offsetWidth ?? 0;
|
|
290
|
+
return n <= 0 ? t : Math.max(0, Math.min(t, window.innerWidth - 4 - n));
|
|
291
|
+
}
|
|
292
|
+
function y(i, s = !1) {
|
|
293
|
+
if (!_(e.enabled)) {
|
|
294
|
+
o();
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
let d = r;
|
|
298
|
+
if (!d) {
|
|
299
|
+
o();
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
let f = d.value, m = d.selectionStart ?? f.length, h = n(u(f), m);
|
|
303
|
+
if (!h) {
|
|
304
|
+
o();
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
let g = h.kind === "open" ? h.end : h.end - 2, v = e.resolve(c(f.slice(h.start + 2, Math.min(m, g))));
|
|
308
|
+
if (!v) {
|
|
309
|
+
o();
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
let y = s ? v.candidates : v.candidates.filter((e) => (e.filterKey ?? e.segment).startsWith(v.partial));
|
|
313
|
+
if (y.length === 0 && v.open !== !0) {
|
|
314
|
+
o();
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
a = {
|
|
318
|
+
fragment: h,
|
|
319
|
+
partial: v.partial,
|
|
320
|
+
cursor: m
|
|
321
|
+
}, (t.open || i) && (t.items = y, t.activeIndex = 0, t.openMapping = v.open === !0, t.open = !0, l(), p(l));
|
|
322
|
+
}
|
|
323
|
+
function b(e) {
|
|
324
|
+
let n = r;
|
|
325
|
+
if (!t.open || i || !n || !a) return;
|
|
326
|
+
let c = t.items[e ?? t.activeIndex];
|
|
327
|
+
if (!c) return;
|
|
328
|
+
let l = s(n.value, a.fragment, a.cursor, a.partial, c);
|
|
329
|
+
if (!l) {
|
|
330
|
+
o();
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
n.value = l.value, n.setSelectionRange(l.cursor, l.cursor), n.dispatchEvent(new Event("input", { bubbles: !0 })), n.dispatchEvent(new Event("change", { bubbles: !0 })), o();
|
|
334
|
+
}
|
|
335
|
+
function x() {
|
|
336
|
+
return _(e.pairing ?? e.enabled);
|
|
337
|
+
}
|
|
338
|
+
function S(e) {
|
|
339
|
+
let t = e.selectionStart;
|
|
340
|
+
return t === null || t !== e.selectionEnd ? null : t;
|
|
341
|
+
}
|
|
342
|
+
let C = !1;
|
|
343
|
+
function w(e) {
|
|
344
|
+
if (C || !x()) return;
|
|
345
|
+
let t = r;
|
|
346
|
+
if (!t) return;
|
|
347
|
+
let n = e.inputType;
|
|
348
|
+
if (n !== void 0 && n !== "" && n !== "insertText") return;
|
|
349
|
+
let i = S(t);
|
|
350
|
+
if (i === null || i < 2) return;
|
|
351
|
+
let a = t.value;
|
|
352
|
+
a.startsWith("{{", i - 2) && (a.includes("}}", i) || (C = !0, t.value = `${a.slice(0, i)}}}${a.slice(i)}`, t.setSelectionRange(i, i), t.dispatchEvent(new Event("input", { bubbles: !0 })), C = !1));
|
|
353
|
+
}
|
|
354
|
+
function T(e) {
|
|
355
|
+
if (!x()) return !1;
|
|
356
|
+
let t = r;
|
|
357
|
+
if (!t) return !1;
|
|
358
|
+
let n = S(t);
|
|
359
|
+
if (n === null || n < 2) return !1;
|
|
360
|
+
let i = t.value;
|
|
361
|
+
return !i.startsWith("{{", n - 2) || !i.startsWith("}}", n) ? !1 : (e.preventDefault(), C = !0, t.value = i.slice(0, n - 2) + i.slice(n + 2), t.setSelectionRange(n - 2, n - 2), t.dispatchEvent(new Event("input", { bubbles: !0 })), C = !1, !0);
|
|
362
|
+
}
|
|
363
|
+
function E(e) {
|
|
364
|
+
if (!x()) return !1;
|
|
365
|
+
let t = r;
|
|
366
|
+
if (!t) return !1;
|
|
367
|
+
let n = S(t);
|
|
368
|
+
return n === null || t.value[n] !== "}" ? !1 : (e.preventDefault(), t.setSelectionRange(n + 1, n + 1), y(!1), !0);
|
|
369
|
+
}
|
|
370
|
+
function D(e) {
|
|
371
|
+
i || e.isComposing || (w(e), y(!0));
|
|
372
|
+
}
|
|
373
|
+
function O() {
|
|
374
|
+
i = !0;
|
|
375
|
+
}
|
|
376
|
+
function k() {
|
|
377
|
+
i = !1, y(!0);
|
|
378
|
+
}
|
|
379
|
+
function A(e) {
|
|
380
|
+
return i || e.isComposing || e.keyCode === 229;
|
|
381
|
+
}
|
|
382
|
+
function j(e) {
|
|
383
|
+
if (!A(e)) {
|
|
384
|
+
if (e.key === " " && (e.ctrlKey || e.metaKey)) {
|
|
385
|
+
e.preventDefault(), y(!0, !0);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (!(e.key === "Backspace" && T(e)) && !(e.key === "}" && E(e)) && t.open) {
|
|
389
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
390
|
+
e.preventDefault();
|
|
391
|
+
let n = t.items.length;
|
|
392
|
+
n > 0 && (t.activeIndex = (t.activeIndex + (e.key === "ArrowDown" ? 1 : n - 1)) % n);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (e.key === "Enter" || e.key === "Tab") {
|
|
396
|
+
e.preventDefault(), b();
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
e.key === "Escape" && (e.preventDefault(), o());
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function M(e) {
|
|
404
|
+
t.open && !A(e) && R.includes(e.key) && y(!1);
|
|
405
|
+
}
|
|
406
|
+
function N() {
|
|
407
|
+
i || y(!1);
|
|
408
|
+
}
|
|
409
|
+
function P() {
|
|
410
|
+
o();
|
|
411
|
+
}
|
|
412
|
+
function F(e) {
|
|
413
|
+
t.open && e.target !== r && o();
|
|
414
|
+
}
|
|
415
|
+
function I() {
|
|
416
|
+
l();
|
|
417
|
+
}
|
|
418
|
+
let z = [
|
|
419
|
+
["input", D],
|
|
420
|
+
["keydown", j],
|
|
421
|
+
["keyup", M],
|
|
422
|
+
["click", N],
|
|
423
|
+
["blur", P],
|
|
424
|
+
["compositionstart", O],
|
|
425
|
+
["compositionend", k]
|
|
426
|
+
];
|
|
427
|
+
function B(e) {
|
|
428
|
+
for (let [t, n] of z) e.addEventListener(t, n);
|
|
429
|
+
}
|
|
430
|
+
function V(e) {
|
|
431
|
+
for (let [t, n] of z) e.removeEventListener(t, n);
|
|
432
|
+
}
|
|
433
|
+
function H(e) {
|
|
434
|
+
r !== e && (r && V(r), r = e, e && B(e));
|
|
435
|
+
}
|
|
436
|
+
return m(() => H(e.target.value)), v(e.target, (e) => H(e)), v(() => _(e.enabled), (e) => {
|
|
437
|
+
e || o();
|
|
438
|
+
}), document.addEventListener("mousedown", F), window.addEventListener("scroll", I, !0), window.addEventListener("resize", I), h(() => {
|
|
439
|
+
r && V(r), document.removeEventListener("mousedown", F), window.removeEventListener("scroll", I, !0), window.removeEventListener("resize", I);
|
|
440
|
+
}), {
|
|
441
|
+
popup: t,
|
|
442
|
+
accept: b
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region src/shared/uploadFile.ts
|
|
447
|
+
async function B(e) {
|
|
448
|
+
return {
|
|
449
|
+
name: e.name,
|
|
450
|
+
mime: e.type,
|
|
451
|
+
bytes: new Uint8Array(await e.arrayBuffer())
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
//#endregion
|
|
455
|
+
export { F as i, z as n, I as r, B as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as e } from "./layerPath-uy2ywyld.js";
|
|
2
|
-
import {
|
|
2
|
+
import { d as t, n, p as r, t as i } from "./completionAnchor-Da8VhzMQ.js";
|
|
3
3
|
import { nextTick as a, onMounted as o, onScopeDispose as s, reactive as c, toValue as l, watch as u } from "vue";
|
|
4
4
|
//#region ../canvas-editor/src/shared/rowsPathCandidates.ts
|
|
5
5
|
function d(e) {
|
|
@@ -25,17 +25,17 @@ function m(e, t) {
|
|
|
25
25
|
}
|
|
26
26
|
function h(e, t) {
|
|
27
27
|
if (e === null) return null;
|
|
28
|
-
let n = t.split("."),
|
|
28
|
+
let n = t.split("."), i = t.endsWith(".") ? "" : n[n.length - 1], a = n.slice(0, -1), o = e;
|
|
29
29
|
for (let e of a) {
|
|
30
30
|
if (d(o)) return null;
|
|
31
|
-
let t =
|
|
31
|
+
let t = r(o, [e]);
|
|
32
32
|
if (t === null) return null;
|
|
33
33
|
o = t;
|
|
34
34
|
}
|
|
35
35
|
if (d(o) || f(o)) return null;
|
|
36
36
|
let s = m(o, a.join("."));
|
|
37
37
|
return {
|
|
38
|
-
partial:
|
|
38
|
+
partial: i,
|
|
39
39
|
candidates: s.candidates,
|
|
40
40
|
...s.open === !0 ? { open: !0 } : {}
|
|
41
41
|
};
|
|
@@ -94,31 +94,31 @@ function S(e) {
|
|
|
94
94
|
top: 0,
|
|
95
95
|
left: 0,
|
|
96
96
|
openMapping: !1
|
|
97
|
-
}),
|
|
97
|
+
}), r = null, d = !1, f = "";
|
|
98
98
|
function p() {
|
|
99
99
|
t.open = !1, t.items = [], t.activeIndex = 0, t.openMapping = !1, f = "";
|
|
100
100
|
}
|
|
101
101
|
function m() {
|
|
102
|
-
if (!t.open || !
|
|
103
|
-
let e = r
|
|
102
|
+
if (!t.open || !r) return;
|
|
103
|
+
let e = i(r);
|
|
104
104
|
t.top = e.bottom + v, t.left = h(e.left);
|
|
105
105
|
}
|
|
106
106
|
function h(t) {
|
|
107
107
|
let n = (e.popupEl ? l(e.popupEl) : null)?.offsetWidth ?? 0;
|
|
108
108
|
return n <= 0 ? t : Math.max(0, Math.min(t, window.innerWidth - y - n));
|
|
109
109
|
}
|
|
110
|
-
function g(n,
|
|
110
|
+
function g(n, i = !1) {
|
|
111
111
|
if (!l(e.enabled)) {
|
|
112
112
|
p();
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
-
let o =
|
|
115
|
+
let o = r;
|
|
116
116
|
if (!o) {
|
|
117
117
|
p();
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
let s = o.value.slice(0, o.selectionStart ?? o.value.length);
|
|
121
|
-
if (s === "" && !
|
|
121
|
+
if (s === "" && !i) {
|
|
122
122
|
p();
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
@@ -127,7 +127,7 @@ function S(e) {
|
|
|
127
127
|
p();
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
|
-
let u =
|
|
130
|
+
let u = i ? c.candidates : c.candidates.filter((e) => e.segment.startsWith(c.partial));
|
|
131
131
|
if (u.length === 0 && c.open !== !0) {
|
|
132
132
|
p();
|
|
133
133
|
return;
|
|
@@ -135,16 +135,16 @@ function S(e) {
|
|
|
135
135
|
f = c.partial, (t.open || n) && (t.items = u, t.activeIndex = 0, t.openMapping = c.open === !0, t.open = !0, m(), a(m));
|
|
136
136
|
}
|
|
137
137
|
function _(e) {
|
|
138
|
-
let
|
|
139
|
-
if (!t.open || d || !
|
|
138
|
+
let i = r;
|
|
139
|
+
if (!t.open || d || !i) return;
|
|
140
140
|
let a = t.items[e ?? t.activeIndex];
|
|
141
141
|
if (!a) return;
|
|
142
|
-
let o =
|
|
142
|
+
let o = i.value.slice(0, i.selectionStart ?? i.value.length), s = n(i.value, x(o), o.length, f, a);
|
|
143
143
|
if (!s) {
|
|
144
144
|
p();
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
i.value = s.value, i.setSelectionRange(s.cursor, s.cursor), i.dispatchEvent(new Event("input", { bubbles: !0 })), i.dispatchEvent(new Event("change", { bubbles: !0 })), p();
|
|
148
148
|
}
|
|
149
149
|
function S(e) {
|
|
150
150
|
d || e.isComposing || g(!0);
|
|
@@ -193,7 +193,7 @@ function S(e) {
|
|
|
193
193
|
p();
|
|
194
194
|
}
|
|
195
195
|
function A(e) {
|
|
196
|
-
t.open && e.target !==
|
|
196
|
+
t.open && e.target !== r && p();
|
|
197
197
|
}
|
|
198
198
|
function j() {
|
|
199
199
|
m();
|
|
@@ -214,12 +214,12 @@ function S(e) {
|
|
|
214
214
|
for (let [t, n] of M) e.removeEventListener(t, n);
|
|
215
215
|
}
|
|
216
216
|
function F(e) {
|
|
217
|
-
|
|
217
|
+
r !== e && (r && P(r), r = e, e && N(e));
|
|
218
218
|
}
|
|
219
219
|
return o(() => F(e.target.value)), u(e.target, (e) => F(e)), u(() => l(e.enabled), (e) => {
|
|
220
220
|
e || p();
|
|
221
221
|
}), document.addEventListener("mousedown", A), window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), s(() => {
|
|
222
|
-
|
|
222
|
+
r && P(r), document.removeEventListener("mousedown", A), window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
|
|
223
223
|
}), {
|
|
224
224
|
popup: t,
|
|
225
225
|
accept: _
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hankchen/canvas-editor-vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Vue 3 薄绑定:响应式桥、composables、画布表面组件、textarea 文本编辑 overlay、schema 驱动属性面板注册表",
|
|
6
6
|
"type": "module",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@lucide/vue": "^1.48.0",
|
|
61
|
-
"@hankchen/canvas-editor": "0.
|
|
61
|
+
"@hankchen/canvas-editor": "0.4.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"vue": "^3.5.0"
|