/** * DOM-based pointer-to-position mapping for the v1 editor. * * Maps viewport click coordinates to ProseMirror document positions by reading * the rendered DOM produced by the painter (`data-pm-start`, `data-pm-end`). * This is more accurate than geometry-based mapping because it uses the * browser's actual rendering and correctly handles PM position gaps that occur * after document edits (e.g. paragraph joins). * * AIDEV-NOTE: compat-fallback - DOM-first browser-coupled pointer logic stays * editor-owned (prep-002). This module reads `data-pm-*` directly because v1 * still consumes PM positions. The editor-neutral neighbour for future v2 * consumers is `LayoutHitV1Compat.resolvePointerLayoutHit`, which reuses the * same DOM-first / geometry-fallback strategy but returns a `LayoutHit`. * * @module dom-observer/DomPointerMapping */ /** * Maps a click coordinate to a ProseMirror document position using DOM data * attributes. * * Resolution strategy: * 1. Find the page element containing the click via `elementsFromPoint`. * 2. Find the fragment (or table-cell line) in the hit chain. * 3. Find the line at the Y coordinate within the fragment. * 4. Find the span at the X coordinate within the line. * 5. Use the browser caret API (or binary-search fallback) to resolve the * exact character boundary. * * Returns `null` when the DOM does not contain enough data to resolve a * position — the caller should fall back to geometry-based mapping. */ export declare function clickToPositionDom(domContainer: HTMLElement, clientX: number, clientY: number): number | null; /** * Resolves a click within a specific rendered fragment. * * Unlike {@link clickToPositionDom}, this helper does not scan the full page * hit chain to choose a fragment. Callers that already know which rendered * fragment owns the click can use this to avoid cross-surface ambiguity when * multiple stories share overlapping PM position ranges. */ export declare function resolvePositionWithinFragmentDom(fragmentEl: HTMLElement, clientX: number, clientY: number): number | null; /** * Finds the page element containing the given viewport coordinates. * * Tries `elementsFromPoint` first, then falls back to bounding-rect checks * on all page elements, and finally returns the first page as a last resort. */ export declare function findPageElement(domContainer: HTMLElement, clientX: number, clientY: number): HTMLElement | null; /** * Reads the layout epoch from DOM `data-layout-epoch` attributes at the given * viewport point. Returns the newest (highest) epoch in the hit chain so that * stale descendants don't block mapping. */ export declare function readLayoutEpochFromDom(domContainer: HTMLElement, clientX: number, clientY: number): number | null; export type TextBoundaryHit = { node: Text; offset: number; }; export declare function resolveTextBoundaryWithinFragmentDom(fragmentEl: HTMLElement, clientX: number, clientY: number): TextBoundaryHit | null; //# sourceMappingURL=DomPointerMapping.d.ts.map