Repository navigation
feat(files): an opt-in outline beside rendered Markdown previews - #3065
Conversation
Settings > File viewer > Markdown outline (off by default) lists a Preview's headings, marks the one being read and keeps it centered in the list without moving the document or the focus. A column on a wide viewer, a drawer from the header's Outline button on a narrow one. Fixes #636.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 22 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
…utline # Conflicts: # src/lib/settings.legacy-fixture.ts # src/lib/settings.ts
… never drags the viewer's sheet Review round 1 (Codex HIGH 1 and 2, both reproduced in scripts/markdown-outline-browser-qa.ts before the fix): the drawer handles Escape only while the focus is in its own viewer, and its list owns its touch strokes (data-sheet-stroke="own", read by lib/sheets.ts ownsStroke).
Review round 1 (head e4efe4b): findings and how each was resolvedReviewers: omo ( Codex HIGH 1 / omo MEDIUM (reproduced, fixed): the drawer took every Escape. While the drawer was open, its capture-phase listener stopped Escape everywhere. A dialog in front of the viewer (Settings) or the pane beside a docked panel (a terminal) never got the key, and the focus was pulled to the Outline button behind them. Reproduced in Codex HIGH 2 (reproduced, fixed): a downward swipe on the drawer dragged the whole viewer. Not reproduced, left as notes (no follow-up issues):
|
Review round 2 (head 57863e2)
MEDIUM (Codex, reproduced, follow-up #3066): on a narrow viewer with the outline drawer open, Escape in the header's More menu closes the menu and the drawer together (reproduced with a scratch step of CodeRabbit did not review this PR (review limit reached). |
…utline # Conflicts: # src/components/FileViewer.tsx # src/lib/i18n.test.ts # src/lib/i18n/files.ja.ts # src/lib/i18n/files.ko.ts # src/lib/i18n/files.zh.ts # src/lib/settings.legacy-fixture.ts # src/lib/settings.ts
…utline # Conflicts: # src/lib/settings.legacy-fixture.ts # src/lib/settings.ts
…n, so the settings dictionary part stays under 400 lines
…utline # Conflicts: # src/lib/settings.legacy-fixture.ts # src/lib/settings.ts
|
Local merge gate (owner-approved): origin/main merged (with #3064, #3067, #3072; both features kept; the outline is off while the #3064 editor is open), |
Fixes #636.
What
A new opt-in setting, Settings > File viewer > Markdown outline (off by default, a device setting in its own storage key like the other recent opt-ins). With it on, a Markdown Preview that has two headings or more lists them:
With the setting off (the default), the viewer is unchanged: the body's new wrapper is
display: contents, so it lays nothing out. The wrapper is always rendered so the body is never remounted when an outline appears, which keeps its focus and scroll.Design reference: Zed's outline panel (the current symbol is marked and kept in view while the editor scrolls) for the column, and GitHub's Markdown file outline button for the narrow drawer. There is a DESIGN.md entry.
Compared with #651 (closed as a duplicate before the Markdown preview landed): this builds on the preview that is on main now, adds only the outline, and keeps it opt-in.
Tests
scripts/markdown-outline-browser-qa.ts(new, added toscripts/ci-browser.sh): the real viewer built by Vite and served under the app's CSP, light and dark.display: contents.#/##/###; the first entry marked at the start with the list at scrollTop 0; scrolling to Section 16 marks it within 2 px of the list's center while the body's scrollTop anddocument.activeElementstay unchanged; at the end the list is at its own end; the third "Notes" entry lands the third Notes heading at 8 px; choosing Section 30 near the end keeps it marked; the button folds and restores the column.src/at origin/main the script fails at its first step (no wrapper, no outline).src/lib/markdownOutline.test.ts: the entry list (levels, words with formatting dropped, quoted headings left out, repeated titles as separate places, wordless headings skipped) and the current-heading rule.src/lib/settings.test.ts: the default, sanitising and device scope, and the setting's own key surviving an old tab's whole-record save.Screenshots
Fixture data (no user session), 1280x800 and 390x844, dark and light; checked by eye: the column and the drawer, the marked entry centered, the indent per level, and the Outline button's on state.
Validation
bun run check fast: pass on the merged head 57863e2 (workflow syntax, generated types/themes, typecheck, build, 12364 unit tests, 0 failures).bun scripts/markdown-outline-browser-qa.ts: pass, also on the merged head (withfiles-prompt-regression, whose fix(dialogs): Escape closes the dialog in front when two are open #3053 Escape steps landed meanwhile).src/lib/sheets.ts), inherdr-ci-runner:local:key-bar-customization-demo-regression,link-menu-demo-regression,phone-worktree-sheet-regression: all PASS.herdr-ci-runner:local: all pass:markdown-outline-browser-qa,file-viewer-regression(79 PASS),file-viewer-mobile-regression,file-preview-text-browser-qa,virtual-source-browser-qa,files-panel-demo-regression,file-text-size-demo-regression,settings-pages-demo-regression,deep-link-demo-regression,render-crash-demo-regression,web-panel-mobile-regression,repo-diff-browser-qa,relay-media-browser-qa,link-menu-demo-regression, andfiles-prompt-regression(throughbun run check run, 8 PASS).