@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.js CHANGED
@@ -1,2 +1,2 @@
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-CS4SmrIO.js";
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-CSdXMg6S.js";
2
2
  export { e as AlignFloatBar, n as CanvasSurface, f as ContentTypePill, a as ContextMenu, l as FindBar, m as GuidesOverlay, d as Ruler, c as TextEditingOverlay, u as createGizmoOverlayPainter, h as createRafScheduler, t as drawCreateRubberBand, s as drawFindMatches, p as drawSelectionGizmo, r as useDpr, o as useFindSession, g as useTextEditing, i as watchDprChanges };
@@ -1,4 +1,4 @@
1
- import { C as e, D as t, G as n, M as r, U as i, W as a, _ as o, b as s, d as c, f as l, g as u, h as d, j as f, k as p, m, u as h, w as g, z as _ } from "./layerPath-BRZK9ka1.js";
1
+ import { Fragment as e, Teleport as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, mergeProps as s, nextTick as c, normalizeClass as l, normalizeStyle as u, openBlock as d, ref as f, renderList as p, resolveDynamicComponent as m, toDisplayString as h, watch as g, withModifiers as _ } from "vue";
2
2
  //#region ../canvas-editor/src/shared/expressionSchema.ts
3
3
  function v(e) {
4
4
  let t = e;
@@ -123,7 +123,7 @@ function T(e, t) {
123
123
  }
124
124
  //#endregion
125
125
  //#region src/shared/PanelIcon.vue
126
- var E = /* @__PURE__ */ s({
126
+ var E = /* @__PURE__ */ o({
127
127
  inheritAttrs: !1,
128
128
  __name: "PanelIcon",
129
129
  props: {
@@ -131,11 +131,11 @@ var E = /* @__PURE__ */ s({
131
131
  size: { default: 14 },
132
132
  strokeWidth: { default: 2 }
133
133
  },
134
- setup(n) {
135
- return (r, i) => (t(), d(f(n.icon), e({
136
- size: n.size,
137
- "stroke-width": n.strokeWidth
138
- }, r.$attrs), null, 16, ["size", "stroke-width"]));
134
+ setup(e) {
135
+ return (t, r) => (d(), n(m(e.icon), s({
136
+ size: e.size,
137
+ "stroke-width": e.strokeWidth
138
+ }, t.$attrs), null, 16, ["size", "stroke-width"]));
139
139
  }
140
140
  }), D = {
141
141
  role: "listbox",
@@ -153,38 +153,38 @@ var E = /* @__PURE__ */ s({
153
153
  }, M = {
154
154
  key: 0,
155
155
  class: "cn-completion__hint px-2 py-1.5 text-[10px] leading-none text-cn-muted"
156
- }, N = /* @__PURE__ */ s({
156
+ }, N = /* @__PURE__ */ o({
157
157
  __name: "ExpressionCompletionPopup",
158
158
  props: { state: {} },
159
159
  emits: ["select"],
160
- setup(e, { expose: s, emit: f }) {
161
- let v = e, y = f, b = _(null);
162
- return s({ rootEl: b }), r(() => v.state.activeIndex, async () => {
163
- await g(), b.value?.querySelector(".cn-completion__option--active")?.scrollIntoView?.({ block: "nearest" });
164
- }), (r, s) => (t(), d(l, { to: "body" }, [e.state.open ? (t(), o("div", {
160
+ setup(o, { expose: s, emit: m }) {
161
+ let v = o, y = m, b = f(null);
162
+ return s({ rootEl: b }), g(() => v.state.activeIndex, async () => {
163
+ await c(), b.value?.querySelector(".cn-completion__option--active")?.scrollIntoView?.({ block: "nearest" });
164
+ }), (s, c) => (d(), n(t, { to: "body" }, [o.state.open ? (d(), i("div", {
165
165
  key: 0,
166
166
  ref_key: "rootRef",
167
167
  ref: b,
168
168
  class: "cn-props cn-completion fixed z-50 max-h-[200px] min-w-[140px] max-w-[280px] overflow-y-auto rounded-md border border-cn-field-line py-1 text-[11px] leading-none",
169
- style: a({
170
- top: `${e.state.top}px`,
171
- left: `${e.state.left}px`
169
+ style: u({
170
+ top: `${o.state.top}px`,
171
+ left: `${o.state.left}px`
172
172
  }),
173
- onMousedown: s[0] ||= h(() => {}, ["prevent", "stop"]),
174
- onPointerdown: s[1] ||= h(() => {}, ["stop"])
175
- }, [m("div", D, [(t(!0), o(c, null, p(e.state.items, (r, a) => (t(), o("button", {
176
- key: `${a}:${r.segment}`,
173
+ onMousedown: c[0] ||= _(() => {}, ["prevent", "stop"]),
174
+ onPointerdown: c[1] ||= _(() => {}, ["stop"])
175
+ }, [a("div", D, [(d(!0), i(e, null, p(o.state.items, (e, t) => (d(), i("button", {
176
+ key: `${t}:${e.segment}`,
177
177
  type: "button",
178
178
  role: "option",
179
- class: i(["cn-completion__option flex w-full items-center gap-1.5 px-2 py-1.5 text-left", a === e.state.activeIndex ? "cn-completion__option--active" : ""]),
180
- "aria-selected": a === e.state.activeIndex,
181
- title: r.path ?? r.segment,
182
- onClick: (e) => y("select", a)
179
+ class: l(["cn-completion__option flex w-full items-center gap-1.5 px-2 py-1.5 text-left", t === o.state.activeIndex ? "cn-completion__option--active" : ""]),
180
+ "aria-selected": t === o.state.activeIndex,
181
+ title: e.path ?? e.segment,
182
+ onClick: (e) => y("select", t)
183
183
  }, [
184
- m("span", k, n(r.segment), 1),
185
- r.type ? (t(), o("span", A, n(r.type), 1)) : u("", !0),
186
- r.description ?? r.title ? (t(), o("span", j, n(r.description ?? r.title), 1)) : u("", !0)
187
- ], 10, O))), 128))]), e.state.openMapping ? (t(), o("div", M, " 动态字段,键由模板定义 ")) : u("", !0)], 36)) : u("", !0)]));
184
+ a("span", k, h(e.segment), 1),
185
+ e.type ? (d(), i("span", A, h(e.type), 1)) : r("", !0),
186
+ e.description ?? e.title ? (d(), i("span", j, h(e.description ?? e.title), 1)) : r("", !0)
187
+ ], 10, O))), 128))]), o.state.openMapping ? (d(), i("div", M, " 动态字段,键由模板定义 ")) : r("", !0)], 36)) : r("", !0)]));
188
188
  }
189
189
  });
190
190
  //#endregion
@@ -0,0 +1,184 @@
1
+ //#region ../../node_modules/.pnpm/@hankchen+canvas@0.1.0/node_modules/@hankchen/canvas/dist/index.js
2
+ var e = [
3
+ "top-left",
4
+ "top",
5
+ "top-right",
6
+ "left",
7
+ "center",
8
+ "right",
9
+ "bottom-left",
10
+ "bottom",
11
+ "bottom-right"
12
+ ], t = [
13
+ "left",
14
+ "center",
15
+ "right"
16
+ ], n = [
17
+ "top",
18
+ "center",
19
+ "bottom"
20
+ ], r = /* @__PURE__ */ ",(。(、(;(:(!(?(」(』()(】(》(〉(…(—(~(·(!(?(%(,(.(;(:()(](}".split("("), i = [
21
+ "「",
22
+ "『",
23
+ "(",
24
+ "【",
25
+ "《",
26
+ "〈",
27
+ "“",
28
+ "‘",
29
+ "(",
30
+ "[",
31
+ "{"
32
+ ], a = new Intl.Segmenter(void 0, { granularity: "grapheme" });
33
+ function o(e) {
34
+ return e === "" ? [] : Array.from(a.segment(e), (e) => e.segment);
35
+ }
36
+ var s = .55;
37
+ function c(e) {
38
+ return e.length === 1 && e >= " " && e <= "~";
39
+ }
40
+ function l(e) {
41
+ return { measure(t) {
42
+ let n = 0;
43
+ for (let e of t) n += c(e) ? s : 1;
44
+ return n * e;
45
+ } };
46
+ }
47
+ var u = (e, t) => l(t);
48
+ function d(e) {
49
+ return e.join("");
50
+ }
51
+ function f(e) {
52
+ return e === " " || e === " ";
53
+ }
54
+ function p(e) {
55
+ return r.includes(e);
56
+ }
57
+ function m(e) {
58
+ return i.includes(e);
59
+ }
60
+ function h() {
61
+ return (e, t, n) => {
62
+ if (e === "") return [];
63
+ let r = [];
64
+ for (let i of e.split("\n")) {
65
+ let e = o(i);
66
+ if (e.length === 0) {
67
+ r.push("");
68
+ continue;
69
+ }
70
+ let a = [];
71
+ for (let i of e) {
72
+ if (a.length === 0 || n.measure(d(a) + i) <= t) {
73
+ a.push(i);
74
+ continue;
75
+ }
76
+ let e = g(a, i);
77
+ e.line.length > 0 && r.push(d(e.line)), a = e.rest;
78
+ }
79
+ a.length > 0 && r.push(d(a));
80
+ }
81
+ return r;
82
+ };
83
+ }
84
+ function g(e, t) {
85
+ let n = e, r = [t], i = _(e);
86
+ if (i !== -1) {
87
+ let a = +(e[i] === "-"), o = e.slice(0, i + a), s = e.slice(i + 1);
88
+ o.length > 0 && (n = o, r = [...s, t]);
89
+ }
90
+ return n = y(n), r = b(r), v(n, r);
91
+ }
92
+ function _(e) {
93
+ for (let t = e.length - 1; t > 0; t--) {
94
+ let n = e[t];
95
+ if (n === " " || n === "-") return t;
96
+ }
97
+ return -1;
98
+ }
99
+ function v(e, t) {
100
+ for (; t.length > 0 && p(t[0]);) e = [...e, t[0]], t = t.slice(1);
101
+ for (; e.length > 0 && m(e[e.length - 1]);) t = [e[e.length - 1], ...t], e = e.slice(0, -1);
102
+ return {
103
+ line: e,
104
+ rest: t
105
+ };
106
+ }
107
+ function y(e) {
108
+ for (; e.length > 0 && f(e[e.length - 1]);) e = e.slice(0, -1);
109
+ return e;
110
+ }
111
+ function b(e) {
112
+ for (; e.length > 0 && f(e[0]);) e = e.slice(1);
113
+ return e;
114
+ }
115
+ var x = h();
116
+ function S(e) {
117
+ return {
118
+ lineBreaker: e?.lineBreaker ?? x,
119
+ measurerFactory: e?.measurerFactory ?? u
120
+ };
121
+ }
122
+ function C(e) {
123
+ return e === 0 ? 0 : e;
124
+ }
125
+ function w(e) {
126
+ return C(Math.trunc(e));
127
+ }
128
+ function T(e, t) {
129
+ switch (e.type) {
130
+ case "TextLayer": {
131
+ if (!e.shape.autoWidth) return e.shape.width;
132
+ let { measurerFactory: n } = S(t), r = n(e.font, e.fontSize), i = 0;
133
+ for (let t of e.text.split("\n")) i = Math.max(i, r.measure(t));
134
+ return w(Math.ceil(i)) + w(e.shape.padding.left + e.shape.padding.right);
135
+ }
136
+ default: return e.shape.width;
137
+ }
138
+ }
139
+ function E(e) {
140
+ return Math.ceil(e.fontSize * e.shape.lineHeight);
141
+ }
142
+ function D(e, t) {
143
+ if (!e.autowrap) return [e.text];
144
+ let { lineBreaker: n, measurerFactory: r } = S(t);
145
+ return n(e.text, k(e, t), r(e.font, e.fontSize));
146
+ }
147
+ function O(e, t) {
148
+ switch (e.type) {
149
+ case "TextLayer": {
150
+ if (!e.shape.autoHeight) return e.shape.height;
151
+ let n = w(e.shape.padding.top + e.shape.padding.bottom);
152
+ return e.autowrap ? E(e) * D(e, t).length + n : e.text === "" ? n : E(e) + n;
153
+ }
154
+ case "QrCodeLayer": return !e.shape.autoHeight && e.shape.height > 0 ? e.shape.height : T(e, t);
155
+ default: return e.shape.height;
156
+ }
157
+ }
158
+ function k(e, t) {
159
+ return w(T(e, t) - e.shape.padding.left - e.shape.padding.right);
160
+ }
161
+ function A(e, t) {
162
+ return w(O(e, t) - e.shape.padding.top - e.shape.padding.bottom);
163
+ }
164
+ function j(e, t, n, r, i) {
165
+ return {
166
+ x: e === "top-right" || e === "right" || e === "bottom-right" ? t - r : e === "top" || e === "center" || e === "bottom" ? w((t - r) / 2) : 0,
167
+ y: e === "bottom-left" || e === "bottom" || e === "bottom-right" ? n - i : e === "left" || e === "center" || e === "right" ? w((n - i) / 2) : 0
168
+ };
169
+ }
170
+ function M(e, t, n, r, i, a) {
171
+ let o = T(e, a), s = O(e, a), c = j(e.position.anchor, r, i, o, s), l = t + c.x + e.position.x, u = n + c.y + e.position.y;
172
+ return {
173
+ x: l,
174
+ y: u,
175
+ width: o,
176
+ height: s,
177
+ contentX: l + e.shape.padding.left,
178
+ contentY: u + e.shape.padding.top,
179
+ contentWidth: k(e, a),
180
+ contentHeight: A(e, a)
181
+ };
182
+ }
183
+ //#endregion
184
+ export { k as a, A as i, t as n, M as o, n as r, e as t };
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
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-CS4SmrIO.js";
2
- import { a as _, i as v, n as y, r as b, t as x } from "./layer-panel-ArP66_vZ.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-jt_rsTVW.js";
4
- import { i as I, n as L, r as R, t as z } from "./completionAnchor-4lhR2kJz.js";
5
- import { n as B, o as V, r as H, s as U, t as W } from "./useTransientFeedback-gS9Xa9GY.js";
6
- import { i as G, n as K, r as q, t as J } from "./uploadFile-CutE_xI-.js";
7
- import { n as Y, t as X } from "./usePathCompletion-DkHoGla4.js";
8
- import { n as Z, t as Q } from "./useViewport-BLe2ise1.js";
9
- import { n as $, r as ee, t as te } from "./useDataSourceSchema-C924m8fc.js";
10
- import { n as ne, r as re, t as ie } from "./status-bar-BhhrVoBZ.js";
11
- import { t as ae } from "./useShortcutsHelp-DTC3yRil.js";
12
- import { n as oe, r as se, t as ce } from "./shared-D9zYUQaw.js";
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-CSdXMg6S.js";
2
+ import { i as _, n as v, r as y, t as b } from "./completionAnchor-CDR5YZhu.js";
3
+ import { a as x, i as S, n as C, r as w, t as T } from "./layer-panel-BM-nX_OX.js";
4
+ import { n as E, o as D, r as O, s as k, t as A } from "./useTransientFeedback-Cnp6aNB7.js";
5
+ import { i as j, n as M, r as N, t as P } from "./uploadFile-BOfv8aLG.js";
6
+ import { n as F, t as I } from "./usePathCompletion-uJ5c_gQ0.js";
7
+ import { a as L, c as R, d as z, f as B, i as V, l as H, m as U, n as W, o as G, p as K, r as q, s as J, t as Y, u as X } from "./property-panel-Cw6T9dAQ.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-DStVoY8Z.js";
10
+ import { n as ne, r as re, t as ie } from "./status-bar-DO8akYAw.js";
11
+ import { t as ae } from "./useShortcutsHelp-CsyarO2P.js";
12
+ import { n as oe, r as se, t as ce } from "./shared-BTyB4vbT.js";
13
13
  //#region src/index.ts
14
14
  var le = "@hankchen/canvas-editor-vue";
15
15
  //#endregion
16
- export { v as ADD_LAYER_MENU, _ as ADD_MENU, H 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, V 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, B as isEditableEventTarget, y as isUpperHalf, j as layerRoleAt, z as measureCursorAnchor, O as readField, Y as rowsPathCompletionSource, U 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 { S as ADD_LAYER_MENU, x as ADD_MENU, O as ARM_LAYER_CREATE_HINT, e as AlignFloatBar, H as CANVAS_FIELD_SECTIONS, n as CanvasSurface, f as ContentTypePill, a as ContextMenu, $ as DropdownMenu, y as ExpressionCompletionPopup, X as FIELD_SECTIONS_BY_TYPE, J as FONT_PICKER_KEY, l as FindBar, m as GuidesOverlay, se as HelpDialog, L as IMAGE_UPLOAD_KEY, T as LayerPanel, le as PACKAGE_NAME, _ as PanelIcon, W as PropertyField, Y as PropertyPanel, d as Ruler, ie as StatusBar, c as TextEditingOverlay, v as applyCompletion, V as controlRegistry, u as createGizmoOverlayPainter, h as createRafScheduler, D as detectShortcutPlatform, t as drawCreateRubberBand, s as drawFindMatches, p as drawSelectionGizmo, N as expressionCompletionSource, j as expressionFieldContext, z as fieldSectionsForPath, B as fieldSectionsForType, ne as formatLayerGeometry, re as formatLayerPath, R as injectFontPicker, G as injectImageUpload, E as isEditableEventTarget, C as isUpperHalf, K as layerRoleAt, b as measureCursorAnchor, U as readField, F as rowsPathCompletionSource, k as shortcutActionLabel, P as uploadFileFromDom, te as useDataSourceSchema, r as useDpr, ee as useDropdownMenu, M as useExpressionCompletion, o as useFindSession, oe as useHistory, w as useLayerPanel, I as usePathCompletion, q as usePropertyPanel, Z as useSelection, ce as useShortcuts, ae as useShortcutsHelp, g as useTextEditing, A as useTransientFeedback, Q as useViewport, i as watchDprChanges };