@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)
EditorPluginCore
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>| Member | Type | Summary |
|---|---|---|
| destroy? | () => void | Called when the plugin is being destroyed. Use this for cleanup (subscriptions, timers, etc.) |
| id | string | Unique plugin identifier |
| initialize? | (view: EditorView | null) => TState | Initialize plugin state when the plugin is first loaded. |
| name | string | Display name for the plugin |
| onStateChange? | (view: EditorView) => TState | undefined | Called when the editor state changes. Use this to update plugin-specific state based on document changes. |
| panelConfig? | PanelConfig | Configuration 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? | string | CSS styles to inject for this plugin. Can be a string of CSS or a URL to a stylesheet. |
PanelConfig
Configuration for plugin panel rendering.
interface PanelConfig| Member | Type | Summary |
|---|---|---|
| collapsible? | boolean | Whether the panel can be collapsed |
| defaultCollapsed? | boolean | Initial collapsed state |
| defaultSize | number | Default width/height of the panel |
| maxSize? | number | Maximum size |
| minSize? | number | Minimum size |
| position | 'left' | 'right' | 'bottom' | Where to render the panel |
| resizable? | boolean | Whether the panel is resizable |
PluginPanelProps
Props passed to plugin panel components (framework-agnostic base).
interface PluginPanelProps<TState = unknown>| Member | Type | Summary |
|---|---|---|
| doc | Node | null | Current ProseMirror document |
| editorView | EditorView | null | Current ProseMirror editor view |
| panelWidth | number | Width of the panel in pixels |
| pluginState | TState | Plugin-specific state (managed by the plugin) |
| renderedDomContext | RenderedDomContext | null | Context for the rendered DOM (LayoutPainter output). May be null if layout hasn't completed yet. |
| scrollToPosition | (pos: number) => void | Scroll editor to a specific position |
| selectRange | (from: number, to: number) => void | Select a range in the editor |
PositionCoordinates
Coordinates returned by position lookup in the rendered DOM.
interface PositionCoordinates| Member | Type | Summary |
|---|---|---|
| height | number | |
| x | number | |
| y | number |
RenderedDomContext
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| Member | Type | Summary |
|---|---|---|
| findElementsForRange | — | Find DOM elements that overlap with a ProseMirror position range. |
| getContainerOffset | — | Offset of the pages container from its parent viewport. |
| getCoordinatesForPosition | — | Get pixel coordinates for a ProseMirror position in the rendered DOM. Returns null if the position cannot be found. |
| getRectsForRange | — | Get bounding rectangles for a range of text, accounting for line wraps. Returns rects relative to the pages container. |
| pagesContainer | HTMLElement | The container element holding all rendered pages. |
| zoom | number | Current zoom level (1 = 100%). |