New

docx-editor 1.x has shipped. Vue support, i18n, agents. Read the migration guide →

API Referencev1.0.2

@eigenpal/docx-editor-core/plugin-api/RenderedDomContext

RenderedDomContext Implementation

Provides DOM-based position mapping for the LayoutPainter output. Uses the same data-pm-start/data-pm-end attribute pattern as the selection overlay in PagedEditor.

Functions(1)

Create a RenderedDomContext for a pages container element.

declare function createRenderedDomContext(pagesContainer: HTMLElement, zoom?: number): RenderedDomContext;

Classes(1)

Implementation of RenderedDomContext.

This class provides position mapping between ProseMirror document positions and pixel coordinates in the rendered DOM. It uses the data-pm-start and data-pm-end attributes that LayoutPainter adds to span elements.

declare class RenderedDomContextImpl implements RenderedDomContext
MemberTypeSummary
(constructor)Constructs a new instance of the `RenderedDomContextImpl` class
findElementsForRangeFind DOM elements that overlap with a ProseMirror position range.
getContainerOffsetGet the offset of the pages container from its parent viewport. This is needed for positioning overlays that are rendered in the viewport container rather than directly in the pages container.
getCoordinatesForPositionGet pixel coordinates for a ProseMirror position. Uses the browser's text rendering via Range API for precise positioning.
getRectsForRangeGet bounding rectangles for a range of text. Handles line wraps by returning multiple rects.
pagesContainerHTMLElement
zoomnumber