/** * Engine-side input contracts. These are intentionally a separate type family * from `@christophervr/docx-core`'s `DocumentModel`: several fields here * (keepNext, cantSplit, tblHeader, explicit page/column breaks, sections, * columns) are not yet represented in the shared model. `adapter.ts` maps * what the current model exposes and leaves the rest at their (Word-default) * fallback, so the pipeline keeps compiling as other agents add model * fields, and nothing here ever reads `(x as any)`. */ import type { SignedTwips, Twips } from '../index.js'; export interface LayoutRun { text: string; bold?: boolean; italic?: boolean; fontFamily?: string; /** Points, matching `TextRun.fontSize` in docx-core. */ fontSizePt?: number; textScalePercent?: number; ligatures?: import('../ligatures.js').Ligatures; characterSpacingPx?: number; kerningThresholdPt?: number; /** Positive raises the baseline, negative lowers it. */ positionPx?: number; /** A hard page/column break placed immediately after this run's text. */ breakAfter?: 'page' | 'column'; /** An inline picture: occupies its size on the line (`text` is empty). */ object?: LayoutObject; /** Generated text (a list label) that is not part of the paragraph's own characters. */ synthetic?: boolean; /** Generated list marker; the remaining characters in this run are its separator. */ marker?: { length: number; alignment: 'left' | 'center' | 'right'; }; /** Superscript or subscript: drawn smaller and raised or lowered (note marks are superscript). */ script?: 'super' | 'sub'; /** `#rrggbb`, display only. */ color?: string; underline?: boolean; strike?: boolean; } /** A picture's package part and size in CSS pixels; the engine never loads its bytes. */ export interface LayoutObject { partName: string; contentType: string; widthPx: number; heightPx: number; } /** A floating picture anchored to a paragraph (`wp:anchor`), positioned on the page. */ export interface LayoutFloat extends LayoutObject { /** `wp:positionH/@relativeFrom`: page, margin, column, leftMargin, rightMargin, character… */ relativeFromH?: string; alignH?: 'left' | 'center' | 'right' | 'inside' | 'outside'; offsetXPx?: number; /** `wp:positionV/@relativeFrom`: page, margin, paragraph, line, topMargin, bottomMargin… */ relativeFromV?: string; alignV?: 'top' | 'center' | 'bottom' | 'inside' | 'outside'; offsetYPx?: number; behindText?: boolean; wrap?: string; } /** A paragraph tab stop, positioned from the paragraph's text margin (not its indent). */ export interface LayoutTabStop { posPx: number; align: 'left' | 'center' | 'right' | 'decimal' | 'bar' | 'clear' | 'start' | 'end' | 'num'; leader?: 'none' | 'dot' | 'hyphen' | 'underscore' | 'heavy' | 'middleDot'; } /** A paragraph border side: the line and its `w:space` gap to the text. */ export interface LayoutParagraphBorder extends LayoutBorder { spacePx: number; } export interface LayoutParagraphBorders { top?: LayoutParagraphBorder; bottom?: LayoutParagraphBorder; left?: LayoutParagraphBorder; right?: LayoutParagraphBorder; } /** A footnote's content, laid out in the page's footnote area. */ export interface LayoutNote { id: string; paragraphs: LayoutParagraph[]; } export type ParagraphAlign = 'left' | 'center' | 'right' | 'justify'; export type LineSpacingRule = 'auto' | 'exact' | 'atLeast'; export interface LayoutParagraph { kind: 'paragraph'; id: string; runs: LayoutRun[]; align?: ParagraphAlign; direction?: 'ltr' | 'rtl'; spacingBeforeTwips?: Twips; spacingAfterTwips?: Twips; lineSpacingTwips?: SignedTwips; lineSpacingRule?: LineSpacingRule; indentLeftTwips?: SignedTwips; indentRightTwips?: SignedTwips; indentStartTwips?: SignedTwips; indentEndTwips?: SignedTwips; firstLineTwips?: Twips; hangingTwips?: Twips; /** `w:contextualSpacing`: suppress spacing between paragraphs sharing `styleId`. */ contextualSpacing?: boolean; styleId?: string; /** `w:pageBreakBefore`. */ pageBreakBefore?: boolean; /** `w:keepNext`: keep this paragraph on the same page as the block after it. */ keepNext?: boolean; /** `w:keepLines`: never split this paragraph's own lines across pages. */ keepLines?: boolean; /** `w:widowControl`; Word's document default is on. Undefined means on. */ widowControl?: boolean; /** Floating pictures anchored in this paragraph. */ floats?: LayoutFloat[]; /** Custom tab stops (`w:tabs`). */ tabStops?: LayoutTabStop[]; /** Footnotes referenced here; they go at the bottom of the page where the paragraph starts. */ footnotes?: LayoutNote[]; /** Border lines around the paragraph, with each side's gap to the text. */ borders?: LayoutParagraphBorders; /** `#rrggbb` shading behind the paragraph. */ shading?: string; } /** A resolved cell border, ready to draw. */ export interface LayoutBorder { widthPx: number; style: 'solid' | 'double' | 'dotted' | 'dashed'; color: string; } export interface LayoutCellBorders { top?: LayoutBorder; right?: LayoutBorder; bottom?: LayoutBorder; left?: LayoutBorder; } export interface LayoutCellPadding { top: number; right: number; bottom: number; left: number; } export interface LayoutTableCell { paragraphs: LayoutParagraph[]; /** Column width in CSS pixels; undefined cells share the row's remaining width evenly. */ widthPx?: number; /** Left edge from the table's left, from the table grid (merged cells span grid columns). */ xPx?: number; /** Cell margins (`w:tcMar`, else the table default); content is inset by them. */ padding?: LayoutCellPadding; borders?: LayoutCellBorders; /** `#rrggbb` shading fill. */ shading?: string; verticalAlign?: 'top' | 'center' | 'bottom'; } export interface LayoutTableRow { cells: LayoutTableCell[]; /** `w:trPr/w:cantSplit`: this row must stay on one page. */ cantSplit?: boolean; /** `w:trHeight`: a minimum (`atLeast`) or fixed (`exact`) row height. */ heightPx?: number; heightRule?: 'atLeast' | 'exact'; /** `w:trPr/w:tblHeader`: repeat this row at the top of every page the table continues onto. */ isHeader?: boolean; } export interface LayoutTable { kind: 'table'; id: string; rows: LayoutTableRow[]; /** Total grid width, for aligning the table in its column. */ widthPx?: number; /** `w:tblInd`: offset from the column's left edge. */ indentPx?: number; /** `w:jc` on the table. */ alignment?: 'left' | 'center' | 'right'; } export type LayoutBlock = LayoutParagraph | LayoutTable; export interface LayoutPageGeometry { widthPx: number; heightPx: number; marginTopPx: number; marginRightPx: number; marginBottomPx: number; marginLeftPx: number; } export interface LayoutColumns { count: number; gapPx: number; separator?: boolean; /** Explicit column widths and the gap after each column (`w:col`). */ widths?: { widthPx: number; gapPx: number; }[]; } export interface LayoutSection { page: LayoutPageGeometry; columns?: LayoutColumns; blocks: LayoutBlock[]; /** How this section begins relative to the previous one; the first section is always a fresh page. */ break?: 'nextPage' | 'continuous' | 'evenPage' | 'oddPage'; /** `w:vAlign`: where content sits vertically on each page of the section. */ verticalAlign?: 'top' | 'center' | 'both' | 'bottom'; } export interface LayoutDocumentInput { sections: LayoutSection[]; } //# sourceMappingURL=input.d.ts.map