refactor: externalize filetree selection runtime
This commit is contained in:
+51
-18
@@ -94,9 +94,11 @@ rust/spikes/leptos-tiptap-spike/src/
|
||||
|
||||
## 7. 分阶段执行清单
|
||||
|
||||
归档说明(2026-05-25):本节保留原始分阶段路线,但不再作为当前 `done/` 状态的未完成 checklist。已经满足归档条件的范围以第 13 节 Done Gate 为准;仍未实施或被明确划到 `03-rust-web` / 后续编辑器切片的条目改为普通状态项,后续需要另起设计或 bug/checklist 承接,不能在本 done 文档中继续以未勾选 checklist 表达。
|
||||
|
||||
### P0:热点函数归属表和基线保护
|
||||
|
||||
- [ ] 列出当前 `src/lib.rs` 中最近 bug 高频函数的归属模块:
|
||||
- 已记录:当前 `src/lib.rs` 中最近 bug 高频函数的归属模块:
|
||||
- `selected_local_attachment_link_in_editor_state` -> `attachment_links.rs`
|
||||
- `selected_local_attachment_link_text` -> `attachment_links.rs` / `dom_selection.rs`
|
||||
- `sync_persisted_editor_command` -> `command_sync.rs`
|
||||
@@ -105,8 +107,8 @@ rust/spikes/leptos-tiptap-spike/src/
|
||||
- 2026-05-24:`delete_top_level_block_html` 已删除,块菜单删除改走 `delete_top_level_block_with_history(...)` -> Tiptap `delete_range` / `insert_content_at`。
|
||||
- upload slash action / local asset path -> `attachment_upload.rs` / `local_markdown_paths.rs`
|
||||
- toolbar/block menu DOM anchor -> `overlays.rs` / `block_menu.rs`
|
||||
- [ ] 建立 history 风险清单:所有用户编辑动作中仍调用 `set_content` 或 HTML 整文替换的路径必须登记。
|
||||
- [ ] 保留当前已通过的 `scripts/task488-local-attachment-link-delete-undo-smoke.js` 作为 RED/GREEN 基线。
|
||||
- 后续:建立 history 风险清单;所有用户编辑动作中仍调用 `set_content` 或 HTML 整文替换的路径必须登记。
|
||||
- 已保留:当前已通过的 `scripts/task488-local-attachment-link-delete-undo-smoke.js` 作为 RED/GREEN 基线。
|
||||
|
||||
### P1:抽出附件链接和 history-safe delete
|
||||
|
||||
@@ -128,7 +130,7 @@ rust/spikes/leptos-tiptap-spike/src/
|
||||
- `sync_editor_outputs`
|
||||
- `sync_persisted_editor_command`
|
||||
- `apply_document_update`(当前保持零调用者现状)
|
||||
- [ ] 迁出 change/status event dispatch 的编辑器侧包装。
|
||||
- 后续:迁出 change/status event dispatch 的编辑器侧包装。
|
||||
- 2026-05-24 复核:`apply_html_update` 仍依赖 `ChangePayload` / `ChangeMetaPayload`、`dispatch_change_event`、`dispatch_runtime_state`、`HoveredBlockState` 和 toolbar overlay state,暂留 `lib.rs`,等待 P4 `bridge_events.rs` / `overlays.rs` 后再迁。
|
||||
- [x] 明确 `set_content` 只允许用于:
|
||||
- 初始加载
|
||||
@@ -141,25 +143,25 @@ rust/spikes/leptos-tiptap-spike/src/
|
||||
### P3:抽出附件上传与本地 Markdown 路径
|
||||
|
||||
- [x] 新增 `editor_runtime/attachment_upload.rs`。
|
||||
- [ ] 新增 `editor_runtime/local_markdown_paths.rs`。
|
||||
- 不纳入本设计当前归档范围:新增 `editor_runtime/local_markdown_paths.rs`。
|
||||
- 2026-05-24 复核:`local_markdown_paths.rs` 不应落在 `leptos-tiptap` 内部;本地 Markdown 路径、`rootUri`、`/api/local-folder/files/open` URL 和上传落盘归 `03-rust-web` 的 shell host runtime / `local-upload-runtime.js`。
|
||||
- [x] 迁出 slash 上传附件、图片的编辑器 intent。
|
||||
- `dispatch_editor_upload_request(kind, accept)` 已迁入 `attachment_upload.rs`。
|
||||
- `SlashActionKind::Image` / `UploadAttachment` 仍留在 slash menu 基础结构中,只调用 editor intent。
|
||||
- [ ] 迁出 Office/PDF/code 文件的编辑器内插入逻辑。
|
||||
- 不纳入本设计当前归档范围:迁出 Office/PDF/code 文件的编辑器内插入逻辑。
|
||||
- 当前实际插入链路在 `layout.rs` / `local-upload-runtime.js`,不是 editor runtime;后续由 `03-rust-web` 继续收口。
|
||||
- [x] 明确 editor 只负责发起上传 intent;资源保存位置和归属仍由 shell/Rust API 合同决定。
|
||||
- [ ] 覆盖:
|
||||
- 后续覆盖:
|
||||
- 上传第一个/第二个附件后链接仍可点击。
|
||||
- 刷新后链接不退化为普通外链。
|
||||
- secondary pane 上传与 primary pane 隔离。
|
||||
|
||||
### P4:抽出 DOM bridge / overlay / block menu
|
||||
|
||||
- [ ] 新增 `editor_runtime/dom_selection.rs`、`overlays.rs`、`block_menu.rs`。
|
||||
- [ ] 迁出 selection、toolbar anchor、slash menu anchor、block menu anchor、image/table toolbar anchor。
|
||||
- [ ] 对所有 keydown/click 捕获建立“谁先处理、谁 stop propagation”的规则,避免 Tiptap 原生快捷键与外层 window listener 互相吞事件。
|
||||
- [ ] 覆盖:
|
||||
- 后续:新增 `editor_runtime/dom_selection.rs`、`overlays.rs`、`block_menu.rs`。
|
||||
- 后续:迁出 selection、toolbar anchor、slash menu anchor、block menu anchor、image/table toolbar anchor。
|
||||
- 后续:对所有 keydown/click 捕获建立“谁先处理、谁 stop propagation”的规则,避免 Tiptap 原生快捷键与外层 window listener 互相吞事件。
|
||||
- 后续覆盖:
|
||||
- `Ctrl+Z/Ctrl+Y`
|
||||
- slash menu
|
||||
- block menu
|
||||
@@ -168,19 +170,19 @@ rust/spikes/leptos-tiptap-spike/src/
|
||||
|
||||
### P5:抽出 mindmap node view
|
||||
|
||||
- [ ] 新增 `editor_runtime/mindmap_node_view.rs`。
|
||||
- [ ] 迁出 mindmap block 的 node view、runtime mount、projection refresh、simplemindmap event bridge。
|
||||
- [ ] 保持 mindmap 只是编辑器块视图,不成为正文事实源。
|
||||
- 后续:新增 `editor_runtime/mindmap_node_view.rs`。
|
||||
- 后续:迁出 mindmap block 的 node view、runtime mount、projection refresh、simplemindmap event bridge。
|
||||
- 后续:保持 mindmap 只是编辑器块视图,不成为正文事实源。
|
||||
|
||||
### P6:收尾
|
||||
|
||||
- [ ] `src/lib.rs` 只保留:
|
||||
- 后续:`src/lib.rs` 只保留:
|
||||
- module imports
|
||||
- top-level component装配
|
||||
- 少量常量和 view glue
|
||||
- [ ] 单个模块超过约 800 行时继续拆分。
|
||||
- [ ] 运行 CodeGraph sync/index,确认新增 Rust 模块被索引。
|
||||
- [ ] 更新 worker skill/task template:编辑器 bug 默认先查 `editor_runtime/*`,再回到 `lib.rs`。
|
||||
- 后续:单个模块超过约 800 行时继续拆分。
|
||||
- 已完成:运行 CodeGraph sync/index,确认新增 Rust 模块被索引。
|
||||
- 后续:更新 worker skill/task template;编辑器 bug 默认先查 `editor_runtime/*`,再回到 `lib.rs`。
|
||||
|
||||
## 8. History 安全规则
|
||||
|
||||
@@ -437,6 +439,37 @@ Reasonix read-only audit:
|
||||
|
||||
- 块手柄拖拽重排和复制副本仍使用 HTML 整文替换,继续登记为后续 history-safe command 切片;本设计 done gate 只要求至少一个已登记用户编辑路径完成迁移。
|
||||
|
||||
### 10.6 后续 P4 只读审计补充(2026-05-25)
|
||||
|
||||
Reasonix read-only audit:
|
||||
|
||||
- run id: `reasonix-2026-05-24T16-25-22-430Z-3a9a1a82`
|
||||
- worktree: `/mnt/Data1T/mnote-worktrees/5-28-dom-bridge-audit`
|
||||
- handoff: `/home/lix/.codex/runtime/reasonix-coding-worker/reasonix-2026-05-24T16-25-22-430Z-3a9a1a82/process-handoff.md`
|
||||
- 类型:只读审计,主控已读取 Hindsight recall 与 `process-handoff.md`。
|
||||
|
||||
可采纳结论:
|
||||
|
||||
- 后续 P4 第一刀应优先新增 `editor_runtime/dom_selection.rs`,而不是直接抽 `block_menu.rs`。
|
||||
- 第一刀候选函数:
|
||||
- `active_editor_text_selection`
|
||||
- `selection_summary`
|
||||
- `has_active_text_selection`
|
||||
- `selection_has_rich_marks`
|
||||
- `selection_payload` / selection event payload 构造
|
||||
- `send_selection_state` / `send_selection_state_to_target`
|
||||
- `block_menu.rs` 暂不先做:当前 block menu / overlay 相关函数仍强依赖大量 `ReadSignal` / `WriteSignal`,在合并 overlay state 或先迁出 `HoveredBlockState` 前,直接抽模块只会把长参数耦合搬到新文件。
|
||||
- `overlays.rs` 可作为 `dom_selection.rs` 之后的第二刀;`apply_html_update` 仍等 `bridge_events.rs` / overlay state 收口后再迁。
|
||||
|
||||
建议验证:
|
||||
|
||||
- `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`
|
||||
- `wasm-bindgen rust/spikes/leptos-tiptap-spike/target/wasm32-unknown-unknown/release/mnote_leptos_tiptap_spike.wasm --target web --out-dir rust/spikes/leptos-tiptap-spike/generated/island --out-name mnote-leptos-tiptap-spike-island`
|
||||
- `node scripts/task488-local-attachment-link-delete-undo-smoke.js`
|
||||
- `node scripts/task489-block-menu-delete-undo-smoke.js`
|
||||
|
||||
## 11. 测试与验收
|
||||
|
||||
### Rust 检查
|
||||
|
||||
Reference in New Issue
Block a user