import type { BoundingBox, VDTDocument } from '../vdt.js'; /** Where something painted comes from. Markdown offsets are absolute in * the chapter file (front matter counted), as every `sourceStart` of the * VDT; `file` is the host's name for that file, when it gave one. */ export type SourceRef = { kind: 'markdown'; start: number; end: number; file?: string; chapter?: number; } | { kind: 'config'; path: string; } | { kind: 'attr'; name: string; start: number; end: number; file?: string; chapter?: number; } | { kind: 'resource'; resourceId: string; anchor?: string; }; /** The selection level of a {@link SourceElement}, innermost first: * `text` a glyph (or a chip, a reference, a formula: one unit of a line), * `attr` an attribute an element shows, `label` a label of a figure (at * its anchor, `resourceId#anchorId`), `resource` a picture, * `line` a line of text, `block` a paragraph, heading, list item, picture * block…, `box` a callout around it, `frame` a frame of a composed page, * `group` a group of frames, `design` an element of a design slot, * `slot` that slot (decoration, header, footer), `template` the composed * page and its template. */ export type SourceLevel = 'text' | 'attr' | 'label' | 'resource' | 'line' | 'block' | 'box' | 'frame' | 'group' | 'design' | 'slot' | 'template'; export interface SourceElement { level: SourceLevel; /** Stable on a composed page (`cp:…`): the same across relayouts * and in every locale of the chapter. Elsewhere the block's id. */ id: string; source: SourceRef; /** The Markdown the element holds, when that is not its `source`: a * frame's slot content, a composed page's fence, a box's fence. */ content?: { start: number; end: number; }; /** Set when the Markdown of `source` and `content` is another chapter's * (#943): text a story carried in from an earlier chapter, laid on this * document's pages. The position of that chapter in the book; absent: * this document's own file. */ chapter?: number; /** The element's box on the page (px): upright, before its frame's turn * (`rotate`). In the page's flow frame when {@link flow} is set, as the * VDT has it. */ rect?: BoundingBox; /** Set when `rect` is in the page's flow frame, not on the sheet: the * flow text of a vertical or right-to-left page, and a composed page's * frames and what they hold there (#929). `flowRectToPage` / * `flowToPage` put it on the sheet, where `sourceAt` reads its point. */ flow?: true; /** Degrees the element's frame is turned, clockwise about the frame's * centre; absent when upright. */ rotate?: number; /** A contents entry (`:::toc`): where the heading it lists starts in its * chapter's Markdown body (front matter not counted, as outlines count). */ heading?: number; /** Set on an element laid past its frame's foot: kept in the source map, * clipped on the page (`frameOverflow`). */ clipped?: true; /** Set on the half of a spread frame shown on the page facing the one * that reads it (`VDTFrame.facingBlocks`, #861): its id is the read * block's. */ facing?: true; } export interface SourceMapOptions { /** The file each page's Markdown offsets belong to: the chapter's name, * or one per page for a document stitched from several chapters. */ file?: string | ((pageIndex: number) => string | undefined); /** The file of the chapter at a position of the book, for text a story * carried in from another chapter (#943; `SourceElement.chapter`). */ chapterFile?: (chapter: number) => string | undefined; /** `elementsForSource`: the chapter the offsets given are in (its * position in the book), and the position of the chapter `doc` is. By * default the offsets are `doc`'s own: text carried in from another * chapter is not found by them. */ chapter?: number; ownChapter?: number; } /** * What page `pageIndex` of `doc` shows at `(x, y)` (page px, the sheet's * top-left origin), innermost first, each element followed by the ones * that hold it: on a composed page a glyph, its line, its paragraph, the * boxes round it, its frame, the frame's groups and the template; a design * element and its slot; on any other page the flow's text, pictures and * boxes, the running heads. Empty when nothing is there. */ export declare function sourceAt(doc: VDTDocument, pageIndex: number, x: number, y: number, options?: SourceMapOptions): SourceElement[]; /** An element {@link elementsForSource} found, on its page. */ export interface SourceMatch { pageIndex: number; element: SourceElement; } /** * Everything of `doc` laid out from the Markdown range `[start, end)` * (absolute offsets; an empty range finds what holds the offset): the * lines and blocks of text, the frames whose slot content it touches, the * composed pages whose fence it touches, the design text that shows an * attribute written there; in page order, frames and pages before their * content. Lines laid past their frame's foot come with `clipped`. */ export declare function elementsForSource(doc: VDTDocument, start: number, end: number, options?: SourceMapOptions): SourceMatch[]; /** The element of `doc` with stable id `id` (a frame `cp0:dinero`, a * composed page `cp0`, a block, a design element `cp0:decoration:tema`, * a figure label `cp0:mapa:label:madrid`), * on its page: what a host looks up again after a relayout. */ export declare function findElement(doc: VDTDocument, id: string, options?: SourceMapOptions): SourceMatch | undefined; //# sourceMappingURL=sourceMap.d.ts.map