Table of contents
TableOfContents generates a clickable navigation block directly from the document's headings (or configured outline styles), with live physical page numbers in paginated mode and one-click refresh whenever headings move or change.
- Included in:
documentConfiguration - Pure-Dart import:
package:vyuh_document_elements/table_of_contents.dartorpackage:vyuh_document_elements/vyuh_document_elements.dart - Flutter extension:
TableOfContentsDocumentExtension(bundled inDocumentEditorElements.defaults) - Action namespace:
TableOfContentsActions
Quick example
dart
import 'package:vyuh_document/vyuh_document.dart';
import 'package:vyuh_document_elements/vyuh_document_elements.dart';
controller.execute(const InsertTableOfContents());
// Refresh entries and page numbers after heading edits
controller.execute(const UpdateTableOfContents());What you can configure
TableOfContentsConfig
| Property | Type / Values | Purpose |
|---|---|---|
minimumLevel, maximumLevel | int (1–6) | Range of heading depths included in the generated index (for example 1–3) |
showPageNumbers | bool | Displays resolved physical page numbers on the right side of each entry |
pageNumberOmittedLevels | Set<int> | Suppresses page numbers on selected levels while keeping them on others |
sourceStyleLevels | Map<String, int> | Maps custom paragraph styles into TOC levels in addition to standard headings |
TableOfContentsPresentation
| Property | Type / Values | Purpose |
|---|---|---|
pageTabMode | TableOfContentsPageTabMode | Leader alignment between entry title and page number (dotted, dashed, solid, or none) |
levelStyles | Map<int, TableOfContentsPartStyle> | Per-level character format (font, weight, color) and paragraph format (indent, spacing) |
decoration | Block decoration | Optional container border, background fill, and padding around the TOC block |
Actions & commands
| Action ID / Command | Effect |
|---|---|
TableOfContentsActions.insert | Insert a new generated table of contents at the caret |
InsertTableOfContents | Pure-Dart command inserting a TOC block |
UpdateTableOfContents | Recomputes entries and page numbers canonically |
Clicking any TOC entry navigates directly to its target heading in the document.
Restricting usage
- Remove TOC: Start from
notesConfigurationor calldocumentConfiguration.withoutElements([TableOfContents.element]). - Pageless documents: In pageless mode, TOC entries still navigate to headings cleanly without physical page numbers.
Format parity
| DOCX | HTML | Markdown | |
|---|---|---|---|
Native OOXML TOC \o "1-3" field + cached entries | Clickable internal PDF links with resolved right-aligned page numbers | <nav role="doc-toc"> with anchor links | Indented anchor link list |