/** * Text wrap (#627): text running beside a picture or a box narrower than * its column. * * The wrapped item is first placed as it would be without wrapping: an * inline figure atomically at the cursor, a float in its band at the head * or foot of its column. When the next block can run beside it (a * paragraph, a quotation, a list item), the band is given back to the flow * and recorded as an exclusion of the column (`VDTColumn.exclusions`): the * flow's cursor may then run beside it, and every text block that takes * lines next to it is broken with those lines set short * (`MeasureBlockOptions.lineInsets`, `wrapInsetSteps`). A block that cannot * run beside it (a heading, a display formula, a figure, a box, a table) * settles the column first: below a picture at the head of the text, the * cursor goes under it; above one at the column's foot, the column ends at * its top. So does leaving the column. A block that never meets a wrap is * set exactly as before. * * This module holds the pure parts: the settings as a resource reads them, * the exclusions still open in each column (per pass: columns are created * afresh by every placement pass) and the line insets they ask of a block. */ import type { ContentBlock } from '../parse/index.js'; import type { Dimension, Resource, ResourceType, ResolvedTextWrapConfig } from '../types.js'; import type { VDTColumn, VDTExclusion } from '../vdt.js'; import type { LineInsetStep } from '../measure/types.js'; /** A `wrap` value as a side of the flow: `'start'` is `'left'`, `'end'` is * `'right'`; `'none'` and anything else are no wrap. */ export declare function wrapSideOf(value: unknown): 'left' | 'right' | undefined; /** A resource's wrap, resolved: its side, the share of the column it * takes and its gap (unset: the document's). */ export interface ResolvedWrap { side: 'left' | 'right'; width: number; gap?: Dimension; /** `wrap: 'contour'` (#883): the text runs round the picture's shape. */ contour?: true; } /** The wrap a resource asks for: its own placement, then its type's * `defaultPlacement`. `undefined` when it does not wrap. */ export declare function resolveResourceWrap(resource: Resource, type: ResourceType | undefined, settings: ResolvedTextWrapConfig): ResolvedWrap | undefined; /** The gap of a wrap in px: its own, else one body line (`floatGapPx`). */ export declare function wrapGapPx(gap: Dimension | undefined, dpi: number, bodyFontSizePx: number, floatGapPx: number): number; /** `layout.wrap.minTextWidth` in px for a column `columnWidth` wide. */ export declare function minTextWidthPx(min: Dimension | number, columnWidth: number, dpi: number, bodyFontSizePx: number): number; /** Whether a block may run beside a wrapped item: running text that splits * line by line (a paragraph, a quotation, a list item). A poem, a * contents or index row, a heading, a formula and every atomic block * clear it. */ export declare function runsBesideWrap(block: ContentBlock): boolean; /** Whether a block takes nothing from the flow on its own and leaves an * open wrap as it is: the markers of a `:::paragraphs` group and a * numbering change. */ export declare function transparentToWrap(block: ContentBlock): boolean; /** An exclusion still open in its column: the text has not gone past it. */ export interface OpenWrap { ex: VDTExclusion; /** `'top'`: it starts at or above the flow's cursor (an inline figure, a * float at the column's head); settling takes the cursor under it. * `'bottom'`: it stands at the column's foot, below the cursor; * settling ends the column at its top. */ kind: 'top' | 'bottom'; } /** Record an exclusion of `col` and open it to the flow. */ export declare function openColumnWrap(col: VDTColumn, ex: VDTExclusion, kind: OpenWrap['kind']): void; /** The exclusions of `col` the flow may still run beside. */ export declare function openColumnWraps(col: VDTColumn): readonly OpenWrap[]; /** The flow's cursor in `col` (page y of the next block's top, before its * spacing). */ export declare function columnCursorY(col: VDTColumn): number; /** * Close the open exclusions of `col`: under one that starts at or above * the cursor the flow goes on below it; above one at the column's foot the * column ends at its top. Returns whether the cursor moved down (the * space the text was owing is then taken by the wrap's own gap). */ export declare function settleColumnWraps(col: VDTColumn): boolean; /** * The lines of a text block set short by the open exclusions of `col` * when its first line's top is at `y0` and its lines are `lineHeight` * apart: a line that meets an exclusion on a grid line (even in part) is * beside it. Line numbers count from `firstLine` (the lines of the block * already placed elsewhere). The insets are the exclusions' widths, from * the column's sides (a contour's width beside each line, #883): they add * to the block's own indents. */ export declare function wrapInsetSteps(col: VDTColumn, y0: number, lineHeight: number, firstLine: number): LineInsetStep[]; /** The steps of `steps` for the lines before `line`, cut there. */ export declare function insetsBefore(steps: readonly LineInsetStep[], line: number): LineInsetStep[]; /** Whether two sets of insets set every line from `line` on alike. */ export declare function sameInsetsFrom(a: readonly LineInsetStep[], b: readonly LineInsetStep[], line: number): boolean; /** The wrap a box asks for with its fence's attributes (#627): * `wrap="left|right|start|end"`, `width` (a share of the column, 0 to 1; * else `layout.wrap.defaultWidth`) and `wrapGap` (a length, `6pt`). * `undefined` when it does not wrap. */ export declare function resolveCalloutWrap(attrs: Readonly>, settings: ResolvedTextWrapConfig): ResolvedWrap | undefined; //# sourceMappingURL=textWrap.d.ts.map