@hankchen/canvas-editor-react 0.0.0-stage → 1.0.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.
Files changed (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +157 -2
  3. package/dist/DropdownMenu-CCvv55NI.js +967 -0
  4. package/dist/PanelIcon-cQ-hx-Ky.js +87 -0
  5. package/dist/Tooltip-BAFJN0xP.js +815 -0
  6. package/dist/canvas/AlignFloatBar.d.ts +6 -0
  7. package/dist/canvas/CanvasSurface.d.ts +13 -0
  8. package/dist/canvas/ContextMenu.d.ts +14 -0
  9. package/dist/canvas/EditOverlayToolbar.d.ts +30 -0
  10. package/dist/canvas/FindBar.d.ts +13 -0
  11. package/dist/canvas/GuidesOverlay.d.ts +19 -0
  12. package/dist/canvas/Ruler.d.ts +32 -0
  13. package/dist/canvas/TextEditingOverlay.d.ts +22 -0
  14. package/dist/canvas/createBand.d.ts +6 -0
  15. package/dist/canvas/findHighlight.d.ts +12 -0
  16. package/dist/canvas/gizmo.d.ts +24 -0
  17. package/dist/canvas/guideSnap.d.ts +5 -0
  18. package/dist/canvas/index.d.ts +24 -0
  19. package/dist/canvas/resizeHandles.d.ts +3 -0
  20. package/dist/canvas/scheduler.d.ts +2 -0
  21. package/dist/canvas/useDpr.d.ts +9 -0
  22. package/dist/canvas/useFindSession.d.ts +12 -0
  23. package/dist/canvas/useTextEditing.d.ts +90 -0
  24. package/dist/canvas-jJ7OaUvZ.js +2171 -0
  25. package/dist/canvas.js +2 -0
  26. package/dist/chevron-down-D0_YGxvV.js +359 -0
  27. package/dist/createLucideIcon-CLd1sc0f.js +140 -0
  28. package/dist/index.d.ts +19 -0
  29. package/dist/index.js +16 -0
  30. package/dist/layer-panel/LayerPanel.d.ts +6 -0
  31. package/dist/layer-panel/TemplateTableForm.d.ts +10 -0
  32. package/dist/layer-panel/addMenu.d.ts +68 -0
  33. package/dist/layer-panel/index.d.ts +11 -0
  34. package/dist/layer-panel/useLayerPanel.d.ts +12 -0
  35. package/dist/layer-panel-DIfOb40N.js +779 -0
  36. package/dist/layer-panel.js +2 -0
  37. package/dist/mergeKey--xr8gdWl.js +694 -0
  38. package/dist/property-panel/PropertyField.d.ts +39 -0
  39. package/dist/property-panel/PropertyPanel.d.ts +5 -0
  40. package/dist/property-panel/controlStyles.d.ts +17 -0
  41. package/dist/property-panel/controls.d.ts +42 -0
  42. package/dist/property-panel/fieldSchema.d.ts +142 -0
  43. package/dist/property-panel/fields/AlignField.d.ts +3 -0
  44. package/dist/property-panel/fields/AnchorDisclosureField.d.ts +3 -0
  45. package/dist/property-panel/fields/BooleanField.d.ts +3 -0
  46. package/dist/property-panel/fields/BorderField.d.ts +3 -0
  47. package/dist/property-panel/fields/BorderWidthInput.d.ts +9 -0
  48. package/dist/property-panel/fields/ColorField.d.ts +3 -0
  49. package/dist/property-panel/fields/FontField.d.ts +3 -0
  50. package/dist/property-panel/fields/ImageSrcField.d.ts +3 -0
  51. package/dist/property-panel/fields/NumberField.d.ts +3 -0
  52. package/dist/property-panel/fields/PaddingField.d.ts +3 -0
  53. package/dist/property-panel/fields/PairField.d.ts +3 -0
  54. package/dist/property-panel/fields/ResourceValueField.d.ts +3 -0
  55. package/dist/property-panel/fields/RowsPathField.d.ts +3 -0
  56. package/dist/property-panel/fields/SelectField.d.ts +3 -0
  57. package/dist/property-panel/fields/ShorthandModeButton.d.ts +7 -0
  58. package/dist/property-panel/fields/TextField.d.ts +3 -0
  59. package/dist/property-panel/fields/TextareaField.d.ts +3 -0
  60. package/dist/property-panel/fields/ValueTypeSegmented.d.ts +8 -0
  61. package/dist/property-panel/fields/index.d.ts +18 -0
  62. package/dist/property-panel/fields/intrinsicSize.d.ts +9 -0
  63. package/dist/property-panel/imageUpload.d.ts +11 -0
  64. package/dist/property-panel/index.d.ts +14 -0
  65. package/dist/property-panel/shorthand.d.ts +28 -0
  66. package/dist/property-panel/usePropertyPanel.d.ts +67 -0
  67. package/dist/property-panel/useShorthandMode.d.ts +17 -0
  68. package/dist/property-panel-DD45Myee.js +1861 -0
  69. package/dist/property-panel.js +3 -0
  70. package/dist/resourceTemplate-B4QRWGq7.js +33 -0
  71. package/dist/shared/DropdownMenu.d.ts +18 -0
  72. package/dist/shared/ExpressionCompletionPopup.d.ts +11 -0
  73. package/dist/shared/ExpressionPathPicker.d.ts +23 -0
  74. package/dist/shared/HelpDialog.d.ts +10 -0
  75. package/dist/shared/PanelIcon.d.ts +11 -0
  76. package/dist/shared/Tooltip.d.ts +11 -0
  77. package/dist/shared/completion.d.ts +73 -0
  78. package/dist/shared/completionAnchor.d.ts +28 -0
  79. package/dist/shared/editableTarget.d.ts +14 -0
  80. package/dist/shared/expressionContext.d.ts +22 -0
  81. package/dist/shared/fontPicker.d.ts +13 -0
  82. package/dist/shared/index.d.ts +42 -0
  83. package/dist/shared/mergeKey.d.ts +2 -0
  84. package/dist/shared/pathPickerModel.d.ts +24 -0
  85. package/dist/shared/popupPosition.d.ts +41 -0
  86. package/dist/shared/resourceTemplate.d.ts +7 -0
  87. package/dist/shared/rowsPathPickerSource.d.ts +15 -0
  88. package/dist/shared/shortcutsHelp.d.ts +30 -0
  89. package/dist/shared/uploadFile.d.ts +2 -0
  90. package/dist/shared/useCnTheme.d.ts +11 -0
  91. package/dist/shared/useDataSourceSchema.d.ts +10 -0
  92. package/dist/shared/useDoc.d.ts +2 -0
  93. package/dist/shared/useDocumentExchange.d.ts +21 -0
  94. package/dist/shared/useDropdownMenu.d.ts +163 -0
  95. package/dist/shared/useExpressionCompletion.d.ts +35 -0
  96. package/dist/shared/useExpressionDiagnostics.d.ts +29 -0
  97. package/dist/shared/useHistory.d.ts +6 -0
  98. package/dist/shared/useSelection.d.ts +2 -0
  99. package/dist/shared/useShortcuts.d.ts +2 -0
  100. package/dist/shared/useShortcutsHelp.d.ts +8 -0
  101. package/dist/shared/useTransientFeedback.d.ts +9 -0
  102. package/dist/shared/useViewport.d.ts +2 -0
  103. package/dist/shared-QI04Xk-a.js +236 -0
  104. package/dist/shared.js +9 -0
  105. package/dist/status-bar/StatusBar.d.ts +14 -0
  106. package/dist/status-bar/index.d.ts +9 -0
  107. package/dist/status-bar/layerGeometryLabel.d.ts +13 -0
  108. package/dist/status-bar/layerPathLabel.d.ts +2 -0
  109. package/dist/status-bar-Bt3TonDm.js +181 -0
  110. package/dist/status-bar.js +2 -0
  111. package/dist/style.css +2 -0
  112. package/dist/theme.css +420 -0
  113. package/dist/useDoc-B2LXNJV7.js +32 -0
  114. package/dist/useViewport-DXtOHYgJ.js +18 -0
  115. package/package.json +83 -3
@@ -0,0 +1,3 @@
1
+ import { n as e, r as t } from "./mergeKey--xr8gdWl.js";
2
+ import { a as n, c as r, d as i, f as a, i as o, l as s, n as c, o as l, r as u, s as d, t as f, u as p } from "./property-panel-DD45Myee.js";
3
+ export { d as CANVAS_FIELD_SECTIONS, r as FIELD_SECTIONS_BY_TYPE, e as FONT_PICKER_KEY, n as IMAGE_UPLOAD_KEY, c as PropertyField, f as PropertyPanel, o as controlRegistry, s as fieldSectionsForPath, p as fieldSectionsForType, t as injectFontPicker, l as injectImageUpload, i as layerRoleAt, a as readField, u as usePropertyPanel };
@@ -0,0 +1,33 @@
1
+ import { f as e } from "./Tooltip-BAFJN0xP.js";
2
+ //#region ../canvas-editor/src/shared/resourcePath.ts
3
+ function t(e, t) {
4
+ return {
5
+ kind: t,
6
+ start: 0,
7
+ end: e.length,
8
+ at: {
9
+ start: 0,
10
+ end: e.length
11
+ }
12
+ };
13
+ }
14
+ function n(n) {
15
+ let r = n.endsWith("\n") ? n.slice(0, -1) : n, i = /^\{\{([^{}]*)\}\}$/.exec(r);
16
+ if (i === null) return [t(n, "resource_not_single_ref")];
17
+ let a = e(i[1] ?? "");
18
+ return a === "" ? [t(n, "empty_fragment")] : a.includes("(") ? [t(n, "resource_function_call")] : [];
19
+ }
20
+ //#endregion
21
+ //#region src/shared/resourceTemplate.ts
22
+ function r(t) {
23
+ if (n(t).length > 0) return null;
24
+ let r = t.endsWith("\n") ? t.slice(0, -1) : t, i = /^\{\{([^{}]*)\}\}$/.exec(r)?.[1];
25
+ if (i === void 0) return null;
26
+ let a = e(i);
27
+ return a === "" ? null : a;
28
+ }
29
+ function i(e) {
30
+ return `{{${e}}}`;
31
+ }
32
+ //#endregion
33
+ export { r as n, n as r, i as t };
@@ -0,0 +1,18 @@
1
+ import { ReactNode } from 'react';
2
+ import { DropdownMenuEntry, DropdownMenuSlotProps } from './useDropdownMenu';
3
+ export interface DropdownMenuProps {
4
+ /** 触发钮文案(▾ 收合指示组件自带)+ 菜单 aria-label */
5
+ label: string;
6
+ items: readonly DropdownMenuEntry[];
7
+ /** 触发钮悬停说明;缺省回落 label */
8
+ title?: string;
9
+ /** 弹层方向:down = 触发钮下缘向下(工具栏缺省);up = 上缘向上(状态栏贴视口底缘) */
10
+ direction?: 'up' | 'down';
11
+ /** 菜单收起回调(开→收即发,收起三路 + 分发都覆盖):消费方随收清理用 */
12
+ onClosed?: () => void;
13
+ /** 自定义触发钮 render-prop(受控 props);缺省渲染内建 ghost 钮 */
14
+ trigger?: (slotProps: DropdownMenuSlotProps) => ReactNode;
15
+ /** 菜单体附加内容 render-prop(渲染在菜单项之后):容器包含判定覆盖——内含点击不收 */
16
+ body?: (slotProps: DropdownMenuSlotProps) => ReactNode;
17
+ }
18
+ export declare function DropdownMenu({ label, items, title, direction, onClosed, trigger, body }: DropdownMenuProps): ReactNode;
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ import { ExpressionCompletionState } from './useExpressionCompletion';
3
+ export interface ExpressionCompletionPopupProps {
4
+ /** 浮层呈现态(useExpressionCompletion 的 popup 快照) */
5
+ state: ExpressionCompletionState;
6
+ /** 候选点选(含键盘 Enter/Tab 接受路径的宿主回接) */
7
+ onSelect: (index: number) => void;
8
+ /** 浮层根元素回调(宿主量宽做视口右缘收口;未挂载 null) */
9
+ rootRef?: (el: HTMLElement | null) => void;
10
+ }
11
+ export declare function ExpressionCompletionPopup({ state, onSelect, rootRef }: ExpressionCompletionPopupProps): ReactNode;
@@ -0,0 +1,23 @@
1
+ import { ReactNode } from 'react';
2
+ import { CompletionSource } from './completion';
3
+ import { PathPickerMode } from './pathPickerModel';
4
+ export interface ExpressionPathPickerProps {
5
+ /** 裸点路径原文(壳已拆 `{{}}`;存量违例拆不动时壳原样透传,只读回显) */
6
+ modelValue: string;
7
+ /** 候选源(面板同款注入缝);null = 未绑声明,不渲染菜单入口整体只读 */
8
+ source: CompletionSource | null;
9
+ /** 禁用(会话内容锁定面):同 null 的只读呈现 */
10
+ disabled?: boolean;
11
+ /** 展示框/菜单的可访问名(字段标签透传) */
12
+ ariaLabel?: string;
13
+ /** 空值占位文案 */
14
+ placeholder?: string;
15
+ /** 终点形态:'resource' = 叶子终点(缺省);'rowsPath' = 数组终点 */
16
+ mode?: PathPickerMode;
17
+ /** 根盒布局/状态类透传(PropertyField 下发:col-span-2、cn-field--expression/invalid
18
+ * 落根盒——描边经 theme.css 后代选择器落到只读展示框) */
19
+ className?: string;
20
+ /** 点选提交(数组/叶子终点;壳层映射回 input+change 双事件) */
21
+ onPick?: (path: string) => void;
22
+ }
23
+ export declare function ExpressionPathPicker({ modelValue, source, disabled, ariaLabel, placeholder, mode, className, onPick, }: ExpressionPathPickerProps): ReactNode;
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ import { EditorShortcutBinding } from '@hankchen/canvas-editor';
3
+ import { ShortcutPlatform } from './shortcutsHelp';
4
+ export interface HelpDialogProps {
5
+ /** 注册表注入缝:缺省内核缺省集;宿主扩展键位后传定制集即自动入面板 */
6
+ bindings?: readonly EditorShortcutBinding[];
7
+ /** 平台注入缝(键位符号形态);缺省按 navigator 侦测 */
8
+ platform?: ShortcutPlatform;
9
+ }
10
+ export declare function HelpDialog({ bindings, platform }: HelpDialogProps): ReactNode;
@@ -0,0 +1,11 @@
1
+ import { LucideIcon } from 'lucide-react';
2
+ import { ReactNode, SVGProps } from 'react';
3
+ export interface PanelIconProps extends SVGProps<SVGSVGElement> {
4
+ /** lucide 图标组件(消费方按名 import,不用字符串名——摇树按引用走) */
5
+ icon: LucideIcon;
6
+ /** 显示边长 px(默认 14:面板 11.5px 字号尺度) */
7
+ size?: number;
8
+ /** 描边宽(viewBox 24 尺度,默认 2 = lucide 设计比例) */
9
+ strokeWidth?: number;
10
+ }
11
+ export declare function PanelIcon({ icon: Icon, size, strokeWidth, ...rest }: PanelIconProps): ReactNode;
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TooltipProps {
3
+ /** 气泡文案(纯文本;富内容不做,spec Out of Scope) */
4
+ label: string;
5
+ /** 悬停延迟毫秒(键盘聚焦即时显示不走本档);缺省 300 */
6
+ delay?: number;
7
+ /** wrapper 布局类透传(面板宫格 flex-1/min-w-0 等消费) */
8
+ className?: string;
9
+ children: ReactNode;
10
+ }
11
+ export declare function Tooltip({ label, delay, className, children }: TooltipProps): ReactNode;
@@ -0,0 +1,73 @@
1
+ import { ExpressionScanFragment, ExpressionScanOpen } from '@hankchen/canvas-editor';
2
+ /** 一条补全候选:接受段 + 展示元信息(path 为补全后的完整点路径) */
3
+ export interface CompletionItem {
4
+ /** 补全后的完整点路径(头部候选即段名);展示/悬停用,源未给可省 */
5
+ path?: string;
6
+ /** 接受时替换 partial 的段文本 */
7
+ segment: string;
8
+ /** schema description(未声明为 undefined) */
9
+ description?: string;
10
+ /** schema title(D8 形状树两字段分离透传,未声明为 undefined)——浮层展示回落 description ?? title */
11
+ title?: string;
12
+ /** 类型徽标数据(未声明为 undefined) */
13
+ type?: string;
14
+ /**
15
+ * 插入后光标从插入文本末端回退的码元数(expression-type-methods 工单 12):
16
+ * date() 调用插入 = 2(光标落引号内 format 参数占位)、函数名候选 = 1(落括号
17
+ * 内);缺省 0(落插入末尾)
18
+ */
19
+ cursorBack?: number;
20
+ /**
21
+ * 接受时从光标锚位回退替换的长度(工单 12;缺省 = partial 长度):桶候选携带
22
+ * 整段 expr 长度——调用插入重写「前缀 + 部分段」全量
23
+ */
24
+ replaceLen?: number;
25
+ /**
26
+ * 前缀过滤键(工单 12;缺省 = segment):桶候选 = 字段键名——与同键路径候选
27
+ * 一起按 partial 过滤(segment 是整段调用文本,直接过滤永不匹配)
28
+ */
29
+ filterKey?: string;
30
+ /**
31
+ * 显式分桶判别(resource-expression-single-ref 工单 03/05,ADR 0020):'path' =
32
+ * 字段/结构头路径候选,'function' = 函数名建议 + 形状分桶调用插入——资源面
33
+ * 选择器(ExpressionPathPicker)按 `kind === 'path'` 过滤函数桶,不用
34
+ * filterKey/含 ( 启发式(工单 12 内部约定不作契约)。缺省 = 两桶之外的
35
+ * 建议面(date 格式快捷项等);镜像内核 ExpressionCandidate 同名字段
36
+ * (结构兼容面),文本浮层零感知。
37
+ */
38
+ kind?: 'path' | 'function';
39
+ }
40
+ /**
41
+ * 候选源一次求值结果(工单 02 partial/candidates 契约):浮层据此开合与渲染。
42
+ * 开放映射信号(D10)已随契约废除移除(ADR 0020)——schema 解析边界显式拒绝后,
43
+ * 候选源只服务具体键声明。
44
+ */
45
+ export interface CompletionResult {
46
+ /** 正在输入的未完整段(恒为 expr 的后缀,尾点态 = 空后缀) */
47
+ partial: string;
48
+ /** 全量合法候选(不按 partial 预过滤——前缀过滤归浮层) */
49
+ candidates: readonly CompletionItem[];
50
+ }
51
+ /**
52
+ * 候选源契约(纯函数注入缝):入参 = 光标所在片段表达式(trim 后,可能带单个
53
+ * 补全尾点),出参 = 正在输入的 partial(恒为 expr 后缀,工单 02 契约)+ 全量
54
+ * 合法候选(不按 partial 预过滤——前缀过滤归浮层);null = 无补全态(语法错误/
55
+ * 无候选),浮层不开。
56
+ */
57
+ export type CompletionSource = (expr: string) => CompletionResult | null;
58
+ /** PHP trim() 默认字符集——内核 expressionScan 导出(单一事实源,勿按值复刻) */
59
+ /**
60
+ * 接受手术(工单 12 起光标锚定):把**光标锚位前**的替换域换成候选段(工单 02
61
+ * 钉定的替换面——非整段重插、不包 `{{}}` 外壳)。part 是扫描产物(start/end 为
62
+ * 码元索引,end 独占),cursor 是刷新时的光标锚位(片段内容区内);替换域 =
63
+ * [锚位 - 尾随空白 - replaceLen, 锚位 - 尾随空白),replaceLen 缺省 = partial
64
+ * 长度(路径面与旧行为全等——尾随输入位锚定)、桶候选携带整段 expr 长度(调用
65
+ * 插入重写前缀+部分段,工单 12)。默认替换保留漂移检验(锚位文本须等于 partial,
66
+ * 对不上拒绝手术返回 null 由调用方安全收口);replaceLen 面由锚位边界把守
67
+ * (expr 全量来自同一次刷新,漂移即越界拒绝)。返回光标 = 插入末端回退
68
+ * cursorBack(format 参数占位/括号内落点)。
69
+ */
70
+ export declare function applyCompletion(value: string, part: ExpressionScanFragment | ExpressionScanOpen, cursor: number, partial: string, item: Pick<CompletionItem, 'segment' | 'replaceLen' | 'cursorBack'>): {
71
+ value: string;
72
+ cursor: number;
73
+ } | null;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 光标视口锚点测量(content-completion 工单 04,spec §3「mirror div 测量,
3
+ * textarea/input 两套」)。
4
+ *
5
+ * 返回光标处的视口坐标盒(left/top/bottom),浮层锚在 bottom 下方。量法:
6
+ * - textarea(多行换行流,white-space 按宿主 computed):mirror div 复刻排版
7
+ * (宽度 = 内容盒宽、同 padding/字族/行高),塞入光标前文本 + 零宽标记 span,
8
+ * 读标记的 offsetLeft/offsetTop 得内容原点偏移,减去宿主滚动量;
9
+ * - input(单行):mirror 量光标前文本宽度,纵向锚在字段盒上下缘。
10
+ *
11
+ * 样式复刻按 getComputedStyle 逐项拷贝,读不到(jsdom/降级)一律按 0 兜底
12
+ * (parseFloat || 0)——测量只影响弹层落点,不阻断补全。镜像节点即建即删。
13
+ */
14
+ /** 光标处的视口坐标盒(css 像素;bottom 供浮层上缘锚定) */
15
+ export interface CompletionAnchor {
16
+ left: number;
17
+ top: number;
18
+ bottom: number;
19
+ }
20
+ /**
21
+ * 测量宿主光标的视口锚点(textarea 换行流 / input 单行两套量法)。
22
+ *
23
+ * scale = 宿主的 CSS transform 缩放系数(缺省 1):画布 textarea 整体在
24
+ * `transform: scale(zoom)` 系(表达式就地编辑 spec 决策 6)——getBoundingClientRect()
25
+ * 已含变换而 mirror 布局偏移未含,zoom ≠ 1 不折算则浮层按偏移量线性漂移;
26
+ * mirror 偏移与行高 × scale 后再叠加 rect 项。面板侧缺省 1,行为不变。
27
+ */
28
+ export declare function measureCursorAnchor(el: HTMLTextAreaElement | HTMLInputElement, scale?: number): CompletionAnchor;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 可编辑元素判定(绑定层共用):快捷键让路与空格平移跟踪的同一口径——
3
+ * 输入框/文本域/下拉/按钮/可编辑节点上的按键属原生控件编辑,不归画布快捷键。
4
+ * 与 vue 包 editableTarget.ts 同源镜像(纯谓词,零框架依赖)。
5
+ */
6
+ export declare function isEditableEventTarget(target: EventTarget | null): boolean;
7
+ /**
8
+ * 文本录入元素判定(Esc 消耗面):Esc 属原生控件语义的目标——输入框/文本域/下拉
9
+ * (IME 取消、下拉收起)。与 isEditableEventTarget 的差异是 BUTTON:按钮让路快捷键
10
+ * (字符键/空格/方向键属控件编辑语义),但按钮不原生消耗 Esc——浮层关闭协议
11
+ * 对按钮焦点必须继续生效(vue 包真机缺陷 2026-10 的镜像口径)。包内消费,
12
+ * 不进 barrel 出口(vue 包同款出口面)。
13
+ */
14
+ export declare function isTextEntryTarget(target: EventTarget | null): boolean;
@@ -0,0 +1,22 @@
1
+ import { Canvas, ExpressionContextKind, ExpressionSchemaNode, LayerPath } from '@hankchen/canvas-editor';
2
+ import { CompletionSource } from './completion';
3
+ /** 数据字段所在位置的补全上下文(kind = 候选分表面;rowSchema 仅行上下文在场) */
4
+ export interface ExpressionFieldContext {
5
+ readonly kind: ExpressionContextKind;
6
+ /** 行键树 schema(rowsPath 数组 items);根上下文/解析不出为 null */
7
+ readonly rowSchema: ExpressionSchemaNode | null;
8
+ }
9
+ /**
10
+ * 选中路径处数据字段的补全上下文:模板格内容层 = 行上下文(rowNamespace 注入
11
+ * 面),其余可达位置(根层/V1 格内容)= 根上下文。doc/path/schema 任一缺席
12
+ * 一律根上下文(画布级目标无数据字段,判定兜底一致)。
13
+ */
14
+ export declare function expressionFieldContext(schema: ExpressionSchemaNode | null, doc: Canvas | null, path: LayerPath | null): ExpressionFieldContext;
15
+ /**
16
+ * 候选源适配(工单 04 注入缝):schema null(未注入/声明被拒降级)= null 源,
17
+ * 浮层恒闭;否则包裹内核枚举器——ok:false(语法错误/无补全态)映射 null,
18
+ * ok:true 原样透传(ExpressionCandidate 结构兼容 CompletionItem——description/
19
+ * title D8 分离透传、展示回落归浮层;partial/candidates 契约见 ./completion)。
20
+ * 开放映射 open 信号透传已随契约废除移除(ADR 0020)。
21
+ */
22
+ export declare function expressionCompletionSource(schema: ExpressionSchemaNode | null, context: ExpressionFieldContext): CompletionSource | null;
@@ -0,0 +1,13 @@
1
+ import { FontCatalogEntry, UploadFile } from '@hankchen/canvas-editor';
2
+ export interface FontPickerContext {
3
+ /** 字体清单(内置 + 自定义快照——上传追加后宿主重渲染实时联动) */
4
+ readonly entries: readonly FontCatalogEntry[];
5
+ /** 上传可用性(内核 canUpload:未注入 uploadHandler 即 false) */
6
+ readonly canUpload: boolean;
7
+ /** 本机字体 → 可物化引用(内核 uploadFont:引用入清单后返回) */
8
+ readonly uploadFont: (file: UploadFile) => Promise<string>;
9
+ }
10
+ /** React Context 形态的注入键(vue 版 InjectionKey 的对位;缺省值 null) */
11
+ export declare const FONT_PICKER_KEY: import('react').Context<FontPickerContext | null>;
12
+ /** 控件渲染内取注入缝;未注入返回 null(控件退化) */
13
+ export declare function injectFontPicker(): FontPickerContext | null;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * 跨域切片桥出口:选择/视口/历史/快捷键切片桥(React hooks,store 订阅切片经
3
+ * React 官方外部 store 同步原语 useSyncExternalStore 接线——一次订阅一快照,
4
+ * 不手工 setState 拼装)、快捷键帮助面板开合单例、状态栏瞬时反馈单例、编辑器
5
+ * 主题状态(日间/夜间单例 + set/toggle,写出即同步 data-cn-theme 信号)、
6
+ * 快捷键展示侧纯函数与常量(键位符号/平台侦测/武装提示句)、可编辑目标谓词、
7
+ * DOM File 上传组装。这是唯一允许被各域引用的层——域间横向 import 被依赖红线
8
+ * (editor-react-*-isolation)禁止,跨域消费一律收口到这里。
9
+ * 面板域切片(表达式补全、点选器、字体清单注入缝、下拉底座、帮助面板展示件等)
10
+ * 随工票 20261201-af5f/bbc9 逐档补齐——出口面对等清单白名单按档摘除
11
+ * (scripts/check-export-parity.mjs)。
12
+ */
13
+ export { isEditableEventTarget } from './editableTarget';
14
+ export { FONT_PICKER_KEY, injectFontPicker, type FontPickerContext } from './fontPicker';
15
+ export { ARM_LAYER_CREATE_HINT, detectShortcutPlatform, shortcutActionLabel } from './shortcutsHelp';
16
+ export { HelpDialog } from './HelpDialog';
17
+ export { DropdownMenu } from './DropdownMenu';
18
+ export { useDropdownMenu, type DropdownMenuController, type DropdownMenuEntry, type DropdownMenuItem, type DropdownMenuSlotProps, } from './useDropdownMenu';
19
+ export { DATA_SOURCE_GATE_HINT, useDataSourceSchema, useDataSourceSchemaRejection } from './useDataSourceSchema';
20
+ export { useDocumentExchange, type DocumentCodec, type DocumentExchange, } from './useDocumentExchange';
21
+ export { useHistory, type HistoryAvailability } from './useHistory';
22
+ export { useCnTheme, type CnTheme } from './useCnTheme';
23
+ export { useSelection } from './useSelection';
24
+ export { useShortcuts } from './useShortcuts';
25
+ export { useShortcutsHelp, type ShortcutsHelp } from './useShortcutsHelp';
26
+ export { useTransientFeedback, type TransientFeedback } from './useTransientFeedback';
27
+ export { uploadFileFromDom } from './uploadFile';
28
+ export { useViewport } from './useViewport';
29
+ export { PanelIcon } from './PanelIcon';
30
+ export { Tooltip } from './Tooltip';
31
+ export { ExpressionCompletionPopup } from './ExpressionCompletionPopup';
32
+ export { ExpressionPathPicker } from './ExpressionPathPicker';
33
+ export { applyCompletion, type CompletionItem, type CompletionResult, type CompletionSource } from './completion';
34
+ export { measureCursorAnchor, type CompletionAnchor } from './completionAnchor';
35
+ export { expressionCompletionSource, expressionFieldContext, type ExpressionFieldContext, } from './expressionContext';
36
+ export { useExpressionCompletion, type ExpressionCompletionState } from './useExpressionCompletion';
37
+ export { expressionDiagnosticHint, useExpressionDiagnostics } from './useExpressionDiagnostics';
38
+ export { rowsPathPickerSource, rowsPathValueDrifts } from './rowsPathPickerSource';
39
+ export { attachResourceTemplate, stripResourceTemplate } from './resourceTemplate';
40
+ export { pathPickerEntries, type PathPickerEntry, type PathPickerMode } from './pathPickerModel';
41
+ export { placePopupInViewport, POPUP_GAP, POPUP_MARGIN, type PopupAnchorBox, type PopupViewportPosition, } from './popupPosition';
42
+ export { selectionFieldMergeKey } from './mergeKey';
@@ -0,0 +1,2 @@
1
+ import { LayerPath } from '@hankchen/canvas-editor';
2
+ export declare function selectionFieldMergeKey(path: LayerPath, key: readonly string[]): string;
@@ -0,0 +1,24 @@
1
+ import { CompletionItem, CompletionSource } from './completion';
2
+ /** 选择器终点形态(rows-path-picker 工单 02):'resource' = 叶子终点(缺省),'rowsPath' = 数组终点 */
3
+ export type PathPickerMode = 'resource' | 'rowsPath';
4
+ /** 一条菜单条目:完整点路径 + 候选元信息 + 终点形态判定(两 mode 矩阵见模块头) */
5
+ export interface PathPickerEntry {
6
+ /** 提交/下钻的完整点路径(缺 path 的候选不构成条目——选择器的 v-model 面就是它) */
7
+ readonly path: string;
8
+ /** 候选元信息(segment/type/description/title,展示回落归组件) */
9
+ readonly item: CompletionItem;
10
+ /** 点选下钻进入下一层(resource = 探层非空;rowsPath = 对象中间站) */
11
+ readonly drillable: boolean;
12
+ /** 点选提交(resource = 叶子即 !drillable;rowsPath = 数组终点,D3 唯一可点终点) */
13
+ readonly activatable: boolean;
14
+ }
15
+ /** 取一层候选(kind 过滤后,mode 定可激活/可下钻判定矩阵);候选源 null 态(语法错/降级)= 空层 */
16
+ export declare function pathPickerEntries(source: CompletionSource, prefix: string, mode?: PathPickerMode): readonly PathPickerEntry[];
17
+ /** 菜单行面包屑分隔符(工单 06 展示词汇单点):前缀与现段名之间的连接符 */
18
+ export declare const PATH_PICKER_BREADCRUMB_SEPARATOR = "\u203A";
19
+ /**
20
+ * 菜单行面包屑前缀(工单 06):path 去尾段——下钻行在段名前弱化显示已积累
21
+ * 路径(点选途中完整落点随时可见),根层行(无父段)空串(组件不渲染前缀,
22
+ * 呈现维持纯段名不变)。纯派生 Node 可测,拆分呈现归组件模板。
23
+ */
24
+ export declare function pathPickerParentPrefix(path: string): string;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * 弹层视口定位纯函数(resource-expression-single-ref 工单 05/06,ADR 0020 伴生
3
+ * 修复):表达式补全浮层与路径选择器菜单共用的落点决策——
4
+ * - 垂直:锚点下方优先 → 下方放不下向上翻转 → 翻转仍不足钳制视口内(下缘贴
5
+ * viewport − margin;浮层比视口还高钉在上 margin);
6
+ * - 横向:右缘收口不越 viewport − margin,左缘同理(浮层比视口还宽钉左)。
7
+ *
8
+ * 实测缺陷(工单 06 背景,example 开发轨 2026-10-14):浮层恒锚光标下方无翻转
9
+ * 钳制,资源字段居面板底部——候选大半截出屏鼠标不可点。两控件(useExpression
10
+ * Completion / 已退役的 usePathCompletion,rows-path-picker 工单 05)的私有
11
+ * clampToViewport 与本函数合并为单点,路径选择器菜单(工单 05)同函数消费。
12
+ *
13
+ * 高/宽度量不到(0——首帧未渲染/降级):按「放得下/原锚放」处理,不误翻转不
14
+ * 误收口(首开路径由调用方延一拍补量)。纯几何、零 DOM、Node 可测。
15
+ */
16
+ /** 锚点盒(视口坐标;取 CompletionAnchor 同形的 top/bottom/left 三轴) */
17
+ export interface PopupAnchorBox {
18
+ top: number;
19
+ bottom: number;
20
+ left: number;
21
+ }
22
+ /** 弹层落点(视口坐标,fixed 定位直用) */
23
+ export interface PopupViewportPosition {
24
+ top: number;
25
+ left: number;
26
+ }
27
+ /** 锚缘与弹层的间隙(px;既有两控件同语常量收口至此) */
28
+ export declare const POPUP_GAP = 4;
29
+ /** 弹层与视口边缘的最小留白(px) */
30
+ export declare const POPUP_MARGIN = 4;
31
+ export declare function placePopupInViewport(options: {
32
+ anchor: PopupAnchorBox;
33
+ popupWidth: number;
34
+ popupHeight: number;
35
+ viewportWidth: number;
36
+ viewportHeight: number;
37
+ /** 锚缘间隙;缺省 POPUP_GAP */
38
+ gap?: number;
39
+ /** 视口留白;缺省 POPUP_MARGIN */
40
+ margin?: number;
41
+ }): PopupViewportPosition;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 拆壳:合法单值引用 → 裸点路径(片段内空白按 phpTrim 收整);违例/拆不动 →
3
+ * null(原文只读回显面)。
4
+ */
5
+ export declare function stripResourceTemplate(template: string): string | null;
6
+ /** 包壳:裸点路径 → 规范形态 `{{path}}`(提交面模板原文) */
7
+ export declare function attachResourceTemplate(path: string): string;
@@ -0,0 +1,15 @@
1
+ import { ExpressionSchemaNode } from '@hankchen/canvas-editor';
2
+ import { CompletionSource } from './completion';
3
+ /** 「行数组」徽标展示文案(rowsPath 面的展示词汇单点):点选器组件徽标映射共用 */
4
+ export declare const ROWS_PATH_ARRAY_BADGE = "\u884C\u6570\u7EC4";
5
+ export declare function rowsPathPickerSource(startSchema: ExpressionSchemaNode | null): CompletionSource | null;
6
+ /**
7
+ * 已提交 rowsPath 的漂移判定(rows-path-picker 工单 03,spec D2):属性面板把
8
+ * 「schema 变更后已选路径枚举不出」呈现为回显标红(菜单照常可开可重选),判定
9
+ * 收口此纯函数(Node 可测)。语义按 spec 钉定面复用补全枚举器——
10
+ * `enumerateRowsPathCandidates === null`(途经漂移/数组内下钻/畸形)或终点非数组
11
+ * (标量/对象落点、空值、尾点残形——枚举候选里寻不到该路径的数组终点条目)。
12
+ * 作用于已提交值,无输入期概念;起点 null(未绑声明/判别降级)= 门态不判漂移
13
+ * (弱提示替代标红,D1)。
14
+ */
15
+ export declare function rowsPathValueDrifts(startSchema: ExpressionSchemaNode | null, value: string): boolean;
@@ -0,0 +1,30 @@
1
+ import { EditorShortcutAction, EditorShortcutGroup, ShortcutCombo } from '@hankchen/canvas-editor';
2
+ export type ShortcutPlatform = 'mac' | 'win';
3
+ /** 分节渲染顺序(条目在节内的顺序 = 注册表声明序;分组展示名与分节序归本包——
4
+ * 内核注册表只定 group 枚举域,中文展示名与分节序是 UI 关注点) */
5
+ export declare const SHORTCUT_GROUP_ORDER: readonly EditorShortcutGroup[];
6
+ /** 分组中文展示名(归本包,帮助面板分节标题) */
7
+ export declare const SHORTCUT_GROUP_LABELS: Record<EditorShortcutGroup, string>;
8
+ /**
9
+ * 键位组合 → 平台键位符号:mac ⌥⇧⌘ + 键帽(⇧⌘L);win Ctrl+Shift+Alt + 键帽
10
+ * (Ctrl+Shift+L)。字母键帽大写(⌘Z / Ctrl+Z),其余走映射表或缺省原样。
11
+ */
12
+ export declare function shortcutKeyLabel(combo: ShortcutCombo, platform: ShortcutPlatform): string;
13
+ /**
14
+ * 注册表动作 → 平台键位符号(如 ⌘/ 与 Ctrl+/):直查内核缺省注册表——注册表是
15
+ * 键位唯一事实源。同动作多注册条目时取声明首条(多通道动作如 delete 的展示歧义
16
+ * 归帮助面板,本口供无歧义提示用)。
17
+ */
18
+ export declare function shortcutActionLabel(action: EditorShortcutAction, platform: ShortcutPlatform): string;
19
+ /**
20
+ * 武装建层的状态栏瞬时提示:面板新增项与 T/G/Q/I 层型快捷键两入口共用同一句
21
+ * (文案单点维护)。瞬时语义 = show 后数秒自动清空(useTransientFeedback TTL),
22
+ * 武装本身是待命态,不随解除主动撤提示。
23
+ */
24
+ export declare const ARM_LAYER_CREATE_HINT = "\u753B\u62C9\u6216\u70B9\u51FB\u843D\u5C42\uFF0CEsc \u53D6\u6D88";
25
+ /**
26
+ * 平台侦测:userAgentData.platform(Client Hints 新 API,Safari 尚无——三源拼串
27
+ * 一次匹配)与 platform/userAgent 含 mac 形态 → mac;未知/其余 → win 文本系。
28
+ * userAgentData 未进全量 TS DOM lib,结构化局部读取免随 lib 版本漂移。
29
+ */
30
+ export declare function detectShortcutPlatform(): ShortcutPlatform;
@@ -0,0 +1,2 @@
1
+ import { UploadFile } from '@hankchen/canvas-editor';
2
+ export declare function uploadFileFromDom(file: File): Promise<UploadFile>;
@@ -0,0 +1,11 @@
1
+ export type CnTheme = 'light' | 'dark';
2
+ export declare function useCnTheme(options?: {
3
+ /** localStorage 持久化键:传入才读写(调用时初始化读、set 时写),缺省不持久化 */
4
+ storageKey?: string;
5
+ /** 信号落点注入缝:缺省 () => document.documentElement;返回 null 跳过写入 */
6
+ target?: () => HTMLElement | null;
7
+ }): {
8
+ theme: CnTheme;
9
+ set(t: CnTheme): void;
10
+ toggle(): void;
11
+ };
@@ -0,0 +1,10 @@
1
+ import { DataSourceSchemaRejection, EditorSession, ExpressionSchemaNode } from '@hankchen/canvas-editor';
2
+ /**
3
+ * 数据源声明门提示(rows-path-picker 工单 04,spec D1;vue 包 useDataSourceSchema.ts
4
+ * 同源镜像):未绑 schema 时建表面菜单项的置灰悬停文案——面板「+」菜单模板表项
5
+ * 门态共用的展示词汇单点(「行数组」徽标同门先例,文案不进数据契约)。
6
+ */
7
+ export declare const DATA_SOURCE_GATE_HINT = "\u5148\u7ED1\u5B9A\u6570\u636E\u6E90";
8
+ export declare function useDataSourceSchema(editor: EditorSession): ExpressionSchemaNode | null;
9
+ /** 声明拒绝详情桥(声明被拒呈现面,2b):null = 未注入/已编译/已清除 */
10
+ export declare function useDataSourceSchemaRejection(editor: EditorSession): DataSourceSchemaRejection | null;
@@ -0,0 +1,2 @@
1
+ import { Canvas, EditorSession } from '@hankchen/canvas-editor';
2
+ export declare function useDoc(editor: EditorSession): Canvas | null;
@@ -0,0 +1,21 @@
1
+ import { Canvas, EditorSession } from '@hankchen/canvas-editor';
2
+ /** 文档编解码器(wire 数据 ↔ 领域文档);标准实现 = @hankchen/canvas 的
3
+ * decodeGraph/encodeGraph(与 vue 宿主同源,见 README 最小用法) */
4
+ export interface DocumentCodec {
5
+ /** wire 数据 → 领域文档;非法数据抛错并指认原因(既有校验语义的来源) */
6
+ decode: (input: unknown) => Canvas;
7
+ /** 领域文档 → wire 数据(canonical 编码,取出侧) */
8
+ encode: (canvas: Canvas) => unknown;
9
+ }
10
+ export interface DocumentExchange {
11
+ /** 当前文档响应式快照(null = 会话无文档),doc 通知驱动(编辑/undo/载入) */
12
+ doc: Canvas | null;
13
+ /**
14
+ * 载入:raw(wire 数据)→ decode → editor.openDocument 整体替换。
15
+ * decode 抛错即原样上抛(指认原因),会话状态零触碰;成功返回载入的文档。
16
+ */
17
+ loadDocument(raw: unknown): Canvas;
18
+ /** 取出:当前文档 canonical encode;会话无文档返回 null */
19
+ extractDocument(): unknown | null;
20
+ }
21
+ export declare function useDocumentExchange(editor: EditorSession, codec: DocumentCodec): DocumentExchange;