Interaction
Interaction 能力回答“用户输入怎样变成画布语义行为”。它位于 Renderer Runtime 之上,消费后端中立的 Input 与 Hit Result;稳定 Document 变化仍通过 Command/Kernel,稳定 Selection 与 Viewport 仍通过 Session。
当前交付
| 层次 | Package | 职责 |
|---|---|---|
| 值契约 | @nodebraid/interaction-api | Node Drag、Viewport Pan、Box Selection 与 Connection Preview 不可变 Projection |
| Port 能力 | @nodebraid/plugin-port | Node/领域 Contribution 到 revision-bound Port Snapshot |
| Runtime 行为 | @nodebraid/plugin-interaction | Selection、Box Selection、Delete Selection、Drag、Pan、Zoom、Port-aware/Node-level Connection |
| 复制行为 | @nodebraid/plugin-duplicate-selection | 独立 Duplicate Command、ID materialization、子图复制与 Ctrl/Cmd+D Binding |
| 剪贴板行为 | @nodebraid/plugin-clipboard | 应用拥有 codec/transport 的 Copy/Paste Command 与 Ctrl/Cmd+C / Ctrl/Cmd+V Binding |
| 投影中介 | @nodebraid/plugin-renderer | 排他的 Interaction Projection Binding 与 Renderer 同步 |
| 参考后端 | @nodebraid/renderer-svg | 在真实 SVG Geometry 上显示 Preview,并统一 Hit/Input 坐标 |
text
Renderer Input + Hit Result
│
▼
Interaction Runtime
├── Preview ─────────▶ Interaction Projection Binding
├── Selection/Viewport ▶ Session Service
└── stable Document result ─▶ typed Command ─▶ Kernel行为边界
- Pointermove 只更新 Projection,不持续写 Kernel 或 Session。
- Primary pointer 从空白 Canvas 拖动会以 World Rect 建立 Box Selection;pointerup 按当前 Kernel View 的 Node Geometry 更新 Session,不产生 Transaction 或 History。
- Node Drag 在 pointerup 执行一次
interaction.nodes.move,一次 Transaction 自然形成至多一个 History Entry。 - mouse 可从 Node-level source Anchor 建立 Connection Preview,应用 materializer 提供完整 Edge,
interaction.edge.create以一次 Transaction 提交。 - Renderer 拥有 Focus 且没有 Active Gesture 时,Delete 执行
interaction.selection.delete:先删除显式或 incident Edge,再删除选中 Node,并自然形成一个可 Undo/Redo 的 History Entry。 - 独立 Duplicate Selection Plugin 通过
selection.duplicate复制 selected-Node induced subgraph;应用只提供完整 ID mapping,Ctrl/Cmd+D 通过 Interaction Shortcut Binding 接入同一 Command。 - Clipboard Plugin 通过
@nodebraid/canvas-fragment复用同一子图语义;Copy 捕获 committed Fragment,Paste 在一个 Transaction 中 materialize 后更新 Selection。文本 codec、navigator.clipboardAdapter 与 opaque data 规则由应用显式提供。 - Middle button 或 Space+primary 可建立 Pan;Wheel Zoom 按 Screen Point 锚定并受显式配置约束。
- 同一 Activation 只有一个 Gesture Pointer;额外 Pointer、Gesture 中的 Wheel、pointercancel、lost capture 与 stale evidence 都有明确语义和诊断。
- 依赖消失或 Plugin unload 会停止输入、清 Preview、释放 Capture、清本地状态并注销 Command;恢复后创建全新 idle Activation。
非目标
首版 Clipboard 不包含 Serialized Document、Persistence、跨版本文本承诺、HTML/image format、rich text 或通用 JSON codec。Connection、Box Selection 与 Delete Selection 的既有非目标保持不变;pinch/touch、HTML overlay、文本编辑、协作 presence、产品 UI 与通用 Tool Registry 仍不在当前范围。
验证
成功链路由真实 Plugin Host、Kernel、Command、Session、Renderer、History 与 SVG Provider 在 Chromium 中组合验证。结构、恢复和 cleanup fault 只通过公开 seam 注入;fake Renderer 不作为 Selection、Drag、Pan、Zoom 或 Capture 成功的证明。