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/types

Framework-Agnostic Plugin Interface for the DOCX Editor

Core plugin types that can be used by any framework (React, Vue, etc.). Framework-specific adapters extend EditorPluginCore with their own UI rendering capabilities (e.g., ReactEditorPlugin, VueEditorPlugin).

Interfaces(7)

Framework-agnostic core plugin interface.

Contains all non-UI plugin capabilities: - ProseMirror plugins (decorations, keymaps, etc.) - State management (initialize, onStateChange, destroy) - CSS injection - Panel configuration

Framework adapters (ReactEditorPlugin, VueEditorPlugin) extend this with their own Panel component type and renderOverlay function.

interface EditorPluginCore<TState = any>
MemberTypeSummary
destroy?() => voidCalled when the plugin is being destroyed. Use this for cleanup (subscriptions, timers, etc.)
idstringUnique plugin identifier
initialize?(view: EditorView | null) => TStateInitialize plugin state when the plugin is first loaded.
namestringDisplay name for the plugin
onStateChange?(view: EditorView) => TState | undefinedCalled when the editor state changes. Use this to update plugin-specific state based on document changes.
panelConfig?PanelConfigConfiguration for the panel (position, size, etc.)
proseMirrorPlugins?Plugin[]ProseMirror plugins to register with the editor. These are merged with the editor's internal plugins.
styles?stringCSS styles to inject for this plugin. Can be a string of CSS or a URL to a stylesheet.

Configuration for plugin panel rendering.

interface PanelConfig
MemberTypeSummary
collapsible?booleanWhether the panel can be collapsed
defaultCollapsed?booleanInitial collapsed state
defaultSizenumberDefault width/height of the panel
maxSize?numberMaximum size
minSize?numberMinimum size
position'left' | 'right' | 'bottom'Where to render the panel
resizable?booleanWhether the panel is resizable

Props passed to plugin panel components (framework-agnostic base).

interface PluginPanelProps<TState = unknown>
MemberTypeSummary
docNode | nullCurrent ProseMirror document
editorViewEditorView | nullCurrent ProseMirror editor view
panelWidthnumberWidth of the panel in pixels
pluginStateTStatePlugin-specific state (managed by the plugin)
renderedDomContextRenderedDomContext | nullContext for the rendered DOM (LayoutPainter output). May be null if layout hasn't completed yet.
scrollToPosition(pos: number) => voidScroll editor to a specific position
selectRange(from: number, to: number) => voidSelect a range in the editor

Coordinates returned by position lookup in the rendered DOM.

interface PositionCoordinates
MemberTypeSummary
heightnumber
xnumber
ynumber

Context for accessing the rendered DOM in the paged editor.

Provides DOM-based position mapping that works with the LayoutPainter output (visible pages). Use this for rendering overlays, annotations, and other visual elements positioned relative to rendered content.

The rendered DOM uses data-pm-start/data-pm-end attributes on spans to map between ProseMirror positions and DOM elements.

interface RenderedDomContext
MemberTypeSummary
findElementsForRangeFind DOM elements that overlap with a ProseMirror position range.
getContainerOffsetOffset of the pages container from its parent viewport.
getCoordinatesForPositionGet pixel coordinates for a ProseMirror position in the rendered DOM. Returns null if the position cannot be found.
getRectsForRangeGet bounding rectangles for a range of text, accounting for line wraps. Returns rects relative to the pages container.
pagesContainerHTMLElementThe container element holding all rendered pages.
zoomnumberCurrent zoom level (1 = 100%).

A sidebar item anchored to a document position. Framework adapters extend this with rendering capabilities.

interface SidebarItem
MemberTypeSummary
anchorKey?stringOptional key into the anchorPositions Map (e.g. "comment-42", "revision-7").
anchorPosnumberProseMirror document position this item anchors to.
fixedY?numberPre-computed Y position (scroll-container coords, pre-zoom). Overrides anchor resolution.
idstringUnique ID for this item (used as React key and for overlap resolution).
isTemporary?booleanTemporary items (e.g. "add comment" input) skip entrance animation.
priority?numberSort priority within items at the same anchor Y. Lower = first. Default: 0.

Context provided to plugins when computing sidebar items.

interface SidebarItemContext
MemberTypeSummary
anchorPositionsMap<string, number>Pre-computed Y positions from layout engine (keys like "comment-id").
editorViewEditorView | null
renderedDomContextRenderedDomContext | null
zoomnumber