+- **Document outline.** Open the outline sidebar from the toolbar or with `Ctrl/⌘+Shift+O` to browse every heading of the current Markdown file as an indented table of contents that updates as you type. Clicking a heading jumps straight to it — the editor puts it at the top of the view, and the preview follows in split and preview modes.
- **In-document link navigation.** Headings get anchor ids, so clicking an in-page link in the preview — like a table of contents `[Section](#section)` — smooth-scrolls to that heading within the preview pane.
- **Links open where they belong.** Web and mail links in the preview open in your default browser or mail app, and links to other Markdown, JSON, or YAML files (`[Guide](docs/guide.md)`) open them in markpad, resolved relative to the current file. The markpad window itself only ever shows markpad: links, forms, and pop-ups can never turn it into a browser.
- **Diagrams from fenced code.** A ` ```mermaid ` block renders as a diagram in the preview — flowcharts, sequence, class, state, ER, gantt, pie, mindmap, timeline, git graphs and the rest of [Mermaid](https://mermaid.js.org/)'s catalogue — and ` ```dot ` (or `graphviz`, `gv`) renders [Graphviz](https://graphviz.org/) DOT source. Both engines run entirely on your machine, follow the app's light/dark theme, and load only when a document actually has a diagram in it. Source that does not parse shows the engine's message inline with the block, so a half-typed diagram never blanks the preview.
diff --git a/src/App.tsx b/src/App.tsx
index 6b9d1e1..ece6d72 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -12,6 +12,8 @@ import ErrorBanner from "./components/ErrorBanner";
import ExternalChangeBanner from "./components/ExternalChangeBanner";
import RecentsPanel, { type RecentEntry } from "./components/RecentsPanel";
import WorkspaceSearchPanel from "./components/WorkspaceSearchPanel";
+import OutlinePanel from "./components/OutlinePanel";
+import { markdownHeadings } from "./lib/markdown";
import ConfirmDialog from "./components/ConfirmDialog";
import type { EditorHandle } from "./components/Editor";
import type { PreviewHandle } from "./components/Preview";
@@ -111,7 +113,7 @@ type ItemSnapshot = {
previewScrollTop: number;
};
-type SidebarView = "recents" | "workspaceSearch";
+type SidebarView = "recents" | "workspaceSearch" | "outline";
type PendingLocation = {
itemId: ItemId;
@@ -276,6 +278,13 @@ function App() {
const searchOpen = activeId !== null && searchItemId === activeId;
const workspaceSearchOpen =
!sidebarCollapsed && sidebarView === "workspaceSearch";
+ const outlineOpen = !sidebarCollapsed && sidebarView === "outline";
+ const activeIsMarkdown = activeItem !== null && activeLanguage === "markdown";
+ // Parsed only while the outline is on screen; it follows every keystroke.
+ const outlineHeadings = useMemo(
+ () => (outlineOpen && activeIsMarkdown ? markdownHeadings(activeText) : []),
+ [outlineOpen, activeIsMarkdown, activeText],
+ );
const recentEntries = useMemo{title}
++ {detail} +
++ {fileName ?? "No document"} +
+