@eigenpal/docx-editor-core/prosemirror/extensions
Extension System — Barrel Export
Functions (13)
clearTrackedChangesfunctionSource ↗
Create a transaction that clears the change tracker
declare function clearTrackedChanges(state: EditorState): Transaction;createExtensionfunctionSource ↗
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;createMarkExtensionfunctionSource ↗
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;createNodeExtensionfunctionSource ↗
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;createStarterKitfunctionSource ↗
Create the full set of extensions for the DOCX editor
declare function createStarterKit(options?: StarterKitOptions): AnyExtension[];getChangedParagraphIdsfunctionSource ↗
Get the set of changed paragraph IDs from an EditorState
declare function getChangedParagraphIds(state: EditorState): Set<string>;hasStructuralChangesfunctionSource ↗
Check if structural changes (paragraph add/delete) occurred
declare function hasStructuralChanges(state: EditorState): boolean;hasUntrackedChangesfunctionSource ↗
Check if any changes affected paragraphs without paraId
declare function hasUntrackedChanges(state: EditorState): boolean;ParagraphChangeTrackerExtensionfunctionSource ↗
ParagraphChangeTrackerExtension: (options?: Partial<{}> | undefined) => ExtensionTableCellExtensionfunctionSource ↗
TableCellExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtensionTableHeaderExtensionfunctionSource ↗
TableHeaderExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtensionTableNodeExtensionfunctionSource ↗
TableNodeExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtensionTableRowExtensionfunctionSource ↗
TableRowExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtensionClasses (1)
ExtensionManagerclassSource ↗
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)
ExtensioninterfaceSource ↗
interface Extension| Member | Type | Summary |
|---|---|---|
| config | ExtensionConfig | |
| onSchemaReady | | |
| type | 'extension' |
ExtensionConfiginterfaceSource ↗
interface ExtensionConfig| Member | Type | Summary |
|---|---|---|
| name | string | |
| options | Record<string, unknown> | |
| priority | ExtensionPriority |
ExtensionContextinterfaceSource ↗
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 |
ExtensionDefinitioninterfaceSource ↗
interface ExtensionDefinition<TOptions = Record<string, unknown>>| Member | Type | Summary |
|---|---|---|
| defaultOptions? | TOptions | |
| name | string | |
| onSchemaReady | | |
| priority? | ExtensionPriority |
ExtensionRuntimeinterfaceSource ↗
interface ExtensionRuntime| Member | Type | Summary |
|---|---|---|
| commands? | CommandMap | |
| keyboardShortcuts? | KeyboardShortcutMap | |
| plugins? | Plugin[] |
MarkExtensioninterfaceSource ↗
interface MarkExtension| Member | Type | Summary |
|---|---|---|
| config | MarkExtensionConfig | |
| onSchemaReady | | |
| type | 'mark' |
MarkExtensionConfiginterfaceSource ↗
interface MarkExtensionConfig extends ExtensionConfig| Member | Type | Summary |
|---|---|---|
| markSpec | MarkSpec | |
| schemaMarkName | string |
MarkExtensionDefinitioninterfaceSource ↗
interface MarkExtensionDefinition<TOptions = Record<string, unknown>>| Member | Type | Summary |
|---|---|---|
| defaultOptions? | TOptions | |
| markSpec | MarkSpec | ((options: TOptions) => MarkSpec) | |
| name | string | |
| onSchemaReady | | |
| priority? | ExtensionPriority | |
| schemaMarkName | string |
NodeExtensioninterfaceSource ↗
interface NodeExtension| Member | Type | Summary |
|---|---|---|
| config | NodeExtensionConfig | |
| onSchemaReady | | |
| type | 'node' |
NodeExtensionConfiginterfaceSource ↗
interface NodeExtensionConfig extends ExtensionConfig| Member | Type | Summary |
|---|---|---|
| nodeSpec | NodeSpec | |
| schemaNodeName | string |
NodeExtensionDefinitioninterfaceSource ↗
interface NodeExtensionDefinition<TOptions = Record<string, unknown>>| Member | Type | Summary |
|---|---|---|
| defaultOptions? | TOptions | |
| name | string | |
| nodeSpec | NodeSpec | ((options: TOptions) => NodeSpec) | |
| onSchemaReady | | |
| priority? | ExtensionPriority | |
| schemaNodeName | string |
StarterKitOptionsinterfaceSource ↗
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 |
TableContextInfointerfaceSource ↗
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)
AnyExtensiontypeSource ↗
type AnyExtension = Extension | NodeExtension | MarkExtension;CommandMaptypeSource ↗
type CommandMap = Record<string, (...args: any[]) => Command>;ExtensionPrioritytypeSource ↗
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;KeyboardShortcutMaptypeSource ↗
type KeyboardShortcutMap = Record<string, Command>;Variables (1)
PriorityconstSource ↗
Priority: {
readonly Highest: 0;
readonly High: 50;
readonly Default: 100;
readonly Low: 150;
readonly Lowest: 200;
}