fix: preserve undo for attachment link deletion

This commit is contained in:
lix-2026
2026-05-24 19:55:37 +08:00
parent 9c4bb58257
commit cafd29a963
9 changed files with 401 additions and 82 deletions
+22
View File
@@ -46,4 +46,26 @@
- Reasonix coding 在隔离 worktree `mnote-wt-0524c-reasonix-title` 完成可用修复,范围控制在 `local_folder_source.rs``task479`,主控复核后采纳。
- Claude Code coding 本轮 Hindsight 注入成功,但因 `--max-budget-usd 1.20` 超预算退出,只停留在代码探索阶段,未产生 diff;这说明 Claude Code full-mode 对编码任务成本较高,需要更小任务切片或更高预算。
4.CTRL+Z/CTRL+Y对于删除链接不可用,不能恢复删除的链接。(你应该系统看看还有没有其它ctrl+z/CTRL+Y(撤销/恢复)不能用的场景)
处理记录(2026-05-24):
- 归类:`05-editor-mainline`,本质是编辑器命令写入链路绕过 Tiptap/ProseMirror history,不能只按单个链接 UI 修补。
- 根因:本地 Markdown 附件链接被选中后按 `Backspace/Delete` 时,旧逻辑识别本地附件链接并走 `get_html -> delete_top_level_block_html -> editor.set_content(html)``set_content` 是整文替换,不会生成可撤销的用户 transaction,因此 `Ctrl+Z/Ctrl+Y` 无法恢复删除的链接。
- 修复:
- `rust/spikes/leptos-tiptap-spike/src/lib.rs`:删除本地附件链接时不再通过 HTML 整文替换;改为在 keydown 捕获阶段识别 Tiptap 当前非空选区是否位于 `/api/local-folder/files/open` 链接 mark 内,并调用 `editor.delete_selection()`,让删除进入 ProseMirror history。
- `rust/spikes/leptos-tiptap-spike/src/lib.rs`:保留 DOM selection 识别作为鼠标选中文本兜底,但主判断改为读取 Tiptap editor state 的 link attributes,避免内部 selection 与 `window.getSelection()` 不同步。
- `scripts/task488-local-attachment-link-delete-undo-smoke.js`:新增真实浏览器回归,上传本地 Markdown 附件、选中附件链接文本、Delete 删除、`Ctrl+Z` 恢复、`Ctrl+Y` 再删除。脚本显式等待超过 Tiptap history `newGroupDelay`,避免把“上传+删除”合并为同一个撤销事件而误判。
- 验证:
- `cargo fmt --manifest-path rust/Cargo.toml --all --check` 通过。
- `cargo check --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml` 通过,只有既有 warning。
- `cargo build --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml --target wasm32-unknown-unknown --release` 通过,只有既有 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 --check scripts/task488-local-attachment-link-delete-undo-smoke.js` 通过。
- `node scripts/task488-local-attachment-link-delete-undo-smoke.js` 通过。
- Worker 对比:
- Claude Code 三轮任务均因预算超限或无可用 `finalText/process-handoff` 失败,隔离 worktree 没有可采纳 diff;本轮说明 Claude Code 轻量 patch mode 仍需要更窄任务和更稳定预算。
- Reasonix 多轮任务卡住;其中 narrow patch worktree 有 diff,但没有 result/handoff,且包含无关格式和英文注释,未采纳。
- 本轮对比结论:两者都没有直接解决第 4 条;可用价值主要是暴露 worker 失败模式。最终根因、修复和 smoke 由主控完成。
- 系统性后续:
- 当前修复覆盖“选中文本删除本地附件链接”的高频路径。块菜单删除、拖拽重排、折叠标题转换等仍有 `set_content`/HTML 整文替换路径,后续应拆一个 editor command history 设计,把块级删除/重排统一迁移到 Tiptap transaction/command,而不是继续扩散整文替换。
5,md文件上传后刷新前面的黑色方块会变成灰色:/mnt/Data1T/mnote/tmp/image copy 80.png/mnt/Data1T/mnote/tmp/image copy 81.png
6. 当前office文件本地可以打开,我们当前使用sakura frp映射3000端口至:https://www.aichem.dpdns.org 后,发现pdf可以正常打开,但onlyoffice打不开了,报错为:ONLYOFFICE 加载失败{"target":{"frameOrigin":"https://www.aichem.dpdns.org"},"data":{"errorCode":-4,"errorDescription":"下载失败"}}。请检查原因,同时要兼容未来更换域名。