import { Position } from "../interfaces.js"; export interface Bounds { x: number; y: number; width: number; height: number; } export declare const parseSvg: (svg: string) => Element; /** Maps `data-id` to the element for every element matching `selector`. */ export declare const getElementsByDataId: (root: Element, selector: string) => Map; /** * Sums the `translate()` transforms of `element` and its ancestors up to * `root`, i.e. the offset of `element`'s local coordinates in `root`. */ export declare const getOffset: (element: Element, root: Element) => Position; /** * The nearest ancestor of `element` (or itself), below `root`, turned by a * `rotate()` transform (about its local origin), and the angle (in degrees). */ export declare const getRotatedAncestor: (element: Element, root: Element) => { node: Element; degrees: number; } | undefined; interface PathSegment { /** Absolute command, uppercase. */ command: string; /** Absolute points: control points first, the segment's end point last. */ points: Position[]; /** An arc's (`A`) parameters. */ arc?: { rx: number; ry: number; rotation: number; largeArc: boolean; sweep: boolean; }; } export declare const parsePath: (d: string) => PathSegment[]; /** * Bounds of a shape, or of the shapes drawn inside a group (labels excluded), * in `root` coordinates. */ export declare const getShapeBounds: (group: Element, root: Element) => Bounds | null; /** * The points an edge path passes through, in `root` coordinates. Cubic curves * keep their midpoint too (e.g. a self-loop drawn as a single curve). * Quadratic curves, which Pele only uses to round the corners of stepped * routes, keep their control point, i.e. the corner. */ export declare const getPathRoute: (path: Element, root: Element) => Position[]; /** Removes consecutive duplicates and the middle of collinear runs. */ export declare const simplifyRoute: (points: Position[], epsilon?: number) => Position[]; /** Whether every segment of a route is horizontal or vertical. */ export declare const isOrthogonalRoute: (route: Position[]) => boolean; /** Pele's stepped curves (it draws `stepBefore` and `stepAfter` as `step`). */ export declare const isSteppedCurve: (curve: string | undefined) => boolean; /** * Whether Pele drew an edge path stepped (e.g. with `curve: "step"`, set in a * definition too): stepped routes are the only ones it rounds the corners of, * with quadratic curves. */ export declare const isSteppedPath: (path: Element | undefined) => boolean; /** * Whether Pele drew the edges that follow a diagram's curve stepped: by their * drawing where it tells (stepped corners, or a slanted or curved edge that * isn't a loop), or else whether it steps them by its config (`stepped`, as * straight edges look the same with any curve; not asked without edges). */ export declare const isDrawnStepped: (edges: { line: Element | undefined; route: Position[]; isLoop: boolean; }[], stepped: () => boolean) => boolean; /** * Pele ends routes in short straight stubs, room for its small arrowheads: * Excalidraw's bigger ones would reach into the bends after them. The bends * next to each end are moved back (towards the run the route comes from), so * that the route ends straight for at least `minLength`, where it can. */ export declare const lengthenRouteEnds: (route: Position[], minLength?: number) => Position[]; /** * Excalidraw draws a round arrow as a (uniform) Catmull-Rom spline through its * points, which overshoots the corners between long and short segments. Long * segments are split near such corners (the route stays the same), so that * segments next to each other are at most `maxRatio` times as long as each * other. */ export declare const evenOutRoute: (route: Position[], maxRatio?: number) => Position[]; /** * How far along a route (0 at its start, 1 at its end, by length) the point * of it closest to `point` is. */ export declare const getRoutePosition: (route: Position[], point: Position) => number; interface MarkerShape { points: Position[]; radius: number; } /** The markers (arrowheads) Pele drew at the start and at the end of a route. */ export declare const getRouteMarkers: (route: Position[], markerElements: Element[], root: Element) => { startMarkers: MarkerShape[]; endMarkers: MarkerShape[]; }; /** * Pele shortens edge paths by the length of their arrowheads, which it draws * as separate shapes (`.pele-marker`). Excalidraw draws arrowheads at the * arrow's end points, so the route is extended to the far end of the markers, * i.e. back to the node outline. */ export declare const extendRouteToMarkers: (path: Position[], markerElements: Element[], root: Element) => Position[]; /** SVG string to a data URL usable as an image source. */ export declare const svgToDataURL: (svg: string) => string; /** Font size of an element, as set on it or inherited from its ancestors. */ export declare const getFontSize: (element: Element, root: Element, fallback: number) => number; /** * The lines Pele broke a text into (at line breaks, and wrapping long ones). * Each line starts with a positioned ``; unpositioned ones (e.g. bold * text) continue it. */ export declare const getTextLines: (text: Element | null) => string[]; export interface TextBlock { text: string; /** x of the anchor `textAlign` refers to, in `root` coordinates. */ x: number; /** Top of the text, laid out with Excalidraw's line height. */ y: number; height: number; fontSize: number; textAlign: "left" | "center" | "right"; } /** Where Pele drew a text, as an Excalidraw text box. */ export declare const getTextBlock: (text: Element, root: Element, defaultFontSize: number) => TextBlock; /** A color set in an element's inline style (by `style` or `classDef`). */ export declare const getStyleColor: (element: Element | null | undefined, property: "fill" | "stroke") => string | undefined; /** A property set in an element's inline style. */ export declare const getStyleValue: (element: Element | null | undefined, property: string) => string | undefined; export {};