import type { ArrowEndpoint } from "@excalidraw/element"; import type { ExcalidrawElement, ExcalidrawTextElement, FixedPoint, NonDeleted } from "@excalidraw/element/types"; import type App from "./App"; import type { AppState } from "../types"; /** * The text tool's interaction with arrows: the hover affordance showing where * a click would attach text to an arrow — a free endpoint (binds the arrow to * a new text element positioned against that endpoint) or the arrow's midpoint * (adds a label bound to the arrow) — and the endpoint-bound flavor of * drag-sizing a new text. * * The scene-level logic lives in `@excalidraw/element`'s `arrowEndpointText.ts`. */ export declare class AppArrowText { private app; constructor(app: App); /** * With the text tool active, an arrow under the cursor is a target for * attaching text. Returns where the text would land (if anywhere), and keeps * `appState.hoveredArrowTextAnchor` — which drives the highlight — in sync. */ updateHoveredAnchor: (scenePointer: { x: number; y: number; }) => AppState["hoveredArrowTextAnchor"]; /** * Re-evaluates the hovered anchor at the last known pointer position — for * events that change what a click would do without the pointer moving, * i.e. the ctrl/cmd binding toggle. (Events that invalidate the anchor * wholesale — tool switches, finalize, deselect — clear it directly * instead.) */ refresh: () => void; /** * A free arrow endpoint a new text could be bound to. Binding an endpoint is * an arrow binding, so it follows the binding toggle (ctrl/cmd) like every * other one — holding it makes the text tool drop plain text instead. */ getBindableEndpointAtPosition(x: number, y: number): ArrowEndpoint | null; /** * Mirrors what `handleTextOnPointerDown` would do at this position, so the * highlight can't promise something the click won't deliver. */ private getAnchorAtPosition; /** * How a text should be created to read as a label for this endpoint — the * side midpoint to bind, the alignment that pins it, and the scene position * it must sit at. `targetStrokeWidth` is the caller's to provide so it can * guarantee it matches the stroke width the text is then created with — the * binding gap derives from it (see `getTextBindingForArrowEndpoint`). */ getTextBinding({ arrow, startOrEnd }: ArrowEndpoint, targetStrokeWidth: number): { fixedPoint: FixedPoint; textAlign: import("@excalidraw/element/types").TextAlign; verticalAlign: import("@excalidraw/element/types").VerticalAlign; anchor: import("@excalidraw/math").GlobalPoint; } | null; /** * Binds the arrow endpoint to the created text, at the side midpoint the * placement resolved (`getTextBinding`'s `fixedPoint`). */ bindText({ arrow, startOrEnd }: ArrowEndpoint, text: NonDeleted, fixedPoint: FixedPoint): void; /** * A text bound to an arrow endpoint can't be positioned by the drag — the * binding already placed it — so only its width is dragged out. Returns * whether it owned the drag. */ maybeDragNewText(newElement: ExcalidrawElement, pointerCoords: { x: number; y: number; }): boolean; }