import { type Twips } from './units.js'; import type { Block, DocumentModel, Paragraph, ParagraphStyleCatalog, TextRun } from './model.js'; export declare const DEFAULT_TOC_INSTRUCTION = " TOC \\o \"1-3\" \\h \\z \\u "; /** Word's result text when a TOC has no entries. */ export declare const EMPTY_TOC_TEXT = "No table of contents entries found."; /** Word's result text when a table of figures has no entries. */ export declare const EMPTY_FIGURES_TEXT = "No table of figures entries found."; /** The heading level (1–9) of a paragraph, from its style id or Word's built-in `heading N` name. */ export declare function headingLevel(paragraph: Paragraph, catalog?: ParagraphStyleCatalog): number | undefined; /** The outline levels a TOC instruction collects (`\o "1-3"`); Word's default is 1–9. */ export declare function tocLevels(instruction: string): { from: number; to: number; }; export interface TocEntry { level: number; text: string; blockId: string; } /** Heading paragraphs in body order that a TOC with `instruction` lists. */ export declare function tocEntries(model: DocumentModel, instruction?: string): TocEntry[]; export interface TocOptions { instruction?: string; /** Page number text per heading block id, from pagination; entries without one show no number. */ pageNumbers?: ReadonlyMap; /** Text width in twips, for the right-aligned page-number tab stop. */ contentWidthTwips?: Twips; /** Creates unique paragraph ids. */ newId: () => string; /** * `_Toc` bookmark per heading block id. With it, entries link to their heading and number * their page with a `PAGEREF` field, as Word writes a TOC with the `\h` switch. */ bookmarks?: ReadonlyMap; } /** * The `_Toc` bookmark each entry links to: the heading's existing one, or a new unique name. * Returns only headings that need a new bookmark added in `added`. */ export declare function tocBookmarks(model: DocumentModel, entries: TocEntry[]): { bookmarks: Map; added: Map; }; /** Whether a TOC instruction asks for hyperlinked entries (`\h`). */ export declare const tocHyperlinks: (instruction: string) => boolean; /** `model` with new `_Toc` bookmarks added to the heading paragraphs named in `added`. */ export declare function withTocBookmarks(model: DocumentModel, added: ReadonlyMap): DocumentModel; /** * The TOC as body paragraphs: one per entry, wrapped in a complex field whose begin, code and * separator open the first paragraph and whose end closes the last. Entries use Word's `TOCn` * styles when the document defines them and matching direct indents otherwise. */ export declare function buildTableOfContents(model: DocumentModel, options: TocOptions): Paragraph[]; export interface TocLocation { /** Body block indexes of the paragraphs holding the field's begin and end markers. */ start: number; end: number; instruction: string; /** Runs before the begin marker and after the end marker, kept when the TOC is rebuilt. */ before: TextRun[]; after: TextRun[]; } /** The first heading TOC field in the body (or the first TOC `accepts`), following nested fields with a marker stack. */ export declare function findTableOfContents(blocks: Block[], accepts?: (instruction: string) => boolean): TocLocation | undefined; /** Replaces the document's TOC field with freshly built entries; returns undefined when there is none. */ export declare function updateTableOfContents(model: DocumentModel, options: Omit): DocumentModel | undefined; //# sourceMappingURL=table-of-contents.d.ts.map