@hankchen/canvas-editor-vue 0.1.0 → 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,5 +1,6 @@
1
- import { E as e, L as t, M as n, R as r, V as i, a, w as o } from "./layerPath-BRZK9ka1.js";
2
- import { c as s, n as c, t as l, u } from "./completionAnchor-4lhR2kJz.js";
1
+ import { a as e } from "./layerPath-uy2ywyld.js";
2
+ import { c as t, n, t as r, u as i } from "./completionAnchor-CDR5YZhu.js";
3
+ import { nextTick as a, onMounted as o, onScopeDispose as s, reactive as c, toValue as l, watch as u } from "vue";
3
4
  //#region ../canvas-editor/src/shared/rowsPathCandidates.ts
4
5
  function d(e) {
5
6
  return e.type === "array" || e.items !== void 0;
@@ -24,31 +25,31 @@ function m(e, t) {
24
25
  }
25
26
  function h(e, t) {
26
27
  if (e === null) return null;
27
- let n = t.split("."), r = t.endsWith(".") ? "" : n[n.length - 1], i = n.slice(0, -1), a = e;
28
- for (let e of i) {
29
- if (d(a)) return null;
30
- let t = u(a, [e]);
28
+ let n = t.split("."), r = t.endsWith(".") ? "" : n[n.length - 1], a = n.slice(0, -1), o = e;
29
+ for (let e of a) {
30
+ if (d(o)) return null;
31
+ let t = i(o, [e]);
31
32
  if (t === null) return null;
32
- a = t;
33
+ o = t;
33
34
  }
34
- if (d(a) || f(a)) return null;
35
- let o = m(a, i.join("."));
35
+ if (d(o) || f(o)) return null;
36
+ let s = m(o, a.join("."));
36
37
  return {
37
38
  partial: r,
38
- candidates: o.candidates,
39
- ...o.open === !0 ? { open: !0 } : {}
39
+ candidates: s.candidates,
40
+ ...s.open === !0 ? { open: !0 } : {}
40
41
  };
41
42
  }
42
- function g(e, t, n) {
43
- if (n === null) return null;
44
- if (e === null || t === null) return n;
45
- let r = null;
46
- for (let i = 0; i < t.length; i += 1) {
47
- if (t[i] !== "template") continue;
48
- let o = a(e, t.slice(0, i));
49
- if (o === null || o.type !== "TableLayer" || (r = s(r ?? n, o.rowsPath), r === null)) return null;
50
- }
51
- return r ?? n;
43
+ function g(n, r, i) {
44
+ if (i === null) return null;
45
+ if (n === null || r === null) return i;
46
+ let a = null;
47
+ for (let o = 0; o < r.length; o += 1) {
48
+ if (r[o] !== "template") continue;
49
+ let s = e(n, r.slice(0, o));
50
+ if (s === null || s.type !== "TableLayer" || (a = t(a ?? i, s.rowsPath), a === null)) return null;
51
+ }
52
+ return a ?? i;
52
53
  }
53
54
  //#endregion
54
55
  //#region src/shared/rowsPathCompletionSource.ts
@@ -85,65 +86,65 @@ function x(e) {
85
86
  error: null
86
87
  };
87
88
  }
88
- function S(a) {
89
- let s = r({
89
+ function S(e) {
90
+ let t = c({
90
91
  open: !1,
91
92
  items: [],
92
93
  activeIndex: 0,
93
94
  top: 0,
94
95
  left: 0,
95
96
  openMapping: !1
96
- }), u = null, d = !1, f = "";
97
+ }), i = null, d = !1, f = "";
97
98
  function p() {
98
- s.open = !1, s.items = [], s.activeIndex = 0, s.openMapping = !1, f = "";
99
+ t.open = !1, t.items = [], t.activeIndex = 0, t.openMapping = !1, f = "";
99
100
  }
100
101
  function m() {
101
- if (!s.open || !u) return;
102
- let e = l(u);
103
- s.top = e.bottom + v, s.left = h(e.left);
102
+ if (!t.open || !i) return;
103
+ let e = r(i);
104
+ t.top = e.bottom + v, t.left = h(e.left);
104
105
  }
105
- function h(e) {
106
- let t = (a.popupEl ? i(a.popupEl) : null)?.offsetWidth ?? 0;
107
- return t <= 0 ? e : Math.max(0, Math.min(e, window.innerWidth - y - t));
106
+ function h(t) {
107
+ let n = (e.popupEl ? l(e.popupEl) : null)?.offsetWidth ?? 0;
108
+ return n <= 0 ? t : Math.max(0, Math.min(t, window.innerWidth - y - n));
108
109
  }
109
- function g(e, t = !1) {
110
- if (!i(a.enabled)) {
110
+ function g(n, r = !1) {
111
+ if (!l(e.enabled)) {
111
112
  p();
112
113
  return;
113
114
  }
114
- let n = u;
115
- if (!n) {
115
+ let o = i;
116
+ if (!o) {
116
117
  p();
117
118
  return;
118
119
  }
119
- let r = n.value.slice(0, n.selectionStart ?? n.value.length);
120
- if (r === "" && !t) {
120
+ let s = o.value.slice(0, o.selectionStart ?? o.value.length);
121
+ if (s === "" && !r) {
121
122
  p();
122
123
  return;
123
124
  }
124
- let c = a.resolve(r);
125
+ let c = e.resolve(s);
125
126
  if (!c) {
126
127
  p();
127
128
  return;
128
129
  }
129
- let l = t ? c.candidates : c.candidates.filter((e) => e.segment.startsWith(c.partial));
130
- if (l.length === 0 && c.open !== !0) {
130
+ let u = r ? c.candidates : c.candidates.filter((e) => e.segment.startsWith(c.partial));
131
+ if (u.length === 0 && c.open !== !0) {
131
132
  p();
132
133
  return;
133
134
  }
134
- f = c.partial, (s.open || e) && (s.items = l, s.activeIndex = 0, s.openMapping = c.open === !0, s.open = !0, m(), o(m));
135
+ f = c.partial, (t.open || n) && (t.items = u, t.activeIndex = 0, t.openMapping = c.open === !0, t.open = !0, m(), a(m));
135
136
  }
136
137
  function _(e) {
137
- let t = u;
138
- if (!s.open || d || !t) return;
139
- let n = s.items[e ?? s.activeIndex];
140
- if (!n) return;
141
- let r = t.value.slice(0, t.selectionStart ?? t.value.length), i = c(t.value, x(r), f, n.segment);
142
- if (!i) {
138
+ let r = i;
139
+ if (!t.open || d || !r) return;
140
+ let a = t.items[e ?? t.activeIndex];
141
+ if (!a) return;
142
+ let o = r.value.slice(0, r.selectionStart ?? r.value.length), s = n(r.value, x(o), f, a.segment);
143
+ if (!s) {
143
144
  p();
144
145
  return;
145
146
  }
146
- t.value = i.value, t.setSelectionRange(i.cursor, i.cursor), t.dispatchEvent(new Event("input", { bubbles: !0 })), t.dispatchEvent(new Event("change", { bubbles: !0 })), p();
147
+ r.value = s.value, r.setSelectionRange(s.cursor, s.cursor), r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })), p();
147
148
  }
148
149
  function S(e) {
149
150
  d || e.isComposing || g(!0);
@@ -163,15 +164,15 @@ function S(a) {
163
164
  e.preventDefault(), g(!0, !0);
164
165
  return;
165
166
  }
166
- if (s.open) {
167
- if (s.items.length === 0) {
167
+ if (t.open) {
168
+ if (t.items.length === 0) {
168
169
  e.key === "Escape" && (e.preventDefault(), p());
169
170
  return;
170
171
  }
171
172
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
172
173
  e.preventDefault();
173
- let t = s.items.length;
174
- t > 0 && (s.activeIndex = (s.activeIndex + (e.key === "ArrowDown" ? 1 : t - 1)) % t);
174
+ let n = t.items.length;
175
+ n > 0 && (t.activeIndex = (t.activeIndex + (e.key === "ArrowDown" ? 1 : n - 1)) % n);
175
176
  return;
176
177
  }
177
178
  if (e.key === "Enter" || e.key === "Tab") {
@@ -183,7 +184,7 @@ function S(a) {
183
184
  }
184
185
  }
185
186
  function D(e) {
186
- s.open && !T(e) && b.includes(e.key) && g(!1);
187
+ t.open && !T(e) && b.includes(e.key) && g(!1);
187
188
  }
188
189
  function O() {
189
190
  d || g(!1);
@@ -192,7 +193,7 @@ function S(a) {
192
193
  p();
193
194
  }
194
195
  function A(e) {
195
- s.open && e.target !== u && p();
196
+ t.open && e.target !== i && p();
196
197
  }
197
198
  function j() {
198
199
  m();
@@ -213,14 +214,14 @@ function S(a) {
213
214
  for (let [t, n] of M) e.removeEventListener(t, n);
214
215
  }
215
216
  function F(e) {
216
- u !== e && (u && P(u), u = e, e && N(e));
217
+ i !== e && (i && P(i), i = e, e && N(e));
217
218
  }
218
- return e(() => F(a.target.value)), n(a.target, (e) => F(e)), n(() => i(a.enabled), (e) => {
219
+ return o(() => F(e.target.value)), u(e.target, (e) => F(e)), u(() => l(e.enabled), (e) => {
219
220
  e || p();
220
- }), document.addEventListener("mousedown", A), window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), t(() => {
221
- u && P(u), document.removeEventListener("mousedown", A), window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
221
+ }), document.addEventListener("mousedown", A), window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), s(() => {
222
+ i && P(i), document.removeEventListener("mousedown", A), window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
222
223
  }), {
223
- popup: s,
224
+ popup: t,
224
225
  accept: _
225
226
  };
226
227
  }
@@ -1,4 +1,4 @@
1
- import { z as e } from "./layerPath-BRZK9ka1.js";
1
+ import { ref as e } from "vue";
2
2
  //#region src/shared/useShortcutsHelp.ts
3
3
  var t = e(!1);
4
4
  function n() {
@@ -1,4 +1,4 @@
1
- import { z as e } from "./layerPath-BRZK9ka1.js";
1
+ import { ref as e } from "vue";
2
2
  //#region ../canvas-editor/src/session/shortcuts.ts
3
3
  var t = {
4
4
  armCreateText: "TextLayer",
@@ -1,18 +1,18 @@
1
- import { B as e, L as t, p as n } from "./layerPath-BRZK9ka1.js";
1
+ import { computed as e, onScopeDispose as t, shallowRef as n } from "vue";
2
2
  //#region src/shared/useSelection.ts
3
3
  function r(r) {
4
- let i = e(r.store.ui.selection), a = r.subscribe((e) => {
4
+ let i = n(r.store.ui.selection), a = r.subscribe((e) => {
5
5
  (e.scope === "doc" || e.scope === "ui" && e.branch === "selection") && (i.value = r.store.ui.selection);
6
6
  });
7
- return t(a, !0), n(() => i.value);
7
+ return t(a, !0), e(() => i.value);
8
8
  }
9
9
  //#endregion
10
10
  //#region src/shared/useViewport.ts
11
11
  function i(r) {
12
- let i = e(r.store.ui.viewport), a = r.subscribe((e) => {
12
+ let i = n(r.store.ui.viewport), a = r.subscribe((e) => {
13
13
  e.scope === "ui" && e.branch === "viewport" && (i.value = r.store.ui.viewport);
14
14
  });
15
- return t(a, !0), n(() => i.value);
15
+ return t(a, !0), e(() => i.value);
16
16
  }
17
17
  //#endregion
18
18
  export { r as n, i as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hankchen/canvas-editor-vue",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
5
  "description": "Vue 3 薄绑定:响应式桥、composables、画布表面组件、textarea 文本编辑 overlay、schema 驱动属性面板注册表",
6
6
  "type": "module",
@@ -36,7 +36,8 @@
36
36
  "default": "./dist/shared.js"
37
37
  },
38
38
  "./panel-theme.css": "./dist/panel-theme.css",
39
- "./style.css": "./dist/style.css"
39
+ "./style.css": "./dist/style.css",
40
+ "./package.json": "./package.json"
40
41
  },
41
42
  "files": [
42
43
  "dist",