refactor: extract editor dom selection runtime

This commit is contained in:
lix-2026
2026-05-25 00:48:37 +08:00
parent ec623c9a82
commit e20c0f95ff
7 changed files with 147 additions and 105 deletions
@@ -696,8 +696,8 @@ Reasonix read-only audit
- [x] 浏览器断言:
- `document.documentElement.dataset.mnoteTreeLiveTransport` 正确。
- 外置 module 实际执行并设置 `window.__mnoteTreeLiveControllerStarted`
- 后续专项验证WS 推送仍更新 page/filetree。
- 后续专项验证:WS 不可用时仍 fallback 到 SSE。
- 后续专项浏览器回归WS 推送仍更新 page/filetree。
- 后续专项浏览器回归:强制禁用 WS 时仍 fallback 到 SSE。
### P3:外置 debug `/tree` shell runtime bridge
@@ -470,6 +470,39 @@ Reasonix read-only audit
- `node scripts/task488-local-attachment-link-delete-undo-smoke.js`
- `node scripts/task489-block-menu-delete-undo-smoke.js`
### 10.7 Batch 5 DOM selection 第一刀(2026-05-25
Codex 主控基于上一批 Reasonix P4 只读审计直接完成:
- 新增 `editor_runtime/dom_selection.rs`
- 迁出纯 DOM / selection helper
- `node_is_within_root`
- `active_editor_text_selection`
- `has_active_text_selection`
- `selection_summary`
- `selection_has_rich_marks`
- `src/lib.rs` 保留 `SelectionPayload``selection_payload``send_selection_state``send_selection_state_to_target``selection_event_payload` 和事件 dispatch;这些仍依赖 bridge event、`HoveredBlockState`、block id 解析和 target dispatch,后续等 `bridge_events.rs` / overlay state 边界更稳后再迁。
- `editor_root_element()` 改为 `pub(crate)`,供 `dom_selection.rs` 读取当前编辑器根节点;shell/resource 语义未进入 editor DOM 模块。
已通过验证:
- `cargo fmt --manifest-path rust/Cargo.toml --all --check`
- `cargo check --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml`35 个既有 warning
- `cargo build --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml --target wasm32-unknown-unknown --release`35 个既有 warning
- `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`
- 结果:`ok=true`
- 证据:`tmp/task488-local-attachment-link-delete-undo-smoke/result.json`
- `node scripts/task489-block-menu-delete-undo-smoke.js`
- 结果:`ok=true`
- 证据:`tmp/task489-block-menu-delete-undo-smoke/result.json`
- 备注:首次与 `task488` 并行执行时在 `Ctrl+Z` 等待上超时;单独重跑通过,后续 smoke 建议串行跑编辑器键盘类场景,避免浏览器/服务端时序争用误报。
后续建议:
- 下一刀可迁 `floating_toolbar_anchor_from_selection` / `sync_text_selection_overlay` 等 overlay anchor 纯计算部分进入 `overlays.rs`
- `selection_payload` / `send_selection_state*` 应与 `bridge_events.rs` 一起迁,避免为了单次拆分扩大 `SelectionPayload``HoveredBlockState` 和 runtime block id 的可见性。
## 11. 测试与验收
### Rust 检查