@eigenpal/docx-editor-core/prosemirror/extensions
Extension System — Barrel Export
Functions(13)
clearTrackedChanges
Create a transaction that clears the change tracker
declare function clearTrackedChanges(state: EditorState): Transaction;createExtension
Create a generic extension (plugins, commands, keymaps — no schema contribution)
declare function createExtension<TOptions extends Record<string, unknown> = Record<string, unknown>>(def: ExtensionDefinition<TOptions>): (options?: Partial<TOptions>) => Extension;createMarkExtension
Create a mark extension (contributes a MarkSpec to the schema)
declare function createMarkExtension<TOptions extends Record<string, unknown> = Record<string, unknown>>(def: MarkExtensionDefinition<TOptions>): (options?: Partial<TOptions>) => MarkExtension;createNodeExtension
Create a node extension (contributes a NodeSpec to the schema)
declare function createNodeExtension<TOptions extends Record<string, unknown> = Record<string, unknown>>(def: NodeExtensionDefinition<TOptions>): (options?: Partial<TOptions>) => NodeExtension;createStarterKit
Create the full set of extensions for the DOCX editor
declare function createStarterKit(options?: StarterKitOptions): AnyExtension[];getChangedParagraphIds
Get the set of changed paragraph IDs from an EditorState
declare function getChangedParagraphIds(state: EditorState): Set<string>;hasStructuralChanges
Check if structural changes (paragraph add/delete) occurred
declare function hasStructuralChanges(state: EditorState): boolean;hasUntrackedChanges
Check if any changes affected paragraphs without paraId
declare function hasUntrackedChanges(state: EditorState): boolean;ParagraphChangeTrackerExtension
ParagraphChangeTrackerExtension: (options?: Partial<{}> | undefined) => ExtensionTableCellExtension
TableCellExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtensionTableHeaderExtension
TableHeaderExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtensionTableNodeExtension
TableNodeExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtensionTableRowExtension
TableRowExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtensionClasses(1)
ExtensionManager
Extension Manager
Two-phase initialization: 1. buildSchema() — collects NodeSpecs/MarkSpecs from extensions → new Schema 2. initializeRuntime() — calls onSchemaReady() on each extension, collects plugins/commands/keymaps
declare class ExtensionManager| Member | Type | Summary |
|---|---|---|
| (constructor) | — | Constructs a new instance of the `ExtensionManager` class |
| buildSchema | — | Phase 1: Build schema from node/mark extensions |
| destroy | — | Lifecycle: destroy |
| getCommand | — | Get a specific command by name |
| getCommands | — | Get the flat command registry |
| getPlugins | — | Get all plugins (raw + keymap merged) |
| getSchema | — | Get the built schema |
| initializeRuntime | — | Phase 2: Initialize runtime (plugins, commands, keymaps) Must be called after buildSchema() |
Interfaces(13)
Extension
interface Extension| Member | Type | Summary |
|---|---|---|
| config | ExtensionConfig | |
| onSchemaReady | — | |
| type | 'extension' |
ExtensionConfig
interface ExtensionConfig| Member | Type | Summary |
|---|---|---|
| name | string | |
| options | Record<string, unknown> | |
| priority | ExtensionPriority |
ExtensionContext
interface ExtensionContext| Member | Type | Summary |
|---|---|---|
| manager | ExtensionManager | The manager that owns this extension. Use this in runtime callbacks (e.g. `handleKeyDown`) that need to dispatch commands, instead of reaching back to the `singletonManager` export — the latter forms a circular import that breaks when the package is consumed as a built bundle. |
| schema | Schema |
ExtensionDefinition
interface ExtensionDefinition<TOptions = Record<string, unknown>>| Member | Type | Summary |
|---|---|---|
| defaultOptions? | TOptions | |
| name | string | |
| onSchemaReady | — | |
| priority? | ExtensionPriority |
ExtensionRuntime
interface ExtensionRuntime| Member | Type | Summary |
|---|---|---|
| commands? | CommandMap | |
| keyboardShortcuts? | KeyboardShortcutMap | |
| plugins? | Plugin[] |
MarkExtension
interface MarkExtension| Member | Type | Summary |
|---|---|---|
| config | MarkExtensionConfig | |
| onSchemaReady | — | |
| type | 'mark' |
MarkExtensionConfig
interface MarkExtensionConfig extends ExtensionConfig| Member | Type | Summary |
|---|---|---|
| markSpec | MarkSpec | |
| schemaMarkName | string |
MarkExtensionDefinition
interface MarkExtensionDefinition<TOptions = Record<string, unknown>>| Member | Type | Summary |
|---|---|---|
| defaultOptions? | TOptions | |
| markSpec | MarkSpec | ((options: TOptions) => MarkSpec) | |
| name | string | |
| onSchemaReady | — | |
| priority? | ExtensionPriority | |
| schemaMarkName | string |
NodeExtension
interface NodeExtension| Member | Type | Summary |
|---|---|---|
| config | NodeExtensionConfig | |
| onSchemaReady | — | |
| type | 'node' |
NodeExtensionConfig
interface NodeExtensionConfig extends ExtensionConfig| Member | Type | Summary |
|---|---|---|
| nodeSpec | NodeSpec | |
| schemaNodeName | string |
NodeExtensionDefinition
interface NodeExtensionDefinition<TOptions = Record<string, unknown>>| Member | Type | Summary |
|---|---|---|
| defaultOptions? | TOptions | |
| name | string | |
| nodeSpec | NodeSpec | ((options: TOptions) => NodeSpec) | |
| onSchemaReady | — | |
| priority? | ExtensionPriority | |
| schemaNodeName | string |
StarterKitOptions
StarterKit — bundles all extensions into a ready-to-use set
Usage: const extensions = createStarterKit(); const manager = new ExtensionManager(extensions); manager.buildSchema(); manager.initializeRuntime();
interface StarterKitOptions| Member | Type | Summary |
|---|---|---|
| disable? | string[] | Extensions to disable by name |
| historyDepth? | number | History depth (default: 100) |
| historyNewGroupDelay? | number | History new group delay (default: 500) |
| onSelectionChange? | SelectionChangeCallback | Selection change callback |
TableContextInfo
Table selection context + navigation helpers.
`getTableContext` walks the selection up from `$from` and reports which table / row / cell the cursor is in, plus the table's row/column counts, whether a multi-cell selection is active, and the current cell's border + fill colors (so the toolbar's color pickers can show the live values).
`goToNextCell` / `goToPrevCell` are tab-stop-style cell navigation commands registered by the plugin extension.
interface TableContextInfo| Member | Type | Summary |
|---|---|---|
| canSplitCell? | boolean | |
| cellBackgroundColor? | string | Current cell's background/fill color (RGB hex without #), if any |
| cellBorderColor? | ColorValue | Current cell's dominant border color, if any |
| columnCount? | number | |
| columnIndex? | number | |
| hasMultiCellSelection? | boolean | |
| isInTable | boolean | |
| rowCount? | number | |
| rowIndex? | number | |
| table? | Node | |
| tablePos? | number |
Type aliases(4)
AnyExtension
type AnyExtension = Extension | NodeExtension | MarkExtension;CommandMap
type CommandMap = Record<string, (...args: any[]) => Command>;ExtensionPriority
Extension System Type Definitions
Tiptap-style extension architecture for ProseMirror. Three extension types: - Extension: plugins, commands, keymaps (no schema) - NodeExtension: adds a node spec to the schema - MarkExtension: adds a mark spec to the schema
type ExtensionPriority = number;KeyboardShortcutMap
type KeyboardShortcutMap = Record<string, Command>;Variables(1)
Priority
Priority: {
readonly Highest: 0;
readonly High: 50;
readonly Default: 100;
readonly Low: 150;
readonly Lowest: 200;
}