import type { OrderedListNumberFormat, DigitSystem } from '../types.js'; import type { ContentBlock } from '../parse/index.js'; import type { ResolvedConfig, VDTBlock } from '../vdt.js'; import type { BlockStyle } from './styles.js'; export interface ListBulletStyle { indentPx: number; bulletText: string; bulletFontString: string; bulletColor: string; bulletWidthPx: number; gapPx: number; hangingIndent: boolean; itemSpacingPx: number; textFontSizePx: number; verticalOffsetPx: number; /** Set the marker on the first line's baseline instead of centring it on * the x-height (a contents entry's number). */ onBaseline?: boolean; /** Ordered-list separator drawn as its own run (only when its style * differs from the number's). `separatorOffsetPx` is measured from the * bullet's left edge. */ separatorText?: string; separatorFontString?: string; separatorColor?: string; separatorOffsetPx?: number; /** Ordered-list prefix (`(` of (一)) drawn as its own run before the * number, in the separator's style, when the separator is one; else * `bulletText` carries it. `prefixOffsetPx` is measured from the * bullet's left edge (negative: the prefix sits before the number). */ prefixText?: string; prefixOffsetPx?: number; /** The box of a task item the renderers draw (`VDTBlock.bulletBox`, * #765): the block then takes it and neither `bulletText` nor * `bulletFontString`, and `bulletWidthPx` is its side. */ box?: { side: number; stroke: number; checked: boolean; }; } /** * The advance of a marker (a bullet, a number, its prefix or separator, a * contents number) in `font`, as it is painted (#770). * * A marker that reads right to left is one text set right to left on the * canvas and in the HTML (`markerSetText`), and a document shaped in its * own language measures that text so: the browser gives a mark with no * letter the forms of the text it stands in, and orders and mirrors it * there. Measured left to right, `«الفصل الأول»` in Markazi Text bold at * 28.13 px is 126.17 px for 120.32 px painted, its guillemets runs apart; * `أ.` 10.92 px for 10.72 px. A marker set left to right or down a * column, and every marker of a document that keeps its host's language, * is measured as it was. */ export declare function markerTextWidth(text: string, font: string, direction?: 'rtl' | 'rtl-arabic' | undefined): number; export declare function listItemGapPx(prev: { spacingPx: number; depth: number; }, next: { spacingPx: number; depth: number; }): number; /** The item spacing (px) of the list a list item belongs to, as * {@link resolveOrderedListItemStyle} and * {@link resolveUnorderedListItemStyle} work it out: its kind's * `itemSpacing`, `em` being the body size. */ export declare function listItemSpacingPx(item: ContentBlock, resolved: ResolvedConfig): number; /** Where a list marker is painted, from the item's first line: centred on * the text's x-height (`bulletY` is the em-box midpoint, painted with * `textBaseline = 'middle'`), and, for a marker set as text * (`onBaseline`), also on the line's baseline (`bulletBaselineY`), which * renderers prefer. `bulletY` keeps its meaning for every marker, so a * renderer that predates `bulletBaselineY` paints as it did. */ export declare function listBulletPosition(bullet: Pick, firstLineBaseline: number): { bulletY: number; bulletBaselineY?: number; }; export interface ListItemResolved { text: BlockStyle; bullet: ListBulletStyle; /** The bullet's left-edge X offset WITHIN the column (for right-aligned ordered numbers). Added to block.bbox.x at finalize time. */ bulletXOffsetInColumn: number; strikethroughText: boolean; } export interface OrderedRunMetric { /** Formatted number; includes the separator unless a distinct separator * run exists (`separatorText` set). */ numberText: string; numberWidthPx: number; maxNumberWidthPx: number; /** Distinct separator run (style differs from the number's). */ separatorText?: string; separatorFontString?: string; separatorColor?: string; separatorGapPx?: number; separatorWidthPx?: number; /** Prefix drawn as a run of its own (with the separator run). */ prefixText?: string; prefixWidthPx?: number; } export interface OrderedListMetrics { perBlock: Map; maxWidthByDepth: Map; } /** Indent cascade for unordered list levels (marker = bullet glyph). */ export declare function computeLevelIndentsPx(resolved: ResolvedConfig, bodyFontSizePx: number): number[]; /** * Indent cascade for ordered list levels. The marker width is the per-depth * max number width observed in the document (falling back to a width * approximation based on "99." when no runs exist at that depth). */ export declare function computeOrderedLevelIndentsPx(resolved: ResolvedConfig, bodyFontSizePx: number, maxNumberWidthByDepth: Map): number[]; /** An ordered-list item's number in its level's format, by the shared * numeral formatter. Lists keep two edges of their own: a number below 1 * (a Markdown list may start at `0.`) prints in digits, and so does a roman * numeral from 4000 up. The resolver hands over the list spelling; a part's * partial override is applied after it, so any spelling is read here too * (unknown → arabic). Decimal numbers, and those digits, are written in * the document's `digits`. */ export declare function formatListNumber(n: number, format: OrderedListNumberFormat, digits?: DigitSystem): string; /** * Walks content blocks identifying contiguous ordered-list runs per depth, * computes each item's formatted number + width, and the max width per run * (for right-align; per depth instead with `orderedLists.numberWidth: * 'level'`, the item's own with `'item'`). Also tracks the global max per depth (for level-indent * cascade in ordered lists). */ export declare function computeOrderedListRunMetrics(contentBlocks: ContentBlock[], resolved: ResolvedConfig, bodyFontSizePx: number): OrderedListMetrics; export declare function resolveUnorderedListItemStyle(depth: number, resolved: ResolvedConfig, levelIndentsPx: number[], checked: boolean, isTask: boolean): ListItemResolved; export declare function resolveOrderedListItemStyle(depth: number, resolved: ResolvedConfig, levelIndentsPx: number[], metric: OrderedRunMetric): ListItemResolved; /** * The marker of a list item set against its frame's direction (#371): an * English list in an Arabic book, an Arabic one in an English book. Its text * runs from the block's left edge (`measureContentBlock` mirrors the lines), * and each run of its marker — the prefix, the number or bullet, the * separator — moves to the mirror place in the block's width, so the marker * stands on the text's start side, its pieces in that side's reading order: * `(1)` keeps its brackets, and right-aligned numbers end up aligned on the * edge that faces the text. Call it once the marker positions are set. */ /** * Says how the marker of `blk` reads (`VDTBlock.bulletDirection`, #664) * once it is set: at a right-to-left level when the block's text runs * right to left (`direction`: the block's own, else its frame's), as an * Arabic-script document reads its numbers when `arabicNumbers` (#665). * A left-to-right block, and a marker of vertical text, say nothing. */ export declare function directListMarker(blk: VDTBlock, direction: 'ltr' | 'rtl', arabicNumbers: boolean, vertical?: boolean): void; export declare function mirrorListMarker(blk: VDTBlock): void; //# sourceMappingURL=lists.d.ts.map