Skip to content

fix:macOS Markdown 预览目录默认展开并使用完整高度 - #1021

Open
Absinthe-yl wants to merge 3 commits into
1lck:previewfrom
Absinthe-yl:sinthdev
Open

Absinthe-yl wants to merge 3 commits into
1lck:previewfrom
Absinthe-yl:sinthdev

Conversation

@Absinthe-yl

Copy link
Copy Markdown

Closes #1002

问题

macOS Markdown 预览目录默认隐藏,展开后高度受 66vh / 560px 限制,长文档导航时未充分利用右侧空间;点击目录标题后还会自动收起。

定位

目录由现有 MarkdownPreview/preview.js 生成,初始 HTML 将目录标记为隐藏;目录链接和点击正文的事件会关闭目录。preview.css 将目录作为固定浮层,并限制最大高度。

修复

  • 有标题的文档首次预览时默认展开目录,按钮和 Escape 仍可收起。
  • 同一文档正文刷新时保留用户的展开/收起选择;切换文档时恢复默认展开。
  • 无标题时隐藏目录和按钮,暂时删除全部标题不会覆盖用户的展开偏好。
  • 点击目录标题完成跳转后保持目录展开,点击正文也不会自动关闭目录,便于连续导航。
  • 目录延伸到预览底部,长目录独立滚动;窄预览沿用可收起浮层,宽预览给正文预留目录空间,避免覆盖正文。
  • 更新独立的 Markdown 目录能力矩阵及生成的 Markdown / CSV;macOS 已实现并验证,Windows 目录入口尚未实现。

验证

  • 开发基线为上游 preview 的 32462a59;提交前合并最新 4773688e,重新生成矩阵文档并保留双方能力记录。本 PR 相对最新基线仅修改 Markdown 预览 JS/CSS 和功能矩阵。
  • macOS arm64、Swift 6.3.3、SDK 26.5:基线及修改后的完整应用、官方插件均构建成功并重新启动验证。本机临时启动脚本让官方插件读取 SDKROOT,最后验证实例使用独立 bundle identifier 以避免控制工具混淆已安装应用;这些本地验证入口调整未包含在 PR 中。
  • 真实 Lithe UI 端到端验证:目录默认展开、按钮收起/展开、Escape 收起、短文档全高目录、60 节目录独立滚动至末尾且正文不随之滚动、点击末尾章节成功跳转且目录保持展开。
  • 分栏中真实编辑并保存新增标题,以及外部修改触发正文刷新:保留收起状态,重新展开后新增标题可见;点击正文不自动收起目录。
  • 删除全部标题后目录和按钮隐藏;恢复标题后保留展开偏好;无标题文档预览不显示目录,新文档首次预览默认展开。窄分栏可收起目录,宽预览正文避让目录。
  • 原生 UI 测试在 32462a59 基线上完成;最新同步仅涉及上游 Windows 功能及矩阵文档,macOS 预览实现未变化。
  • 操作前后应用包内 990 个文件的清单及 SHA-256 完全一致;验证应用及辅助进程已关闭。
  • node --check macos/Sources/Lithe/Resources/MarkdownPreview/preview.js、./scripts/verify-runtime-bundle-immutability.sh、./scripts/verify-platform-feature-matrix-change.sh origin/preview HEAD、./scripts/verify-platform-feature-matrix.sh、git diff --check 均通过。
  • ./scripts/verify-service-boundaries.sh 被上游已有的 AppModel+RunConfiguration.swift 616 行超过 600 行限制阻断,该文件与上游一致,本 PR 未修改。
  • 本次只验证 macOS;Windows 未运行。

@ghfind-review ghfind-review Bot added the review: medium ghfind author score; see https://ghfind.com label Oct 1, 2026

@xiaoyumuxi xiaoyumuxi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

补充一个状态保持的边界条件,见 inline comment。

tocToggle.setAttribute('aria-expanded', String(visible));
document.body.classList.toggle('toc-open', visible);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closeTOC() now persists tocExpanded = false, but the Escape handler calls it even when the document currently has no headings and the TOC toggle is hidden. This means an unrelated Escape (for example, closing the image viewer) can overwrite the preserved expanded preference: open TOC → remove all headings → press Escape → restore headings now leaves the TOC collapsed. Could we only mutate the TOC preference here when !tocToggle.hidden (or otherwise distinguish “TOC unavailable” from an explicit user collapse)?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: medium ghfind author score; see https://ghfind.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants