Skip to content

0.15.0:Word(.docx)支持与 Windows 支持 - #7

Merged
2019wakeup merged 15 commits into
mainfrom
feat/0.15-word-windows
Nov 24, 2026
Merged

2019wakeup merged 15 commits into
mainfrom
feat/0.15-word-windows

Conversation

@2019wakeup

@2019wakeup 2019wakeup commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

概述

按 docs/PRD-v0.15-Word与Windows.md 实现 0.15.0:

  • Word(.docx):mammoth 懒加载资产 + 适配层,接入连续滚动阅读、目录、划词、翻译、标注、跨章搜索、导读和 reader_context;不还原分页/页眉页脚。
  • Windows:统一 POSIX 相对路径、GBK/UTF-16 编码探测、文件占用 423 与原子写重试、Ctrl+Y、Ctrl+滚轮、字体/滚动条、书库垃圾文件过滤,并把测试/发布链路与 CI 扩到 windows-latest。

修复的 0.14 发布阻断

npm pack 的 0.14.0 缺 src/client/translate.js,Host 入口会 ERR_MODULE_NOT_FOUND。已移到 lib/block-hash.js,并让 publish-check 解包后 import Host 入口。

验证

  • 单元 + DOM:429/429
  • eval:18/18
  • Word pipeline:9/9(真实 mammoth)
  • 视觉:170/170 + 22 基线(含 Word 打开、表格、目录、划词工具条、跨章搜索)
  • 动效:16/16
  • 发布门禁:13/13
  • 发布包:PASS(227 个文件,Host 入口可 import)
  • GitHub Actions:windows-latest / macos-latest / ubuntu-latest 全绿

验收记录:docs/0.15-验收记录.md(含待真机的 Windows 清单)。

发布前

  1. 合并后打 v0.15.0 tag(Release workflow 会 npm publish)。
  2. 发布后确认 plugin-market.json 的 0.15.0 源为 npm。
  3. Windows 真机手工清单(DPI、文件占用、输入法)按验收记录第 4 节走一遍;CI 已覆盖单测与 eval。

lead added 15 commits November 24, 2026 19:22
win32 path.relative returns backslashes, which broke basename/dirname,
markdown image resolution, breadcrumbs and store path comparisons. Normalize
at the host boundary, in the store reader, and in every client path consumer;
legacy backslash paths are rewritten on read.
Decode UTF-8/UTF-16/GB18030 instead of assuming UTF-8, map ENOENT/EACCES/EBUSY
to readable 404/403/423 responses, retry atomic renames and fall back to a
copy, hide Windows junk files from the library, add Ctrl+Y, and test on both
macOS and Windows in CI.
Handle Ctrl+wheel inside the reader instead of scaling the whole window,
add Segoe UI/YaHei/Consolas to the font stacks, and reserve a stable
scrollbar gutter so short documents do not shift when the scrollbar appears.
Vendor mammoth as a lazy asset, parse heading levels from style names and
outlineLvl, sanitize the generated HTML, split h1 chapters, and route .docx
through the existing prose, TOC, chapter navigation and guide pipeline.
Search now walks every docx chapter and jumps across chapters, and the
reader_context window/position treat docx like EPUB without inventing a page.
…parts

Word documents can be large or hostile; reject archives with too many parts
or an oversized document.xml, and stop injecting translations into table
cells where they break the column layout.
Generate a small .docx fixture for the browser run, open it after the other
demos, and assert the prose, table wrapper and chapter TOC. Accept the
ArrayBuffer that the host fetch returns (the previous Uint8Array-only path
broke the real reader).
Run the real mammoth conversion in eval/docx.mjs, verify chapters, outline,
table wrapping, TOC cleanup and the missing-part guard, then include it as the
13th release check. Stabilize the card-stacking motion probe while here.
Add browser assertions for the docx selection toolbar and a search that jumps
from chapter one to chapter two, then record the 0.15 acceptance evidence and
the remaining Windows-only manual checks.
Fail closed when a realpath check cannot run, use path.relative for workspace
containment, sort names numerically, ignore Escape during IME composition and
report clipboard failures instead of dropping them.
@2019wakeup
2019wakeup merged commit a080101 into main Nov 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant