/** * The document viewport — what a word processor calls the page view's zoom. * * The editor's continuous view used to have no page geometry at all: it injected the * converter's body into whatever box the host gave it, so the text column was the DEVICE's * width. Three things follow from that, and all three are wrong: * * - Line breaking differs on every screen, and matches neither Word nor the editor's own * paginated view of the same document. * - A table authored at, say, 496pt cannot fit a 354pt phone column. A table box never * shrinks below its content's minimum, so it overflows the sheet and is clipped by the * window — the document visibly runs off the paper. * - Enlarging a run's font size makes that minimum grow, so the overflow gets worse exactly * when the user is editing. * * Word and LibreOffice hold the column at the section's authored width and ZOOM the page to * fit the window. This class does the same: it stamps each section wrapper with its own * `w:sectPr` geometry (content width + margins, so the section IS the sheet), then observes * the host and applies a fit-to-width zoom. Narrow screens get a smaller — never a reflowed — * page, so what the user sees is what the document says. */ /** * How the continuous view sizes its text column. * * - `"section"` (default): the section's own content width, as Word lays it out. Fidelity. * - `"fluid"`: the host's width, the pre-geometry behavior. For embeds that want the document * to reflow as ordinary web text and accept that line breaking will not match Word. */ export type ColumnWidth = "section" | "fluid"; export interface DocumentViewportOptions { /** Text-column sizing for the continuous view. Default `"section"`. */ columnWidth?: ColumnWidth; /** * Scale the page down when it is wider than the host, the way a word processor's * fit-to-width zoom does. Default true. With it off, an oversized page simply overflows * (the host may scroll). */ fitToWidth?: boolean; /** Author-pinned zoom, applied on top of fit-to-width (which never magnifies past it). Default 1. */ scale?: number; } export declare class DocumentViewport { private host; private readonly options; private root; /** Natural page size in points — the widest section's PAGE box, which is what must fit. */ private natural; private observer; constructor(host: HTMLElement, options?: DocumentViewportOptions); /** Retarget the mounted document to an equivalent host after its DOM is adopted. */ adoptHost(host: HTMLElement): void; /** * Adopt a freshly mounted document root (a continuous flow, or the paginated page stack). * Safe to call on every remount; the previous root is released first. * * `applySectionGeometry` is false for the paginated view, which already builds real page * boxes at the section's dimensions — there the viewport contributes only the fit zoom. */ attach(root: HTMLElement, applySectionGeometry: boolean): void; /** Recompute the fit zoom against the host's current width. */ refresh(): void; /** * Change the author-pinned zoom and re-apply it. Fit-to-width still caps it: a page wider * than the host never magnifies past what fits, so "100%" on a phone is the fit zoom. */ setScale(scale: number): void; /** The author-pinned zoom (the value a zoom control shows), before fit-to-width caps it. */ get requestedScale(): number; /** The zoom currently applied (1 = 100%). Reported by the ribbon's anchor rail. */ get scale(): number; dispose(): void; private release; /** The host's content box, which is the space a page has to fit into. */ private availableWidthPx; /** * Give each section wrapper its `w:sectPr` geometry: the authored text column, guttered by * the authored margins. The wrapper then measures exactly one page wide, which is what the * sheet chrome paints and what the fit zoom scales. */ private stampSections; /** * The paginated view's page boxes are already page-sized — `pagination.ts` writes each * box's `width` in points — so the widest of those is the natural width. Reading the * inline width rather than the laid-out box keeps this independent of the per-box zoom * pagination may itself have applied. */ private measurePages; } //# sourceMappingURL=viewport.d.ts.map