@hankchen/canvas-editor-vue 0.1.1 → 0.1.2
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-CSdXMg6S.js +1601 -0
- package/dist/canvas.js +1 -1
- package/dist/{completionAnchor-4lhR2kJz.js → completionAnchor-CDR5YZhu.js} +28 -28
- package/dist/dist-B6-i-hhY.js +184 -0
- package/dist/index.js +13 -13
- package/dist/layer-panel-BM-nX_OX.js +536 -0
- package/dist/layer-panel.js +1 -1
- package/dist/layerPath-uy2ywyld.js +76 -0
- package/dist/property-panel-Cw6T9dAQ.js +1667 -0
- package/dist/property-panel.js +1 -1
- package/dist/shared-BTyB4vbT.js +123 -0
- package/dist/shared.js +8 -8
- package/dist/{status-bar-BhhrVoBZ.js → status-bar-DO8akYAw.js} +50 -49
- package/dist/status-bar.js +1 -1
- package/dist/{uploadFile-CutE_xI-.js → uploadFile-BOfv8aLG.js} +106 -105
- package/dist/{useDataSourceSchema-C924m8fc.js → useDataSourceSchema-DStVoY8Z.js} +47 -47
- package/dist/{usePathCompletion-DkHoGla4.js → usePathCompletion-uJ5c_gQ0.js} +60 -59
- package/dist/{useShortcutsHelp-DTC3yRil.js → useShortcutsHelp-CsyarO2P.js} +1 -1
- package/dist/{useTransientFeedback-gS9Xa9GY.js → useTransientFeedback-Cnp6aNB7.js} +1 -1
- package/dist/{useViewport-BLe2ise1.js → useViewport-D9Ipevzs.js} +5 -5
- package/package.json +1 -1
- package/dist/canvas-CS4SmrIO.js +0 -1649
- package/dist/createLucideIcon-CMq8ZKo2.js +0 -96
- package/dist/dist-DuXLYZZ9.js +0 -341
- package/dist/layer-panel-ArP66_vZ.js +0 -652
- package/dist/layerPath-BRZK9ka1.js +0 -2160
- package/dist/property-panel-jt_rsTVW.js +0 -1719
- package/dist/shared-D9zYUQaw.js +0 -123
|
@@ -1,652 +0,0 @@
|
|
|
1
|
-
import { B as e, D as t, F as n, G as r, H as i, L as a, M as o, P as s, U as c, W as ee, _ as l, b as u, d, g as f, h as te, i as p, k as ne, l as m, m as h, p as g, r as _, s as v, t as y, u as b, w as re, y as x, z as S } from "./layerPath-BRZK9ka1.js";
|
|
2
|
-
import { t as C } from "./createLucideIcon-CMq8ZKo2.js";
|
|
3
|
-
import { i as w, o as T, r as ie } from "./completionAnchor-4lhR2kJz.js";
|
|
4
|
-
import { o as E, r as ae, s as D, t as oe } from "./useTransientFeedback-gS9Xa9GY.js";
|
|
5
|
-
import { n as se, t as ce } from "./usePathCompletion-DkHoGla4.js";
|
|
6
|
-
import { n as le, t as ue } from "./useDataSourceSchema-C924m8fc.js";
|
|
7
|
-
var de = C({
|
|
8
|
-
name: "eye-off",
|
|
9
|
-
size: 24,
|
|
10
|
-
node: [
|
|
11
|
-
["path", {
|
|
12
|
-
d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
|
|
13
|
-
key: "ct8e1f"
|
|
14
|
-
}],
|
|
15
|
-
["path", {
|
|
16
|
-
d: "M14.084 14.158a3 3 0 0 1-4.242-4.242",
|
|
17
|
-
key: "151rxh"
|
|
18
|
-
}],
|
|
19
|
-
["path", {
|
|
20
|
-
d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",
|
|
21
|
-
key: "13bj9a"
|
|
22
|
-
}],
|
|
23
|
-
["path", {
|
|
24
|
-
d: "m2 2 20 20",
|
|
25
|
-
key: "1ooewy"
|
|
26
|
-
}]
|
|
27
|
-
]
|
|
28
|
-
}), fe = C({
|
|
29
|
-
name: "eye",
|
|
30
|
-
size: 24,
|
|
31
|
-
node: [["path", {
|
|
32
|
-
d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
|
|
33
|
-
key: "1nclc0"
|
|
34
|
-
}], ["circle", {
|
|
35
|
-
cx: "12",
|
|
36
|
-
cy: "12",
|
|
37
|
-
r: "3",
|
|
38
|
-
key: "1v7zrd"
|
|
39
|
-
}]]
|
|
40
|
-
}), pe = C({
|
|
41
|
-
name: "grip-vertical",
|
|
42
|
-
size: 24,
|
|
43
|
-
node: [
|
|
44
|
-
["circle", {
|
|
45
|
-
cx: "9",
|
|
46
|
-
cy: "12",
|
|
47
|
-
r: "1",
|
|
48
|
-
key: "1vctgf"
|
|
49
|
-
}],
|
|
50
|
-
["circle", {
|
|
51
|
-
cx: "9",
|
|
52
|
-
cy: "5",
|
|
53
|
-
r: "1",
|
|
54
|
-
key: "hp0tcf"
|
|
55
|
-
}],
|
|
56
|
-
["circle", {
|
|
57
|
-
cx: "9",
|
|
58
|
-
cy: "19",
|
|
59
|
-
r: "1",
|
|
60
|
-
key: "fkjjf6"
|
|
61
|
-
}],
|
|
62
|
-
["circle", {
|
|
63
|
-
cx: "15",
|
|
64
|
-
cy: "12",
|
|
65
|
-
r: "1",
|
|
66
|
-
key: "1tmaij"
|
|
67
|
-
}],
|
|
68
|
-
["circle", {
|
|
69
|
-
cx: "15",
|
|
70
|
-
cy: "5",
|
|
71
|
-
r: "1",
|
|
72
|
-
key: "19l28e"
|
|
73
|
-
}],
|
|
74
|
-
["circle", {
|
|
75
|
-
cx: "15",
|
|
76
|
-
cy: "19",
|
|
77
|
-
r: "1",
|
|
78
|
-
key: "f4zoj3"
|
|
79
|
-
}]
|
|
80
|
-
]
|
|
81
|
-
}), me = C({
|
|
82
|
-
name: "lock-open",
|
|
83
|
-
size: 24,
|
|
84
|
-
node: [["rect", {
|
|
85
|
-
width: "18",
|
|
86
|
-
height: "11",
|
|
87
|
-
x: "3",
|
|
88
|
-
y: "11",
|
|
89
|
-
rx: "2",
|
|
90
|
-
ry: "2",
|
|
91
|
-
key: "1w4ew1"
|
|
92
|
-
}], ["path", {
|
|
93
|
-
d: "M7 11V7a5 5 0 0 1 9.9-1",
|
|
94
|
-
key: "1mm8w8"
|
|
95
|
-
}]],
|
|
96
|
-
aliases: ["unlock"]
|
|
97
|
-
}), he = C({
|
|
98
|
-
name: "lock",
|
|
99
|
-
size: 24,
|
|
100
|
-
node: [["rect", {
|
|
101
|
-
width: "18",
|
|
102
|
-
height: "11",
|
|
103
|
-
x: "3",
|
|
104
|
-
y: "11",
|
|
105
|
-
rx: "2",
|
|
106
|
-
ry: "2",
|
|
107
|
-
key: "1w4ew1"
|
|
108
|
-
}], ["path", {
|
|
109
|
-
d: "M7 11V7a5 5 0 0 1 10 0v4",
|
|
110
|
-
key: "fwvmzm"
|
|
111
|
-
}]]
|
|
112
|
-
}), ge = C({
|
|
113
|
-
name: "pencil",
|
|
114
|
-
size: 24,
|
|
115
|
-
node: [["path", {
|
|
116
|
-
d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",
|
|
117
|
-
key: "1a8usu"
|
|
118
|
-
}], ["path", {
|
|
119
|
-
d: "m15 5 4 4",
|
|
120
|
-
key: "1mk7zo"
|
|
121
|
-
}]]
|
|
122
|
-
});
|
|
123
|
-
//#endregion
|
|
124
|
-
//#region ../canvas-editor/src/editing/layerPanel.ts
|
|
125
|
-
function O(e) {
|
|
126
|
-
switch (e.type) {
|
|
127
|
-
case "TableLayer": return e.template === null ? [{
|
|
128
|
-
key: "rows",
|
|
129
|
-
layers: e.rows
|
|
130
|
-
}] : [{
|
|
131
|
-
key: "template",
|
|
132
|
-
layers: [e.template]
|
|
133
|
-
}];
|
|
134
|
-
case "TableRowLayer": return [{
|
|
135
|
-
key: "cells",
|
|
136
|
-
layers: e.cells
|
|
137
|
-
}];
|
|
138
|
-
case "TableCellLayer": return e.content ? [{
|
|
139
|
-
key: "content",
|
|
140
|
-
layers: [e.content]
|
|
141
|
-
}] : [];
|
|
142
|
-
case "ImageLayer":
|
|
143
|
-
case "TextLayer":
|
|
144
|
-
case "QrCodeLayer": return [];
|
|
145
|
-
case "TableRowTemplate": return [{
|
|
146
|
-
key: "cells",
|
|
147
|
-
layers: e.cells
|
|
148
|
-
}];
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
function k(e) {
|
|
152
|
-
switch (e.type) {
|
|
153
|
-
case "TextLayer":
|
|
154
|
-
case "ImageLayer":
|
|
155
|
-
case "QrCodeLayer": return e.expression;
|
|
156
|
-
default: return null;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
var A = "{{…}}";
|
|
160
|
-
function j(e) {
|
|
161
|
-
let t = k(e);
|
|
162
|
-
if (t === null) return "";
|
|
163
|
-
let n = T(t).parts.flatMap((e) => e.kind === "fragment" && e.expr !== "" ? [e.expr] : []);
|
|
164
|
-
return n.length === 0 ? A : n.map((e) => `{{${e}}}`).join(" ");
|
|
165
|
-
}
|
|
166
|
-
function M(e, t, n, r) {
|
|
167
|
-
let i = [];
|
|
168
|
-
for (let { key: n, layers: a } of O(e)) for (let e = 0; e < a.length; e += 1) {
|
|
169
|
-
let o = n === "rows" ? "row" : n === "cells" ? "cell" : n === "template" ? "templateRow" : "content", s = n === "content" ? [...t, "content"] : n === "template" ? [...t, "template"] : [
|
|
170
|
-
...t,
|
|
171
|
-
n,
|
|
172
|
-
e
|
|
173
|
-
];
|
|
174
|
-
i.push(M(a[e], s, o, r));
|
|
175
|
-
}
|
|
176
|
-
return {
|
|
177
|
-
type: e.type,
|
|
178
|
-
path: t,
|
|
179
|
-
role: n,
|
|
180
|
-
name: e.name,
|
|
181
|
-
visible: e.visible,
|
|
182
|
-
locked: y(t, r),
|
|
183
|
-
expressionPrefix: j(e),
|
|
184
|
-
...e.type === "TableLayer" ? { templated: e.template !== null } : null,
|
|
185
|
-
children: i
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
function N(e, t = []) {
|
|
189
|
-
let n = [];
|
|
190
|
-
for (let r = e.layers.length - 1; r >= 0; --r) n.push(M(e.layers[r], ["layers", r], "root", t));
|
|
191
|
-
return n;
|
|
192
|
-
}
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/layer-panel/addMenu.ts
|
|
195
|
-
var P = [
|
|
196
|
-
{
|
|
197
|
-
kind: "layer",
|
|
198
|
-
type: "TextLayer",
|
|
199
|
-
label: "文本层",
|
|
200
|
-
title: "画拉建文本层(点击后在画布拖拽定落位与尺寸,Esc 取消)"
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
kind: "layer",
|
|
204
|
-
type: "ImageLayer",
|
|
205
|
-
label: "图片层",
|
|
206
|
-
title: "画拉建图片层(点击后在画布拖拽定落位与尺寸,Esc 取消)"
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
kind: "layer",
|
|
210
|
-
type: "QrCodeLayer",
|
|
211
|
-
label: "二维码层",
|
|
212
|
-
title: "画拉建二维码层(点击后在画布拖拽定落位与尺寸,恒方形,Esc 取消)"
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
kind: "layer",
|
|
216
|
-
type: "TableLayer",
|
|
217
|
-
label: "表格",
|
|
218
|
-
title: "画拉建表格(点击后在画布拖拽定落位与尺寸,Esc 取消)"
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
kind: "template-table",
|
|
222
|
-
label: "模板表",
|
|
223
|
-
title: "新增模板表(行模板 + 数据行展开)"
|
|
224
|
-
}
|
|
225
|
-
], F = P.filter((e) => e.kind === "layer");
|
|
226
|
-
//#endregion
|
|
227
|
-
//#region src/layer-panel/useLayerPanel.ts
|
|
228
|
-
function I(t) {
|
|
229
|
-
let n = e(t.store.doc), r = e(t.store.ui.selection), i = e(t.store.ui.hovered), o = e(t.store.ui.renaming), s = e(t.store.ui.lockedPaths), c = t.subscribe((e) => {
|
|
230
|
-
e.scope === "doc" ? (n.value = t.store.doc, r.value = t.store.ui.selection, i.value = t.store.ui.hovered, o.value = t.store.ui.renaming, s.value = t.store.ui.lockedPaths) : e.branch === "selection" ? r.value = t.store.ui.selection : e.branch === "hovered" ? i.value = t.store.ui.hovered : e.branch === "renaming" ? o.value = t.store.ui.renaming : e.branch === "lockedPaths" && (s.value = t.store.ui.lockedPaths);
|
|
231
|
-
});
|
|
232
|
-
return a(c, !0), {
|
|
233
|
-
outline: g(() => n.value ? N(n.value, s.value) : []),
|
|
234
|
-
selection: g(() => r.value),
|
|
235
|
-
hovered: g(() => i.value),
|
|
236
|
-
renaming: g(() => o.value)
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
function L(e, t) {
|
|
240
|
-
return t > 0 && e < t / 2;
|
|
241
|
-
}
|
|
242
|
-
//#endregion
|
|
243
|
-
//#region src/layer-panel/LayerPanel.vue?vue&type=script&setup=true&lang.ts
|
|
244
|
-
var _e = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rounded-xl border border-cn-line bg-cn-bg text-cn-fg shadow-[0_16px_40px_-12px_rgba(2,6,23,0.55)]" }, ve = { class: "sticky top-0 z-10 flex items-center justify-between border-b border-cn-line bg-cn-bg-elevated/95 px-3.5 py-2.5" }, ye = { class: "flex items-center gap-1" }, be = [
|
|
245
|
-
"aria-expanded",
|
|
246
|
-
"onClick",
|
|
247
|
-
"onKeydown"
|
|
248
|
-
], xe = ["onKeydown"], Se = {
|
|
249
|
-
key: 0,
|
|
250
|
-
class: "px-2 pb-1 text-[11px] text-cn-danger"
|
|
251
|
-
}, Ce = { class: "flex gap-1 p-1" }, we = ["onClick"], Te = ["onClick"], Ee = {
|
|
252
|
-
key: 0,
|
|
253
|
-
class: "mx-3.5 my-4 rounded-lg border border-dashed border-cn-line px-3 py-6 text-center text-[11px] leading-5 text-cn-muted"
|
|
254
|
-
}, De = [
|
|
255
|
-
"data-key",
|
|
256
|
-
"draggable",
|
|
257
|
-
"onClick",
|
|
258
|
-
"onMouseenter",
|
|
259
|
-
"onDragstart",
|
|
260
|
-
"onDragover",
|
|
261
|
-
"onDrop"
|
|
262
|
-
], Oe = ["onDragstart"], ke = ["title"], Ae = ["onDblclick"], je = [
|
|
263
|
-
"title",
|
|
264
|
-
"aria-pressed",
|
|
265
|
-
"onClick"
|
|
266
|
-
], Me = [
|
|
267
|
-
"title",
|
|
268
|
-
"aria-pressed",
|
|
269
|
-
"onClick"
|
|
270
|
-
], Ne = ["onClick"], Pe = [
|
|
271
|
-
"disabled",
|
|
272
|
-
"title",
|
|
273
|
-
"onClick"
|
|
274
|
-
], Fe = ["onClick"], Ie = ["onClick"], Le = [
|
|
275
|
-
"disabled",
|
|
276
|
-
"title",
|
|
277
|
-
"onClick"
|
|
278
|
-
], R = /* @__PURE__ */ u({
|
|
279
|
-
__name: "LayerPanel",
|
|
280
|
-
props: { editor: {} },
|
|
281
|
-
setup(e) {
|
|
282
|
-
let a = e, u = `解锁图层(${D("toggleLayerLock", E())})`, y = `图层已锁定(${D("toggleLayerLock", E())} 解锁后可删除)`, C = I(a.editor), T = S(!1), O = S(""), k = S(!1);
|
|
283
|
-
function A() {
|
|
284
|
-
T.value = !1, O.value = "", k.value = !1;
|
|
285
|
-
}
|
|
286
|
-
let j = g(() => T.value ? [] : P.map((e) => e.kind === "layer" ? {
|
|
287
|
-
label: e.label,
|
|
288
|
-
title: e.title,
|
|
289
|
-
dataAttrs: { "data-add-layer": e.type },
|
|
290
|
-
run: () => {
|
|
291
|
-
a.editor.armLayerCreate(e.type), oe().show(ae);
|
|
292
|
-
}
|
|
293
|
-
} : {
|
|
294
|
-
label: e.label,
|
|
295
|
-
title: e.title,
|
|
296
|
-
dataAttrs: { "data-add-layer": "template-table" },
|
|
297
|
-
keepsOpen: !0,
|
|
298
|
-
run: () => {
|
|
299
|
-
T.value = !0;
|
|
300
|
-
}
|
|
301
|
-
}));
|
|
302
|
-
function M(e) {
|
|
303
|
-
let t = O.value.trim();
|
|
304
|
-
if (t === "") {
|
|
305
|
-
k.value = !0;
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
a.editor.addTemplateTable(t), A(), e();
|
|
309
|
-
}
|
|
310
|
-
function N(e) {
|
|
311
|
-
A(), e();
|
|
312
|
-
}
|
|
313
|
-
function F() {
|
|
314
|
-
A();
|
|
315
|
-
}
|
|
316
|
-
let R = ue(a.editor), Re = g(() => se(R.value)), z = S(null), B = S(null), { popup: V, accept: ze } = ce({
|
|
317
|
-
target: z,
|
|
318
|
-
enabled: () => T.value,
|
|
319
|
-
resolve: (e) => Re.value?.(e) ?? null,
|
|
320
|
-
popupEl: g(() => B.value?.rootEl ?? null)
|
|
321
|
-
});
|
|
322
|
-
function Be(e, t) {
|
|
323
|
-
if (e.key === "Enter") {
|
|
324
|
-
if (V.open && V.items.length > 0) return;
|
|
325
|
-
e.preventDefault(), M(t);
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
e.key === "Escape" && V.open && e.stopPropagation();
|
|
329
|
-
}
|
|
330
|
-
function Ve(e, t) {
|
|
331
|
-
switch (e.role) {
|
|
332
|
-
case "root": return e.name === "" ? `${e.type} ${t}` : e.name;
|
|
333
|
-
case "row": return `行 ${Number(e.path[e.path.length - 1]) + 1}`;
|
|
334
|
-
case "templateRow": return "⌗ 行模板";
|
|
335
|
-
case "cell": return `格 ${Number(e.path[e.path.length - 1]) + 1}`;
|
|
336
|
-
case "content": return e.type;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
let H = g(() => {
|
|
340
|
-
let e = [], t = /* @__PURE__ */ new Map();
|
|
341
|
-
function n(r, i, a, o) {
|
|
342
|
-
let s = r.role === "row" ? r.path.slice(0, -2) : r.role === "templateRow" ? r.path.slice(0, -1) : o, c = 0;
|
|
343
|
-
r.role === "root" && (c = (t.get(r.type) ?? 0) + 1, t.set(r.type, c)), e.push({
|
|
344
|
-
key: r.path.join("."),
|
|
345
|
-
node: r,
|
|
346
|
-
indentLevel: i,
|
|
347
|
-
label: Ve(r, c),
|
|
348
|
-
indexInGroup: a,
|
|
349
|
-
tablePath: s,
|
|
350
|
-
inTemplate: _(r.path),
|
|
351
|
-
draggable: r.role === "root" || r.role === "row" || r.role === "cell"
|
|
352
|
-
}), r.children.forEach((e, t) => n(e, i + 1, t, s));
|
|
353
|
-
}
|
|
354
|
-
return C.outline.value.forEach((e, t) => n(e, 0, t, null)), e;
|
|
355
|
-
}), He = g(() => H.value.length > 0);
|
|
356
|
-
function Ue(e) {
|
|
357
|
-
a.editor.setSelection(e.node.path);
|
|
358
|
-
}
|
|
359
|
-
function U(e) {
|
|
360
|
-
a.editor.setHovered(e === null ? null : e.node.path);
|
|
361
|
-
}
|
|
362
|
-
function We(e) {
|
|
363
|
-
a.editor.addTableRow(e.node.path);
|
|
364
|
-
}
|
|
365
|
-
function Ge(e) {
|
|
366
|
-
a.editor.addTableCell(e.node.path);
|
|
367
|
-
}
|
|
368
|
-
function Ke(e) {
|
|
369
|
-
a.editor.addTemplateCell(e.node.path.slice(0, -1));
|
|
370
|
-
}
|
|
371
|
-
function qe(e) {
|
|
372
|
-
a.editor.deleteLayer(e.node.path);
|
|
373
|
-
}
|
|
374
|
-
function Je(e) {
|
|
375
|
-
a.editor.toggleLayerVisibility(e.node.path);
|
|
376
|
-
}
|
|
377
|
-
function Ye(e) {
|
|
378
|
-
a.editor.toggleLayerLock(e.node.path);
|
|
379
|
-
}
|
|
380
|
-
let W = S(null), G = S(null);
|
|
381
|
-
function K(e) {
|
|
382
|
-
let t = W.value;
|
|
383
|
-
if (!t) return !1;
|
|
384
|
-
if (t.kind === "root") return e.node.role === "root";
|
|
385
|
-
if (t.kind === "row") return e.node.role === "row";
|
|
386
|
-
if (e.node.role !== "cell") return !1;
|
|
387
|
-
let n = _(t.cellPath);
|
|
388
|
-
return n === e.inTemplate ? !n || p(t.cellPath.slice(0, -2), e.node.path.slice(0, -2)) : !1;
|
|
389
|
-
}
|
|
390
|
-
function q(e) {
|
|
391
|
-
return e.node.role === "root";
|
|
392
|
-
}
|
|
393
|
-
function J(e, t) {
|
|
394
|
-
e.draggable && (W.value = e.node.role === "root" ? {
|
|
395
|
-
kind: "root",
|
|
396
|
-
from: e.indexInGroup
|
|
397
|
-
} : e.node.role === "row" ? {
|
|
398
|
-
kind: "row",
|
|
399
|
-
from: e.indexInGroup,
|
|
400
|
-
tablePath: e.tablePath,
|
|
401
|
-
rowPath: e.node.path
|
|
402
|
-
} : {
|
|
403
|
-
kind: "cell",
|
|
404
|
-
from: e.indexInGroup,
|
|
405
|
-
cellPath: e.node.path
|
|
406
|
-
}, t.dataTransfer?.setData("text/plain", e.key), t.dataTransfer && (t.dataTransfer.effectAllowed = "move"));
|
|
407
|
-
}
|
|
408
|
-
function Xe(e, t) {
|
|
409
|
-
q(e) || J(e, t);
|
|
410
|
-
}
|
|
411
|
-
function Ze(e) {
|
|
412
|
-
if (!q(e)) return e.draggable || void 0;
|
|
413
|
-
}
|
|
414
|
-
function Qe(e, t) {
|
|
415
|
-
if (!K(e)) return;
|
|
416
|
-
let n = t.currentTarget.getBoundingClientRect(), r = L(t.clientY - n.top, n.height);
|
|
417
|
-
t.preventDefault(), G.value = {
|
|
418
|
-
key: e.key,
|
|
419
|
-
edge: r ? "before" : "after"
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
function $e(e, t) {
|
|
423
|
-
if (!K(e)) return;
|
|
424
|
-
let n = G.value, r = W.value;
|
|
425
|
-
if (!r || !n || n.key !== e.key) return;
|
|
426
|
-
t.preventDefault();
|
|
427
|
-
let i = n.edge === "before" ? e.indexInGroup : e.indexInGroup + 1;
|
|
428
|
-
r.kind === "root" ? a.editor.moveRootLayer(r.from, i) : r.kind === "row" ? e.tablePath !== null && e.tablePath.join(".") === r.tablePath.join(".") ? a.editor.moveTableRow(r.tablePath, r.from, i) : a.editor.moveTableRowToTable(r.rowPath, e.tablePath, i) : a.editor.moveTableCellToRow(r.cellPath, e.node.path.slice(0, -2), i), W.value = null, G.value = null;
|
|
429
|
-
}
|
|
430
|
-
function et() {
|
|
431
|
-
W.value = null, G.value = null;
|
|
432
|
-
}
|
|
433
|
-
function Y(e) {
|
|
434
|
-
return p(C.selection.value, e.node.path);
|
|
435
|
-
}
|
|
436
|
-
function tt(e) {
|
|
437
|
-
return p(C.hovered.value, e.node.path);
|
|
438
|
-
}
|
|
439
|
-
let X = S(""), Z = null, Q = null;
|
|
440
|
-
function nt(e) {
|
|
441
|
-
Q = e instanceof HTMLInputElement ? e : null;
|
|
442
|
-
}
|
|
443
|
-
function rt(e) {
|
|
444
|
-
return p(C.renaming.value, e.node.path);
|
|
445
|
-
}
|
|
446
|
-
function $(e) {
|
|
447
|
-
q(e) && a.editor.beginRename(e.node.path);
|
|
448
|
-
}
|
|
449
|
-
function it() {
|
|
450
|
-
let e = X.value.trim();
|
|
451
|
-
if (Z !== null && e === Z.trim()) {
|
|
452
|
-
a.editor.cancelRename();
|
|
453
|
-
return;
|
|
454
|
-
}
|
|
455
|
-
a.editor.commitRename(e);
|
|
456
|
-
}
|
|
457
|
-
function at() {
|
|
458
|
-
a.editor.cancelRename();
|
|
459
|
-
}
|
|
460
|
-
return o(C.renaming, async (e) => {
|
|
461
|
-
if (e === null) {
|
|
462
|
-
Z = null;
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
let t = H.value.find((t) => p(t.node.path, e));
|
|
466
|
-
X.value = t?.label ?? "", Z = X.value, await re();
|
|
467
|
-
let n = Q;
|
|
468
|
-
n && (n.focus({ preventScroll: !0 }), n.select());
|
|
469
|
-
}), (e, a) => (t(), l("aside", _e, [
|
|
470
|
-
h("header", ve, [a[9] ||= h("span", { class: "text-[12px] font-medium tracking-wide text-cn-fg/90" }, "图层", -1), h("div", ye, [x(le, {
|
|
471
|
-
label: "新增图层",
|
|
472
|
-
items: j.value,
|
|
473
|
-
onClosed: F
|
|
474
|
-
}, {
|
|
475
|
-
trigger: s(({ open: e, toggle: t, triggerRef: n, onKeydown: r }) => [h("button", {
|
|
476
|
-
ref: n,
|
|
477
|
-
type: "button",
|
|
478
|
-
"data-add-menu": "",
|
|
479
|
-
"aria-expanded": e,
|
|
480
|
-
"aria-haspopup": "menu",
|
|
481
|
-
title: "新增图层",
|
|
482
|
-
class: "flex size-6 items-center justify-center rounded border border-cn-field-line bg-cn-field text-[13px] leading-none text-cn-fg/80 hover:border-cn-accent/40 hover:text-cn-accent",
|
|
483
|
-
onClick: t,
|
|
484
|
-
onKeydown: r
|
|
485
|
-
}, " + ", 40, be)]),
|
|
486
|
-
body: s(({ closeMenu: e }) => [T.value ? (t(), l(d, { key: 0 }, [
|
|
487
|
-
a[8] ||= h("p", { class: "px-2 pt-1 text-[11px] leading-4 text-cn-muted" }, "模板行按数据行路径展开成表", -1),
|
|
488
|
-
n(h("input", {
|
|
489
|
-
ref_key: "rowsPathInputEl",
|
|
490
|
-
ref: z,
|
|
491
|
-
"onUpdate:modelValue": a[0] ||= (e) => O.value = e,
|
|
492
|
-
"data-template-rows-path": "",
|
|
493
|
-
type: "text",
|
|
494
|
-
placeholder: "如 order.items",
|
|
495
|
-
class: c(["mx-1 my-1 w-[calc(100%-8px)] rounded border bg-cn-field px-2 py-1 text-[12px] text-cn-fg outline-none focus:border-cn-accent/60", k.value ? "border-cn-danger" : "border-cn-field-line"]),
|
|
496
|
-
onKeydown: (t) => Be(t, e)
|
|
497
|
-
}, null, 42, xe), [[v, O.value]]),
|
|
498
|
-
k.value ? (t(), l("p", Se, "rowsPath 必填")) : f("", !0),
|
|
499
|
-
h("div", Ce, [h("button", {
|
|
500
|
-
type: "button",
|
|
501
|
-
"data-template-confirm": "",
|
|
502
|
-
class: "flex-1 rounded bg-cn-accent/20 px-2 py-1 text-[12px] text-cn-accent hover:bg-cn-accent/30",
|
|
503
|
-
onClick: (t) => M(e)
|
|
504
|
-
}, " 创建 ", 8, we), h("button", {
|
|
505
|
-
type: "button",
|
|
506
|
-
class: "flex-1 rounded px-2 py-1 text-[12px] text-cn-muted hover:text-cn-fg",
|
|
507
|
-
onClick: (t) => N(e)
|
|
508
|
-
}, " 取消 ", 8, Te)])
|
|
509
|
-
], 64)) : f("", !0)]),
|
|
510
|
-
_: 1
|
|
511
|
-
}, 8, ["items"]), T.value ? (t(), te(ie, {
|
|
512
|
-
key: 0,
|
|
513
|
-
ref_key: "pathPopupRef",
|
|
514
|
-
ref: B,
|
|
515
|
-
state: i(V),
|
|
516
|
-
onSelect: i(ze)
|
|
517
|
-
}, null, 8, ["state", "onSelect"])) : f("", !0)])]),
|
|
518
|
-
He.value ? f("", !0) : (t(), l("p", Ee, " 画布还没有图层,用上方按钮新增 ")),
|
|
519
|
-
h("ul", {
|
|
520
|
-
class: "cn-layers__tree flex flex-col gap-0.5 px-1.5 py-1",
|
|
521
|
-
onDragend: et
|
|
522
|
-
}, [(t(!0), l(d, null, ne(H.value, (e) => (t(), l("li", {
|
|
523
|
-
key: e.key,
|
|
524
|
-
"data-key": e.key,
|
|
525
|
-
draggable: Ze(e),
|
|
526
|
-
class: c(["cn-layers__row group flex cursor-default select-none items-center gap-1 py-1 pr-1 text-[12px]", {
|
|
527
|
-
"cn-layers__row--selected": Y(e),
|
|
528
|
-
"cn-layers__row--hovered": tt(e) && !Y(e),
|
|
529
|
-
"cn-layers__row--hidden": q(e) && !e.node.visible,
|
|
530
|
-
"cn-layers__row--template": e.inTemplate,
|
|
531
|
-
"cursor-grab": e.draggable && !q(e),
|
|
532
|
-
"cn-layers__row--drop-before": G.value?.key === e.key && G.value?.edge === "before",
|
|
533
|
-
"cn-layers__row--drop-after": G.value?.key === e.key && G.value?.edge === "after"
|
|
534
|
-
}]),
|
|
535
|
-
style: ee({ paddingLeft: `${4 + e.indentLevel * 14}px` }),
|
|
536
|
-
onClick: (t) => Ue(e),
|
|
537
|
-
onMouseenter: (t) => U(e),
|
|
538
|
-
onMouseleave: a[7] ||= (e) => U(null),
|
|
539
|
-
onDragstart: (t) => Xe(e, t),
|
|
540
|
-
onDragover: (t) => Qe(e, t),
|
|
541
|
-
onDrop: (t) => $e(e, t)
|
|
542
|
-
}, [
|
|
543
|
-
q(e) ? (t(), l("span", {
|
|
544
|
-
key: 0,
|
|
545
|
-
"data-drag-handle": "",
|
|
546
|
-
draggable: "true",
|
|
547
|
-
title: "拖动排序",
|
|
548
|
-
class: "cn-layers__handle shrink-0",
|
|
549
|
-
onDragstart: (t) => J(e, t)
|
|
550
|
-
}, [x(w, {
|
|
551
|
-
icon: i(pe),
|
|
552
|
-
size: 12,
|
|
553
|
-
"stroke-width": 2.5
|
|
554
|
-
}, null, 8, ["icon"])], 40, Oe)) : f("", !0),
|
|
555
|
-
e.node.expressionPrefix === "" ? f("", !0) : (t(), l("span", {
|
|
556
|
-
key: 1,
|
|
557
|
-
class: "cn-layers__prefix",
|
|
558
|
-
title: e.node.expressionPrefix
|
|
559
|
-
}, r(e.node.expressionPrefix), 9, ke)),
|
|
560
|
-
rt(e) ? n((t(), l("input", {
|
|
561
|
-
key: 2,
|
|
562
|
-
ref_for: !0,
|
|
563
|
-
ref: nt,
|
|
564
|
-
"onUpdate:modelValue": a[1] ||= (e) => X.value = e,
|
|
565
|
-
"data-rename-input": "",
|
|
566
|
-
"aria-label": "图层重命名",
|
|
567
|
-
class: "cn-layers__rename-input min-w-0 flex-1",
|
|
568
|
-
onClick: a[2] ||= b(() => {}, ["stop"]),
|
|
569
|
-
onDblclick: a[3] ||= b(() => {}, ["stop"]),
|
|
570
|
-
onKeydown: [a[4] ||= m(b((e) => it(), ["prevent"]), ["enter"]), a[5] ||= m(b((e) => at(), ["prevent"]), ["esc"])],
|
|
571
|
-
onBlur: a[6] ||= (e) => it()
|
|
572
|
-
}, null, 544)), [[v, X.value]]) : (t(), l("span", {
|
|
573
|
-
key: 3,
|
|
574
|
-
class: "cn-layers__label min-w-0 flex-1 truncate font-mono text-[11px] leading-4",
|
|
575
|
-
onDblclick: (t) => $(e)
|
|
576
|
-
}, r(e.label), 41, Ae)),
|
|
577
|
-
q(e) ? (t(), l("button", {
|
|
578
|
-
key: 4,
|
|
579
|
-
type: "button",
|
|
580
|
-
"data-visibility": "",
|
|
581
|
-
class: c(["cn-layers__eye size-5 shrink-0 items-center justify-center rounded text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent", e.node.visible ? "hidden group-hover:flex" : "flex"]),
|
|
582
|
-
title: e.node.visible ? "隐藏图层(最终输出不含该层)" : "显示图层",
|
|
583
|
-
"aria-pressed": !e.node.visible,
|
|
584
|
-
onClick: b((t) => Je(e), ["stop"])
|
|
585
|
-
}, [x(w, {
|
|
586
|
-
icon: e.node.visible ? i(fe) : i(de),
|
|
587
|
-
size: 11,
|
|
588
|
-
"stroke-width": 2
|
|
589
|
-
}, null, 8, ["icon"])], 10, je)) : f("", !0),
|
|
590
|
-
q(e) ? (t(), l("button", {
|
|
591
|
-
key: 5,
|
|
592
|
-
type: "button",
|
|
593
|
-
"data-lock": "",
|
|
594
|
-
class: c(["cn-layers__lock size-5 shrink-0 items-center justify-center rounded text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent", e.node.locked ? "flex" : "hidden group-hover:flex"]),
|
|
595
|
-
title: e.node.locked ? u : "锁定图层(画布不可点选/拖动/删除,渲染照常)",
|
|
596
|
-
"aria-pressed": e.node.locked,
|
|
597
|
-
onClick: b((t) => Ye(e), ["stop"])
|
|
598
|
-
}, [x(w, {
|
|
599
|
-
icon: e.node.locked ? i(he) : i(me),
|
|
600
|
-
size: 11,
|
|
601
|
-
"stroke-width": 2
|
|
602
|
-
}, null, 8, ["icon"])], 10, Me)) : f("", !0),
|
|
603
|
-
q(e) ? (t(), l("button", {
|
|
604
|
-
key: 6,
|
|
605
|
-
type: "button",
|
|
606
|
-
"data-rename": "",
|
|
607
|
-
class: "cn-layers__delete hidden size-5 shrink-0 items-center justify-center rounded text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent group-hover:flex",
|
|
608
|
-
title: "重命名(双击名称或 F2)",
|
|
609
|
-
onClick: b((t) => $(e), ["stop"])
|
|
610
|
-
}, [x(w, {
|
|
611
|
-
icon: i(ge),
|
|
612
|
-
size: 11,
|
|
613
|
-
"stroke-width": 2
|
|
614
|
-
}, null, 8, ["icon"])], 8, Ne)) : f("", !0),
|
|
615
|
-
e.node.role === "root" && e.node.type === "TableLayer" ? (t(), l("button", {
|
|
616
|
-
key: 7,
|
|
617
|
-
type: "button",
|
|
618
|
-
"data-add-row": "",
|
|
619
|
-
class: "cn-layers__delete hidden size-5 shrink-0 items-center justify-center rounded text-[10px] leading-none text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent group-hover:flex disabled:cursor-not-allowed disabled:text-cn-muted/50 disabled:hover:bg-transparent",
|
|
620
|
-
disabled: e.node.templated === !0,
|
|
621
|
-
title: e.node.templated === !0 ? "模板态不可加行——行由数据展开" : "加行(缺省行 + 缺省格与文本,行宽=表宽)",
|
|
622
|
-
onClick: b((t) => We(e), ["stop"])
|
|
623
|
-
}, " +行 ", 8, Pe)) : f("", !0),
|
|
624
|
-
e.node.role === "row" ? (t(), l("button", {
|
|
625
|
-
key: 8,
|
|
626
|
-
type: "button",
|
|
627
|
-
"data-add-cell": "",
|
|
628
|
-
class: "cn-layers__delete hidden size-5 shrink-0 items-center justify-center rounded text-[10px] leading-none text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent group-hover:flex",
|
|
629
|
-
title: "加格(缺省格 + 文本内容,行高取最高格)",
|
|
630
|
-
onClick: b((t) => Ge(e), ["stop"])
|
|
631
|
-
}, " +格 ", 8, Fe)) : f("", !0),
|
|
632
|
-
e.node.role === "templateRow" ? (t(), l("button", {
|
|
633
|
-
key: 9,
|
|
634
|
-
type: "button",
|
|
635
|
-
"data-add-template-cell": "",
|
|
636
|
-
class: "cn-layers__delete hidden size-5 shrink-0 items-center justify-center rounded text-[10px] leading-none text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent group-hover:flex",
|
|
637
|
-
title: "加格(缺省格 + 文本内容,零高度耦合——行高由数据展开定稿)",
|
|
638
|
-
onClick: b((t) => Ke(e), ["stop"])
|
|
639
|
-
}, " +格 ", 8, Ie)) : f("", !0),
|
|
640
|
-
h("button", {
|
|
641
|
-
type: "button",
|
|
642
|
-
class: "cn-layers__delete hidden size-5 shrink-0 items-center justify-center rounded text-[10px] leading-none text-cn-muted hover:bg-cn-danger/15 hover:text-cn-danger group-hover:flex disabled:cursor-not-allowed disabled:text-cn-muted/50 disabled:hover:bg-transparent disabled:hover:text-cn-muted/50",
|
|
643
|
-
disabled: e.node.role === "templateRow" || e.node.locked,
|
|
644
|
-
title: e.node.role === "templateRow" ? "行模板由表持有——转换回普通表请用 V2 转换入口" : e.node.locked ? y : "删除(含子层)",
|
|
645
|
-
onClick: b((t) => qe(e), ["stop"])
|
|
646
|
-
}, " ✕ ", 8, Le)
|
|
647
|
-
], 46, De))), 128))], 32)
|
|
648
|
-
]));
|
|
649
|
-
}
|
|
650
|
-
});
|
|
651
|
-
//#endregion
|
|
652
|
-
export { P as a, F as i, L as n, I as r, R as t };
|