export type LineRect = { left: number; right: number; top: number; bottom: number; }; /** * Pull a line's right edge back off the letter-space CSS hangs past the last * glyph, so a background drawn on the rect hugs the ink. Both line-rect sources * report the CSS line box, which includes it: `getClientRects` in the DOM and * render-tag's `LayoutLine.bounds`. * * Always the right edge, both directions — Blink and WebKit hang the space off * each character's PHYSICAL right, so an RTL line overhangs right exactly like * an LTR one. The test pins that, and carries the measurement. * * Lives here, not beside `letterSpacingOverhang` in text-html.ts, because * measure-html must stay free of that module's Konva import. */ export declare function trimTrailingLetterSpace(rect: LineRect, overhang: number): LineRect; /** The box the rects cover, grown by `padding` on every side — the extent of * the background shape built from them. */ export declare function backgroundShapeBounds(rects: LineRect[], padding: number): { x: number; y: number; width: number; height: number; }; /** * Build a continuous "Instagram-style" background polygon wrapping a list of * per-line rects, with convex/concave bends at width changes between lines, * then apply rounded corners via svg-round-corners. * * Shared by text-element (which derives rects from Konva.Text's textArr + * alignment) and html-element (which derives rects from DOM measurement via * detectLineRects). The data model is intentionally the same: one rect per * visual line, each with {left, right, top, bottom}. * * Uses a *width* comparison (`prev.right - prev.left > curr.right - curr.left`) * to decide convex vs concave corners at each boundary — matching the original * text-element behavior. This is the right heuristic for both element types in * practice: all lines within a single element share an alignment, so "wider on * the right" is equivalent to "wider overall", and we avoid inconsistencies * that arise when comparing left and right edges independently. */ export declare function generateBackgroundShapeFromRects({ rects: inputRects, padding, cornerRadius, }: { rects: LineRect[]; padding?: number; cornerRadius?: number; }): string; /** * Convert an array of text-element-style text lines (each with a `width` and an * optional `lastInParagraph` flag and `contentBox`) plus a uniform `lineHeight` * and alignment into the rect representation that * generateBackgroundShapeFromRects consumes. * * Mirrors the alignment/justify semantics that the original * generateBackgroundShape in text-element.tsx implemented inline. */ export type TextBackgroundLine = { width: number; lastInParagraph?: boolean; /** * The horizontal box this line aligns and justifies inside, when it is not * the element's full box — an indented list item has its own, narrower one. * Where that box sits is the caller's business (it depends on nesting depth * and base direction); this only aligns within it. Defaults to `[0, width]`. */ contentBox?: { left: number; right: number; }; /** * Where this line sits when `align` is `justify` and it does NOT stretch — * i.e. CSS `text-align-last`, which defaults to the start edge and so * follows base direction: `left` in LTR, `right` in RTL. Only a * last-in-paragraph line under justify reads it; every other line is * positioned by `align`. Defaults to `left`. */ alignLast?: 'left' | 'right'; /** * This line's own vertical box, when the lines are NOT a uniform stack: a * line carrying a bigger inline run gets a taller box and pushes the lines * under it down. render-tag reports exactly that as `LayoutLine.bounds`, so * a caller laying lines out itself passes the equivalent. Defaults to the * `lineHeight` stack, which is what the legacy Konva renderer * (polotno/canvas/text-element.tsx) measures. */ box?: { top: number; height: number; }; }; export declare function textLinesToRects({ lines, lineHeight, width, align, }: { lines: TextBackgroundLine[]; lineHeight: number; width: number; align: 'left' | 'center' | 'right' | 'justify'; }): LineRect[];