/** * Pure layout for note bodies: tokenization, kinsoku-aware wrapping, * truncation, and final rect/font metrics. The Note component consumes * a NoteLayout and only renders SVG. */ import type { NoteDef } from '../types.js'; import type { GridLayout } from '../geometry/grid.js'; import type { LabelRect } from '../geometry/collision.js'; export interface LineSegment { text: string; bold: boolean; } export type NoteLine = LineSegment[]; export interface NoteLayout { /** Pixel rect of the note body */ rect: LabelRect; /** Wrapped (and possibly truncated) lines; each line is a list of styled segments */ lines: NoteLine[]; fontSize: number; lineHeight: number; innerPad: number; cornerRadius: number; } /** * Character-wise wrap with 禁則処理 (kinsoku) and **bold** support: * - NO_LINE_START chars never begin a line; we extend the current line (ぶら下げ). * - NO_LINE_END chars never end a line; the break is deferred. */ export declare function wrapText(text: string, fontSize: number, maxWidth: number): NoteLine[]; /** Keep at most `maxLines`, appending a `…` to the last retained line. */ export declare function truncateLines(lines: NoteLine[], maxLines: number, fontSize: number, maxWidth: number): NoteLine[]; /** * Compute the note body layout (rect, wrapped lines, font metrics). * Width stretches with text up to the cell interior width; height stretches * with line count up to the cell interior height (excess is ellipsized). */ export declare function computeNoteLayout(note: NoteDef, layout: GridLayout): NoteLayout; /** * A single endpoint a note's leader line wants to reach. * * Shared by the Note renderer (draws the leader) and the pipeline's * label-collision pass (so labels on nodes/connectors avoid sitting * on top of leaders). Kept next to `computeNoteLeaders` since that's * the function that consumes and produces these. */ export interface LeaderTarget { /** The pixel point the leader aims at (usually a node centre or a connector midpoint). */ aim: { x: number; y: number; }; /** Distance before reaching `aim` where the leader terminates (e.g. node radius). */ stopRadius: number; } export interface NoteLeader { start: { x: number; y: number; }; end: { x: number; y: number; }; } /** Closest point on the rectangle's edge to a target point (in pixel space). */ export declare function rectEdgeTowards(rect: LabelRect, target: { x: number; y: number; }): { x: number; y: number; }; /** * Compute the leader-line segments from a note body to each of its * targets, stopping `target.stopRadius` short of the aim point so * lines visually "arrive at" the target instead of driving into it. */ export declare function computeNoteLeaders(noteRect: LabelRect, targets: LeaderTarget[]): NoteLeader[]; //# sourceMappingURL=note-layout.d.ts.map