Repository navigation
feat(web): add a heading outline beside Markdown previews - #960
Matt Van Horn (mvanhorn) wants to merge 3 commits into
Conversation
Rendered Markdown previews list the document's headings in a collapsible outline beside the document. Clicking an entry scrolls that heading in the preview scroller, the current section is marked as the reader scrolls, and the hide/show choice persists per client.
…preview Allocate heading ids once from a GFM parse so the outline, in-document anchors, and spliced review segments land on the same elements. Unicode headings get a nonempty slug; existing ASCII slugs stay unchanged.
0780441 to
5109076
Compare
|
|
Thanks for looking at this.
|
I think that a setting makes sense. I'm not a team member, so can't guide you on flow of PRs. |
- Match spliced-segment heading ids by source line and reserve every document id, so a heading that only parses inside a segment (a split setext underline) cannot take a later heading's id. - Reveal the active outline entry by adjusting only the list's own scrollTop, so an enclosing transcript never scrolls. - Open closed <details> ancestors before scrolling to a selected heading. - Cache heading elements and binary-search the active one at most once per animation frame instead of querying every heading on every scroll. - Add a Left/Right "Markdown outline position" option to Appearance settings (client preference, defaults to right).
|
Added the setting in c755dd2. Appearance settings now has a "Markdown outline position" row with Left and Right; it defaults to Right and is stored as a client preference next to the outline's show/hide state. The editor-side outline for |
Problem
Long Markdown files, specs included, are hard to move around in Preview. The only options are scrolling or searching for a heading's text, and nothing shows the shape of the document while you read.
Approach
The preview builds an outline from the headings it already renders and reuses their ids, so outline links always land on the rendered heading. The outline sits beside the document. It tracks the section you're reading with an observer instead of re-rendering on scroll, and it hides itself in narrow panes and in documents with fewer than two headings.
Changes
packages/resource-renderers/SPEC.mdupdated. New strings added topackages/locales/en.json.Screenshots
Before: the preview of a long Markdown file has no outline.
After: the heading outline sits beside the preview, with the current section highlighted.
Related issues
Closes #757
Checklist
bun run lint,bun run typecheck,bun run testbun run e2e). The newe2e/markdown-outline.spec.tspasses. Locally, 4topbar-review.spec.tstests fail on agit pushto the sample remote, which this change doesn't touch.SPEC.md/ top-level specs updated to reflect any boundary, contract, or behavior changeDemo