import { Node as ProseMirrorNode } from 'prosemirror-model'; import { TocSwitchConfig } from '../../../../../../document-api/src/index.js'; export interface TocSource { /** Flat display text for this entry (used as a fallback and for diagnostics). */ text: string; /** * Per-text-node segments captured from the source paragraph, preserving the * character-level marks (bold, italic, color, font…). When present, the * entry builder emits one styled text node per segment so heading-level * formatting is reflected in the TOC. Absent for TC fields, where only a * plain string is available from the field instruction. */ segments?: TocTextSegment[]; /** TOC level (1-based). */ level: number; /** * sdBlockId of the source paragraph. * For headings: the heading paragraph's sdBlockId. * For TC fields: the containing paragraph's sdBlockId. */ sdBlockId: string; /** Source type for diagnostic purposes. */ kind: 'heading' | 'appliedOutline' | 'tcField'; /** Whether to omit the page number for this specific entry (TC \n switch). */ omitPageNumber?: boolean; } /** A run of source text with its surviving character marks. */ export interface TocTextSegment { text: string; marks?: EntryTextMark[]; } /** * Collects all document nodes that qualify as TOC entry sources. * * Sources are collected based on the instruction's active switches: * - \o (outlineLevels): heading nodes whose level falls within the range * - \u (useAppliedOutlineLevel): paragraph nodes with explicit outlineLevel * - \f (tcFieldIdentifier): TC field nodes with matching identifier * - \l (tcFieldLevels): TC field nodes within the level range * * All sources are merged into a single list sorted by document position. * No deduplication — TC fields and headings at the same position are both included. */ export declare function collectTocSources(doc: ProseMirrorNode, config: TocSwitchConfig): TocSource[]; /** @deprecated Use `collectTocSources` instead. Kept for backward compatibility. */ export declare const collectHeadingSources: typeof collectTocSources; export interface EntryParagraphJson { type: 'paragraph'; attrs: Record; content: Array>; } /** A mark in JSON form, as carried on the rebuilt TOC entry's text runs. */ export interface EntryTextMark { type: string; attrs?: Record; } /** * Optional context that lets the entry builder produce final-looking output * (resolved page numbers, preserved tab spacing) without a follow-up * `mode: 'pageNumbers'` pass. * * Run-level formatting is intentionally NOT sampled from the existing TOC. * Word's "Update field" rebuilds entries from the linked TOC1, TOC2, … * paragraph styles — it does not copy direct formatting from the first entry. * Sampling marks from the existing TOC made any direct formatting on entry 1 * (e.g. bold) leak into every rebuilt entry. */ export interface BuildTocEntryOptions { /** sdBlockId → page number map from PresentationEditor's last layout cycle. */ pageMap?: Map; /** Right-tab stop position (twips) to mirror the existing TOC's spacing. */ tabPos?: number; } /** * Build TOC entry paragraphs. Each paragraph carries `pStyle="TOC{level}"`, * a `tocSourceId` attr pointing back to the source heading, and three runs: * the (linked) entry title, the tab/separator, and the page number. */ export declare function buildTocEntryParagraphs(sources: TocSource[], config: TocSwitchConfig, options?: BuildTocEntryOptions): EntryParagraphJson[]; //# sourceMappingURL=toc-entry-builder.d.ts.map