@hankchen/canvas-editor-vue 0.2.0 → 0.4.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/canvas/CanvasSurface.d.ts +28 -1
- package/dist/canvas/{ContentTypePill.d.ts → EditOverlayToolbar.d.ts} +19 -0
- package/dist/canvas/TextEditingOverlay.d.ts +31 -3
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas/useTextEditing.d.ts +30 -8
- package/dist/{canvas-C70NSsoF.js → canvas-DqQislJ_.js} +813 -434
- package/dist/canvas.js +2 -2
- package/dist/index.js +15 -14
- package/dist/{layer-panel-BEcT9HhJ.js → layer-panel-DskyCgF5.js} +10 -10
- package/dist/layer-panel.js +1 -1
- package/dist/panel-theme.css +24 -0
- package/dist/popupPosition-Ck5Gsvjy.js +526 -0
- package/dist/property-panel/PropertyField.d.ts +6 -0
- package/dist/property-panel/fieldSchema.d.ts +7 -1
- package/dist/property-panel/fields/ImageSrcField.d.ts +5 -1
- package/dist/property-panel/fields/ResourceValueField.d.ts +19 -0
- package/dist/property-panel/fields/TextareaField.d.ts +1 -0
- package/dist/property-panel/fields/ValueTypeSegmented.d.ts +3 -1
- package/dist/property-panel/index.d.ts +5 -3
- package/dist/property-panel/usePropertyPanel.d.ts +16 -4
- package/dist/{property-panel-C2etsIhF.js → property-panel-B32ZBQdf.js} +472 -376
- package/dist/property-panel.js +3 -2
- package/dist/resourceTemplate-cdcQtp9a.js +246 -0
- package/dist/shared/ExpressionPathPicker.d.ts +25 -0
- package/dist/shared/completion.d.ts +40 -16
- package/dist/shared/expressionContext.d.ts +2 -2
- package/dist/shared/index.d.ts +14 -1
- package/dist/shared/mergeKey.d.ts +2 -0
- package/dist/shared/pathPickerModel.d.ts +11 -0
- package/dist/shared/popupPosition.d.ts +41 -0
- package/dist/shared/resourceTemplate.d.ts +7 -0
- package/dist/shared/useExpressionCompletion.d.ts +0 -7
- package/dist/shared/useExpressionDiagnostics.d.ts +15 -0
- package/dist/shared.js +10 -9
- package/dist/style.css +1 -1
- package/dist/uploadFile-D1RY-ji0.js +516 -0
- package/dist/usePathCompletion-Do17CQ6l.js +220 -0
- package/package.json +2 -2
- package/dist/completionAnchor-CDR5YZhu.js +0 -273
- package/dist/uploadFile-BOfv8aLG.js +0 -331
- package/dist/usePathCompletion-uJ5c_gQ0.js +0 -229
- /package/dist/{property-panel → shared}/fontPicker.d.ts +0 -0
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-
|
|
2
|
-
export { e as AlignFloatBar, n as CanvasSurface,
|
|
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-DqQislJ_.js";
|
|
2
|
+
export { e as AlignFloatBar, n as CanvasSurface, a as ContextMenu, f as EditOverlayToolbar, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
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-
|
|
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-
|
|
3
|
-
import { a as w, c as T, d as E, f as D, i as O, l as k,
|
|
4
|
-
import { i as
|
|
5
|
-
import { c as
|
|
6
|
-
import { i as
|
|
7
|
-
import { n as
|
|
8
|
-
import { n as
|
|
9
|
-
import { n as
|
|
10
|
-
import { n as
|
|
11
|
-
import { t as
|
|
12
|
-
import {
|
|
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-DqQislJ_.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-DskyCgF5.js";
|
|
3
|
+
import { a as w, c as T, d as E, f as D, i as O, l as k, n as A, o as j, r as M, s as N, t as P, u as F } from "./property-panel-B32ZBQdf.js";
|
|
4
|
+
import { a as I, i as L, n as R, o as z, r as B, s as V, t as H } from "./popupPosition-Ck5Gsvjy.js";
|
|
5
|
+
import { c as U, i as W, n as G, s as K, t as q } from "./useTransientFeedback-CTjmMmFF.js";
|
|
6
|
+
import { a as J, c as Y, i as X, l as Z, n as Q, o as $, r as ee, s as te, t as ne } from "./uploadFile-D1RY-ji0.js";
|
|
7
|
+
import { i as re, n as ie, r as ae, t as oe } from "./resourceTemplate-cdcQtp9a.js";
|
|
8
|
+
import { n as se, t as ce } from "./usePathCompletion-Do17CQ6l.js";
|
|
9
|
+
import { n as le, t as ue } from "./useViewport-D9Ipevzs.js";
|
|
10
|
+
import { n as de, r as fe, t as pe } from "./useDataSourceSchema-CGbldbUj.js";
|
|
11
|
+
import { n as me, r as he, t as ge } from "./status-bar-_PvEXyq8.js";
|
|
12
|
+
import { t as _e } from "./useShortcutsHelp-CsyarO2P.js";
|
|
13
|
+
import { n as ve, r as ye, t as be } from "./shared-wuupBoZg.js";
|
|
13
14
|
//#region src/index.ts
|
|
14
|
-
var
|
|
15
|
+
var xe = "@hankchen/canvas-editor-vue";
|
|
15
16
|
//#endregion
|
|
16
|
-
export { v as ADD_LAYER_MENU, _ as ADD_MENU, b as ADD_TEXT_PRESET_MENU,
|
|
17
|
+
export { v as ADD_LAYER_MENU, _ as ADD_MENU, b as ADD_TEXT_PRESET_MENU, W as ARM_LAYER_CREATE_HINT, e as AlignFloatBar, N as CANVAS_FIELD_SECTIONS, n as CanvasSurface, a as ContextMenu, de as DropdownMenu, f as EditOverlayToolbar, z as ExpressionCompletionPopup, ae as ExpressionPathPicker, T as FIELD_SECTIONS_BY_TYPE, ee as FONT_PICKER_KEY, l as FindBar, m as GuidesOverlay, ye as HelpDialog, w as IMAGE_UPLOAD_KEY, C as LayerPanel, xe as PACKAGE_NAME, S as PANEL_ADD_MENU, H as POPUP_GAP, R as POPUP_MARGIN, V as PanelIcon, A as PropertyField, P as PropertyPanel, d as Ruler, ge as StatusBar, c as TextEditingOverlay, I as applyCompletion, oe as attachResourceTemplate, O as controlRegistry, u as createGizmoOverlayPainter, h as createRafScheduler, K as detectShortcutPlatform, t as drawCreateRubberBand, s as drawFindMatches, p as drawSelectionGizmo, Y as expressionCompletionSource, J as expressionDiagnosticHint, Z as expressionFieldContext, k as fieldSectionsForPath, F as fieldSectionsForType, me as formatLayerGeometry, he as formatLayerPath, X as injectFontPicker, j as injectImageUpload, G as isEditableEventTarget, y as isUpperHalf, E as layerRoleAt, L as measureCursorAnchor, re as pathPickerEntries, B as placePopupInViewport, D as readField, se as rowsPathCompletionSource, Q as selectionFieldMergeKey, U as shortcutActionLabel, ie as stripResourceTemplate, ne as uploadFileFromDom, pe as useDataSourceSchema, r as useDpr, fe as useDropdownMenu, te as useExpressionCompletion, $ as useExpressionDiagnostics, o as useFindSession, ve as useHistory, x as useLayerPanel, ce as usePathCompletion, M as usePropertyPanel, le as useSelection, be as useShortcuts, _e as useShortcutsHelp, g as useTextEditing, q as useTransientFeedback, ue as useViewport, i as watchDprChanges };
|
|
@@ -1,8 +1,8 @@
|
|
|
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
|
-
import { i,
|
|
3
|
+
import { o as i, s as a, u as o } from "./popupPosition-Ck5Gsvjy.js";
|
|
4
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-
|
|
5
|
+
import { n as ee, t as te } from "./usePathCompletion-Do17CQ6l.js";
|
|
6
6
|
import { n as ne, t as re } from "./useDataSourceSchema-CGbldbUj.js";
|
|
7
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({
|
|
@@ -161,7 +161,7 @@ var j = "{{…}}";
|
|
|
161
161
|
function M(e) {
|
|
162
162
|
let t = A(e);
|
|
163
163
|
if (t === null) return "";
|
|
164
|
-
let n =
|
|
164
|
+
let n = o(t).parts.flatMap((e) => e.kind === "fragment" && e.expr !== "" ? [e.expr] : []);
|
|
165
165
|
return n.length === 0 ? j : n.map((e) => `{{${e}}}`).join(" ");
|
|
166
166
|
}
|
|
167
167
|
function N(e, t, n, i) {
|
|
@@ -307,7 +307,7 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
|
|
|
307
307
|
__name: "LayerPanel",
|
|
308
308
|
props: { editor: {} },
|
|
309
309
|
setup(e) {
|
|
310
|
-
let r = e,
|
|
310
|
+
let r = e, o = `解锁图层(${s("toggleLayerLock", l())})`, _ = `图层已锁定(${s("toggleLayerLock", l())} 解锁后可删除)`, y = V(r.editor), S = x(!1), k = x(""), A = x(!1);
|
|
311
311
|
function j() {
|
|
312
312
|
S.value = !1, k.value = "", A.value = !1;
|
|
313
313
|
}
|
|
@@ -546,7 +546,7 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
|
|
|
546
546
|
}, " 取消 ", 8, we)])
|
|
547
547
|
], 64)) : p("", !0)]),
|
|
548
548
|
_: 1
|
|
549
|
-
}, 8, ["items"]), S.value ? (b(), ie(
|
|
549
|
+
}, 8, ["items"]), S.value ? (b(), ie(i, {
|
|
550
550
|
key: 0,
|
|
551
551
|
ref_key: "pathPopupRef",
|
|
552
552
|
ref: B,
|
|
@@ -585,7 +585,7 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
|
|
|
585
585
|
title: "拖动排序",
|
|
586
586
|
class: "cn-layers__handle shrink-0",
|
|
587
587
|
onDragstart: (t) => X(e, t)
|
|
588
|
-
}, [g(
|
|
588
|
+
}, [g(a, {
|
|
589
589
|
icon: C(fe),
|
|
590
590
|
size: 12,
|
|
591
591
|
"stroke-width": 2.5
|
|
@@ -620,7 +620,7 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
|
|
|
620
620
|
title: e.node.visible ? "隐藏图层(最终输出不含该层)" : "显示图层",
|
|
621
621
|
"aria-pressed": !e.node.visible,
|
|
622
622
|
onClick: O((t) => Ke(e), ["stop"])
|
|
623
|
-
}, [g(
|
|
623
|
+
}, [g(a, {
|
|
624
624
|
icon: e.node.visible ? C(de) : C(ue),
|
|
625
625
|
size: 11,
|
|
626
626
|
"stroke-width": 2
|
|
@@ -630,10 +630,10 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
|
|
|
630
630
|
type: "button",
|
|
631
631
|
"data-lock": "",
|
|
632
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"]),
|
|
633
|
-
title: e.node.locked ?
|
|
633
|
+
title: e.node.locked ? o : "锁定图层(画布不可点选/拖动/删除,渲染照常)",
|
|
634
634
|
"aria-pressed": e.node.locked,
|
|
635
635
|
onClick: O((t) => qe(e), ["stop"])
|
|
636
|
-
}, [g(
|
|
636
|
+
}, [g(a, {
|
|
637
637
|
icon: e.node.locked ? C(me) : C(pe),
|
|
638
638
|
size: 11,
|
|
639
639
|
"stroke-width": 2
|
|
@@ -645,7 +645,7 @@ var ge = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
|
|
|
645
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",
|
|
646
646
|
title: "重命名(双击名称或 F2)",
|
|
647
647
|
onClick: O((t) => rt(e), ["stop"])
|
|
648
|
-
}, [g(
|
|
648
|
+
}, [g(a, {
|
|
649
649
|
icon: C(he),
|
|
650
650
|
size: 11,
|
|
651
651
|
"stroke-width": 2
|
package/dist/layer-panel.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./layer-panel-
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./layer-panel-DskyCgF5.js";
|
|
2
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/dist/panel-theme.css
CHANGED
|
@@ -252,3 +252,27 @@
|
|
|
252
252
|
background-color: var(--cn-accent-soft);
|
|
253
253
|
color: var(--cn-accent);
|
|
254
254
|
}
|
|
255
|
+
|
|
256
|
+
/* ---- 资源路径选择器浮层(resource-expression-single-ref 工单 05)----
|
|
257
|
+
portal 到 body 后脱离面板 DOM 子树,根元素自带 .cn-props 重建令牌命名空间;
|
|
258
|
+
抬升底色/投影与高亮态与补全浮层同语言(option 几何以 tailwind utility 留在
|
|
259
|
+
组件模板)。只读展示框的盒子视觉(bg/border/圆角)同 cn-field 输入框族。 */
|
|
260
|
+
.cn-props.cn-pathpicker__menu {
|
|
261
|
+
background-color: var(--cn-bg-elevated);
|
|
262
|
+
box-shadow: 0 16px 40px -12px rgba(2, 6, 23, 0.55);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.cn-props .cn-pathpicker__option--active {
|
|
266
|
+
background-color: var(--cn-accent-soft);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/* 选择器的状态描边(工单 05):PropertyField 的状态类(cn-field--expression/
|
|
270
|
+
cn-field--invalid)经 fallthrough 落在选择器根盒(flex 容器无边框),描边经
|
|
271
|
+
后代选择器落到只读展示框——与 cn-field--invalid 单类规则同值的定向版 */
|
|
272
|
+
.cn-props .cn-field--expression .cn-pathpicker__value {
|
|
273
|
+
border-color: var(--cn-accent);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.cn-props .cn-field--invalid .cn-pathpicker__value {
|
|
277
|
+
border-color: var(--cn-danger);
|
|
278
|
+
}
|
|
@@ -0,0 +1,526 @@
|
|
|
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
|
+
//#region ../canvas-editor/src/shared/expressionSchema.ts
|
|
3
|
+
function v(e) {
|
|
4
|
+
let t = e;
|
|
5
|
+
for (; t !== void 0;) {
|
|
6
|
+
if (t.properties !== void 0) return t.properties;
|
|
7
|
+
t = t.items;
|
|
8
|
+
}
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
function y(e, t) {
|
|
12
|
+
let n = e;
|
|
13
|
+
for (let e of t) {
|
|
14
|
+
let t = v(n)?.get(e);
|
|
15
|
+
if (t === void 0) return null;
|
|
16
|
+
n = t;
|
|
17
|
+
}
|
|
18
|
+
return n;
|
|
19
|
+
}
|
|
20
|
+
function b(e) {
|
|
21
|
+
return e.type === "array" || e.items !== void 0 ? { entries: [] } : { entries: e.properties === void 0 ? [] : [...e.properties].map(([e, t]) => ({
|
|
22
|
+
key: e,
|
|
23
|
+
node: t
|
|
24
|
+
})) };
|
|
25
|
+
}
|
|
26
|
+
function x(e, t) {
|
|
27
|
+
let n = t.split(".");
|
|
28
|
+
return t === "" || n.includes("") ? null : y(e, n)?.items ?? null;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region ../canvas-editor/src/shared/expressionPath.ts
|
|
32
|
+
function S(e) {
|
|
33
|
+
if (e === "") return {
|
|
34
|
+
ok: !1,
|
|
35
|
+
error: "expression_syntax_error"
|
|
36
|
+
};
|
|
37
|
+
let t = e.split(".");
|
|
38
|
+
if (t.includes("")) return {
|
|
39
|
+
ok: !1,
|
|
40
|
+
error: "expression_syntax_error"
|
|
41
|
+
};
|
|
42
|
+
let n = t[0], r = t.slice(1);
|
|
43
|
+
return n === "row" ? {
|
|
44
|
+
ok: !0,
|
|
45
|
+
head: { kind: "row" },
|
|
46
|
+
rest: r
|
|
47
|
+
} : n === "$root" ? {
|
|
48
|
+
ok: !0,
|
|
49
|
+
head: { kind: "root" },
|
|
50
|
+
rest: r
|
|
51
|
+
} : {
|
|
52
|
+
ok: !0,
|
|
53
|
+
head: {
|
|
54
|
+
kind: "bare",
|
|
55
|
+
name: n
|
|
56
|
+
},
|
|
57
|
+
rest: r
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region ../canvas-editor/src/shared/expressionCall.ts
|
|
62
|
+
var C = " \n\r\0\v", w = " \n\r", T = `()',.${C}`;
|
|
63
|
+
function E(e) {
|
|
64
|
+
let t = 0, n = e.length;
|
|
65
|
+
for (; t < n && C.includes(e[t]);) t += 1;
|
|
66
|
+
for (; n > t && C.includes(e[n - 1]);) --n;
|
|
67
|
+
return e.slice(t, n);
|
|
68
|
+
}
|
|
69
|
+
function D(e, t) {
|
|
70
|
+
for (; t < e.length && w.includes(e[t]);) t += 1;
|
|
71
|
+
return t;
|
|
72
|
+
}
|
|
73
|
+
function O(e, t, n) {
|
|
74
|
+
return {
|
|
75
|
+
ok: !1,
|
|
76
|
+
error: "expression_syntax_error",
|
|
77
|
+
kind: e,
|
|
78
|
+
at: {
|
|
79
|
+
start: t,
|
|
80
|
+
end: n
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function k(e) {
|
|
85
|
+
let t = 0;
|
|
86
|
+
for (; t < e.length && !T.includes(e[t]);) t += 1;
|
|
87
|
+
if (t === 0) return !1;
|
|
88
|
+
let n = t;
|
|
89
|
+
for (; n < e.length && C.includes(e[n]);) n += 1;
|
|
90
|
+
return e[n] === "(";
|
|
91
|
+
}
|
|
92
|
+
function A(e) {
|
|
93
|
+
let t = 0;
|
|
94
|
+
for (; t < e.length && !T.includes(e[t]);) t += 1;
|
|
95
|
+
if (t === 0) return O("invalid_path", 0, e.length);
|
|
96
|
+
let n = e.slice(0, t), r = D(e, t);
|
|
97
|
+
if (r >= e.length || e[r] !== "(") return O("missing_open_paren", t, e.length);
|
|
98
|
+
let i = r;
|
|
99
|
+
r = D(e, r + 1);
|
|
100
|
+
let a = [], o = [];
|
|
101
|
+
if (r < e.length && e[r] === ")") r += 1;
|
|
102
|
+
else for (;;) {
|
|
103
|
+
if (r >= e.length) return O("unbalanced_paren", i, e.length);
|
|
104
|
+
let t = j(e, r);
|
|
105
|
+
if (!t.ok) return t;
|
|
106
|
+
if (a.push(t.value), o.push({
|
|
107
|
+
start: t.start,
|
|
108
|
+
end: t.end
|
|
109
|
+
}), r = D(e, t.end), r >= e.length) return O("unbalanced_paren", i, e.length);
|
|
110
|
+
if (e[r] === ",") {
|
|
111
|
+
let t = r;
|
|
112
|
+
if (r = D(e, r + 1), r < e.length && e[r] === ")") return O("empty_arg_slot", t + 1, r);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (e[r] === ")") {
|
|
116
|
+
r += 1;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
return O("bad_arg_syntax", r, r + 1);
|
|
120
|
+
}
|
|
121
|
+
if (r = D(e, r), r !== e.length) return O("trailing_after_call", r, e.length);
|
|
122
|
+
if (a[0] !== void 0 && a[0].type !== "path") {
|
|
123
|
+
let e = o[0];
|
|
124
|
+
return O("first_arg_not_path", e.start, e.end);
|
|
125
|
+
}
|
|
126
|
+
for (let e = 0; e < a.length; e += 1) {
|
|
127
|
+
let t = a[e], n = o[e];
|
|
128
|
+
if (t.type === "path" && !S(t.value).ok) return O("invalid_path_arg", n.start, n.end);
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
ok: !0,
|
|
132
|
+
name: n,
|
|
133
|
+
args: a
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function j(e, t) {
|
|
137
|
+
let n = e.length, r = t, i = e[t];
|
|
138
|
+
if (i === "'") {
|
|
139
|
+
let i = t + 1, a = "";
|
|
140
|
+
for (;;) {
|
|
141
|
+
if (i >= n) return {
|
|
142
|
+
ok: !1,
|
|
143
|
+
error: "expression_syntax_error",
|
|
144
|
+
kind: "unterminated_string",
|
|
145
|
+
at: {
|
|
146
|
+
start: r,
|
|
147
|
+
end: n
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
if (e[i] === "'") {
|
|
151
|
+
if (i + 1 < n && e[i + 1] === "'") {
|
|
152
|
+
a += "'", i += 2;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
i += 1;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
a += e[i], i += 1;
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
ok: !0,
|
|
162
|
+
value: {
|
|
163
|
+
type: "string",
|
|
164
|
+
value: a
|
|
165
|
+
},
|
|
166
|
+
start: r,
|
|
167
|
+
end: i
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (i >= "0" && i <= "9") {
|
|
171
|
+
let i = (t) => {
|
|
172
|
+
let n = e[t];
|
|
173
|
+
return n !== void 0 && n >= "0" && n <= "9";
|
|
174
|
+
};
|
|
175
|
+
for (; i(t);) t += 1;
|
|
176
|
+
if (t < n && e[t] === "." && i(t + 1)) for (t += 1; i(t);) t += 1;
|
|
177
|
+
return {
|
|
178
|
+
ok: !0,
|
|
179
|
+
value: {
|
|
180
|
+
type: "number",
|
|
181
|
+
value: e.slice(r, t)
|
|
182
|
+
},
|
|
183
|
+
start: r,
|
|
184
|
+
end: t
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
for (; t < n && e[t] !== "," && e[t] !== ")";) t += 1;
|
|
188
|
+
let a = E(e.slice(r, t));
|
|
189
|
+
return a === "" ? {
|
|
190
|
+
ok: !1,
|
|
191
|
+
error: "expression_syntax_error",
|
|
192
|
+
kind: "empty_arg_slot",
|
|
193
|
+
at: {
|
|
194
|
+
start: r,
|
|
195
|
+
end: t
|
|
196
|
+
}
|
|
197
|
+
} : {
|
|
198
|
+
ok: !0,
|
|
199
|
+
value: {
|
|
200
|
+
type: "path",
|
|
201
|
+
value: a
|
|
202
|
+
},
|
|
203
|
+
start: r,
|
|
204
|
+
end: t
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function M(e) {
|
|
208
|
+
let t = 0;
|
|
209
|
+
for (; t < e.length && !T.includes(e[t]);) t += 1;
|
|
210
|
+
if (t === 0) return null;
|
|
211
|
+
let n = D(e, t);
|
|
212
|
+
if (n >= e.length || e[n] !== "(") return null;
|
|
213
|
+
n = D(e, n + 1);
|
|
214
|
+
let r = 0;
|
|
215
|
+
for (;;) {
|
|
216
|
+
if (n >= e.length) return {
|
|
217
|
+
name: e.slice(0, t),
|
|
218
|
+
index: r,
|
|
219
|
+
text: "",
|
|
220
|
+
stringSlot: !1
|
|
221
|
+
};
|
|
222
|
+
let i = e[n];
|
|
223
|
+
if (i === "'") {
|
|
224
|
+
let i = n + 1;
|
|
225
|
+
for (;;) {
|
|
226
|
+
if (i >= e.length) return {
|
|
227
|
+
name: e.slice(0, t),
|
|
228
|
+
index: r,
|
|
229
|
+
text: e.slice(n + 1),
|
|
230
|
+
stringSlot: !0
|
|
231
|
+
};
|
|
232
|
+
if (e[i] === "'") {
|
|
233
|
+
if (i + 1 < e.length && e[i + 1] === "'") {
|
|
234
|
+
i += 2;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
i += 1;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
i += 1;
|
|
241
|
+
}
|
|
242
|
+
n = i;
|
|
243
|
+
} else if (i !== "," && i !== ")") {
|
|
244
|
+
let i = n;
|
|
245
|
+
for (; n < e.length && e[n] !== "," && e[n] !== ")";) n += 1;
|
|
246
|
+
if (n >= e.length) return {
|
|
247
|
+
name: e.slice(0, t),
|
|
248
|
+
index: r,
|
|
249
|
+
text: E(e.slice(i)),
|
|
250
|
+
stringSlot: !1
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
if (n >= e.length) return {
|
|
254
|
+
name: e.slice(0, t),
|
|
255
|
+
index: r + 1,
|
|
256
|
+
text: "",
|
|
257
|
+
stringSlot: !1
|
|
258
|
+
};
|
|
259
|
+
if (e[n] === ")") return null;
|
|
260
|
+
r += 1, n = D(e, n + 1);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function N(e) {
|
|
264
|
+
let t = 0, n = e.length;
|
|
265
|
+
for (; t < n && " \n\r\0\v".includes(e[t]);) t += 1;
|
|
266
|
+
for (; n > t && " \n\r\0\v".includes(e[n - 1]);) --n;
|
|
267
|
+
return e.slice(t, n);
|
|
268
|
+
}
|
|
269
|
+
function P(e) {
|
|
270
|
+
if (e === "") return {
|
|
271
|
+
kind: "empty_fragment",
|
|
272
|
+
at: {
|
|
273
|
+
start: 0,
|
|
274
|
+
end: 0
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
if (k(e)) {
|
|
278
|
+
let t = A(e);
|
|
279
|
+
return t.ok ? null : {
|
|
280
|
+
kind: t.kind,
|
|
281
|
+
at: t.at
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
return S(e).ok ? null : {
|
|
285
|
+
kind: "invalid_path",
|
|
286
|
+
at: {
|
|
287
|
+
start: 0,
|
|
288
|
+
end: e.length
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function F(e) {
|
|
293
|
+
let t = 0;
|
|
294
|
+
for (; t < e.length && " \n\r\0\v".includes(e[t]);) t += 1;
|
|
295
|
+
return t;
|
|
296
|
+
}
|
|
297
|
+
function I(e) {
|
|
298
|
+
let t = [], n = 0, r = e.indexOf("{{");
|
|
299
|
+
for (; r !== -1;) {
|
|
300
|
+
let i = e.indexOf("}}", r + 2);
|
|
301
|
+
if (i === -1) {
|
|
302
|
+
r > n && t.push({
|
|
303
|
+
kind: "literal",
|
|
304
|
+
start: n,
|
|
305
|
+
end: r,
|
|
306
|
+
text: e.slice(n, r)
|
|
307
|
+
});
|
|
308
|
+
let i = e.slice(r);
|
|
309
|
+
return t.push({
|
|
310
|
+
kind: "open",
|
|
311
|
+
start: r,
|
|
312
|
+
end: e.length,
|
|
313
|
+
text: i,
|
|
314
|
+
expr: N(i.slice(2))
|
|
315
|
+
}), {
|
|
316
|
+
template: e,
|
|
317
|
+
parts: t
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
r > n && t.push({
|
|
321
|
+
kind: "literal",
|
|
322
|
+
start: n,
|
|
323
|
+
end: r,
|
|
324
|
+
text: e.slice(n, r)
|
|
325
|
+
});
|
|
326
|
+
let a = e.slice(r + 2, i), o = N(a), s = null, c = P(o);
|
|
327
|
+
if (c) {
|
|
328
|
+
let e = r + 2 + F(a);
|
|
329
|
+
s = {
|
|
330
|
+
kind: c.kind,
|
|
331
|
+
start: r,
|
|
332
|
+
end: i + 2,
|
|
333
|
+
at: {
|
|
334
|
+
start: e + c.at.start,
|
|
335
|
+
end: e + c.at.end
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
t.push({
|
|
340
|
+
kind: "fragment",
|
|
341
|
+
start: r,
|
|
342
|
+
end: i + 2,
|
|
343
|
+
raw: a,
|
|
344
|
+
expr: o,
|
|
345
|
+
error: s === null ? null : "expression_syntax_error",
|
|
346
|
+
diagnostic: s
|
|
347
|
+
}), n = i + 2, r = e.indexOf("{{", n);
|
|
348
|
+
}
|
|
349
|
+
return n < e.length && t.push({
|
|
350
|
+
kind: "literal",
|
|
351
|
+
start: n,
|
|
352
|
+
end: e.length,
|
|
353
|
+
text: e.slice(n)
|
|
354
|
+
}), {
|
|
355
|
+
template: e,
|
|
356
|
+
parts: t
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
function L(e, t) {
|
|
360
|
+
for (let n of e.parts) if (n.kind !== "literal" && (n.kind === "open" ? t > n.start && t <= n.end : t > n.start && t < n.end)) return n;
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region src/shared/PanelIcon.vue
|
|
365
|
+
var R = /* @__PURE__ */ o({
|
|
366
|
+
inheritAttrs: !1,
|
|
367
|
+
__name: "PanelIcon",
|
|
368
|
+
props: {
|
|
369
|
+
icon: {},
|
|
370
|
+
size: { default: 14 },
|
|
371
|
+
strokeWidth: { default: 2 }
|
|
372
|
+
},
|
|
373
|
+
setup(e) {
|
|
374
|
+
return (t, r) => (d(), n(m(e.icon), s({
|
|
375
|
+
size: e.size,
|
|
376
|
+
"stroke-width": e.strokeWidth
|
|
377
|
+
}, t.$attrs), null, 16, ["size", "stroke-width"]));
|
|
378
|
+
}
|
|
379
|
+
}), z = {
|
|
380
|
+
role: "listbox",
|
|
381
|
+
"aria-label": "表达式路径候选"
|
|
382
|
+
}, B = [
|
|
383
|
+
"aria-selected",
|
|
384
|
+
"title",
|
|
385
|
+
"onClick"
|
|
386
|
+
], V = { class: "cn-completion__segment font-mono text-cn-fg" }, H = {
|
|
387
|
+
key: 0,
|
|
388
|
+
class: "shrink-0 rounded-sm bg-cn-field px-1 py-0.5 text-[9px] leading-none text-cn-muted"
|
|
389
|
+
}, U = {
|
|
390
|
+
key: 1,
|
|
391
|
+
class: "truncate text-[10px] leading-none text-cn-muted"
|
|
392
|
+
}, W = /* @__PURE__ */ o({
|
|
393
|
+
__name: "ExpressionCompletionPopup",
|
|
394
|
+
props: { state: {} },
|
|
395
|
+
emits: ["select"],
|
|
396
|
+
setup(o, { expose: s, emit: m }) {
|
|
397
|
+
let v = o, y = m, b = f(null);
|
|
398
|
+
return s({ rootEl: b }), g(() => v.state.activeIndex, async () => {
|
|
399
|
+
await c(), b.value?.querySelector(".cn-completion__option--active")?.scrollIntoView?.({ block: "nearest" });
|
|
400
|
+
}), (s, c) => (d(), n(t, { to: "body" }, [o.state.open ? (d(), i("div", {
|
|
401
|
+
key: 0,
|
|
402
|
+
ref_key: "rootRef",
|
|
403
|
+
ref: b,
|
|
404
|
+
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",
|
|
405
|
+
style: u({
|
|
406
|
+
top: `${o.state.top}px`,
|
|
407
|
+
left: `${o.state.left}px`
|
|
408
|
+
}),
|
|
409
|
+
onMousedown: c[0] ||= _(() => {}, ["prevent", "stop"]),
|
|
410
|
+
onPointerdown: c[1] ||= _(() => {}, ["stop"])
|
|
411
|
+
}, [a("div", z, [(d(!0), i(e, null, p(o.state.items, (e, t) => (d(), i("button", {
|
|
412
|
+
key: `${t}:${e.segment}`,
|
|
413
|
+
type: "button",
|
|
414
|
+
role: "option",
|
|
415
|
+
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" : ""]),
|
|
416
|
+
"aria-selected": t === o.state.activeIndex,
|
|
417
|
+
title: e.path ?? e.segment,
|
|
418
|
+
onClick: (e) => y("select", t)
|
|
419
|
+
}, [
|
|
420
|
+
a("span", V, h(e.segment), 1),
|
|
421
|
+
e.type ? (d(), i("span", H, h(e.type), 1)) : r("", !0),
|
|
422
|
+
e.description ?? e.title ? (d(), i("span", U, h(e.description ?? e.title), 1)) : r("", !0)
|
|
423
|
+
], 10, B))), 128))])], 36)) : r("", !0)]));
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region src/shared/completion.ts
|
|
428
|
+
function G(e, t, n, r, i) {
|
|
429
|
+
let a = t.start + 2, o = t.kind === "open" ? t.end : t.end - 2, s = Math.min(n, o), c = 0;
|
|
430
|
+
for (; s - c > a && " \n\r\0\v".includes(e[s - 1 - c]);) c += 1;
|
|
431
|
+
let l = s - c, u = l - (i.replaceLen ?? r.length);
|
|
432
|
+
if (u < a || i.replaceLen === void 0 && e.slice(u, l) !== r) return null;
|
|
433
|
+
let d = i.cursorBack ?? 0;
|
|
434
|
+
return d > i.segment.length ? null : {
|
|
435
|
+
value: e.slice(0, u) + i.segment + e.slice(l),
|
|
436
|
+
cursor: u + i.segment.length - d
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/shared/completionAnchor.ts
|
|
441
|
+
function K(e, t) {
|
|
442
|
+
return parseFloat(e.getPropertyValue(t)) || 0;
|
|
443
|
+
}
|
|
444
|
+
function q(e, t, n) {
|
|
445
|
+
for (let r of n) {
|
|
446
|
+
let n = e.getPropertyValue(r);
|
|
447
|
+
n && t.setProperty(r, n);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
var J = [
|
|
451
|
+
"font-family",
|
|
452
|
+
"font-size",
|
|
453
|
+
"font-weight",
|
|
454
|
+
"font-style",
|
|
455
|
+
"font-stretch",
|
|
456
|
+
"letter-spacing",
|
|
457
|
+
"word-spacing",
|
|
458
|
+
"line-height",
|
|
459
|
+
"text-transform",
|
|
460
|
+
"text-indent",
|
|
461
|
+
"tab-size"
|
|
462
|
+
];
|
|
463
|
+
function Y(e) {
|
|
464
|
+
return K(e, "line-height") || K(e, "font-size") * 1.4;
|
|
465
|
+
}
|
|
466
|
+
function X(e) {
|
|
467
|
+
let t = document.createElement("div"), n = t.style;
|
|
468
|
+
return n.position = "fixed", n.top = "0", n.left = "0", n.visibility = "hidden", e(t, n), document.body.appendChild(t), t;
|
|
469
|
+
}
|
|
470
|
+
function Z(e, t) {
|
|
471
|
+
let n = e.selectionStart ?? e.value.length, r = e.getBoundingClientRect(), i = getComputedStyle(e), a = K(i, "padding-left"), o = K(i, "padding-top"), s = null, c = X((t, r) => {
|
|
472
|
+
r.whiteSpace = i.whiteSpace || "pre-wrap", r.boxSizing = "content-box", r.width = `${Math.max(0, e.clientWidth - a - K(i, "padding-right"))}px`, q(i, r, [
|
|
473
|
+
"padding-left",
|
|
474
|
+
"padding-right",
|
|
475
|
+
"padding-top",
|
|
476
|
+
"padding-bottom",
|
|
477
|
+
"word-break",
|
|
478
|
+
"overflow-wrap"
|
|
479
|
+
]), q(i, r, J), s = document.createElement("span"), s.textContent = "", t.append(document.createTextNode(e.value.slice(0, n)), s);
|
|
480
|
+
});
|
|
481
|
+
try {
|
|
482
|
+
let n = r.left + K(i, "border-left-width") + a + s.offsetLeft * t - e.scrollLeft, c = r.top + K(i, "border-top-width") + o + s.offsetTop * t - e.scrollTop;
|
|
483
|
+
return {
|
|
484
|
+
left: n,
|
|
485
|
+
top: c,
|
|
486
|
+
bottom: c + Y(i) * t
|
|
487
|
+
};
|
|
488
|
+
} finally {
|
|
489
|
+
c.remove();
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
function Q(e, t) {
|
|
493
|
+
let n = e.selectionStart ?? e.value.length, r = e.getBoundingClientRect(), i = getComputedStyle(e), a = X((t, r) => {
|
|
494
|
+
r.display = "inline-block", r.whiteSpace = "pre", q(i, r, J), t.textContent = e.value.slice(0, n);
|
|
495
|
+
});
|
|
496
|
+
try {
|
|
497
|
+
let n = a.getBoundingClientRect().width || a.offsetWidth;
|
|
498
|
+
return {
|
|
499
|
+
left: r.left + K(i, "border-left-width") + K(i, "padding-left") + n * t - e.scrollLeft,
|
|
500
|
+
top: r.top + K(i, "border-top-width"),
|
|
501
|
+
bottom: r.bottom - K(i, "border-bottom-width")
|
|
502
|
+
};
|
|
503
|
+
} finally {
|
|
504
|
+
a.remove();
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
function $(e, t = 1) {
|
|
508
|
+
return e instanceof HTMLTextAreaElement ? Z(e, t) : Q(e, t);
|
|
509
|
+
}
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region src/shared/popupPosition.ts
|
|
512
|
+
var ee = 4, te = 4;
|
|
513
|
+
function ne(e) {
|
|
514
|
+
let { anchor: t, popupWidth: n, popupHeight: r, viewportWidth: i, viewportHeight: a } = e, o = e.gap ?? 4, s = e.margin ?? 4, c = t.bottom + o;
|
|
515
|
+
if (r > 0 && c + r > a - s) {
|
|
516
|
+
let e = t.top - o - r;
|
|
517
|
+
c = e >= s ? e : Math.max(s, Math.min(c, a - s - r));
|
|
518
|
+
}
|
|
519
|
+
let l = t.left;
|
|
520
|
+
return n > 0 && (l = Math.max(s, Math.min(l, i - s - n))), {
|
|
521
|
+
top: c,
|
|
522
|
+
left: l
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
//#endregion
|
|
526
|
+
export { G as a, L as c, M as d, k as f, y as g, b as h, $ as i, N as l, x as m, te as n, W as o, S as p, ne as r, R as s, ee as t, I as u };
|