/** * JSON schema for section configuration (extracted from document schema) * * Styled single page with custom positioning * * Flowing content across multiple pages */ export interface Section { /** * Vertical alignment of page content */ align?: SectionAlign; /** * Page content elements * * Flow content elements */ content: Element[]; /** * Y position in cm (overrides align) */ startY?: number; type: SectionType; /** * Start this section on a new page (default: true) */ newPage?: boolean; } /** * Vertical alignment of page content */ export type SectionAlign = "top" | "center" | "bottom"; export interface Element { /** * Text alignment * * Horizontal alignment of the math block * * Image alignment * * QR code alignment * * Chart alignment * * Code block alignment (for rendered images) */ align?: ElementAlign; /** * Text color in hex format */ color?: string; /** * Font family for this specific element */ fontFamily?: string; /** * Font size in points */ fontSize?: number; /** * Font weight */ fontWeight?: FontWeight; spacing?: SpacingOverride; /** * Text with markdown: **bold**, *italic*, [link](url) */ text?: string; /** * Text element type * * Math element type (block-level LaTeX formula) * * Image element type * * Table element type * * List element type * * QR code element type * * Chart element type (rendered via internal Chart API) * * Code block element (optionally rendered via internal render API as image) * * Page break element type */ type: ElementType; /** * LaTeX formula string (e.g. E = mc^2) */ latex?: string; /** * Alternative text for accessibility */ alt?: string; /** * Image height in pixels * * Rendered chart image height in pixels */ height?: number; /** * Image file path (storage URL starting with /image/ or public HTTP/HTTPS URL) */ src?: string; /** * Image width in pixels * * Rendered chart image width in pixels * * Rendered code image width in pixels (when renderAsImage=true) */ width?: number; /** * Table caption */ caption?: string; /** * Table headers */ headers?: string[]; /** * Table data rows */ rows?: Array; style?: StyleClass; /** * List items */ items?: ListItem[]; /** * true = ordered (1,2,3), false = unordered (bullets) */ ordered?: boolean; /** * QR code data (structure depends on qrType) */ data?: { [key: string]: any }; /** * Error correction level: L (~7%), M (~15%), Q (~25%), H (~30%) */ errorCorrection?: ErrorCorrection; /** * Type of QR code: url (link), wifi (WiFi credentials), vcard (contact card) */ qrType?: QrType; /** * QR code size in pixels (width and height, always 1:1 ratio) */ size?: number; config?: ChartConfig; /** * Background color for rendered code image in hex format */ backgroundColor?: string; /** * Code content to render or display */ code?: string; /** * Programming language key for syntax highlighting (highlight.js language id) */ language?: string; /** * If true, the code block will be rendered as an image via the internal render API */ renderAsImage?: boolean; /** * Page orientation after break */ orientation?: Orientation; } /** * Text alignment * * Horizontal alignment of the math block * * Image alignment * * QR code alignment * * Chart alignment * * Code block alignment (for rendered images) */ export type ElementAlign = "left" | "center" | "right" | "justify"; export interface ChartConfig { /** * Canvas background color (CSS color string) */ backgroundColor?: string; data: Data; height?: number; /** * Chart.js options object */ options?: { [key: string]: any }; /** * Chart.js chart type */ type: ConfigType; width?: number; } export interface Data { datasets: Dataset[]; labels?: X[]; } export interface Dataset { data: Datum[]; label?: string; [property: string]: any; } export type Datum = Point | number | string; export interface Point { r?: number; x: X; y: X; } export type X = number | string; /** * Chart.js chart type */ export type ConfigType = "line" | "bar" | "pie" | "doughnut" | "radar" | "polarArea" | "scatter" | "bubble"; /** * Error correction level: L (~7%), M (~15%), Q (~25%), H (~30%) */ export type ErrorCorrection = "L" | "M" | "Q" | "H"; /** * Font weight * * Header font weight * * Row font weight */ export type FontWeight = "normal" | "bold"; export interface ListItemClass { /** * Nested list items */ items?: ListItem[]; /** * Item text (supports markdown) */ text: string; } export type ListItem = ListItemClass | string; /** * Page orientation after break */ export type Orientation = "portrait" | "landscape"; /** * Type of QR code: url (link), wifi (WiFi credentials), vcard (contact card) */ export type QrType = "url" | "wifi" | "vcard"; export interface SpacingOverride { /** * Spacing after element in pt */ after?: number; /** * Spacing before element in pt */ before?: number; } export interface StyleClass { borders?: Borders; cellPadding?: CellPadding; header?: Header; rows?: Rows; } export interface Borders { inner?: Inner; outer?: Outer; } export interface Inner { /** * Border color in hex */ color?: string; /** * Border style */ style?: StyleEnum; /** * Border width in pt */ width?: number; } /** * Border style */ export type StyleEnum = "solid" | "dashed" | "dotted"; export interface Outer { /** * Border color in hex */ color?: string; /** * Border style */ style?: StyleEnum; /** * Border width in pt */ width?: number; } export interface CellPadding { /** * Cell padding bottom in pt */ bottom?: number; /** * Cell padding left in pt */ left?: number; /** * Cell padding right in pt */ right?: number; /** * Cell padding top in pt */ top?: number; } export interface Header { /** * Header text alignment */ align?: HeaderAlign; /** * Header background color in hex */ backgroundColor?: string; /** * Header text color in hex */ color?: string; /** * Header font size in pt */ fontSize?: number; /** * Header font style */ fontStyle?: FontStyle; /** * Header font weight */ fontWeight?: FontWeight; } /** * Header text alignment * * Row text alignment */ export type HeaderAlign = "left" | "center" | "right"; /** * Header font style * * Row font style */ export type FontStyle = "normal" | "italic"; export interface Rows { /** * Row text alignment */ align?: HeaderAlign; /** * Alternate row background color for striped tables */ alternateBackgroundColor?: string; /** * Row background color in hex */ backgroundColor?: string; /** * Row text color in hex */ color?: string; /** * Row font size in pt */ fontSize?: number; /** * Row font style */ fontStyle?: FontStyle; /** * Row font weight */ fontWeight?: FontWeight; } /** * Text element type */ export type ElementType = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "text" | "text2" | "math" | "image" | "table" | "list" | "qrcode" | "chart" | "code" | "pageBreak"; export type SectionType = "page" | "flow";