@hankchen/canvas-editor-vue 0.1.4 → 0.2.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/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g } from "./canvas-C70NSsoF.js";
2
- import { a as _, i as v, n as y, r as b, t as x } from "./layer-panel-GiVy_B4A.js";
3
- import { a as S, c as C, d as w, f as T, i as E, l as D, m as O, n as k, o as A, p as j, r as M, s as N, t as P, u as F } from "./property-panel-C2etsIhF.js";
4
- import { i as I, n as L, r as R, t as z } from "./completionAnchor-CDR5YZhu.js";
5
- import { c as B, i as V, n as H, s as U, t as W } from "./useTransientFeedback-CTjmMmFF.js";
6
- import { i as G, n as K, r as q, t as J } from "./uploadFile-BOfv8aLG.js";
7
- import { n as Y, t as X } from "./usePathCompletion-uJ5c_gQ0.js";
8
- import { n as Z, t as Q } from "./useViewport-D9Ipevzs.js";
9
- import { n as $, r as ee, t as te } from "./useDataSourceSchema-CGbldbUj.js";
10
- import { n as ne, r as re, t as ie } from "./status-bar-_PvEXyq8.js";
11
- import { t as ae } from "./useShortcutsHelp-CsyarO2P.js";
12
- import { n as oe, r as se, t as ce } from "./shared-wuupBoZg.js";
2
+ import { a as _, i as v, n as y, o as b, r as x, s as S, t as C } from "./layer-panel-BEcT9HhJ.js";
3
+ import { a as w, c as T, d as E, f as D, i as O, l as k, m as A, n as j, o as M, p as N, r as P, s as F, t as I, u as L } from "./property-panel-C2etsIhF.js";
4
+ import { i as R, n as z, r as B, t as V } from "./completionAnchor-CDR5YZhu.js";
5
+ import { c as H, i as U, n as W, s as G, t as K } from "./useTransientFeedback-CTjmMmFF.js";
6
+ import { i as q, n as J, r as Y, t as X } from "./uploadFile-BOfv8aLG.js";
7
+ import { n as Z, t as Q } from "./usePathCompletion-uJ5c_gQ0.js";
8
+ import { n as $, t as ee } from "./useViewport-D9Ipevzs.js";
9
+ import { n as te, r as ne, t as re } from "./useDataSourceSchema-CGbldbUj.js";
10
+ import { n as ie, r as ae, t as oe } from "./status-bar-_PvEXyq8.js";
11
+ import { t as se } from "./useShortcutsHelp-CsyarO2P.js";
12
+ import { n as ce, r as le, t as ue } from "./shared-wuupBoZg.js";
13
13
  //#region src/index.ts
14
- var le = "@hankchen/canvas-editor-vue";
14
+ var de = "@hankchen/canvas-editor-vue";
15
15
  //#endregion
16
- export { v as ADD_LAYER_MENU, _ as ADD_MENU, V as ARM_LAYER_CREATE_HINT, e as AlignFloatBar, D as CANVAS_FIELD_SECTIONS, n as CanvasSurface, f as ContentTypePill, a as ContextMenu, $ as DropdownMenu, R as ExpressionCompletionPopup, F as FIELD_SECTIONS_BY_TYPE, N as FONT_PICKER_KEY, l as FindBar, m as GuidesOverlay, se as HelpDialog, S as IMAGE_UPLOAD_KEY, x as LayerPanel, le as PACKAGE_NAME, I as PanelIcon, k as PropertyField, P as PropertyPanel, d as Ruler, ie as StatusBar, c as TextEditingOverlay, L as applyCompletion, E as controlRegistry, u as createGizmoOverlayPainter, h as createRafScheduler, U as detectShortcutPlatform, t as drawCreateRubberBand, s as drawFindMatches, p as drawSelectionGizmo, q as expressionCompletionSource, G as expressionFieldContext, w as fieldSectionsForPath, T as fieldSectionsForType, ne as formatLayerGeometry, re as formatLayerPath, C as injectFontPicker, A as injectImageUpload, H as isEditableEventTarget, y as isUpperHalf, j as layerRoleAt, z as measureCursorAnchor, O as readField, Y as rowsPathCompletionSource, B as shortcutActionLabel, J as uploadFileFromDom, te as useDataSourceSchema, r as useDpr, ee as useDropdownMenu, K as useExpressionCompletion, o as useFindSession, oe as useHistory, b as useLayerPanel, X as usePathCompletion, M as usePropertyPanel, Z as useSelection, ce as useShortcuts, ae as useShortcutsHelp, g as useTextEditing, W as useTransientFeedback, Q as useViewport, i as watchDprChanges };
16
+ export { v as ADD_LAYER_MENU, _ as ADD_MENU, b as ADD_TEXT_PRESET_MENU, U as ARM_LAYER_CREATE_HINT, e as AlignFloatBar, k as CANVAS_FIELD_SECTIONS, n as CanvasSurface, f as ContentTypePill, a as ContextMenu, te as DropdownMenu, B as ExpressionCompletionPopup, L as FIELD_SECTIONS_BY_TYPE, F as FONT_PICKER_KEY, l as FindBar, m as GuidesOverlay, le as HelpDialog, w as IMAGE_UPLOAD_KEY, C as LayerPanel, de as PACKAGE_NAME, S as PANEL_ADD_MENU, R as PanelIcon, j as PropertyField, I as PropertyPanel, d as Ruler, oe as StatusBar, c as TextEditingOverlay, z as applyCompletion, O as controlRegistry, u as createGizmoOverlayPainter, h as createRafScheduler, G as detectShortcutPlatform, t as drawCreateRubberBand, s as drawFindMatches, p as drawSelectionGizmo, Y as expressionCompletionSource, q as expressionFieldContext, E as fieldSectionsForPath, D as fieldSectionsForType, ie as formatLayerGeometry, ae as formatLayerPath, T as injectFontPicker, M as injectImageUpload, W as isEditableEventTarget, y as isUpperHalf, N as layerRoleAt, V as measureCursorAnchor, A as readField, Z as rowsPathCompletionSource, H as shortcutActionLabel, X as uploadFileFromDom, re as useDataSourceSchema, r as useDpr, ne as useDropdownMenu, J as useExpressionCompletion, o as useFindSession, ce as useHistory, x as useLayerPanel, Q as usePathCompletion, P as usePropertyPanel, $ as useSelection, ue as useShortcuts, se as useShortcutsHelp, g as useTextEditing, K as useTransientFeedback, ee as useViewport, i as watchDprChanges };
@@ -1,4 +1,4 @@
1
- import { LayerType } from '@hankchen/canvas-editor';
1
+ import { LayerType, TextPresetId } from '@hankchen/canvas-editor';
2
2
  /** 新增菜单项(spec §2.1):四类图层武装画拉(drag-create 工单 03);模板表带 rowsPath 必填表单 */
3
3
  export type AddMenuKind = {
4
4
  kind: 'layer';
@@ -10,7 +10,20 @@ export type AddMenuKind = {
10
10
  label: string;
11
11
  title: string;
12
12
  };
13
+ /** 文本预设项(text-defaults 工单 02,spec 决策 5):面板专用入口——应用即写新层样式槽 + 武装画拉 */
14
+ export type AddTextPresetKind = {
15
+ kind: 'text-preset';
16
+ preset: TextPresetId;
17
+ label: string;
18
+ title: string;
19
+ };
13
20
  export declare const ADD_MENU: readonly AddMenuKind[];
21
+ /** 文本预设三项(text-defaults 工单 02,spec 决策 4):从内核 TEXT_PRESETS 派生
22
+ * (字号单一事实源,内核改档位文案自动跟随),v1 只定字号——字体缺口由新层样式槽补 */
23
+ export declare const ADD_TEXT_PRESET_MENU: readonly AddTextPresetKind[];
24
+ /** 面板「+」完整序(text-defaults 工单 02,spec 决策 5):文本预设三项插在「文本层」之后;
25
+ * 工具栏派生视图 ADD_LAYER_MENU 不含预设(预设只属面板) */
26
+ export declare const PANEL_ADD_MENU: readonly (AddMenuKind | AddTextPresetKind)[];
14
27
  /** 层型项视图(工具栏「+插入▾」消费,editor-top-toolbar 工单 03):ADD_MENU 的
15
28
  * 四类图层项,模板表项不进工具栏 */
16
29
  export declare const ADD_LAYER_MENU: readonly Extract<AddMenuKind, {
@@ -4,4 +4,4 @@
4
4
  */
5
5
  export { default as LayerPanel } from './LayerPanel';
6
6
  export { isUpperHalf, useLayerPanel, type LayerPanelBinding } from './useLayerPanel';
7
- export { ADD_LAYER_MENU, ADD_MENU, type AddMenuKind } from './addMenu';
7
+ export { ADD_LAYER_MENU, ADD_MENU, ADD_TEXT_PRESET_MENU, PANEL_ADD_MENU, type AddMenuKind, type AddTextPresetKind, } from './addMenu';
@@ -1,10 +1,10 @@
1
1
  import { t as e } from "./createLucideIcon-SCvtEGVf.js";
2
2
  import { i as t, r as n, t as r } from "./layerPath-uy2ywyld.js";
3
3
  import { i, o as a, r as o } from "./completionAnchor-CDR5YZhu.js";
4
- import { c as s, i as c, s as l, t as ee } from "./useTransientFeedback-CTjmMmFF.js";
5
- import { n as te, t as ne } from "./usePathCompletion-uJ5c_gQ0.js";
6
- import { n as re, t as ie } from "./useDataSourceSchema-CGbldbUj.js";
7
- import { Fragment as u, computed as d, createBlock as ae, createCommentVNode as f, createElementBlock as p, createElementVNode as m, createVNode as h, defineComponent as g, nextTick as oe, normalizeClass as _, normalizeStyle as se, onScopeDispose as v, openBlock as y, ref as b, renderList as ce, shallowRef as x, toDisplayString as S, unref as C, vModelText as w, watch as le, withCtx as T, withDirectives as E, withKeys as D, withModifiers as O } from "vue";
4
+ import { c as s, i as c, s as l, t as u } from "./useTransientFeedback-CTjmMmFF.js";
5
+ import { n as ee, t as te } from "./usePathCompletion-uJ5c_gQ0.js";
6
+ import { n as ne, t as re } from "./useDataSourceSchema-CGbldbUj.js";
7
+ import { Fragment as d, computed as f, createBlock as ie, createCommentVNode as p, createElementBlock as m, createElementVNode as h, createVNode as g, defineComponent as _, nextTick as ae, normalizeClass as v, normalizeStyle as oe, onScopeDispose as y, openBlock as b, ref as x, renderList as se, shallowRef as S, toDisplayString as ce, unref as C, vModelText as w, watch as le, withCtx as T, withDirectives as E, withKeys as D, withModifiers as O } from "vue";
8
8
  var ue = e({
9
9
  name: "eye-off",
10
10
  size: 24,
@@ -191,9 +191,20 @@ function P(e, t = []) {
191
191
  for (let r = e.layers.length - 1; r >= 0; --r) n.push(N(e.layers[r], ["layers", r], "root", t));
192
192
  return n;
193
193
  }
194
- //#endregion
195
- //#region src/layer-panel/addMenu.ts
196
194
  var F = [
195
+ {
196
+ id: "heading",
197
+ fontSize: 40
198
+ },
199
+ {
200
+ id: "subheading",
201
+ fontSize: 28
202
+ },
203
+ {
204
+ id: "body",
205
+ fontSize: 16
206
+ }
207
+ ], I = [
197
208
  {
198
209
  kind: "layer",
199
210
  type: "TextLayer",
@@ -223,21 +234,37 @@ var F = [
223
234
  label: "模板表",
224
235
  title: "新增模板表(行模板 + 数据行展开)"
225
236
  }
226
- ], I = F.filter((e) => e.kind === "layer");
237
+ ], L = {
238
+ heading: "标题",
239
+ subheading: "副标题",
240
+ body: "正文"
241
+ }, R = F.map(({ id: e, fontSize: t }) => ({
242
+ kind: "text-preset",
243
+ preset: e,
244
+ label: L[e],
245
+ title: `画拉建${L[e]}文本层(字号 ${t},点击后在画布拖拽定落位与尺寸,Esc 取消)`
246
+ })), z = (() => {
247
+ let e = I.findIndex((e) => e.kind === "layer" && e.type === "TextLayer");
248
+ return [
249
+ ...I.slice(0, e + 1),
250
+ ...R,
251
+ ...I.slice(e + 1)
252
+ ];
253
+ })(), B = I.filter((e) => e.kind === "layer");
227
254
  //#endregion
228
255
  //#region src/layer-panel/useLayerPanel.ts
229
- function L(e) {
230
- 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) => {
256
+ function V(e) {
257
+ let t = S(e.store.doc), n = S(e.store.ui.selection), r = S(e.store.ui.hovered), i = S(e.store.ui.renaming), a = S(e.store.ui.lockedPaths), o = e.subscribe((o) => {
231
258
  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);
232
259
  });
233
- return v(o, !0), {
234
- outline: d(() => t.value ? P(t.value, a.value) : []),
235
- selection: d(() => n.value),
236
- hovered: d(() => r.value),
237
- renaming: d(() => i.value)
260
+ return y(o, !0), {
261
+ outline: f(() => t.value ? P(t.value, a.value) : []),
262
+ selection: f(() => n.value),
263
+ hovered: f(() => r.value),
264
+ renaming: f(() => i.value)
238
265
  };
239
266
  }
240
- function R(e, t) {
267
+ function H(e, t) {
241
268
  return t > 0 && e < t / 2;
242
269
  }
243
270
  //#endregion
@@ -276,20 +303,30 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
276
303
  "disabled",
277
304
  "title",
278
305
  "onClick"
279
- ], z = /* @__PURE__ */ g({
306
+ ], U = /* @__PURE__ */ _({
280
307
  __name: "LayerPanel",
281
308
  props: { editor: {} },
282
309
  setup(e) {
283
- let r = e, a = `解锁图层(${s("toggleLayerLock", l())})`, g = `图层已锁定(${s("toggleLayerLock", l())} 解锁后可删除)`, v = L(r.editor), x = b(!1), k = b(""), A = b(!1);
310
+ let r = e, a = `解锁图层(${s("toggleLayerLock", l())})`, _ = `图层已锁定(${s("toggleLayerLock", l())} 解锁后可删除)`, y = V(r.editor), S = x(!1), k = x(""), A = x(!1);
284
311
  function j() {
285
- x.value = !1, k.value = "", A.value = !1;
312
+ S.value = !1, k.value = "", A.value = !1;
286
313
  }
287
- let M = d(() => x.value ? [] : F.map((e) => e.kind === "layer" ? {
314
+ let M = f(() => S.value ? [] : z.map((e) => e.kind === "layer" ? {
288
315
  label: e.label,
289
316
  title: e.title,
290
317
  dataAttrs: { "data-add-layer": e.type },
291
318
  run: () => {
292
- r.editor.armLayerCreate(e.type), ee().show(c);
319
+ r.editor.armLayerCreate(e.type), u().show(c);
320
+ }
321
+ } : e.kind === "text-preset" ? {
322
+ label: e.label,
323
+ title: e.title,
324
+ dataAttrs: {
325
+ "data-add-layer": "TextLayer",
326
+ "data-text-preset": e.preset
327
+ },
328
+ run: () => {
329
+ r.editor.armLayerCreate("TextLayer", e.preset), u().show(c);
293
330
  }
294
331
  } : {
295
332
  label: e.label,
@@ -297,7 +334,7 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
297
334
  dataAttrs: { "data-add-layer": "template-table" },
298
335
  keepsOpen: !0,
299
336
  run: () => {
300
- x.value = !0;
337
+ S.value = !0;
301
338
  }
302
339
  }));
303
340
  function N(e) {
@@ -311,24 +348,24 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
311
348
  function P(e) {
312
349
  j(), e();
313
350
  }
314
- function I() {
351
+ function F() {
315
352
  j();
316
353
  }
317
- let z = ie(r.editor), Le = d(() => te(z.value)), B = b(null), V = b(null), { popup: H, accept: Re } = ne({
318
- target: B,
319
- enabled: () => x.value,
320
- resolve: (e) => Le.value?.(e) ?? null,
321
- popupEl: d(() => V.value?.rootEl ?? null)
354
+ let I = re(r.editor), L = f(() => ee(I.value)), R = x(null), B = x(null), { popup: U, accept: Le } = te({
355
+ target: R,
356
+ enabled: () => S.value,
357
+ resolve: (e) => L.value?.(e) ?? null,
358
+ popupEl: f(() => B.value?.rootEl ?? null)
322
359
  });
323
- function ze(e, t) {
360
+ function Re(e, t) {
324
361
  if (e.key === "Enter") {
325
- if (H.open && H.items.length > 0) return;
362
+ if (U.open && U.items.length > 0) return;
326
363
  e.preventDefault(), N(t);
327
364
  return;
328
365
  }
329
- e.key === "Escape" && H.open && e.stopPropagation();
366
+ e.key === "Escape" && U.open && e.stopPropagation();
330
367
  }
331
- function Be(e, t) {
368
+ function ze(e, t) {
332
369
  switch (e.role) {
333
370
  case "root": return e.name === "" ? `${e.type} ${t}` : e.name;
334
371
  case "row": return `行 ${Number(e.path[e.path.length - 1]) + 1}`;
@@ -337,7 +374,7 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
337
374
  case "content": return e.type;
338
375
  }
339
376
  }
340
- let U = d(() => {
377
+ let W = f(() => {
341
378
  let e = [], t = /* @__PURE__ */ new Map();
342
379
  function r(i, a, o, s) {
343
380
  let c = i.role === "row" ? i.path.slice(0, -2) : i.role === "templateRow" ? i.path.slice(0, -1) : s, l = 0;
@@ -345,42 +382,42 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
345
382
  key: i.path.join("."),
346
383
  node: i,
347
384
  indentLevel: a,
348
- label: Be(i, l),
385
+ label: ze(i, l),
349
386
  indexInGroup: o,
350
387
  tablePath: c,
351
388
  inTemplate: n(i.path),
352
389
  draggable: i.role === "root" || i.role === "row" || i.role === "cell"
353
390
  }), i.children.forEach((e, t) => r(e, a + 1, t, c));
354
391
  }
355
- return v.outline.value.forEach((e, t) => r(e, 0, t, null)), e;
356
- }), Ve = d(() => U.value.length > 0);
357
- function He(e) {
392
+ return y.outline.value.forEach((e, t) => r(e, 0, t, null)), e;
393
+ }), Be = f(() => W.value.length > 0);
394
+ function Ve(e) {
358
395
  r.editor.setSelection(e.node.path);
359
396
  }
360
- function W(e) {
397
+ function G(e) {
361
398
  r.editor.setHovered(e === null ? null : e.node.path);
362
399
  }
363
- function Ue(e) {
400
+ function He(e) {
364
401
  r.editor.addTableRow(e.node.path);
365
402
  }
366
- function We(e) {
403
+ function Ue(e) {
367
404
  r.editor.addTableCell(e.node.path);
368
405
  }
369
- function Ge(e) {
406
+ function We(e) {
370
407
  r.editor.addTemplateCell(e.node.path.slice(0, -1));
371
408
  }
372
- function Ke(e) {
409
+ function Ge(e) {
373
410
  r.editor.deleteLayer(e.node.path);
374
411
  }
375
- function qe(e) {
412
+ function Ke(e) {
376
413
  r.editor.toggleLayerVisibility(e.node.path);
377
414
  }
378
- function Je(e) {
415
+ function qe(e) {
379
416
  r.editor.toggleLayerLock(e.node.path);
380
417
  }
381
- let G = b(null), K = b(null);
382
- function q(e) {
383
- let r = G.value;
418
+ let K = x(null), q = x(null);
419
+ function J(e) {
420
+ let r = K.value;
384
421
  if (!r) return !1;
385
422
  if (r.kind === "root") return e.node.role === "root";
386
423
  if (r.kind === "row") return e.node.role === "row";
@@ -388,11 +425,11 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
388
425
  let i = n(r.cellPath);
389
426
  return i === e.inTemplate ? !i || t(r.cellPath.slice(0, -2), e.node.path.slice(0, -2)) : !1;
390
427
  }
391
- function J(e) {
428
+ function Y(e) {
392
429
  return e.node.role === "root";
393
430
  }
394
- function Y(e, t) {
395
- e.draggable && (G.value = e.node.role === "root" ? {
431
+ function X(e, t) {
432
+ e.draggable && (K.value = e.node.role === "root" ? {
396
433
  kind: "root",
397
434
  from: e.indexInGroup
398
435
  } : e.node.role === "row" ? {
@@ -406,50 +443,50 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
406
443
  cellPath: e.node.path
407
444
  }, t.dataTransfer?.setData("text/plain", e.key), t.dataTransfer && (t.dataTransfer.effectAllowed = "move"));
408
445
  }
409
- function Ye(e, t) {
410
- J(e) || Y(e, t);
446
+ function Je(e, t) {
447
+ Y(e) || X(e, t);
411
448
  }
412
- function Xe(e) {
413
- if (!J(e)) return e.draggable || void 0;
449
+ function Ye(e) {
450
+ if (!Y(e)) return e.draggable || void 0;
414
451
  }
415
- function Ze(e, t) {
416
- if (!q(e)) return;
417
- let n = t.currentTarget.getBoundingClientRect(), r = R(t.clientY - n.top, n.height);
418
- t.preventDefault(), K.value = {
452
+ function Xe(e, t) {
453
+ if (!J(e)) return;
454
+ let n = t.currentTarget.getBoundingClientRect(), r = H(t.clientY - n.top, n.height);
455
+ t.preventDefault(), q.value = {
419
456
  key: e.key,
420
457
  edge: r ? "before" : "after"
421
458
  };
422
459
  }
423
- function Qe(e, t) {
424
- if (!q(e)) return;
425
- let n = K.value, i = G.value;
460
+ function Ze(e, t) {
461
+ if (!J(e)) return;
462
+ let n = q.value, i = K.value;
426
463
  if (!i || !n || n.key !== e.key) return;
427
464
  t.preventDefault();
428
465
  let a = n.edge === "before" ? e.indexInGroup : e.indexInGroup + 1;
429
- i.kind === "root" ? r.editor.moveRootLayer(i.from, a) : i.kind === "row" ? e.tablePath !== null && e.tablePath.join(".") === i.tablePath.join(".") ? r.editor.moveTableRow(i.tablePath, i.from, a) : r.editor.moveTableRowToTable(i.rowPath, e.tablePath, a) : r.editor.moveTableCellToRow(i.cellPath, e.node.path.slice(0, -2), a), G.value = null, K.value = null;
466
+ i.kind === "root" ? r.editor.moveRootLayer(i.from, a) : i.kind === "row" ? e.tablePath !== null && e.tablePath.join(".") === i.tablePath.join(".") ? r.editor.moveTableRow(i.tablePath, i.from, a) : r.editor.moveTableRowToTable(i.rowPath, e.tablePath, a) : r.editor.moveTableCellToRow(i.cellPath, e.node.path.slice(0, -2), a), K.value = null, q.value = null;
430
467
  }
431
- function $e() {
432
- G.value = null, K.value = null;
468
+ function Qe() {
469
+ K.value = null, q.value = null;
433
470
  }
434
- function X(e) {
435
- return t(v.selection.value, e.node.path);
471
+ function Z(e) {
472
+ return t(y.selection.value, e.node.path);
436
473
  }
437
- function et(e) {
438
- return t(v.hovered.value, e.node.path);
474
+ function $e(e) {
475
+ return t(y.hovered.value, e.node.path);
439
476
  }
440
- let Z = b(""), Q = null, $ = null;
477
+ let Q = x(""), $ = null, et = null;
441
478
  function tt(e) {
442
- $ = e instanceof HTMLInputElement ? e : null;
479
+ et = e instanceof HTMLInputElement ? e : null;
443
480
  }
444
481
  function nt(e) {
445
- return t(v.renaming.value, e.node.path);
482
+ return t(y.renaming.value, e.node.path);
446
483
  }
447
484
  function rt(e) {
448
- J(e) && r.editor.beginRename(e.node.path);
485
+ Y(e) && r.editor.beginRename(e.node.path);
449
486
  }
450
487
  function it() {
451
- let e = Z.value.trim();
452
- if (Q !== null && e === Q.trim()) {
488
+ let e = Q.value.trim();
489
+ if ($ !== null && e === $.trim()) {
453
490
  r.editor.cancelRename();
454
491
  return;
455
492
  }
@@ -458,22 +495,22 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
458
495
  function at() {
459
496
  r.editor.cancelRename();
460
497
  }
461
- return le(v.renaming, async (e) => {
498
+ return le(y.renaming, async (e) => {
462
499
  if (e === null) {
463
- Q = null;
500
+ $ = null;
464
501
  return;
465
502
  }
466
- let n = U.value.find((n) => t(n.node.path, e));
467
- Z.value = n?.label ?? "", Q = Z.value, await oe();
468
- let r = $;
503
+ let n = W.value.find((n) => t(n.node.path, e));
504
+ Q.value = n?.label ?? "", $ = Q.value, await ae();
505
+ let r = et;
469
506
  r && (r.focus({ preventScroll: !0 }), r.select());
470
- }), (e, t) => (y(), p("aside", ge, [
471
- m("header", _e, [t[9] ||= m("span", { class: "text-[12px] font-medium tracking-wide text-cn-fg/90" }, "图层", -1), m("div", ve, [h(re, {
507
+ }), (e, t) => (b(), m("aside", ge, [
508
+ h("header", _e, [t[9] ||= h("span", { class: "text-[12px] font-medium tracking-wide text-cn-fg/90" }, "图层", -1), h("div", ve, [g(ne, {
472
509
  label: "新增图层",
473
510
  items: M.value,
474
- onClosed: I
511
+ onClosed: F
475
512
  }, {
476
- trigger: T(({ open: e, toggle: t, triggerRef: n, onKeydown: r }) => [m("button", {
513
+ trigger: T(({ open: e, toggle: t, triggerRef: n, onKeydown: r }) => [h("button", {
477
514
  ref: n,
478
515
  type: "button",
479
516
  "data-add-menu": "",
@@ -484,85 +521,85 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
484
521
  onClick: t,
485
522
  onKeydown: r
486
523
  }, " + ", 40, ye)]),
487
- body: T(({ closeMenu: e }) => [x.value ? (y(), p(u, { key: 0 }, [
488
- t[8] ||= m("p", { class: "px-2 pt-1 text-[11px] leading-4 text-cn-muted" }, "模板行按数据行路径展开成表", -1),
489
- E(m("input", {
524
+ body: T(({ closeMenu: e }) => [S.value ? (b(), m(d, { key: 0 }, [
525
+ t[8] ||= h("p", { class: "px-2 pt-1 text-[11px] leading-4 text-cn-muted" }, "模板行按数据行路径展开成表", -1),
526
+ E(h("input", {
490
527
  ref_key: "rowsPathInputEl",
491
- ref: B,
528
+ ref: R,
492
529
  "onUpdate:modelValue": t[0] ||= (e) => k.value = e,
493
530
  "data-template-rows-path": "",
494
531
  type: "text",
495
532
  placeholder: "如 order.items",
496
- 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", A.value ? "border-cn-danger" : "border-cn-field-line"]),
497
- onKeydown: (t) => ze(t, e)
533
+ class: v(["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", A.value ? "border-cn-danger" : "border-cn-field-line"]),
534
+ onKeydown: (t) => Re(t, e)
498
535
  }, null, 42, be), [[w, k.value]]),
499
- A.value ? (y(), p("p", xe, "rowsPath 必填")) : f("", !0),
500
- m("div", Se, [m("button", {
536
+ A.value ? (b(), m("p", xe, "rowsPath 必填")) : p("", !0),
537
+ h("div", Se, [h("button", {
501
538
  type: "button",
502
539
  "data-template-confirm": "",
503
540
  class: "flex-1 rounded bg-cn-accent/20 px-2 py-1 text-[12px] text-cn-accent hover:bg-cn-accent/30",
504
541
  onClick: (t) => N(e)
505
- }, " 创建 ", 8, Ce), m("button", {
542
+ }, " 创建 ", 8, Ce), h("button", {
506
543
  type: "button",
507
544
  class: "flex-1 rounded px-2 py-1 text-[12px] text-cn-muted hover:text-cn-fg",
508
545
  onClick: (t) => P(e)
509
546
  }, " 取消 ", 8, we)])
510
- ], 64)) : f("", !0)]),
547
+ ], 64)) : p("", !0)]),
511
548
  _: 1
512
- }, 8, ["items"]), x.value ? (y(), ae(o, {
549
+ }, 8, ["items"]), S.value ? (b(), ie(o, {
513
550
  key: 0,
514
551
  ref_key: "pathPopupRef",
515
- ref: V,
516
- state: C(H),
517
- onSelect: C(Re)
518
- }, null, 8, ["state", "onSelect"])) : f("", !0)])]),
519
- Ve.value ? f("", !0) : (y(), p("p", Te, " 画布还没有图层,用上方按钮新增 ")),
520
- m("ul", {
552
+ ref: B,
553
+ state: C(U),
554
+ onSelect: C(Le)
555
+ }, null, 8, ["state", "onSelect"])) : p("", !0)])]),
556
+ Be.value ? p("", !0) : (b(), m("p", Te, " 画布还没有图层,用上方按钮新增 ")),
557
+ h("ul", {
521
558
  class: "cn-layers__tree flex flex-col gap-0.5 px-1.5 py-1",
522
- onDragend: $e
523
- }, [(y(!0), p(u, null, ce(U.value, (e) => (y(), p("li", {
559
+ onDragend: Qe
560
+ }, [(b(!0), m(d, null, se(W.value, (e) => (b(), m("li", {
524
561
  key: e.key,
525
562
  "data-key": e.key,
526
- draggable: Xe(e),
527
- class: _(["cn-layers__row group flex cursor-default select-none items-center gap-1 py-1 pr-1 text-[12px]", {
528
- "cn-layers__row--selected": X(e),
529
- "cn-layers__row--hovered": et(e) && !X(e),
530
- "cn-layers__row--hidden": J(e) && !e.node.visible,
563
+ draggable: Ye(e),
564
+ class: v(["cn-layers__row group flex cursor-default select-none items-center gap-1 py-1 pr-1 text-[12px]", {
565
+ "cn-layers__row--selected": Z(e),
566
+ "cn-layers__row--hovered": $e(e) && !Z(e),
567
+ "cn-layers__row--hidden": Y(e) && !e.node.visible,
531
568
  "cn-layers__row--template": e.inTemplate,
532
- "cursor-grab": e.draggable && !J(e),
533
- "cn-layers__row--drop-before": K.value?.key === e.key && K.value?.edge === "before",
534
- "cn-layers__row--drop-after": K.value?.key === e.key && K.value?.edge === "after"
569
+ "cursor-grab": e.draggable && !Y(e),
570
+ "cn-layers__row--drop-before": q.value?.key === e.key && q.value?.edge === "before",
571
+ "cn-layers__row--drop-after": q.value?.key === e.key && q.value?.edge === "after"
535
572
  }]),
536
- style: se({ paddingLeft: `${4 + e.indentLevel * 14}px` }),
537
- onClick: (t) => He(e),
538
- onMouseenter: (t) => W(e),
539
- onMouseleave: t[7] ||= (e) => W(null),
540
- onDragstart: (t) => Ye(e, t),
541
- onDragover: (t) => Ze(e, t),
542
- onDrop: (t) => Qe(e, t)
573
+ style: oe({ paddingLeft: `${4 + e.indentLevel * 14}px` }),
574
+ onClick: (t) => Ve(e),
575
+ onMouseenter: (t) => G(e),
576
+ onMouseleave: t[7] ||= (e) => G(null),
577
+ onDragstart: (t) => Je(e, t),
578
+ onDragover: (t) => Xe(e, t),
579
+ onDrop: (t) => Ze(e, t)
543
580
  }, [
544
- J(e) ? (y(), p("span", {
581
+ Y(e) ? (b(), m("span", {
545
582
  key: 0,
546
583
  "data-drag-handle": "",
547
584
  draggable: "true",
548
585
  title: "拖动排序",
549
586
  class: "cn-layers__handle shrink-0",
550
- onDragstart: (t) => Y(e, t)
551
- }, [h(i, {
587
+ onDragstart: (t) => X(e, t)
588
+ }, [g(i, {
552
589
  icon: C(fe),
553
590
  size: 12,
554
591
  "stroke-width": 2.5
555
- }, null, 8, ["icon"])], 40, De)) : f("", !0),
556
- e.node.expressionPrefix === "" ? f("", !0) : (y(), p("span", {
592
+ }, null, 8, ["icon"])], 40, De)) : p("", !0),
593
+ e.node.expressionPrefix === "" ? p("", !0) : (b(), m("span", {
557
594
  key: 1,
558
595
  class: "cn-layers__prefix",
559
596
  title: e.node.expressionPrefix
560
- }, S(e.node.expressionPrefix), 9, Oe)),
561
- nt(e) ? E((y(), p("input", {
597
+ }, ce(e.node.expressionPrefix), 9, Oe)),
598
+ nt(e) ? E((b(), m("input", {
562
599
  key: 2,
563
600
  ref_for: !0,
564
601
  ref: tt,
565
- "onUpdate:modelValue": t[1] ||= (e) => Z.value = e,
602
+ "onUpdate:modelValue": t[1] ||= (e) => Q.value = e,
566
603
  "data-rename-input": "",
567
604
  "aria-label": "图层重命名",
568
605
  class: "cn-layers__rename-input min-w-0 flex-1",
@@ -570,84 +607,84 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
570
607
  onDblclick: t[3] ||= O(() => {}, ["stop"]),
571
608
  onKeydown: [t[4] ||= D(O((e) => it(), ["prevent"]), ["enter"]), t[5] ||= D(O((e) => at(), ["prevent"]), ["esc"])],
572
609
  onBlur: t[6] ||= (e) => it()
573
- }, null, 544)), [[w, Z.value]]) : (y(), p("span", {
610
+ }, null, 544)), [[w, Q.value]]) : (b(), m("span", {
574
611
  key: 3,
575
612
  class: "cn-layers__label min-w-0 flex-1 truncate font-mono text-[11px] leading-4",
576
613
  onDblclick: (t) => rt(e)
577
- }, S(e.label), 41, ke)),
578
- J(e) ? (y(), p("button", {
614
+ }, ce(e.label), 41, ke)),
615
+ Y(e) ? (b(), m("button", {
579
616
  key: 4,
580
617
  type: "button",
581
618
  "data-visibility": "",
582
- 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"]),
619
+ class: v(["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"]),
583
620
  title: e.node.visible ? "隐藏图层(最终输出不含该层)" : "显示图层",
584
621
  "aria-pressed": !e.node.visible,
585
- onClick: O((t) => qe(e), ["stop"])
586
- }, [h(i, {
622
+ onClick: O((t) => Ke(e), ["stop"])
623
+ }, [g(i, {
587
624
  icon: e.node.visible ? C(de) : C(ue),
588
625
  size: 11,
589
626
  "stroke-width": 2
590
- }, null, 8, ["icon"])], 10, Ae)) : f("", !0),
591
- J(e) ? (y(), p("button", {
627
+ }, null, 8, ["icon"])], 10, Ae)) : p("", !0),
628
+ Y(e) ? (b(), m("button", {
592
629
  key: 5,
593
630
  type: "button",
594
631
  "data-lock": "",
595
- 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"]),
632
+ class: v(["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"]),
596
633
  title: e.node.locked ? a : "锁定图层(画布不可点选/拖动/删除,渲染照常)",
597
634
  "aria-pressed": e.node.locked,
598
- onClick: O((t) => Je(e), ["stop"])
599
- }, [h(i, {
635
+ onClick: O((t) => qe(e), ["stop"])
636
+ }, [g(i, {
600
637
  icon: e.node.locked ? C(me) : C(pe),
601
638
  size: 11,
602
639
  "stroke-width": 2
603
- }, null, 8, ["icon"])], 10, je)) : f("", !0),
604
- J(e) ? (y(), p("button", {
640
+ }, null, 8, ["icon"])], 10, je)) : p("", !0),
641
+ Y(e) ? (b(), m("button", {
605
642
  key: 6,
606
643
  type: "button",
607
644
  "data-rename": "",
608
645
  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",
609
646
  title: "重命名(双击名称或 F2)",
610
647
  onClick: O((t) => rt(e), ["stop"])
611
- }, [h(i, {
648
+ }, [g(i, {
612
649
  icon: C(he),
613
650
  size: 11,
614
651
  "stroke-width": 2
615
- }, null, 8, ["icon"])], 8, Me)) : f("", !0),
616
- e.node.role === "root" && e.node.type === "TableLayer" ? (y(), p("button", {
652
+ }, null, 8, ["icon"])], 8, Me)) : p("", !0),
653
+ e.node.role === "root" && e.node.type === "TableLayer" ? (b(), m("button", {
617
654
  key: 7,
618
655
  type: "button",
619
656
  "data-add-row": "",
620
657
  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",
621
658
  disabled: e.node.templated === !0,
622
659
  title: e.node.templated === !0 ? "模板态不可加行——行由数据展开" : "加行(缺省行 + 缺省格与文本,行宽=表宽)",
623
- onClick: O((t) => Ue(e), ["stop"])
624
- }, " +行 ", 8, Ne)) : f("", !0),
625
- e.node.role === "row" ? (y(), p("button", {
660
+ onClick: O((t) => He(e), ["stop"])
661
+ }, " +行 ", 8, Ne)) : p("", !0),
662
+ e.node.role === "row" ? (b(), m("button", {
626
663
  key: 8,
627
664
  type: "button",
628
665
  "data-add-cell": "",
629
666
  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",
630
667
  title: "加格(缺省格 + 文本内容,行高取最高格)",
631
- onClick: O((t) => We(e), ["stop"])
632
- }, " +格 ", 8, Pe)) : f("", !0),
633
- e.node.role === "templateRow" ? (y(), p("button", {
668
+ onClick: O((t) => Ue(e), ["stop"])
669
+ }, " +格 ", 8, Pe)) : p("", !0),
670
+ e.node.role === "templateRow" ? (b(), m("button", {
634
671
  key: 9,
635
672
  type: "button",
636
673
  "data-add-template-cell": "",
637
674
  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",
638
675
  title: "加格(缺省格 + 文本内容,零高度耦合——行高由数据展开定稿)",
639
- onClick: O((t) => Ge(e), ["stop"])
640
- }, " +格 ", 8, Fe)) : f("", !0),
641
- m("button", {
676
+ onClick: O((t) => We(e), ["stop"])
677
+ }, " +格 ", 8, Fe)) : p("", !0),
678
+ h("button", {
642
679
  type: "button",
643
680
  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",
644
681
  disabled: e.node.role === "templateRow" || e.node.locked,
645
- title: e.node.role === "templateRow" ? "行模板由表持有——转换回普通表请用 V2 转换入口" : e.node.locked ? g : "删除(含子层)",
646
- onClick: O((t) => Ke(e), ["stop"])
682
+ title: e.node.role === "templateRow" ? "行模板由表持有——转换回普通表请用 V2 转换入口" : e.node.locked ? _ : "删除(含子层)",
683
+ onClick: O((t) => Ge(e), ["stop"])
647
684
  }, " ✕ ", 8, Ie)
648
685
  ], 46, Ee))), 128))], 32)
649
686
  ]));
650
687
  }
651
688
  });
652
689
  //#endregion
653
- export { F as a, I as i, R as n, L as r, z as t };
690
+ export { I as a, B as i, H as n, R as o, V as r, z as s, U as t };
@@ -1,2 +1,2 @@
1
- import { a as e, i as t, n, r, t as i } from "./layer-panel-GiVy_B4A.js";
2
- export { t as ADD_LAYER_MENU, e as ADD_MENU, i as LayerPanel, n as isUpperHalf, r as useLayerPanel };
1
+ import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./layer-panel-BEcT9HhJ.js";
2
+ export { t as ADD_LAYER_MENU, e as ADD_MENU, r as ADD_TEXT_PRESET_MENU, o as LayerPanel, a as PANEL_ADD_MENU, n as isUpperHalf, i as useLayerPanel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hankchen/canvas-editor-vue",
3
- "version": "0.1.4",
3
+ "version": "0.2.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.1.1"
61
+ "@hankchen/canvas-editor": "0.3.0"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "vue": "^3.5.0"