@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.
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, d as n, f as r, i, l as a, m as o, n as s, o as c, p as l, r as u, s as d, t as f, u as p } from "./property-panel-jt_rsTVW.js";
1
+ import { a as e, c as t, d as n, f as r, i, l as a, m as o, n as s, o as c, p as l, r as u, s as d, t as f, u as p } from "./property-panel-Cw6T9dAQ.js";
2
2
  export { a as CANVAS_FIELD_SECTIONS, p as FIELD_SECTIONS_BY_TYPE, d as FONT_PICKER_KEY, e as IMAGE_UPLOAD_KEY, s as PropertyField, f as PropertyPanel, i as controlRegistry, n as fieldSectionsForPath, r as fieldSectionsForType, t as injectFontPicker, c as injectImageUpload, l as layerRoleAt, o as readField, u as usePropertyPanel };
@@ -0,0 +1,123 @@
1
+ import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, t as l, u } from "./useTransientFeedback-Cnp6aNB7.js";
2
+ import { t as d } from "./useShortcutsHelp-CsyarO2P.js";
3
+ import { Fragment as f, Teleport as p, computed as m, createBlock as h, createCommentVNode as g, createElementBlock as _, createElementVNode as v, defineComponent as y, onBeforeUnmount as b, onScopeDispose as x, openBlock as S, renderList as C, shallowRef as w, toDisplayString as T, unref as E, watch as D, withModifiers as O } from "vue";
4
+ //#region src/shared/HelpDialog.vue?vue&type=script&setup=true&lang.ts
5
+ var k = {
6
+ class: "cn-help__panel",
7
+ role: "dialog",
8
+ "aria-modal": "true",
9
+ "aria-label": "快捷键帮助",
10
+ "data-help-dialog": ""
11
+ }, A = { class: "cn-help__header" }, j = { class: "cn-help__body" }, M = ["data-help-group"], N = { class: "cn-help__section-title" }, P = { class: "cn-help__list" }, F = { class: "cn-help__label" }, I = { class: "cn-help__keys" }, L = {
12
+ class: "cn-help__section",
13
+ "data-help-interactions": ""
14
+ }, R = { class: "cn-help__list" }, z = { class: "cn-help__label" }, B = { class: "cn-help__keys" }, V = /*#__PURE__*/ a(/* @__PURE__ */ y({
15
+ __name: "HelpDialog",
16
+ props: {
17
+ bindings: { default: () => n },
18
+ platform: {}
19
+ },
20
+ setup(n) {
21
+ let r = n, { open: a, close: o } = d(), c = m(() => r.platform ?? s()), l = m(() => e.map((e) => ({
22
+ group: e,
23
+ label: i[e],
24
+ bindings: r.bindings.filter((t) => t.group === e)
25
+ })).filter((e) => e.bindings.length > 0)), u = [
26
+ {
27
+ gesture: "Ctrl/⌘ + 滚轮",
28
+ text: "缩放画布(以指针为中心,5%–800%)"
29
+ },
30
+ {
31
+ gesture: "空格拖动",
32
+ text: "平移画布(中键拖拽、左键拖空白同效)"
33
+ },
34
+ {
35
+ gesture: "面板菜单 / T·G·Q·I",
36
+ text: "画拉建层:点层型或按键武装 → 画布拖拽定落位与尺寸(位移小于死区 = 点击兜底缺省尺寸)→ 自动选中、文本直打;Esc 取消"
37
+ },
38
+ {
39
+ gesture: "双击",
40
+ text: "就地编辑文本"
41
+ },
42
+ {
43
+ gesture: "Esc",
44
+ text: "退出编辑 / 解除武装 / 关闭弹层 / 选择逐级升级(格→行→表)"
45
+ },
46
+ {
47
+ gesture: "方向键",
48
+ text: "微调选中图层 1px(按住 Shift 大步 10px)"
49
+ },
50
+ {
51
+ gesture: "Tab / ⇧Tab",
52
+ text: "在根图层间循环选层(跳过隐藏与锁定)"
53
+ }
54
+ ];
55
+ function y(e) {
56
+ e.key === "Escape" && o();
57
+ }
58
+ return D(a, (e) => {
59
+ e ? window.addEventListener("keydown", y) : window.removeEventListener("keydown", y);
60
+ }), b(() => window.removeEventListener("keydown", y)), (e, n) => (S(), h(p, { to: "body" }, [E(a) ? (S(), _("div", {
61
+ key: 0,
62
+ class: "cn-help",
63
+ "data-help-overlay": "",
64
+ onPointerdown: n[1] ||= O((...e) => E(o) && E(o)(...e), ["self"])
65
+ }, [v("div", k, [v("header", A, [n[2] ||= v("h2", { class: "cn-help__title" }, "快捷键", -1), v("button", {
66
+ type: "button",
67
+ class: "cn-help__close",
68
+ "data-help-close": "",
69
+ "aria-label": "关闭快捷键帮助",
70
+ onClick: n[0] ||= (...e) => E(o) && E(o)(...e)
71
+ }, " ✕ ")]), v("div", j, [(S(!0), _(f, null, C(l.value, (e) => (S(), _("section", {
72
+ key: e.group,
73
+ class: "cn-help__section",
74
+ "data-help-group": e.group
75
+ }, [v("h3", N, T(e.label), 1), v("ul", P, [(S(!0), _(f, null, C(e.bindings, (e) => (S(), _("li", {
76
+ key: `${e.action}:${e.combo.key}`,
77
+ class: "cn-help__row",
78
+ "data-help-shortcut": ""
79
+ }, [v("span", F, T(e.label), 1), v("kbd", I, T(E(t)(e.combo, c.value)), 1)]))), 128))])], 8, M))), 128)), v("section", L, [n[3] ||= v("h3", { class: "cn-help__section-title" }, "内置交互", -1), v("ul", R, [(S(), _(f, null, C(u, (e) => v("li", {
80
+ key: e.gesture,
81
+ class: "cn-help__row",
82
+ "data-help-interaction": ""
83
+ }, [v("span", z, T(e.text), 1), v("kbd", B, T(e.gesture), 1)])), 64))])])])])], 32)) : g("", !0)]));
84
+ }
85
+ }), [["__scopeId", "data-v-486e5be3"]]);
86
+ //#endregion
87
+ //#region src/shared/useHistory.ts
88
+ function H(e) {
89
+ let t = w(e.store.canUndo), n = w(e.store.canRedo), r = e.subscribe((r) => {
90
+ r.scope === "doc" && (t.value = e.store.canUndo, n.value = e.store.canRedo);
91
+ });
92
+ return x(r, !0), {
93
+ canUndo: m(() => t.value),
94
+ canRedo: m(() => n.value)
95
+ };
96
+ }
97
+ //#endregion
98
+ //#region src/shared/useShortcuts.ts
99
+ var U = new Set(Object.keys(u));
100
+ function W(e) {
101
+ let t = d(), n = l(), i = (i) => {
102
+ let a = r({
103
+ key: i.key,
104
+ mod: i.ctrlKey || i.metaKey,
105
+ shift: i.shiftKey,
106
+ alt: i.altKey,
107
+ code: i.code,
108
+ composing: i.isComposing || i.keyCode === 229,
109
+ editing: e.store.ui.editing !== null,
110
+ editableTarget: o(i.target)
111
+ });
112
+ if (a !== null) {
113
+ if (i.preventDefault(), a === "helpShortcuts") {
114
+ t.toggle();
115
+ return;
116
+ }
117
+ e.executeShortcut(a), U.has(a) && n.show(c);
118
+ }
119
+ };
120
+ window.addEventListener("keydown", i), x(() => window.removeEventListener("keydown", i), !0);
121
+ }
122
+ //#endregion
123
+ export { H as n, V as r, W as t };
package/dist/shared.js CHANGED
@@ -1,9 +1,9 @@
1
- import { i as e, n as t, r as n, t as r } from "./completionAnchor-4lhR2kJz.js";
2
- import { n as i, o as a, r as o, s, t as c } from "./useTransientFeedback-gS9Xa9GY.js";
3
- import { i as l, n as u, r as d, t as f } from "./uploadFile-CutE_xI-.js";
4
- import { n as p, t as m } from "./usePathCompletion-DkHoGla4.js";
5
- import { n as h, t as g } from "./useViewport-BLe2ise1.js";
6
- import { n as _, r as v, t as y } from "./useDataSourceSchema-C924m8fc.js";
7
- import { t as b } from "./useShortcutsHelp-DTC3yRil.js";
8
- import { n as x, r as S, t as C } from "./shared-D9zYUQaw.js";
1
+ import { i as e, n as t, r as n, t as r } from "./completionAnchor-CDR5YZhu.js";
2
+ import { n as i, o as a, r as o, s, t as c } from "./useTransientFeedback-Cnp6aNB7.js";
3
+ import { i as l, n as u, r as d, t as f } from "./uploadFile-BOfv8aLG.js";
4
+ import { n as p, t as m } from "./usePathCompletion-uJ5c_gQ0.js";
5
+ import { n as h, t as g } from "./useViewport-D9Ipevzs.js";
6
+ import { n as _, r as v, t as y } from "./useDataSourceSchema-DStVoY8Z.js";
7
+ import { t as b } from "./useShortcutsHelp-CsyarO2P.js";
8
+ import { n as x, r as S, t as C } from "./shared-BTyB4vbT.js";
9
9
  export { o as ARM_LAYER_CREATE_HINT, _ as DropdownMenu, n as ExpressionCompletionPopup, S as HelpDialog, e as PanelIcon, t as applyCompletion, a as detectShortcutPlatform, d as expressionCompletionSource, l as expressionFieldContext, i as isEditableEventTarget, r as measureCursorAnchor, p as rowsPathCompletionSource, s as shortcutActionLabel, f as uploadFileFromDom, y as useDataSourceSchema, v as useDropdownMenu, u as useExpressionCompletion, x as useHistory, m as usePathCompletion, h as useSelection, C as useShortcuts, b as useShortcutsHelp, c as useTransientFeedback, g as useViewport };
@@ -1,8 +1,9 @@
1
- import { B as e, D as t, G as n, H as r, L as i, P as a, _ as o, a as s, b as c, d as l, g as u, m as d, p as f, y as p } from "./layerPath-BRZK9ka1.js";
2
- import { l as m, o as h, s as g, t as _ } from "./useTransientFeedback-gS9Xa9GY.js";
3
- import { n as v, t as y } from "./useViewport-BLe2ise1.js";
4
- import { n as b, t as x } from "./useDataSourceSchema-C924m8fc.js";
5
- import { t as S } from "./useShortcutsHelp-DTC3yRil.js";
1
+ import { a as e } from "./layerPath-uy2ywyld.js";
2
+ import { l as t, o as n, s as r, t as i } from "./useTransientFeedback-Cnp6aNB7.js";
3
+ import { n as a, t as o } from "./useViewport-D9Ipevzs.js";
4
+ import { n as s, t as c } from "./useDataSourceSchema-DStVoY8Z.js";
5
+ import { t as l } from "./useShortcutsHelp-CsyarO2P.js";
6
+ import { Fragment as u, computed as d, createCommentVNode as f, createElementBlock as p, createElementVNode as m, createVNode as h, defineComponent as g, onScopeDispose as _, openBlock as v, shallowRef as y, toDisplayString as b, unref as x, withCtx as S } from "vue";
6
7
  //#region src/status-bar/layerPathLabel.ts
7
8
  function C(e) {
8
9
  let t = `图层 ${String(e[1])}`;
@@ -34,11 +35,11 @@ function T(e, t) {
34
35
  }
35
36
  //#endregion
36
37
  //#region src/status-bar/useDoc.ts
37
- function E(t) {
38
- let n = e(t.store.doc), r = t.subscribe((e) => {
39
- e.scope === "doc" && (n.value = t.store.doc);
38
+ function E(e) {
39
+ let t = y(e.store.doc), n = e.subscribe((n) => {
40
+ n.scope === "doc" && (t.value = e.store.doc);
40
41
  });
41
- return i(r, !0), f(() => n.value);
42
+ return _(n, !0), d(() => t.value);
42
43
  }
43
44
  //#endregion
44
45
  //#region src/status-bar/StatusBar.vue?vue&type=script&setup=true&lang.ts
@@ -71,7 +72,7 @@ var D = {
71
72
  }, F = {
72
73
  class: "cn-statusbar__segment",
73
74
  "data-feedback": ""
74
- }, I = /*#__PURE__*/ m(/* @__PURE__ */ c({
75
+ }, I = /*#__PURE__*/ t(/* @__PURE__ */ g({
75
76
  __name: "StatusBar",
76
77
  props: {
77
78
  editor: {},
@@ -80,38 +81,38 @@ var D = {
80
81
  saveState: {},
81
82
  feedback: { default: "" }
82
83
  },
83
- setup(e) {
84
- let i = e, c = y(i.editor), m = v(i.editor), w = E(i.editor), I = x(i.editor), L = f(() => Math.round(c.value.zoom * 100)), R = f(() => {
85
- let e = m.value;
84
+ setup(t) {
85
+ let g = t, _ = o(g.editor), y = a(g.editor), w = E(g.editor), I = c(g.editor), L = d(() => Math.round(_.value.zoom * 100)), R = d(() => {
86
+ let e = y.value;
86
87
  return e === null ? "未选中图层" : C(e);
87
- }), z = f(() => {
88
- let e = m.value, t = w.value;
89
- if (e === null || t === null) return null;
90
- let n = s(t, e), r = i.editor.layerBoxAt(e);
91
- return !n || !r ? null : T(n.position, r);
92
- }), B = f(() => {
88
+ }), z = d(() => {
89
+ let t = y.value, n = w.value;
90
+ if (t === null || n === null) return null;
91
+ let r = e(n, t), i = g.editor.layerBoxAt(t);
92
+ return !r || !i ? null : T(r.position, i);
93
+ }), B = d(() => {
93
94
  let e = I.value;
94
95
  return e === null ? "schema 无候选" : `schema 已注入顶层 ${e.properties?.size ?? 0} 键`;
95
- }), { toggle: V } = S(), H = `快捷键帮助(${g("helpShortcuts", h())})`, U = _(), W = f(() => i.feedback === "" ? U.message.value : i.feedback);
96
+ }), { toggle: V } = l(), H = `快捷键帮助(${r("helpShortcuts", n())})`, U = i(), W = d(() => g.feedback === "" ? U.message.value : g.feedback);
96
97
  function G(e) {
97
- let { width: t, height: n } = i.editor.getSurfaceSize();
98
- i.editor.zoomAt(t / 2, n / 2, c.value.zoom * e);
98
+ let { width: t, height: n } = g.editor.getSurfaceSize();
99
+ g.editor.zoomAt(t / 2, n / 2, _.value.zoom * e);
99
100
  }
100
- let K = f(() => [
101
+ let K = d(() => [
101
102
  {
102
103
  label: "100%",
103
104
  dataAttrs: { "data-zoom-100": "" },
104
- run: () => i.editor.resetZoom()
105
+ run: () => g.editor.resetZoom()
105
106
  },
106
107
  {
107
108
  label: "适应画布",
108
109
  dataAttrs: { "data-zoom-fit": "" },
109
- run: () => i.editor.fitToSurface()
110
+ run: () => g.editor.fitToSurface()
110
111
  },
111
112
  {
112
113
  label: "适应选区",
113
114
  dataAttrs: { "data-zoom-fit-selection": "" },
114
- run: () => i.editor.fitToSelection()
115
+ run: () => g.editor.fitToSelection()
115
116
  },
116
117
  {
117
118
  label: "放大",
@@ -126,14 +127,14 @@ var D = {
126
127
  run: () => G(1 / 1.25)
127
128
  }
128
129
  ]);
129
- return (e, s) => (t(), o("footer", D, [
130
- p(b, {
130
+ return (e, t) => (v(), p("footer", D, [
131
+ h(s, {
131
132
  label: "缩放",
132
133
  direction: "up",
133
134
  items: K.value
134
135
  }, {
135
- trigger: a(({ open: e, toggle: t, triggerRef: r, onKeydown: i }) => [d("button", {
136
- ref: r,
136
+ trigger: S(({ open: e, toggle: t, triggerRef: n, onKeydown: r }) => [m("button", {
137
+ ref: n,
137
138
  type: "button",
138
139
  class: "cn-statusbar__segment cn-statusbar__zoom-trigger",
139
140
  "data-zoom": "",
@@ -141,51 +142,51 @@ var D = {
141
142
  "aria-expanded": e,
142
143
  title: "缩放",
143
144
  onClick: t,
144
- onKeydown: i
145
- }, n(L.value) + "% ", 41, O)]),
145
+ onKeydown: r
146
+ }, b(L.value) + "% ", 41, O)]),
146
147
  _: 1
147
148
  }, 8, ["items"]),
148
- s[6] ||= d("span", {
149
+ t[6] ||= m("span", {
149
150
  class: "cn-statusbar__divider",
150
151
  "aria-hidden": "true"
151
152
  }, null, -1),
152
- d("span", k, n(R.value), 1),
153
- i.pendingCount > 0 ? (t(), o(l, { key: 0 }, [s[1] ||= d("span", {
153
+ m("span", k, b(R.value), 1),
154
+ g.pendingCount > 0 ? (v(), p(u, { key: 0 }, [t[1] ||= m("span", {
154
155
  class: "cn-statusbar__divider",
155
156
  "aria-hidden": "true"
156
- }, null, -1), d("span", A, " 物化中 " + n(i.pendingCount), 1)], 64)) : u("", !0),
157
- z.value === null ? u("", !0) : (t(), o(l, { key: 1 }, [s[2] ||= d("span", {
157
+ }, null, -1), m("span", A, " 物化中 " + b(g.pendingCount), 1)], 64)) : f("", !0),
158
+ z.value === null ? f("", !0) : (v(), p(u, { key: 1 }, [t[2] ||= m("span", {
158
159
  class: "cn-statusbar__divider",
159
160
  "aria-hidden": "true"
160
- }, null, -1), d("span", j, n(z.value), 1)], 64)),
161
- i.resourceNote === "" ? u("", !0) : (t(), o(l, { key: 2 }, [s[3] ||= d("span", {
161
+ }, null, -1), m("span", j, b(z.value), 1)], 64)),
162
+ g.resourceNote === "" ? f("", !0) : (v(), p(u, { key: 2 }, [t[3] ||= m("span", {
162
163
  class: "cn-statusbar__divider",
163
164
  "aria-hidden": "true"
164
- }, null, -1), d("span", M, n(i.resourceNote), 1)], 64)),
165
- i.saveState === void 0 ? u("", !0) : (t(), o(l, { key: 3 }, [s[4] ||= d("span", {
165
+ }, null, -1), m("span", M, b(g.resourceNote), 1)], 64)),
166
+ g.saveState === void 0 ? f("", !0) : (v(), p(u, { key: 3 }, [t[4] ||= m("span", {
166
167
  class: "cn-statusbar__divider",
167
168
  "aria-hidden": "true"
168
- }, null, -1), d("span", N, n(i.saveState === "dirty" ? "● 未保存" : "○ 已保存"), 1)], 64)),
169
- s[7] ||= d("span", {
169
+ }, null, -1), m("span", N, b(g.saveState === "dirty" ? "● 未保存" : "○ 已保存"), 1)], 64)),
170
+ t[7] ||= m("span", {
170
171
  class: "cn-statusbar__divider",
171
172
  "aria-hidden": "true"
172
173
  }, null, -1),
173
- d("span", P, n(B.value), 1),
174
- W.value === "" ? u("", !0) : (t(), o(l, { key: 4 }, [s[5] ||= d("span", {
174
+ m("span", P, b(B.value), 1),
175
+ W.value === "" ? f("", !0) : (v(), p(u, { key: 4 }, [t[5] ||= m("span", {
175
176
  class: "cn-statusbar__divider",
176
177
  "aria-hidden": "true"
177
- }, null, -1), d("span", F, n(W.value), 1)], 64)),
178
- s[8] ||= d("span", {
178
+ }, null, -1), m("span", F, b(W.value), 1)], 64)),
179
+ t[8] ||= m("span", {
179
180
  class: "cn-statusbar__divider",
180
181
  "aria-hidden": "true"
181
182
  }, null, -1),
182
- d("button", {
183
+ m("button", {
183
184
  type: "button",
184
185
  class: "cn-statusbar__segment cn-statusbar__help",
185
186
  "data-help": "",
186
187
  "aria-haspopup": "dialog",
187
188
  title: H,
188
- onClick: s[0] ||= (...e) => r(V) && r(V)(...e)
189
+ onClick: t[0] ||= (...e) => x(V) && x(V)(...e)
189
190
  }, " 快捷键 ")
190
191
  ]));
191
192
  }
@@ -1,2 +1,2 @@
1
- import { n as e, r as t, t as n } from "./status-bar-BhhrVoBZ.js";
1
+ import { n as e, r as t, t as n } from "./status-bar-DO8akYAw.js";
2
2
  export { n as StatusBar, e as formatLayerGeometry, t as formatLayerPath };