Files
mnote/design/05-editor-mainline/process/5-19-resource-open-resolver-and-onlyoffice-checklist-v1.md
T

63 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 5-19 Resource Open Resolver 与 OnlyOffice 回源 Checklist v1
> 状态:process
>
> 日期:2026-05-20
>
> Owner:资源打开 resolver / attachment capture / OnlyOffice URL 配置
## 1. 目标
补齐 P0-3:把资源类型识别、badge、默认打开目标、显式 `active-tab / side / new-window` 目标收口到轻量 resolver,并优先修复本地上传 `.docx` 在主编辑区 tab 内无法回源的问题。
## 2. 允许修改范围
- `rust/crates/mnote-web/src/routes/web_shell.rs`
- `rust/crates/mnote-web/src/ssr/pages/layout.rs`
- `rust/crates/mnote-web/src/routes/onlyoffice.rs`
- `rust/crates/mnote-web/src/ssr/styles.rs`
- `scripts/task457-main-editor-resource-tab-smoke.js`
- `scripts/task461-resource-kind-smoke.js`
- 可新增 OnlyOffice/resolver smoke
## 3. 禁止事项
- 不引入 Monaco / CodeMirror。
- 不重构 OnlyOffice DocumentServer 部署。
- 不改变 `.md` / `.txt` / code 资源继续用 tiptap resource editor 的口径。
- 不处理 File Tree open target 合同;该项由 4-39 处理。
## 4. Checklist
- [x] 定义轻量 resource open resolver,输入包含 `name/mimeType/href/assetId/rootUri/path/openTarget`
- [x] resolver 输出 `editorKind/badgeKind/defaultOpenMode/editable/viewerUrl` 或等价结构。
- [x] `tree.asset.open`、attachment click capture、显式 new-window 复用同一 resolver 判断。
- [x] 默认打开目标为主编辑区 `active-tab``new-window` 显式保留;`side` 不回归。
- [x] `.docx/.pptx/.xlsx` 默认进入主编辑区 Office iframe,显式 new-window 打开 `/onlyoffice`
- [x] OnlyOffice iframe 的 document URL 对 local-folder 文件使用 Rust 可访问的 `/api/local-folder/files/open``/api/onlyoffice/proxy` 回源 URL,避免 DocumentServer 访问浏览器不可达 URL。
- [x] 如果本机 DocumentServer 不可用,smoke 至少断言 iframe config URL / document URL / callback URL 正确,不把外部服务不可用误判为 resolver 失败。
## 5. 验收
- [x] `node --check scripts/task457-main-editor-resource-tab-smoke.js && node --check scripts/task461-resource-kind-smoke.js`
- [x] `node scripts/task457-main-editor-resource-tab-smoke.js`
- [x] `node scripts/task461-resource-kind-smoke.js`
- [x] 新增或更新 Office smoke,覆盖 `.docx` 主编辑区 tab iframe 与显式 new-window。
- [x] `cargo test -p mnote-web onlyoffice -- --test-threads=1`
## 6. 本轮执行记录
- 已完成:
- `resolveResourceOpen` 已集中输出 `editorKind` / `badgeKind` / `defaultOpenMode` / `editable` / `viewerUrl` / `openTarget`
- 本地 Office 资源默认进入主编辑区 iframe,显式 `new-window` 仍打开 `/onlyoffice`
- `buildOnlyOfficeOpenUrl` 会把相对 `fileUrl` 绝对化,local-folder Office iframe 携带 `http://127.0.0.1:3000/api/local-folder/files/open?...` 这类 Rust 可访问回源 URL。
- 新增 `scripts/task463-onlyoffice-resolver-smoke.js`,已覆盖 `.docx/.pptx/.xlsx` badge、主编辑区 iframe、显式 new-window、OnlyOffice 页面脚本结构。
- 未完成:
- 未验证真实外部 DocumentServer 协同编辑会话,只验证 MNote 侧 URL / iframe / proxy / callback 配置。
- 风险:无
## 7. 非目标
- 不修复外部 DocumentServer 服务部署本身。
- 不实现云端资源写回。