@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
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
import { i as e, r as t, t as n } from "./layerPath-uy2ywyld.js";
|
|
2
|
+
import { i as r, o as i, r as a } from "./completionAnchor-CDR5YZhu.js";
|
|
3
|
+
import { o, r as s, s as c, t as l } from "./useTransientFeedback-Cnp6aNB7.js";
|
|
4
|
+
import { n as ee, t as te } from "./usePathCompletion-uJ5c_gQ0.js";
|
|
5
|
+
import { n as ne, t as re } from "./useDataSourceSchema-DStVoY8Z.js";
|
|
6
|
+
import { Fragment as u, computed as d, createBlock as ie, createCommentVNode as f, createElementBlock as p, createElementVNode as m, createVNode as h, defineComponent as g, nextTick as ae, normalizeClass as _, normalizeStyle as oe, onScopeDispose as v, openBlock as y, ref as b, renderList as se, shallowRef as x, toDisplayString as S, unref as C, vModelText as w, watch as ce, withCtx as T, withDirectives as E, withKeys as D, withModifiers as O } from "vue";
|
|
7
|
+
import { Eye as le, EyeOff as ue, GripVertical as de, Lock as fe, LockOpen as pe, Pencil as me } from "@lucide/vue";
|
|
8
|
+
//#region ../canvas-editor/src/editing/layerPanel.ts
|
|
9
|
+
function k(e) {
|
|
10
|
+
switch (e.type) {
|
|
11
|
+
case "TableLayer": return e.template === null ? [{
|
|
12
|
+
key: "rows",
|
|
13
|
+
layers: e.rows
|
|
14
|
+
}] : [{
|
|
15
|
+
key: "template",
|
|
16
|
+
layers: [e.template]
|
|
17
|
+
}];
|
|
18
|
+
case "TableRowLayer": return [{
|
|
19
|
+
key: "cells",
|
|
20
|
+
layers: e.cells
|
|
21
|
+
}];
|
|
22
|
+
case "TableCellLayer": return e.content ? [{
|
|
23
|
+
key: "content",
|
|
24
|
+
layers: [e.content]
|
|
25
|
+
}] : [];
|
|
26
|
+
case "ImageLayer":
|
|
27
|
+
case "TextLayer":
|
|
28
|
+
case "QrCodeLayer": return [];
|
|
29
|
+
case "TableRowTemplate": return [{
|
|
30
|
+
key: "cells",
|
|
31
|
+
layers: e.cells
|
|
32
|
+
}];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function A(e) {
|
|
36
|
+
switch (e.type) {
|
|
37
|
+
case "TextLayer":
|
|
38
|
+
case "ImageLayer":
|
|
39
|
+
case "QrCodeLayer": return e.expression;
|
|
40
|
+
default: return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
var j = "{{…}}";
|
|
44
|
+
function M(e) {
|
|
45
|
+
let t = A(e);
|
|
46
|
+
if (t === null) return "";
|
|
47
|
+
let n = i(t).parts.flatMap((e) => e.kind === "fragment" && e.expr !== "" ? [e.expr] : []);
|
|
48
|
+
return n.length === 0 ? j : n.map((e) => `{{${e}}}`).join(" ");
|
|
49
|
+
}
|
|
50
|
+
function N(e, t, r, i) {
|
|
51
|
+
let a = [];
|
|
52
|
+
for (let { key: n, layers: r } of k(e)) for (let e = 0; e < r.length; e += 1) {
|
|
53
|
+
let o = n === "rows" ? "row" : n === "cells" ? "cell" : n === "template" ? "templateRow" : "content", s = n === "content" ? [...t, "content"] : n === "template" ? [...t, "template"] : [
|
|
54
|
+
...t,
|
|
55
|
+
n,
|
|
56
|
+
e
|
|
57
|
+
];
|
|
58
|
+
a.push(N(r[e], s, o, i));
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
type: e.type,
|
|
62
|
+
path: t,
|
|
63
|
+
role: r,
|
|
64
|
+
name: e.name,
|
|
65
|
+
visible: e.visible,
|
|
66
|
+
locked: n(t, i),
|
|
67
|
+
expressionPrefix: M(e),
|
|
68
|
+
...e.type === "TableLayer" ? { templated: e.template !== null } : null,
|
|
69
|
+
children: a
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function P(e, t = []) {
|
|
73
|
+
let n = [];
|
|
74
|
+
for (let r = e.layers.length - 1; r >= 0; --r) n.push(N(e.layers[r], ["layers", r], "root", t));
|
|
75
|
+
return n;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/layer-panel/addMenu.ts
|
|
79
|
+
var F = [
|
|
80
|
+
{
|
|
81
|
+
kind: "layer",
|
|
82
|
+
type: "TextLayer",
|
|
83
|
+
label: "文本层",
|
|
84
|
+
title: "画拉建文本层(点击后在画布拖拽定落位与尺寸,Esc 取消)"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
kind: "layer",
|
|
88
|
+
type: "ImageLayer",
|
|
89
|
+
label: "图片层",
|
|
90
|
+
title: "画拉建图片层(点击后在画布拖拽定落位与尺寸,Esc 取消)"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
kind: "layer",
|
|
94
|
+
type: "QrCodeLayer",
|
|
95
|
+
label: "二维码层",
|
|
96
|
+
title: "画拉建二维码层(点击后在画布拖拽定落位与尺寸,恒方形,Esc 取消)"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
kind: "layer",
|
|
100
|
+
type: "TableLayer",
|
|
101
|
+
label: "表格",
|
|
102
|
+
title: "画拉建表格(点击后在画布拖拽定落位与尺寸,Esc 取消)"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
kind: "template-table",
|
|
106
|
+
label: "模板表",
|
|
107
|
+
title: "新增模板表(行模板 + 数据行展开)"
|
|
108
|
+
}
|
|
109
|
+
], I = F.filter((e) => e.kind === "layer");
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/layer-panel/useLayerPanel.ts
|
|
112
|
+
function L(e) {
|
|
113
|
+
let t = x(e.store.doc), n = x(e.store.ui.selection), r = x(e.store.ui.hovered), i = x(e.store.ui.renaming), a = x(e.store.ui.lockedPaths), o = e.subscribe((o) => {
|
|
114
|
+
o.scope === "doc" ? (t.value = e.store.doc, n.value = e.store.ui.selection, r.value = e.store.ui.hovered, i.value = e.store.ui.renaming, a.value = e.store.ui.lockedPaths) : o.branch === "selection" ? n.value = e.store.ui.selection : o.branch === "hovered" ? r.value = e.store.ui.hovered : o.branch === "renaming" ? i.value = e.store.ui.renaming : o.branch === "lockedPaths" && (a.value = e.store.ui.lockedPaths);
|
|
115
|
+
});
|
|
116
|
+
return v(o, !0), {
|
|
117
|
+
outline: d(() => t.value ? P(t.value, a.value) : []),
|
|
118
|
+
selection: d(() => n.value),
|
|
119
|
+
hovered: d(() => r.value),
|
|
120
|
+
renaming: d(() => i.value)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function R(e, t) {
|
|
124
|
+
return t > 0 && e < t / 2;
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/layer-panel/LayerPanel.vue?vue&type=script&setup=true&lang.ts
|
|
128
|
+
var he = { 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)]" }, ge = { 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" }, _e = { class: "flex items-center gap-1" }, ve = [
|
|
129
|
+
"aria-expanded",
|
|
130
|
+
"onClick",
|
|
131
|
+
"onKeydown"
|
|
132
|
+
], ye = ["onKeydown"], be = {
|
|
133
|
+
key: 0,
|
|
134
|
+
class: "px-2 pb-1 text-[11px] text-cn-danger"
|
|
135
|
+
}, xe = { class: "flex gap-1 p-1" }, Se = ["onClick"], Ce = ["onClick"], we = {
|
|
136
|
+
key: 0,
|
|
137
|
+
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"
|
|
138
|
+
}, Te = [
|
|
139
|
+
"data-key",
|
|
140
|
+
"draggable",
|
|
141
|
+
"onClick",
|
|
142
|
+
"onMouseenter",
|
|
143
|
+
"onDragstart",
|
|
144
|
+
"onDragover",
|
|
145
|
+
"onDrop"
|
|
146
|
+
], Ee = ["onDragstart"], De = ["title"], Oe = ["onDblclick"], ke = [
|
|
147
|
+
"title",
|
|
148
|
+
"aria-pressed",
|
|
149
|
+
"onClick"
|
|
150
|
+
], Ae = [
|
|
151
|
+
"title",
|
|
152
|
+
"aria-pressed",
|
|
153
|
+
"onClick"
|
|
154
|
+
], je = ["onClick"], Me = [
|
|
155
|
+
"disabled",
|
|
156
|
+
"title",
|
|
157
|
+
"onClick"
|
|
158
|
+
], Ne = ["onClick"], Pe = ["onClick"], Fe = [
|
|
159
|
+
"disabled",
|
|
160
|
+
"title",
|
|
161
|
+
"onClick"
|
|
162
|
+
], z = /* @__PURE__ */ g({
|
|
163
|
+
__name: "LayerPanel",
|
|
164
|
+
props: { editor: {} },
|
|
165
|
+
setup(n) {
|
|
166
|
+
let i = n, g = `解锁图层(${c("toggleLayerLock", o())})`, v = `图层已锁定(${c("toggleLayerLock", o())} 解锁后可删除)`, x = L(i.editor), k = b(!1), A = b(""), j = b(!1);
|
|
167
|
+
function M() {
|
|
168
|
+
k.value = !1, A.value = "", j.value = !1;
|
|
169
|
+
}
|
|
170
|
+
let N = d(() => k.value ? [] : F.map((e) => e.kind === "layer" ? {
|
|
171
|
+
label: e.label,
|
|
172
|
+
title: e.title,
|
|
173
|
+
dataAttrs: { "data-add-layer": e.type },
|
|
174
|
+
run: () => {
|
|
175
|
+
i.editor.armLayerCreate(e.type), l().show(s);
|
|
176
|
+
}
|
|
177
|
+
} : {
|
|
178
|
+
label: e.label,
|
|
179
|
+
title: e.title,
|
|
180
|
+
dataAttrs: { "data-add-layer": "template-table" },
|
|
181
|
+
keepsOpen: !0,
|
|
182
|
+
run: () => {
|
|
183
|
+
k.value = !0;
|
|
184
|
+
}
|
|
185
|
+
}));
|
|
186
|
+
function P(e) {
|
|
187
|
+
let t = A.value.trim();
|
|
188
|
+
if (t === "") {
|
|
189
|
+
j.value = !0;
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
i.editor.addTemplateTable(t), M(), e();
|
|
193
|
+
}
|
|
194
|
+
function I(e) {
|
|
195
|
+
M(), e();
|
|
196
|
+
}
|
|
197
|
+
function z() {
|
|
198
|
+
M();
|
|
199
|
+
}
|
|
200
|
+
let Ie = re(i.editor), Le = d(() => ee(Ie.value)), B = b(null), V = b(null), { popup: H, accept: Re } = te({
|
|
201
|
+
target: B,
|
|
202
|
+
enabled: () => k.value,
|
|
203
|
+
resolve: (e) => Le.value?.(e) ?? null,
|
|
204
|
+
popupEl: d(() => V.value?.rootEl ?? null)
|
|
205
|
+
});
|
|
206
|
+
function ze(e, t) {
|
|
207
|
+
if (e.key === "Enter") {
|
|
208
|
+
if (H.open && H.items.length > 0) return;
|
|
209
|
+
e.preventDefault(), P(t);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
e.key === "Escape" && H.open && e.stopPropagation();
|
|
213
|
+
}
|
|
214
|
+
function Be(e, t) {
|
|
215
|
+
switch (e.role) {
|
|
216
|
+
case "root": return e.name === "" ? `${e.type} ${t}` : e.name;
|
|
217
|
+
case "row": return `行 ${Number(e.path[e.path.length - 1]) + 1}`;
|
|
218
|
+
case "templateRow": return "⌗ 行模板";
|
|
219
|
+
case "cell": return `格 ${Number(e.path[e.path.length - 1]) + 1}`;
|
|
220
|
+
case "content": return e.type;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
let U = d(() => {
|
|
224
|
+
let e = [], n = /* @__PURE__ */ new Map();
|
|
225
|
+
function r(i, a, o, s) {
|
|
226
|
+
let c = i.role === "row" ? i.path.slice(0, -2) : i.role === "templateRow" ? i.path.slice(0, -1) : s, l = 0;
|
|
227
|
+
i.role === "root" && (l = (n.get(i.type) ?? 0) + 1, n.set(i.type, l)), e.push({
|
|
228
|
+
key: i.path.join("."),
|
|
229
|
+
node: i,
|
|
230
|
+
indentLevel: a,
|
|
231
|
+
label: Be(i, l),
|
|
232
|
+
indexInGroup: o,
|
|
233
|
+
tablePath: c,
|
|
234
|
+
inTemplate: t(i.path),
|
|
235
|
+
draggable: i.role === "root" || i.role === "row" || i.role === "cell"
|
|
236
|
+
}), i.children.forEach((e, t) => r(e, a + 1, t, c));
|
|
237
|
+
}
|
|
238
|
+
return x.outline.value.forEach((e, t) => r(e, 0, t, null)), e;
|
|
239
|
+
}), Ve = d(() => U.value.length > 0);
|
|
240
|
+
function He(e) {
|
|
241
|
+
i.editor.setSelection(e.node.path);
|
|
242
|
+
}
|
|
243
|
+
function W(e) {
|
|
244
|
+
i.editor.setHovered(e === null ? null : e.node.path);
|
|
245
|
+
}
|
|
246
|
+
function Ue(e) {
|
|
247
|
+
i.editor.addTableRow(e.node.path);
|
|
248
|
+
}
|
|
249
|
+
function We(e) {
|
|
250
|
+
i.editor.addTableCell(e.node.path);
|
|
251
|
+
}
|
|
252
|
+
function Ge(e) {
|
|
253
|
+
i.editor.addTemplateCell(e.node.path.slice(0, -1));
|
|
254
|
+
}
|
|
255
|
+
function Ke(e) {
|
|
256
|
+
i.editor.deleteLayer(e.node.path);
|
|
257
|
+
}
|
|
258
|
+
function qe(e) {
|
|
259
|
+
i.editor.toggleLayerVisibility(e.node.path);
|
|
260
|
+
}
|
|
261
|
+
function Je(e) {
|
|
262
|
+
i.editor.toggleLayerLock(e.node.path);
|
|
263
|
+
}
|
|
264
|
+
let G = b(null), K = b(null);
|
|
265
|
+
function q(n) {
|
|
266
|
+
let r = G.value;
|
|
267
|
+
if (!r) return !1;
|
|
268
|
+
if (r.kind === "root") return n.node.role === "root";
|
|
269
|
+
if (r.kind === "row") return n.node.role === "row";
|
|
270
|
+
if (n.node.role !== "cell") return !1;
|
|
271
|
+
let i = t(r.cellPath);
|
|
272
|
+
return i === n.inTemplate ? !i || e(r.cellPath.slice(0, -2), n.node.path.slice(0, -2)) : !1;
|
|
273
|
+
}
|
|
274
|
+
function J(e) {
|
|
275
|
+
return e.node.role === "root";
|
|
276
|
+
}
|
|
277
|
+
function Y(e, t) {
|
|
278
|
+
e.draggable && (G.value = e.node.role === "root" ? {
|
|
279
|
+
kind: "root",
|
|
280
|
+
from: e.indexInGroup
|
|
281
|
+
} : e.node.role === "row" ? {
|
|
282
|
+
kind: "row",
|
|
283
|
+
from: e.indexInGroup,
|
|
284
|
+
tablePath: e.tablePath,
|
|
285
|
+
rowPath: e.node.path
|
|
286
|
+
} : {
|
|
287
|
+
kind: "cell",
|
|
288
|
+
from: e.indexInGroup,
|
|
289
|
+
cellPath: e.node.path
|
|
290
|
+
}, t.dataTransfer?.setData("text/plain", e.key), t.dataTransfer && (t.dataTransfer.effectAllowed = "move"));
|
|
291
|
+
}
|
|
292
|
+
function Ye(e, t) {
|
|
293
|
+
J(e) || Y(e, t);
|
|
294
|
+
}
|
|
295
|
+
function Xe(e) {
|
|
296
|
+
if (!J(e)) return e.draggable || void 0;
|
|
297
|
+
}
|
|
298
|
+
function Ze(e, t) {
|
|
299
|
+
if (!q(e)) return;
|
|
300
|
+
let n = t.currentTarget.getBoundingClientRect(), r = R(t.clientY - n.top, n.height);
|
|
301
|
+
t.preventDefault(), K.value = {
|
|
302
|
+
key: e.key,
|
|
303
|
+
edge: r ? "before" : "after"
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function Qe(e, t) {
|
|
307
|
+
if (!q(e)) return;
|
|
308
|
+
let n = K.value, r = G.value;
|
|
309
|
+
if (!r || !n || n.key !== e.key) return;
|
|
310
|
+
t.preventDefault();
|
|
311
|
+
let a = n.edge === "before" ? e.indexInGroup : e.indexInGroup + 1;
|
|
312
|
+
r.kind === "root" ? i.editor.moveRootLayer(r.from, a) : r.kind === "row" ? e.tablePath !== null && e.tablePath.join(".") === r.tablePath.join(".") ? i.editor.moveTableRow(r.tablePath, r.from, a) : i.editor.moveTableRowToTable(r.rowPath, e.tablePath, a) : i.editor.moveTableCellToRow(r.cellPath, e.node.path.slice(0, -2), a), G.value = null, K.value = null;
|
|
313
|
+
}
|
|
314
|
+
function $e() {
|
|
315
|
+
G.value = null, K.value = null;
|
|
316
|
+
}
|
|
317
|
+
function X(t) {
|
|
318
|
+
return e(x.selection.value, t.node.path);
|
|
319
|
+
}
|
|
320
|
+
function et(t) {
|
|
321
|
+
return e(x.hovered.value, t.node.path);
|
|
322
|
+
}
|
|
323
|
+
let Z = b(""), Q = null, $ = null;
|
|
324
|
+
function tt(e) {
|
|
325
|
+
$ = e instanceof HTMLInputElement ? e : null;
|
|
326
|
+
}
|
|
327
|
+
function nt(t) {
|
|
328
|
+
return e(x.renaming.value, t.node.path);
|
|
329
|
+
}
|
|
330
|
+
function rt(e) {
|
|
331
|
+
J(e) && i.editor.beginRename(e.node.path);
|
|
332
|
+
}
|
|
333
|
+
function it() {
|
|
334
|
+
let e = Z.value.trim();
|
|
335
|
+
if (Q !== null && e === Q.trim()) {
|
|
336
|
+
i.editor.cancelRename();
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
i.editor.commitRename(e);
|
|
340
|
+
}
|
|
341
|
+
function at() {
|
|
342
|
+
i.editor.cancelRename();
|
|
343
|
+
}
|
|
344
|
+
return ce(x.renaming, async (t) => {
|
|
345
|
+
if (t === null) {
|
|
346
|
+
Q = null;
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
let n = U.value.find((n) => e(n.node.path, t));
|
|
350
|
+
Z.value = n?.label ?? "", Q = Z.value, await ae();
|
|
351
|
+
let r = $;
|
|
352
|
+
r && (r.focus({ preventScroll: !0 }), r.select());
|
|
353
|
+
}), (e, t) => (y(), p("aside", he, [
|
|
354
|
+
m("header", ge, [t[9] ||= m("span", { class: "text-[12px] font-medium tracking-wide text-cn-fg/90" }, "图层", -1), m("div", _e, [h(ne, {
|
|
355
|
+
label: "新增图层",
|
|
356
|
+
items: N.value,
|
|
357
|
+
onClosed: z
|
|
358
|
+
}, {
|
|
359
|
+
trigger: T(({ open: e, toggle: t, triggerRef: n, onKeydown: r }) => [m("button", {
|
|
360
|
+
ref: n,
|
|
361
|
+
type: "button",
|
|
362
|
+
"data-add-menu": "",
|
|
363
|
+
"aria-expanded": e,
|
|
364
|
+
"aria-haspopup": "menu",
|
|
365
|
+
title: "新增图层",
|
|
366
|
+
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",
|
|
367
|
+
onClick: t,
|
|
368
|
+
onKeydown: r
|
|
369
|
+
}, " + ", 40, ve)]),
|
|
370
|
+
body: T(({ closeMenu: e }) => [k.value ? (y(), p(u, { key: 0 }, [
|
|
371
|
+
t[8] ||= m("p", { class: "px-2 pt-1 text-[11px] leading-4 text-cn-muted" }, "模板行按数据行路径展开成表", -1),
|
|
372
|
+
E(m("input", {
|
|
373
|
+
ref_key: "rowsPathInputEl",
|
|
374
|
+
ref: B,
|
|
375
|
+
"onUpdate:modelValue": t[0] ||= (e) => A.value = e,
|
|
376
|
+
"data-template-rows-path": "",
|
|
377
|
+
type: "text",
|
|
378
|
+
placeholder: "如 order.items",
|
|
379
|
+
class: _(["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", j.value ? "border-cn-danger" : "border-cn-field-line"]),
|
|
380
|
+
onKeydown: (t) => ze(t, e)
|
|
381
|
+
}, null, 42, ye), [[w, A.value]]),
|
|
382
|
+
j.value ? (y(), p("p", be, "rowsPath 必填")) : f("", !0),
|
|
383
|
+
m("div", xe, [m("button", {
|
|
384
|
+
type: "button",
|
|
385
|
+
"data-template-confirm": "",
|
|
386
|
+
class: "flex-1 rounded bg-cn-accent/20 px-2 py-1 text-[12px] text-cn-accent hover:bg-cn-accent/30",
|
|
387
|
+
onClick: (t) => P(e)
|
|
388
|
+
}, " 创建 ", 8, Se), m("button", {
|
|
389
|
+
type: "button",
|
|
390
|
+
class: "flex-1 rounded px-2 py-1 text-[12px] text-cn-muted hover:text-cn-fg",
|
|
391
|
+
onClick: (t) => I(e)
|
|
392
|
+
}, " 取消 ", 8, Ce)])
|
|
393
|
+
], 64)) : f("", !0)]),
|
|
394
|
+
_: 1
|
|
395
|
+
}, 8, ["items"]), k.value ? (y(), ie(a, {
|
|
396
|
+
key: 0,
|
|
397
|
+
ref_key: "pathPopupRef",
|
|
398
|
+
ref: V,
|
|
399
|
+
state: C(H),
|
|
400
|
+
onSelect: C(Re)
|
|
401
|
+
}, null, 8, ["state", "onSelect"])) : f("", !0)])]),
|
|
402
|
+
Ve.value ? f("", !0) : (y(), p("p", we, " 画布还没有图层,用上方按钮新增 ")),
|
|
403
|
+
m("ul", {
|
|
404
|
+
class: "cn-layers__tree flex flex-col gap-0.5 px-1.5 py-1",
|
|
405
|
+
onDragend: $e
|
|
406
|
+
}, [(y(!0), p(u, null, se(U.value, (e) => (y(), p("li", {
|
|
407
|
+
key: e.key,
|
|
408
|
+
"data-key": e.key,
|
|
409
|
+
draggable: Xe(e),
|
|
410
|
+
class: _(["cn-layers__row group flex cursor-default select-none items-center gap-1 py-1 pr-1 text-[12px]", {
|
|
411
|
+
"cn-layers__row--selected": X(e),
|
|
412
|
+
"cn-layers__row--hovered": et(e) && !X(e),
|
|
413
|
+
"cn-layers__row--hidden": J(e) && !e.node.visible,
|
|
414
|
+
"cn-layers__row--template": e.inTemplate,
|
|
415
|
+
"cursor-grab": e.draggable && !J(e),
|
|
416
|
+
"cn-layers__row--drop-before": K.value?.key === e.key && K.value?.edge === "before",
|
|
417
|
+
"cn-layers__row--drop-after": K.value?.key === e.key && K.value?.edge === "after"
|
|
418
|
+
}]),
|
|
419
|
+
style: oe({ paddingLeft: `${4 + e.indentLevel * 14}px` }),
|
|
420
|
+
onClick: (t) => He(e),
|
|
421
|
+
onMouseenter: (t) => W(e),
|
|
422
|
+
onMouseleave: t[7] ||= (e) => W(null),
|
|
423
|
+
onDragstart: (t) => Ye(e, t),
|
|
424
|
+
onDragover: (t) => Ze(e, t),
|
|
425
|
+
onDrop: (t) => Qe(e, t)
|
|
426
|
+
}, [
|
|
427
|
+
J(e) ? (y(), p("span", {
|
|
428
|
+
key: 0,
|
|
429
|
+
"data-drag-handle": "",
|
|
430
|
+
draggable: "true",
|
|
431
|
+
title: "拖动排序",
|
|
432
|
+
class: "cn-layers__handle shrink-0",
|
|
433
|
+
onDragstart: (t) => Y(e, t)
|
|
434
|
+
}, [h(r, {
|
|
435
|
+
icon: C(de),
|
|
436
|
+
size: 12,
|
|
437
|
+
"stroke-width": 2.5
|
|
438
|
+
}, null, 8, ["icon"])], 40, Ee)) : f("", !0),
|
|
439
|
+
e.node.expressionPrefix === "" ? f("", !0) : (y(), p("span", {
|
|
440
|
+
key: 1,
|
|
441
|
+
class: "cn-layers__prefix",
|
|
442
|
+
title: e.node.expressionPrefix
|
|
443
|
+
}, S(e.node.expressionPrefix), 9, De)),
|
|
444
|
+
nt(e) ? E((y(), p("input", {
|
|
445
|
+
key: 2,
|
|
446
|
+
ref_for: !0,
|
|
447
|
+
ref: tt,
|
|
448
|
+
"onUpdate:modelValue": t[1] ||= (e) => Z.value = e,
|
|
449
|
+
"data-rename-input": "",
|
|
450
|
+
"aria-label": "图层重命名",
|
|
451
|
+
class: "cn-layers__rename-input min-w-0 flex-1",
|
|
452
|
+
onClick: t[2] ||= O(() => {}, ["stop"]),
|
|
453
|
+
onDblclick: t[3] ||= O(() => {}, ["stop"]),
|
|
454
|
+
onKeydown: [t[4] ||= D(O((e) => it(), ["prevent"]), ["enter"]), t[5] ||= D(O((e) => at(), ["prevent"]), ["esc"])],
|
|
455
|
+
onBlur: t[6] ||= (e) => it()
|
|
456
|
+
}, null, 544)), [[w, Z.value]]) : (y(), p("span", {
|
|
457
|
+
key: 3,
|
|
458
|
+
class: "cn-layers__label min-w-0 flex-1 truncate font-mono text-[11px] leading-4",
|
|
459
|
+
onDblclick: (t) => rt(e)
|
|
460
|
+
}, S(e.label), 41, Oe)),
|
|
461
|
+
J(e) ? (y(), p("button", {
|
|
462
|
+
key: 4,
|
|
463
|
+
type: "button",
|
|
464
|
+
"data-visibility": "",
|
|
465
|
+
class: _(["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"]),
|
|
466
|
+
title: e.node.visible ? "隐藏图层(最终输出不含该层)" : "显示图层",
|
|
467
|
+
"aria-pressed": !e.node.visible,
|
|
468
|
+
onClick: O((t) => qe(e), ["stop"])
|
|
469
|
+
}, [h(r, {
|
|
470
|
+
icon: e.node.visible ? C(le) : C(ue),
|
|
471
|
+
size: 11,
|
|
472
|
+
"stroke-width": 2
|
|
473
|
+
}, null, 8, ["icon"])], 10, ke)) : f("", !0),
|
|
474
|
+
J(e) ? (y(), p("button", {
|
|
475
|
+
key: 5,
|
|
476
|
+
type: "button",
|
|
477
|
+
"data-lock": "",
|
|
478
|
+
class: _(["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"]),
|
|
479
|
+
title: e.node.locked ? g : "锁定图层(画布不可点选/拖动/删除,渲染照常)",
|
|
480
|
+
"aria-pressed": e.node.locked,
|
|
481
|
+
onClick: O((t) => Je(e), ["stop"])
|
|
482
|
+
}, [h(r, {
|
|
483
|
+
icon: e.node.locked ? C(fe) : C(pe),
|
|
484
|
+
size: 11,
|
|
485
|
+
"stroke-width": 2
|
|
486
|
+
}, null, 8, ["icon"])], 10, Ae)) : f("", !0),
|
|
487
|
+
J(e) ? (y(), p("button", {
|
|
488
|
+
key: 6,
|
|
489
|
+
type: "button",
|
|
490
|
+
"data-rename": "",
|
|
491
|
+
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",
|
|
492
|
+
title: "重命名(双击名称或 F2)",
|
|
493
|
+
onClick: O((t) => rt(e), ["stop"])
|
|
494
|
+
}, [h(r, {
|
|
495
|
+
icon: C(me),
|
|
496
|
+
size: 11,
|
|
497
|
+
"stroke-width": 2
|
|
498
|
+
}, null, 8, ["icon"])], 8, je)) : f("", !0),
|
|
499
|
+
e.node.role === "root" && e.node.type === "TableLayer" ? (y(), p("button", {
|
|
500
|
+
key: 7,
|
|
501
|
+
type: "button",
|
|
502
|
+
"data-add-row": "",
|
|
503
|
+
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",
|
|
504
|
+
disabled: e.node.templated === !0,
|
|
505
|
+
title: e.node.templated === !0 ? "模板态不可加行——行由数据展开" : "加行(缺省行 + 缺省格与文本,行宽=表宽)",
|
|
506
|
+
onClick: O((t) => Ue(e), ["stop"])
|
|
507
|
+
}, " +行 ", 8, Me)) : f("", !0),
|
|
508
|
+
e.node.role === "row" ? (y(), p("button", {
|
|
509
|
+
key: 8,
|
|
510
|
+
type: "button",
|
|
511
|
+
"data-add-cell": "",
|
|
512
|
+
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",
|
|
513
|
+
title: "加格(缺省格 + 文本内容,行高取最高格)",
|
|
514
|
+
onClick: O((t) => We(e), ["stop"])
|
|
515
|
+
}, " +格 ", 8, Ne)) : f("", !0),
|
|
516
|
+
e.node.role === "templateRow" ? (y(), p("button", {
|
|
517
|
+
key: 9,
|
|
518
|
+
type: "button",
|
|
519
|
+
"data-add-template-cell": "",
|
|
520
|
+
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",
|
|
521
|
+
title: "加格(缺省格 + 文本内容,零高度耦合——行高由数据展开定稿)",
|
|
522
|
+
onClick: O((t) => Ge(e), ["stop"])
|
|
523
|
+
}, " +格 ", 8, Pe)) : f("", !0),
|
|
524
|
+
m("button", {
|
|
525
|
+
type: "button",
|
|
526
|
+
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",
|
|
527
|
+
disabled: e.node.role === "templateRow" || e.node.locked,
|
|
528
|
+
title: e.node.role === "templateRow" ? "行模板由表持有——转换回普通表请用 V2 转换入口" : e.node.locked ? v : "删除(含子层)",
|
|
529
|
+
onClick: O((t) => Ke(e), ["stop"])
|
|
530
|
+
}, " ✕ ", 8, Fe)
|
|
531
|
+
], 46, Te))), 128))], 32)
|
|
532
|
+
]));
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
//#endregion
|
|
536
|
+
export { F as a, I as i, R as n, L as r, z as t };
|
package/dist/layer-panel.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, i as t, n, r, t as i } from "./layer-panel-
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./layer-panel-BM-nX_OX.js";
|
|
2
2
|
export { t as ADD_LAYER_MENU, e as ADD_MENU, i as LayerPanel, n as isUpperHalf, r as useLayerPanel };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//#region ../canvas-editor/src/shared/layerPath.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return typeof e == "number" && Number.isSafeInteger(e) && e >= 0;
|
|
4
|
+
}
|
|
5
|
+
function t(t) {
|
|
6
|
+
if (!Array.isArray(t) || t.length < 2 || t[0] !== "layers" || !e(t[1])) return !1;
|
|
7
|
+
let n = [
|
|
8
|
+
"rows",
|
|
9
|
+
"cells",
|
|
10
|
+
"content"
|
|
11
|
+
], r = 0, i = 2;
|
|
12
|
+
for (; i < t.length;) {
|
|
13
|
+
let a = t[i];
|
|
14
|
+
if (r === 0 && a === "template") {
|
|
15
|
+
if (i === t.length - 1) return !0;
|
|
16
|
+
if (t[i + 1] !== "cells") return !1;
|
|
17
|
+
r = 1, i += 1;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
let o = n[r];
|
|
21
|
+
if (a !== o) return !1;
|
|
22
|
+
if (o === "content") return i === t.length - 1;
|
|
23
|
+
if (!e(t[i + 1])) return !1;
|
|
24
|
+
r += 1, i += 2;
|
|
25
|
+
}
|
|
26
|
+
return !0;
|
|
27
|
+
}
|
|
28
|
+
function n(e) {
|
|
29
|
+
return e.includes("template");
|
|
30
|
+
}
|
|
31
|
+
function r(e) {
|
|
32
|
+
return t(e) && e.length === 2;
|
|
33
|
+
}
|
|
34
|
+
function i(e, t) {
|
|
35
|
+
if (e === t) return !0;
|
|
36
|
+
if (!e || !t || e.length !== t.length) return !1;
|
|
37
|
+
for (let n = 0; n < e.length; n += 1) if (e[n] !== t[n]) return !1;
|
|
38
|
+
return !0;
|
|
39
|
+
}
|
|
40
|
+
function a(e, t) {
|
|
41
|
+
if (e.length < t.length) return !1;
|
|
42
|
+
for (let n = 0; n < t.length; n += 1) if (e[n] !== t[n]) return !1;
|
|
43
|
+
return !0;
|
|
44
|
+
}
|
|
45
|
+
function o(e, t) {
|
|
46
|
+
return t.some((t) => a(e, t));
|
|
47
|
+
}
|
|
48
|
+
function s(e, t) {
|
|
49
|
+
let n = e, r = 0;
|
|
50
|
+
for (; r < t.length;) {
|
|
51
|
+
let e = n;
|
|
52
|
+
if (typeof e != "object" || !e) return null;
|
|
53
|
+
let i = t[r];
|
|
54
|
+
if (typeof i != "string" || (n = e[i], n == null)) return null;
|
|
55
|
+
if (i === "template") {
|
|
56
|
+
r += 1;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (r + 1 >= t.length) break;
|
|
60
|
+
let a = n, o = t[r + 1];
|
|
61
|
+
if (!Array.isArray(a) || typeof o != "number" || (n = a[o], n == null)) return null;
|
|
62
|
+
r += 2;
|
|
63
|
+
}
|
|
64
|
+
return n;
|
|
65
|
+
}
|
|
66
|
+
function c(e, n) {
|
|
67
|
+
if (!t(n)) return null;
|
|
68
|
+
let r = s(e, n);
|
|
69
|
+
return typeof r != "object" || !r || !("type" in r) ? null : r;
|
|
70
|
+
}
|
|
71
|
+
function l(e, t) {
|
|
72
|
+
let n = t[1];
|
|
73
|
+
return typeof n != "number" || !Number.isSafeInteger(n) || n < 0 ? null : e.layers[n] ?? null;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { c as a, i, r as n, l as o, n as r, o as t };
|