Document Outline

Pro

A live table of contents for one rich text editor — headings down to a level, the current one marked, a click scrolls there; no ids are written into the document.

</>sv-rte-outline editortocoutlinenavigation
import { SvRteOutlineComponent } from '@styloviz-pro/rich-editor';

Demo & usage

Basic usage

Pro

Usage example — open the gallery for the full interactive demo.

Pro

An interactive demo for this component lives in the gallery.

Open live demo

More examples

Beside the editor

Pro

The outline follows every edit; `headingSelect` reports the heading chosen.

When to use

  • Documents long enough to scroll: handbooks, specs, policies.
  • A short note with one heading does not need one.

Async states

None — this component has nothing to load, so it has no loading, empty or error state to drive.

Inputs

NameTypeDefaultDescription
editorrequiredSvRichTextEditorComponent—The editor whose headings to list.
maxLevelnumber3Deepest heading level shown (1–6).
ariaLabelstring''Accessible name of the outline's `<nav>`. Defaults to the "Document outline" label.

Outputs

EventPayload typeDescription
headingSelectSvRteOutlineItemEmitted when a heading is chosen.

Customization & theming

  • `maxLevel` (1–6, default 3) and `ariaLabel` for the `<nav>`.

Forms integration

  • sv-rte-outline — Output-driven, not a ControlValueAccessor. It navigates a document and has no value of its own — it reports the heading chosen through `headingSelect`.

Best practices

  • Do: Use real heading levels in order (h1 → h2 → h3); the outline indents by level.
  • Tip: `svRteOutline(element, maxLevel)` returns the same list for a printed TOC or a sidebar of your own.

Accessibility

  • A labelled `<nav>` of buttons; the heading the caret is under carries `aria-current="location"`.
  • Choosing a heading moves the caret there and focuses the editor, so keyboard users continue typing at the heading.

Feedback on Document Outline

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.