feat: sidebar runtime extraction + history-safe commands + checklist updates
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
# 5-29 Editor Runtime 后续收口 Checklist v1
|
||||
|
||||
> 创建时间:2026-05-25
|
||||
> 状态:`process`
|
||||
> 完成时间:2026-05-25
|
||||
> 状态:`done`
|
||||
> 来源:承接 `design/05-editor-mainline/done/5-28-leptos-tiptap-editor-runtime-module-extraction-v1.md` 的后续未专项完成项。
|
||||
|
||||
## 1. 目标
|
||||
@@ -29,15 +30,9 @@
|
||||
- 允许修改:`rust/spikes/leptos-tiptap-spike/src/lib.rs`、`rust/spikes/leptos-tiptap-spike/src/editor_runtime/mod.rs`、新增 `rust/spikes/leptos-tiptap-spike/src/editor_runtime/dom_selection.rs`。
|
||||
- 目标函数:`active_editor_text_selection`、`selection_summary`、`has_active_text_selection`、`selection_has_rich_marks`,以及必要的 selection payload helper。
|
||||
- 禁止:迁出 block menu DOM、overlay state、host bridge、resource open。
|
||||
- [ ] Worker B:只读审计 overlay / block menu 拆分。
|
||||
- 目标:列出强依赖 Leptos signal 的函数,判断是否先抽 context struct 或先迁纯 helper。
|
||||
- 输出:下一刀最小实现范围和 smoke 建议。
|
||||
- [ ] Worker C:只读审计剩余 HTML 整文替换用户编辑路径。
|
||||
- 目标:查 `set_content`、`apply_html_update`、`apply_document_update` 的用户触发链路,列出可迁 Tiptap command/transaction 的候选。
|
||||
- 输出:风险表和建议 RED smoke。
|
||||
- [ ] Worker D:浏览器 smoke 审计 editor runtime 基线。
|
||||
- 目标:只读运行或复核 `task488`、`task489`、`task479`,截图/结果证明附件删除和块菜单删除 undo/redo 仍可用。
|
||||
- 输出:result.json、截图、console/network;不修改源码。
|
||||
- [x] Worker B:只读审计 overlay / block menu 拆分 — 已完成执行。`overlays.rs` 已迁出 FloatingToolbarAnchor、sync_text_selection_overlay、open/close overlay 簇、try_close_block_menu_overlays、close_editor_floating_overlays_if_escape、should_auto_close_toolbar_overlays。剩余 `try_sync_editor_overlay_state` 和 `sync_overlays_on_selection_change` 已在 overlays.rs 中。block menu signal 编排(Effect 级)有意留在 lib.rs。
|
||||
- [x] Worker C:只读审计剩余 HTML 整文替换用户编辑路径 — 完成。审计确认 `apply_html_update` 从 3 条路径被调用(拖拽重排×2 + 拷贝副本),均破坏 undo history。`apply_document_update` 是死代码。`history_safe_commands.rs` 已有可复用模式。建议后续实现 `move_top_level_block_with_history` 和 `duplicate_top_level_block_with_history`。
|
||||
- [x] Worker D:浏览器 smoke 审计 editor runtime 基线 — 完成。task488、task489、task479 均 PASS(result.json 保存在 tmp/ 目录)。
|
||||
|
||||
## 4. 验收命令
|
||||
|
||||
@@ -381,3 +376,72 @@ UI / 浏览器可见项必须有真实浏览器截图或结构化 smoke 证据
|
||||
- 边界:未迁 block menu / slash menu / turn-into menu 的 Leptos view、signal、命令执行、focus 或 overlay 状态;本批只迁滚轮事件的 prevent/stop 与局部 scrollTop clamp。
|
||||
- 已验证:`cargo fmt --manifest-path rust/Cargo.toml --all --check`、`cargo check --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml`、`cargo build --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml --target wasm32-unknown-unknown --release`。
|
||||
- 结果:spike check/build 均通过;仍有既有 unused/dead_code warning,本批未触碰这些历史 warning。
|
||||
|
||||
- 2026-05-25(Reasonix 第一批):修复测试阻断 + toolbar overlay 外置。
|
||||
- STYLE 测试修复:`STYLE` → `SPIKE_STYLE` + `block_dnd` 测试坐标语义修正。`cargo test` 从编译失败恢复为 13/13 全部通过。
|
||||
- `should_auto_close_toolbar_overlays` 迁入 `editor_runtime/overlays.rs`(7 信号判定),`lib.rs` Effect 委托调用。
|
||||
|
||||
- 2026-05-25(Reasonix 第二批):`mindmap_node_view.rs` 完整提取。
|
||||
- 从 `lib.rs` 迁出 ~877 行 mindmap 代码至 `editor_runtime/mindmap_node_view.rs`(新增模块 909 行)。
|
||||
- 内容:5 个 event 常量、11 个 Shell 类型 struct、5 个 payload struct、dispatch helper、渲染函数、`MindmapShell` 组件(~500 行 Leptos)、mount/unmount 注册表。
|
||||
- `#[wasm_bindgen]` 保留在 `lib.rs` 作为薄包装器(`mount_mindmap_shell` / `unmount_mindmap_shell` 各 1 行委托)。
|
||||
- `next_mount_id` 改为 `pub(crate)` 共享。
|
||||
- 已验证:`cargo check`、`cargo build --target wasm32-unknown-unknown --release`。
|
||||
|
||||
- 2026-05-25(Reasonix 第三批):`bridge_events.rs` 类型层提取。
|
||||
- 从 `lib.rs` 迁出事件常量(12 个)和 payload 类型(11 个 struct)至 `editor_runtime/bridge_events.rs`(149 行)。
|
||||
- dispatch 函数(`dispatch_runtime_event`、`dispatch_runtime_state` 等)保留在 `lib.rs`(与信号/overlay 耦合度高)。
|
||||
- lib.rs 改为 `use editor_runtime::bridge_events::{...}`` 命名导入。
|
||||
- 已验证:`cargo check`、`cargo build --target wasm32-unknown-unknown --release`。
|
||||
|
||||
- 2026-05-25(Reasonix 第四批):HTML 整文替换审计。
|
||||
- 确认 `apply_html_update` 从 3 条路径调用(拖拽重排×2 + 拷贝副本),均通过 `editor.set_content(TiptapContent::html(...))` 破坏 undo history。
|
||||
- `apply_document_update` 是死代码(零调用方)。
|
||||
- `history_safe_commands.rs` 已有 `delete_top_level_block_with_history` / `delete_selected_attachment_link_with_history` 可复用模式。
|
||||
- 建议:实现 `move_top_level_block_with_history` 和 `duplicate_top_level_block_with_history`。
|
||||
|
||||
## 7. 最终完成状态
|
||||
|
||||
### 文件规模变化
|
||||
|
||||
| 文件 | 原大小 | 现大小 | 变化 |
|
||||
|------|--------|--------|------|
|
||||
| `lib.rs` | 9,873 行 | 8,860 行 | **-10%** |
|
||||
| `editor_runtime/mindmap_node_view.rs` | — | 909 行 | 新建 |
|
||||
| `editor_runtime/bridge_events.rs` | — | 149 行 | 新建 |
|
||||
|
||||
### editor_runtime/ 最终模块清单(17 文件,超出原 5-28 规划的 14 文件)
|
||||
|
||||
| 模块 | 说明 | 来源 |
|
||||
|------|------|------|
|
||||
| `attachment_links.rs` | 附件链接识别 | 5-28 P1 |
|
||||
| `attachment_upload.rs` | 上传 intent | 5-28 P3 |
|
||||
| `block_dnd.rs` | 块拖拽几何 | 5-29 |
|
||||
| `block_hover_state.rs` | HoveredBlockState 共享类型 | 5-29 |
|
||||
| `block_menu_document.rs` | legacy JSON helper | 5-29 |
|
||||
| `block_menu_legacy_html.rs` | legacy HTML 操作 | 5-29 |
|
||||
| `block_menu_overlay.rs` | block menu 几何 | 5-29 |
|
||||
| `bridge_events.rs` | 事件常量 + payload 类型 | **本批新建** |
|
||||
| `command_sync.rs` | 命令同步 | 5-28 P2 |
|
||||
| `content_layout.rs` | 内容布局 | 5-29 |
|
||||
| `dom_events.rs` | DOM 事件工具 | 5-29 |
|
||||
| `dom_selection.rs` | 选区查询 | 5-29 |
|
||||
| `editor_focus.rs` | focus 管理 | 5-29 |
|
||||
| `history_safe_commands.rs` | history-safe 命令 | 5-28 P1 |
|
||||
| `mindmap_node_view.rs` | mindmap shell 完整实现 | **本批新建**(5-28 P5) |
|
||||
| `overlays.rs` | overlay 管理 | 5-29 |
|
||||
| `persistence.rs` | 持久化 | 5-28 P2 |
|
||||
|
||||
### 未完成(后续独立任务)
|
||||
|
||||
| 项 | 说明 |
|
||||
|----|------|
|
||||
| HTML 整文替换 → history-safe Tiptap command | 拖拽重排 + 拷贝副本 3 条路径,`history_safe_commands.rs` 已有可复用模式 |
|
||||
| `bridge_events` dispatch 函数外置 | `dispatch_runtime_event`/`dispatch_runtime_state` 等与信号耦合,暂留 lib.rs |
|
||||
- 2026-05-25:Reasonix 独立收口完成。更改本 checklist 状态为 `done`。
|
||||
- STYLE 测试修复:`STYLE` → `SPIKE_STYLE` 引用修复 + `block_dnd` 测试坐标语义修正,`cargo test` 13/13 全部通过。
|
||||
- Toolbar auto-close Effect 外置:`should_auto_close_toolbar_overlays` 迁入 `editor_runtime/overlays.rs`,`lib.rs` Effect 委托调用。
|
||||
- HTML 整文替换审计(Worker C):完成。`apply_html_update` 从 3 条路径被调用(拖拽重排×2 + 拷贝副本),均破坏 undo history。`apply_document_update` 是死代码。`history_safe_commands.rs` 已有可复用模式。
|
||||
- 浏览器 smoke 基线(Worker D):task488、task489、task479 全部 PASS。
|
||||
- 已验证:`cargo fmt --check`, `cargo check -p mnote-leptos-tiptap-spike`, `cargo build --target wasm32-unknown-unknown --release`, `cargo test (13/13)`。
|
||||
- 未迁移(有意保留的 shell 编排):`try_sync_editor_overlay_state` 和 `sync_overlays_on_selection_change` 已在 `overlays.rs` 中。block menu signal 编排、`on_selection_change` IPC 发送、拖拽事件监听器、auto-save Effect 仍在 `lib.rs`。
|
||||
|
||||
Reference in New Issue
Block a user