@eigenpal/docx-editor-core/layout-bridge/clickToPositionDom
DOM-based Click-to-Position Mapping
Uses the browser's actual rendered DOM to find ProseMirror positions. This is more accurate than geometry-based calculation because it uses the browser's own text rendering with document.elementsFromPoint().
DOM elements are tagged with data-pm-start and data-pm-end attributes, enabling binary search to find exact character positions.
Functions(4)
clickToPositionDom
Find ProseMirror position from a click using DOM-based detection.
declare function clickToPositionDom(container: HTMLElement, clientX: number, clientY: number, zoom?: number): number | null;clipRectToTableWindow
Vertically clip a client rect to the enclosing page-fragment table's visible box. A table that breaks across a page sits in a `.layout-table` with `overflow:hidden` and `height = visibleHeight`; getClientRects() still reports the geometry of lines that are visually clipped (off the page / in the inter-page gap), so selection highlights must be clipped to the same box.
Uses `.layout-table:not(.layout-nested-table)` because only the page-fragment table carries the window clip — the inner nested table has no overflow:hidden. Clips vertically only (the gap bug is vertical; horizontal clipping could trim change bars on tracked-change tables that set overflow-x: visible).
Returns null when the rect is fully outside the window.
declare function clipRectToTableWindow(spanEl: Element, rect: {
readonly left: number;
readonly top: number;
readonly right: number;
readonly bottom: number;
}): {
left: number;
top: number;
right: number;
bottom: number;
} | null;getCaretPositionFromDom
declare function getCaretPositionFromDom(container: HTMLElement, pmPos: number, overlayRect: DOMRect): DomCaretPosition | null;getSelectionRectsFromDom
declare function getSelectionRectsFromDom(container: HTMLElement, from: number, to: number, overlayRect: DOMRect): DomSelectionRect[];Interfaces(2)
DomCaretPosition
Get caret position from DOM for a PM position.
interface DomCaretPosition| Member | Type | Summary |
|---|---|---|
| height | number | |
| pageIndex | number | |
| x | number | |
| y | number |
DomSelectionRect
Get selection rectangles for a PM range using DOM-based detection.
interface DomSelectionRect| Member | Type | Summary |
|---|---|---|
| height | number | |
| pageIndex | number | |
| width | number | |
| x | number | |
| y | number |