import { ShadingType, type IParagraphStylePropertiesOptions } from "docx"; import type { Element } from "domhandler"; import type { StyleResolver } from "./style-resolver.js"; import type { BlockLayout, RunTypography } from "./types.js"; export interface ParsedBorder { widthPx: number; color?: string; } export interface ParsedCss { color?: string; backgroundColor?: string; display?: string; flexDirection?: string; gap?: number; textAlign?: string; /** `font-family` mapped to a Word-safe installed font (first recognized family wins). */ fontFamily?: string; /** `border-collapse` keyword — separate (default) tables get UA border-spacing gaps. */ borderCollapse?: string; /** `text-transform` keyword (uppercase → Word all-caps display property). */ textTransform?: string; /** Parsed from `text-decoration` / `text-decoration-line` — underline on/off/none. */ textDecoration?: string; /** `letter-spacing` in twips (absolute units). */ letterSpacingTwips?: number; /** `letter-spacing` in em (resolved against font size at typography build). */ letterSpacingEm?: number; fontSize?: number; /** CSS `line-height` as a unitless multiplier (e.g. 1.5). */ lineHeight?: number; fontWeight?: string; fontStyle?: string; listStyleType?: string; marginTop?: number; marginRight?: number; marginBottom?: number; marginLeft?: number; paddingTop?: number; paddingRight?: number; paddingBottom?: number; paddingLeft?: number; /** Explicit CSS height in twips (px/pt/em) — used for color-bar sizing. */ heightTwips?: number; /** CSS `min-height` in twips — a floor for flex-item box height. */ minHeightTwips?: number; /** Explicit CSS width: absolute in twips, or percentage of the containing block. */ widthTwips?: number; widthPercent?: number; maxWidthTwips?: number; maxHeightTwips?: number; visibility?: string; opacity?: number; overflow?: string; border?: ParsedBorder; /** `border-color` — color override for borders declared elsewhere (attr or shorthand). */ borderColor?: string; borderTop?: ParsedBorder; borderRight?: ParsedBorder; borderBottom?: ParsedBorder; borderLeft?: ParsedBorder; /** CSS break-before / page-break-before → Word pageBreakBefore. */ pageBreakBefore?: boolean; /** CSS break-after / page-break-after — applied to the next block sibling. */ pageBreakAfter?: boolean; /** CSS writing-mode — vertical modes rotate table cell text (w:textDirection). */ writingMode?: string; /** CSS text-orientation — `upright` has no OOXML equivalent and stays horizontal. */ textOrientation?: string; /** CSS `vertical-align: super | sub` → superscript / subscript on text runs. */ verticalAlign?: string; } export declare function pxToTwips(px: number): number; export declare function pxToHalfPoints(px: number): number; /** Flex gap in twips from px or bare number (treated as px). */ export declare function parseGap(value: string | undefined): number | undefined; export declare function parseColor(value: string | undefined): string | undefined; export declare function parseFontSize(value: string | undefined): number | undefined; /** Parse CSS `line-height` to a unitless multiplier (e.g. 1.5). */ export declare function parseLineHeight(value: string | undefined, fontSizeHalfPoints?: number): number | undefined; export declare function parseInlineStyle(style: string | undefined): ParsedCss; /** True for CSS break values that start a new page in print layout. */ export declare function isPageBreakCssValue(value: string): boolean; export declare function elementRequestsPageBreakAfter(element: Element, resolver?: StyleResolver): boolean; /** * Element is invisible in a browser — skip it entirely. Covers `display:none`, * `visibility:hidden`, `opacity:0`, and the email-preheader idiom * (`max-height:0` + `overflow:hidden`). */ export declare function isHiddenCss(css: ParsedCss): boolean; /** * Transient overlay content — dialogs, tooltips, popovers — shown only on a user action, * so it is not part of the linear document and must not be rendered. Two ways it leaks: * a modal holds a duplicate (a figure's "expand" dialog with a second copy of the image), * or a tooltip's label bleeds into the text (a heading's copy-link tooltip renders as * "Copy link"). Native `` without `open` is already `display:none` on the computed * path, but overlay *web components* (``, ``, ``) hide * inside shadow DOM, so their light-DOM host looks visible — match them by the * custom-element `-dialog`/`-modal`/`-tooltip`/`-popover` suffix, plus ARIA. */ export declare function isOverlayElement(element: Element): boolean; export declare function isHiddenElement(element: Element, resolver?: StyleResolver): boolean; /** * Legacy presentational attributes (`bgcolor`, ``, * `align`, `
`) → their CSS equivalents. Inline `style=""` wins over * attributes, matching browser precedence. */ export declare function presentationalAttributesCss(element: Element): ParsedCss; /** Block if tag is structural block OR display is block / inline-block. */ export declare function isBlockElement(element: Element, resolver?: StyleResolver): boolean; export declare function mapTextAlign(value: string | undefined): BlockLayout["alignment"]; export declare function pxPaddingToBorderSpace(paddingTwips: number | undefined): number; /** Block containers: background-color → paragraph shading only. */ export declare function cssToBlockLayout(css: ParsedCss): BlockLayout; /** Block foreground typography — never carries background-color. */ export declare function cssToBlockTypography(css: ParsedCss): RunTypography; /** Inline elements: background-color → TextRun shading only. */ export declare function cssToInlineRunTypography(css: ParsedCss): RunTypography; /** * Accent-bar color if `element` is a callout/admonition, else null. Docs sites render * notes as web-component alerts (``) or `class="admonition note"` blocks whose * box (fill, accent bar, icon) is drawn in shadow DOM or an external stylesheet — the * light-DOM host reads as transparent, so the note would otherwise flatten to plain text. */ export declare function admonitionAccent(element: Element): string | null; /** True for the title element inside an admonition (bolded like the rendered label). */ export declare function isAdmonitionHeader(element: Element): boolean; export declare function layoutFromElement(element: Element, resolver?: StyleResolver): BlockLayout; /** Nearest `font-family` up the ancestor chain (CSS inheritance), if any. */ export declare function inheritedFontFamily(element: Element, resolver?: StyleResolver): string | undefined; export declare function typographyFromBlockElement(element: Element, resolver?: StyleResolver): RunTypography; /** Native shaded block: keep padding fields for makeParagraph; no indent/spacing bleed. */ export declare function layoutForNativeShadedBlock(layout: BlockLayout): BlockLayout; /** Normalize fill hex for consistent LO PDF rendering. */ export declare function runShadingForFill(fill: string): { type: typeof ShadingType.CLEAR; fill: string; color: string; }; /** * Vertical padding inside a shaded paragraph band. * Embed all padding in one EXACT line — LO paints spacing.before outside w:shd. */ export declare function shadedBlockParagraphSpacing(layout: BlockLayout): IParagraphStylePropertiesOptions["spacing"]; export declare function blockLayoutToParagraphProps(layout: BlockLayout): IParagraphStylePropertiesOptions; /** @deprecated */ export declare function cssToBlockStyle(css: ParsedCss): BlockLayout; /** @deprecated */ export declare function cssToRunTypography(_css: ParsedCss, _tag?: string): RunTypography; /** @deprecated */ export declare function cssToRunStyle(css: ParsedCss, tag?: string): RunTypography; /** @deprecated */ export declare function blockStyleToParagraphProps(layout: BlockLayout): IParagraphStylePropertiesOptions; //# sourceMappingURL=css.d.ts.map