@eigenpal/docx-editor-core/prosemirror
ProseMirror Integration for DOCX Editor
This module provides ProseMirror-based editing: - Schema for DOCX document structure - Bidirectional conversion between Document and PM - React wrapper component - Plugins for selection tracking - Commands for formatting - Extension system for schema, plugins, and keymaps
Functions (88)
addColumnLeftfunctionSource ↗
declare function addColumnLeft(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;addColumnRightfunctionSource ↗
declare function addColumnRight(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;addRepeatingSectionItemTrfunctionSource ↗
Build a transaction that adds a repeating-section item by cloning the item at itemPos (its blockSdt before position) and inserting the copy after it. Throws [RepeatingSectionError](RepeatingSectionError) if itemPos isn't a repeating item.
declare function addRepeatingSectionItemTr(state: EditorState, itemPos: number): Transaction;addRowAbovefunctionSource ↗
declare function addRowAbove(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;addRowBelowfunctionSource ↗
declare function addRowBelow(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;addTabStopfunctionSource ↗
declare function addTabStop(position: number, alignment?: TabStopAlignment, leader?: TabLeader): Command;applyStylefunctionSource ↗
declare function applyStyle(styleId: string, resolvedAttrs?: ResolvedStyleAttrs): Command;applyTableStylefunctionSource ↗
declare function applyTableStyle(styleData: {
styleId: string;
tableBorders?: Record<string, unknown>;
conditionals?: Record<string, unknown>;
look?: Record<string, boolean>;
}): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;autoFitContentsfunctionSource ↗
declare function autoFitContents(): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;createDocumentContextPluginfunctionSource ↗
Create the plugin holding [DocumentContext](DocumentContext) for the lifetime of the EditorState. Separate from the resolver plugin so the resolver's public documentStylesKey shape stays stable. The table-insert command reads the theme + default-table styleId from here to bake an inserted table the same way convertTable does on import.
declare function createDocumentContextPlugin(options?: Partial<DocumentContext>): Plugin;createDocumentStylesPluginfunctionSource ↗
Create the plugin holding a StyleResolver for the document's styles for the lifetime of the EditorState. The resolver is fixed per document load; loading a new document recreates the state (and thus this plugin) with a fresh resolver. Accepts a pre-built resolver too, for callers that already have one.
declare function createDocumentStylesPlugin(styles: StyleDefinitions | StyleResolver | null | undefined): Plugin;createEmptyDocfunctionSource ↗
Create an empty ProseMirror document
declare function createEmptyDoc(): Node;createSelectionTrackerPluginfunctionSource ↗
Create selection tracker plugin
declare function createSelectionTrackerPlugin(onSelectionChange?: SelectionChangeCallback): Plugin;createStyleResolverfunctionSource ↗
Create a style resolver from document's style definitions
declare function createStyleResolver(styleDefinitions: StyleDefinitions | undefined): StyleResolver;decreaseIndentfunctionSource ↗
declare function decreaseIndent(amount?: number): Command;deleteColumnfunctionSource ↗
declare function deleteColumn(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;deleteRowfunctionSource ↗
declare function deleteRow(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;deleteTablefunctionSource ↗
declare function deleteTable(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;distributeColumnsfunctionSource ↗
declare function distributeColumns(): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;ensureParaIdsInStatefunctionSource ↗
Allocate any missing / duplicate paragraph ids on a freshly-created state, returning the corrected state. Apply this to the initial EditorState (before wiring the view) so the load doesn't dispatch a transaction — hosts see ids without a spurious onChange. No-op when every paragraph already has a unique id.
declare function ensureParaIdsInState(state: EditorState): EditorState;extractSelectionContextfunctionSource ↗
Extract selection context from editor state
declare function extractSelectionContext(state: EditorState): SelectionContext;extractSelectionStatefunctionSource ↗
Extract selection state from editor state. Used by PagedEditor integration in DocxEditor for toolbar state.
declare function extractSelectionState(state: EditorState): SelectionState | null;findContentControlPosfunctionSource ↗
PM position of the first control matching filter, or null.
declare function findContentControlPos(doc: Node, filter: ContentControlFilter): number | null;findContentControlsInPMfunctionSource ↗
All content controls in the PM doc (document order), optionally filtered.
declare function findContentControlsInPM(doc: Node, filter?: ContentControlFilter): PMContentControl[];findHyperlinkRangeAtfunctionSource ↗
Resolve the hyperlink mark + contiguous range that surrounds the current cursor. Used by edit/remove popup actions in both adapters.
Resolution order for the mark itself: 1. $from.marks() — the normal active-marks lookup 2. $from.nodeAfter/nodeBefore marks — boundary positions don't report active marks via marks() 3. (optional) text-node search by fallbackHref — last resort when the popup knows the href but the cursor sits at a gap
The returned range walks the parent block grouping consecutive text nodes that share the same href, and returns whichever range contains the cursor.
declare function findHyperlinkRangeAt(state: EditorState, fallbackHref?: string): {
mark: Mark;
start: number;
end: number;
} | null;findParagraphByParaIdfunctionSource ↗
ProseMirror position range for the paragraph (or any textblock) whose paraId attribute equals paraId. Returns the inclusive from and exclusive to positions, plus the node, so callers can both target the paragraph (e.g. addMark over its text range) and inspect it.
from is the position immediately before the textblock; to is from + node.nodeSize. The text content lives at [from + 1, to - 1].
Returns null if no textblock with that paraId exists.
declare function findParagraphByParaId(doc: Node, paraId: string): {
node: Node;
from: number;
to: number;
} | null;findStartPosForParaIdfunctionSource ↗
ProseMirror position immediately before the first textblock whose paraId attribute equals paraId (Word w14:paraId / OOXML paragraph id).
Match is strict string equality on node.attrs.paraId.
declare function findStartPosForParaId(doc: Node, paraId: string): number | null;footnoteToProseDocfunctionSource ↗
Convert footnote/endnote content (array of Paragraph/Table blocks) to a ProseMirror document. Mirrors headerFooterToProseDoc so footnotes flow through the same body pipeline (toFlowBlocks → measureBlocks → renderFragment) and inherit its block support — paragraph + table + image + textBox + fields. Pre-PR, footnoteLayout's convertFootnoteToContent re-implemented run/paragraph conversion by hand and silently dropped tables, images, and fields nested inside a footnote.
declare function footnoteToProseDoc(content: BlockContent[], options?: ToProseDocOptions & {
theme?: Theme | null;
}): Node;fromProseDocfunctionSource ↗
Convert a ProseMirror document to our Document type
declare function fromProseDoc(pmDoc: Node, baseDocument?: Document): Document;getDefaultTableStyleIdfunctionSource ↗
Read w:defaultTableStyle (styleId for new tables), or null.
declare function getDefaultTableStyleId(state: EditorState): string | null;getDocumentStyleResolverfunctionSource ↗
Read the document's StyleResolver, or null when the plugin isn't installed.
declare function getDocumentStyleResolver(state: EditorState): StyleResolver | null;getDocumentThemefunctionSource ↗
Read the document theme, or null when the context plugin isn't installed.
declare function getDocumentTheme(state: EditorState): Theme | null;getHyperlinkAttrsfunctionSource ↗
declare function getHyperlinkAttrs(state: EditorState): {
href: string;
tooltip?: string;
} | null;getListInfofunctionSource ↗
declare function getListInfo(state: EditorState): {
numId: number;
ilvl: number;
} | null;getMarkAttrfunctionSource ↗
Get the current value of a mark attribute
declare function getMarkAttr(state: EditorState, markType: MarkType, attr: string): unknown | null;getParagraphAlignmentfunctionSource ↗
declare function getParagraphAlignment(state: EditorState): ParagraphAlignment | null;getParagraphBidifunctionSource ↗
declare function getParagraphBidi(state: EditorState): boolean;getSelectedTextfunctionSource ↗
declare function getSelectedText(state: EditorState): string;getSelectionContextfunctionSource ↗
Get current selection context from editor state
declare function getSelectionContext(state: EditorState): SelectionContext | null;getStyleIdfunctionSource ↗
declare function getStyleId(state: EditorState): string | null;getTableContextfunctionSource ↗
declare function getTableContext(state: EditorState): TableContextInfo;headerFooterToProseDocfunctionSource ↗
Convert HeaderFooter content (array of Paragraph/Table blocks) to a ProseMirror document. Used for editing headers/footers in their own ProseMirror editor and for the unified header/footer render pipeline. theme must be threaded for themeColor resolution in cell shading (<w:shd w:themeFill=...>) — without it, themed fills in HF tables fall back to the unresolved theme key.
declare function headerFooterToProseDoc(content: BlockContent[], options?: ToProseDocOptions & {
theme?: Theme | null;
}): Node;increaseIndentfunctionSource ↗
declare function increaseIndent(amount?: number): Command;insertHyperlinkfunctionSource ↗
declare function insertHyperlink(text: string, href: string, tooltip?: string): Command;insertTablefunctionSource ↗
declare function insertTable(rows: number, cols: number): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;isHyperlinkActivefunctionSource ↗
declare function isHyperlinkActive(state: EditorState): boolean;isInListfunctionSource ↗
declare function isInList(state: EditorState): boolean;isInTablefunctionSource ↗
declare function isInTableCell(state: EditorState): boolean;isMarkActivefunctionSource ↗
Check if a mark is active in the current selection
declare function isMarkActive(state: EditorState, markType: MarkType, attrs?: Record<string, unknown>): boolean;mergeCellsfunctionSource ↗
declare function mergeCells(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;removeContentControlTrfunctionSource ↗
Build a transaction that removes the first matching control. With keepContent the inner blocks are unwrapped in place; otherwise the whole region is deleted. Throws if nothing matches or the control is deletion-locked (unless force).
declare function removeContentControlTr(state: EditorState, filter: ContentControlFilter, options?: {
force?: boolean;
keepContent?: boolean;
}): Transaction;removeRepeatingSectionItemTrfunctionSource ↗
Build a transaction that removes the repeating-section item at itemPos. Throws [RepeatingSectionError](RepeatingSectionError) if it isn't an item or is the only one in its section.
declare function removeRepeatingSectionItemTr(state: EditorState, itemPos: number): Transaction;removeTableBordersfunctionSource ↗
declare function removeTableBorders(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;removeTabStopfunctionSource ↗
declare function removeTabStop(position: number): Command;selectColumnfunctionSource ↗
declare function selectColumn(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;selectRowfunctionSource ↗
declare function selectRow(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;selectTablefunctionSource ↗
declare function selectTable(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;setAlignmentfunctionSource ↗
Paragraph Formatting Commands — thin re-exports from extension system
Alignment, line spacing, indentation, lists, paragraph styles. All implementations live in extensions/; this file re-exports for backward compatibility.
declare function setAlignment(alignment: ParagraphAlignment): Command;setAllTableBordersfunctionSource ↗
declare function setAllTableBorders(state: EditorState, dispatch?: (tr: Transaction) => void, borderSpec?: {
style: string;
size: number;
color: {
rgb: string;
};
}): boolean;setCellBorderfunctionSource ↗
declare function setCellBorder(side: 'top' | 'bottom' | 'left' | 'right' | 'all', spec: {
style: string;
size?: number;
color?: {
rgb: string;
};
} | null, clearOthers?: boolean): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;setCellFillColorfunctionSource ↗
declare function setCellFillColor(color: string | null): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;setCellMarginsfunctionSource ↗
declare function setCellMargins(margins: {
top?: number;
bottom?: number;
left?: number;
right?: number;
}): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;setCellTextDirectionfunctionSource ↗
declare function setCellTextDirection(direction: string | null): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;setCellVerticalAlignfunctionSource ↗
declare function setCellVerticalAlign(align: 'top' | 'center' | 'bottom'): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;setContentControlContentTrfunctionSource ↗
Build a transaction that replaces the first matching control's content with text (newlines become paragraphs; a plainText control stays one paragraph). Throws if nothing matches, the control is content-locked, a typed (dropdown/date/…) control, or data-bound (unless force). The control's identity/raw props are kept; a w:showingPlcHdr placeholder flag is cleared so the new content isn't rendered as placeholder.
declare function setContentControlContentTr(state: EditorState, filter: ContentControlFilter, text: string, options?: {
force?: boolean;
}): Transaction;setContentControlValueAtPosTrfunctionSource ↗
Build a transaction that applies a typed value to the content control at a specific PM node position. This is used by painted inline widgets because Word templates may repeat or omit w:tag values.
declare function setContentControlValueAtPosTr(state: EditorState, pos: number, value: ContentControlValue, options?: {
force?: boolean;
}): Transaction;setContentControlValueTrfunctionSource ↗
Build a transaction that applies a typed value (dropdown selection, checkbox toggle, or date) to the first control matching filter, updating both the visible content and the control's structured attrs (checked / raw w:sdtPr). Reuses the headless value-applier so the live editor and headless paths agree. Throws as the headless [setContentControlValue](setContentControlValue) does.
declare function setContentControlValueTr(state: EditorState, filter: ContentControlFilter, value: ContentControlValue, options?: {
force?: boolean;
}): Transaction;setFontFamilyfunctionSource ↗
declare function setFontFamily(fontName: string): Command;setFontSizefunctionSource ↗
declare function setFontSize(size: number): Command;setHighlightfunctionSource ↗
declare function setHighlight(color: string): Command;setHyperlinkfunctionSource ↗
declare function setHyperlink(href: string, tooltip?: string): Command;setIndentFirstLinefunctionSource ↗
declare function setIndentFirstLine(twips: number, hanging?: boolean): Command;setIndentLeftfunctionSource ↗
declare function setIndentLeft(twips: number): Command;setIndentRightfunctionSource ↗
declare function setIndentRight(twips: number): Command;setInsideTableBordersfunctionSource ↗
declare function setInsideTableBorders(state: EditorState, dispatch?: (tr: Transaction) => void, borderSpec?: {
style: string;
size: number;
color: {
rgb: string;
};
}): boolean;setLineSpacingfunctionSource ↗
declare function setLineSpacing(value: number, rule?: LineSpacingRule): Command;setOutsideTableBordersfunctionSource ↗
declare function setOutsideTableBorders(state: EditorState, dispatch?: (tr: Transaction) => void, borderSpec?: {
style: string;
size: number;
color: {
rgb: string;
};
}): boolean;setRowHeightfunctionSource ↗
declare function setRowHeight(height: number | null, rule?: 'auto' | 'atLeast' | 'exact'): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;setTableBorderColorfunctionSource ↗
declare function setTableBorderColor(color: string): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;setTableBordersfunctionSource ↗
declare function setTableBorders(preset: BorderPreset, borderSpec?: {
style: string;
size: number;
color: {
rgb: string;
};
}): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;setTableBorderWidthfunctionSource ↗
declare function setTableBorderWidth(size: number): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;setTablePropertiesfunctionSource ↗
declare function setTableProperties(props: {
width?: number | null;
widthType?: string | null;
justification?: 'left' | 'center' | 'right' | null;
}): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;setTextColorfunctionSource ↗
declare function setTextColor(attrs: TextColorAttrs): Command;splitCellfunctionSource ↗
declare function splitCell(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;toggleHeaderRowfunctionSource ↗
declare function toggleHeaderRow(): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;toggleNoWrapfunctionSource ↗
declare function toggleNoWrap(): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;toProseDocfunctionSource ↗
Convert a Document to a ProseMirror document
declare function toProseDoc(document: Document, options?: ToProseDocOptions): Node;updateDocumentContentfunctionSource ↗
Update a Document with content from a ProseMirror document Preserves all non-content parts of the original document
declare function updateDocumentContent(originalDocument: Document, pmDoc: Node): Document;Classes (2)
LayoutSelectionGateclassSource ↗
LayoutSelectionGate coordinates the timing between document edits and layout reflow so that selection overlays are only painted against current DOM geometry.
Workflow: 1. Document changes → setStateSeq(++seq) 2. Layout starts → onLayoutStart() 3. Layout completes → onLayoutComplete(seq) 4. Selection update requested → requestRender() 5. If safe → callback is called
declare class LayoutSelectionGate| Member | Type | Summary |
|---|---|---|
| getDebugInfo | | Get debug info about current state. |
| getRenderSeq | | Get current layout render sequence. |
| getStateSeq | | Get current document state sequence. |
| incrementStateSeq | | Increment document state sequence (convenience method). Returns the new sequence value. |
| isSafeToRender | | Check if it's safe to render selection. Safe when: layout is not updating AND render sequence = state sequence |
| onLayoutComplete | | Called when layout computation and DOM painting completes. |
| onLayoutStart | | Called when layout computation starts. |
| onRender | | Register a callback to be called on render events. |
| requestRender | | Request a selection render. Will be executed when safe. If already safe, executes immediately. |
| reset | | Reset the gate state (useful for testing or document reload). |
| setStateSeq | | Set the document state sequence (call when document changes). This should be called on every ProseMirror transaction that changes the doc. |
StyleResolverclassSource ↗
StyleResolver provides efficient access to resolved style properties
declare class StyleResolver| Member | Type | Summary |
|---|---|---|
| (constructor) | | Constructs a new instance of the `StyleResolver` class |
| getDefaultCharacterStyle | | Get the default character style (the one marked `w:default="1"`). |
| getDefaultParagraphStyle | | Get default paragraph style (usually "Normal") |
| getDefaultTableStyle | | Get the default table style (the one marked `w:default="1"`). |
| getDocDefaults | | Get document defaults |
| getNextStyleId | | Resolve the style applied to the paragraph that follows one styled with `styleId` when the user presses Enter (OOXML `w:next`, §17.7.4.10). |
| getParagraphStyles | | Get all available paragraph styles (for toolbar dropdown) |
| getRunStyleOwnProperties | | Get a character style's own properties WITHOUT docDefaults. Used when the caller already has docDefaults applied (e.g., from paragraph style resolution). This prevents docDefault fonts from incorrectly overriding paragraph style fonts. |
| getStyle | | Get a style by ID |
| getTableStyles | | Get all available table styles (for style gallery) |
| hasParagraphStyle | | Whether a paragraph style with the given id is defined in the document's `styles.xml`. Used by the agent toolkit to refuse `set_paragraph_style({ styleId: 'NoSuchStyle' })` instead of silently writing an invalid `<w:pStyle>` reference. |
| hasStyle | | Check if a style exists |
| resolveParagraphStyle | | Resolve paragraph style properties, including docDefaults cascade |
| resolveRunStyle | | Resolve run (character) style properties |
Interfaces (14)
DocumentContextinterfaceSource ↗
Extra document-level context parked alongside the StyleResolver.
interface DocumentContext| Member | Type | Summary |
|---|---|---|
| defaultTableStyleId | string | null | `w:defaultTableStyle` (settings.xml) — styleId for newly created tables. |
| theme | Theme | null | The document theme, for resolving themed colors in commands. |
FontFamilyAttrsinterfaceSource ↗
Font family mark attributes
interface FontFamilyAttrs| Member | Type | Summary |
|---|---|---|
| ascii? | string | |
| asciiTheme? | string | |
| cs? | string | |
| csTheme? | string | |
| eastAsia? | string | |
| eastAsiaTheme? | string | |
| hAnsi? | string | |
| hAnsiTheme? | string |
FontSizeAttrsinterfaceSource ↗
Font size mark attributes
interface FontSizeAttrs| Member | Type | Summary |
|---|---|---|
| size? | number | null | |
| sizeCs? | number | null |
HyperlinkAttrsinterfaceSource ↗
Hyperlink mark attributes
interface HyperlinkAttrs| Member | Type | Summary |
|---|---|---|
| href | string | |
| rId? | string | |
| tooltip? | string |
ImageAttrsinterfaceSource ↗
Image node attributes
interface ImageAttrs| Member | Type | Summary |
|---|---|---|
| allowOverlap? | boolean | `wp:anchor allowOverlap`. Same tri-state convention as `layoutInCell`. |
| alt? | string | |
| borderColor? | string | Border color as CSS color string |
| borderStyle? | string | Border style (CSS border-style value) |
| borderWidth? | number | Border width in pixels |
| cropBottom? | number | |
| cropLeft? | number | |
| cropRight? | number | |
| cropTop? | number | `wp:srcRect` crop fractions in [0, 1]. Each side is the fraction of the source image that should be hidden. Renders as CSS `clip-path: inset(...)`. |
| cssFloat? | 'left' | 'right' | 'none' | CSS float direction for floating images |
| displayMode? | 'inline' | 'float' | 'block' | Display mode for CSS: inline (flows with text), float (left/right float), block (centered) |
| distBottom? | number | Distance from text below (pixels) |
| distLeft? | number | Distance from text left (pixels) |
| distRight? | number | Distance from text right (pixels) |
| distTop? | number | Distance from text above (pixels) |
| effectExtentBottom? | number | |
| effectExtentLeft? | number | |
| effectExtentRight? | number | |
| effectExtentTop? | number | `wp:effectExtent` padding (pixels) — extra space reserved around the image for shadows, glows, soft edges, etc. Applied as outer margin so the effect isn't clipped by surrounding content. |
| height? | number | Height in pixels (already converted from EMU) |
| hlinkHref? | string | Hyperlink URL for clickable image |
| layoutInCell? | boolean | `wp:anchor layoutInCell`. Tri-state: true / false / undefined (= Word's default "1"). Floating-only; round-tripped on save. |
| opacity? | number | `a:alphaModFix amt` mapped to CSS `opacity` in [0, 1]. |
| position? | ImagePositionAttrs | Position for floating images (horizontal and vertical alignment) |
| rId? | string | |
| src | string | |
| title? | string | |
| transform? | string | CSS transform string (rotation, flip) |
| width? | number | Width in pixels (already converted from EMU) |
| wrapText? | string | Wrap text setting from DOCX (left, right, bothSides, largest) for round-trip |
| wrapType? | WrapType | Wrap type from DOCX: inline, square, tight, through, topAndBottom, behind, inFront |
ParagraphAttrsinterfaceSource ↗
Paragraph node attributes - maps to ParagraphFormatting
interface ParagraphAttrs| Member | Type | Summary |
|---|---|---|
| _originalFormatting? | ParagraphFormatting | Original inline paragraph formatting from DOCX (pre-style-resolution). Used by fromProseDoc for lossless round-trip serialization. |
| _originalRunBoundaries? | Array<{
text: string;
marksKey?: string;
formatting?: TextFormatting;
propertyChanges?: RunPropertyChange[];
}> | Source run boundaries captured during DOCX → PM conversion. ProseMirror normalizes adjacent text nodes with identical marks, and empty runs have no PM representation, so fromProseDoc uses this metadata to restore no-op run segmentation when the paragraph's text/marks still match the source. |
| _sectionProperties? | SectionProperties | Full section properties for paragraphs that end a section. Used by layout engine for per-section column/page config and round-trip. |
| alignment? | ParagraphAlignment | |
| bidi? | boolean | |
| bookmarks? | Array<{
id: number;
name: string;
}> | |
| borders? | {
top?: BorderSpec;
bottom?: BorderSpec;
left?: BorderSpec;
right?: BorderSpec;
between?: BorderSpec;
bar?: BorderSpec;
} | |
| contextualSpacing? | boolean | Contextual spacing — suppress space between same-style paragraphs |
| defaultTextFormatting? | TextFormatting | |
| hangingIndent? | boolean | |
| indentFirstLine? | number | |
| indentLeft? | number | |
| indentRight? | number | |
| keepLines? | boolean | |
| keepNext? | boolean | |
| lineSpacing? | number | |
| lineSpacingRule? | LineSpacingRule | |
| listAbstractNumId? | number | See ListRendering.abstractNumId. |
| listIsBullet? | boolean | Whether this is a bullet list |
| listLevelNumFmts? | NumberFormat[] | NumberFormat for each level 0..ilvl (inclusive). Lets toFlowBlocks resolve multi-level templates like "%1.%2." with the correct format per token. |
| listMarker? | string | Computed list marker text (e.g., "1.", "1.1.", "•") |
| listMarkerFontFamily? | string | Marker font family from numbering level rPr |
| listMarkerFontSize? | number | Marker font size from numbering level rPr, in points |
| listMarkerSuffix? | 'tab' | 'space' | 'nothing' | Suffix after the marker (§17.9.25); default `tab`. |
| listNumFmt? | NumberFormat | List number format (decimal, lowerRoman, upperRoman, etc.) for CSS counter styling |
| listStartOverride? | number | See ListRendering.startOverride. |
| numPr? | {
numId?: number;
ilvl?: number;
} | |
| numPrFromStyle? | {
numId?: number;
ilvl?: number;
} | The style-sourced numPr value when `numPr` came from the paragraph style rather than direct formatting. While `numPr` still equals this, fromProseDoc omits it from serialized formatting (writing it as direct `<w:numPr>` would flip Word's level-indent precedence on reload). List commands that change `numPr` make the values diverge, which re-enables direct serialization — no explicit clearing needed. |
| outlineLevel? | number | |
| pageBreakBefore? | boolean | |
| paraId? | string | |
| pPrChange? | ParagraphPropertyChange[] | null | Paragraph property changes (`<w:pPrChange>`). Each entry carries the OOXML triple plus a `prior` snapshot of the paragraph properties before the edit. Array because multiple authors can stack edits on the same paragraph; on reject by id, only the matching entry's prior is restored. The shape mirrors the existing model `Paragraph.propertyChanges: ParagraphPropertyChange[]` — see `packages/core/src/types/content/trackedChange.ts`. |
| pPrDel? | RevisionInfo | null | Paragraph-mark deletion tracking (`<w:pPr><w:rPr><w:del/>`). Same shape and provenance as `pPrIns`. Accept joins this paragraph with the following one; reject clears the marker, keeping the split. |
| pPrIns? | RevisionInfo | null | Paragraph-mark insertion tracking (`<w:pPr><w:rPr><w:ins/>`). Carries the OOXML tracked-change triple `(w:id, w:author, w:date)` when the pilcrow terminating this paragraph was added as a tracked change. `date` is ISO 8601 UTC with `Z` suffix; `null` if the source DOCX omitted `w:date`. Reject joins this paragraph with the following one. |
| renderedPageBreakBefore? | boolean | Word's cached layout marker (`<w:lastRenderedPageBreak/>`). Treated like `pageBreakBefore` for layout, kept as a separate attr so save+reload preserves the marker at the same position Word recorded. |
| sectionBreakType? | 'nextPage' | 'continuous' | 'oddPage' | 'evenPage' | |
| shading? | ShadingProperties | |
| spaceAfter? | number | |
| spaceBefore? | number | |
| spacingExplicit? | SpacingExplicit | See ParagraphFormatting.spacingExplicit. |
| styleId? | string | |
| tabs? | TabStop[] | |
| textId? | string |
PMContentControlinterfaceSource ↗
A control discovered in the PM doc, with its PM position for scroll/edit.
interface PMContentControl| Member | Type | Summary |
|---|---|---|
| alias? | string | |
| checked? | boolean | Checkbox state, for checkbox controls. |
| dataBinding? | SdtDataBinding | XML data binding (`w:dataBinding`), if the control is bound. |
| dateFormat? | string | Date format, for date controls. |
| dateValue? | string | Current date value (ISO `yyyy-mm-dd`) for a date control, from `w:fullDate`. |
| depth | number | Nesting depth among content controls (0 = not inside another control). |
| id? | number | |
| listItems? | {
displayText: string;
value: string;
}[] | Dropdown/combobox list items, if modeled. |
| lock? | SdtProperties['lock'] | |
| pos | number | PM position of the `blockSdt` or inline `sdt` node (its `before` position). |
| sdtType | SdtType | |
| showingPlaceholder? | boolean | Whether the control is currently showing placeholder text. |
| tag? | string | |
| text | string | Plain text of the control's content. |
ResolvedParagraphStyleinterfaceSource ↗
Resolved style properties ready for rendering
interface ResolvedParagraphStyle| Member | Type | Summary |
|---|---|---|
| paragraphFormatting? | ParagraphFormatting | Paragraph formatting (alignment, spacing, indentation, etc.) |
| runFormatting? | TextFormatting | Default run formatting from the style |
SelectionContextinterfaceSource ↗
Selection context for toolbar state
interface SelectionContext| Member | Type | Summary |
|---|---|---|
| activeCommentIds | number[] | Active comment IDs at cursor position |
| endParagraphIndex | number | End paragraph index |
| hasSelection | boolean | Whether there's a non-collapsed selection |
| inDeletion | boolean | Whether cursor is inside a tracked deletion |
| inInsertion | boolean | Whether cursor is inside a tracked insertion |
| inList | boolean | Whether cursor is in a list |
| isMultiParagraph | boolean | Whether selection spans multiple paragraphs |
| listLevel? | number | List level (0-8) |
| listType? | 'bullet' | 'numbered' | List type if in list |
| paragraphFormatting | ParagraphFormatting | Current paragraph formatting |
| startParagraphIndex | number | Start paragraph index |
| textFormatting | TextFormatting | Current text formatting at cursor/selection |
SelectionStateinterfaceSource ↗
Selection state for toolbar integration
interface SelectionState| Member | Type | Summary |
|---|---|---|
| endParagraphIndex | number | End paragraph index |
| hasSelection | boolean | Whether there's an active selection (not just cursor) |
| isMultiParagraph | boolean | Whether selection spans multiple paragraphs |
| paragraphFormatting | ParagraphFormatting | Current paragraph formatting |
| startParagraphIndex | number | Start paragraph index |
| styleId | string | null | Current paragraph style ID (e.g., 'Heading1', 'Normal') |
| textFormatting | TextFormatting | Current text formatting at selection/cursor |
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 |
TextColorAttrsinterfaceSource ↗
Text color mark attributes
interface TextColorAttrs| Member | Type | Summary |
|---|---|---|
| rgb? | string | |
| themeColor? | ThemeColorSlot | |
| themeShade? | string | |
| themeTint? | string |
ToProseDocOptionsinterfaceSource ↗
Options for document conversion
interface ToProseDocOptions| Member | Type | Summary |
|---|---|---|
| defaultTabStopTwips? | number | null | Doc-level `w:defaultTabStop` (§17.6.13) in twips, stamped onto the PM doc node so `toFlowBlocks` picks it up. The body entry point reads this from the parsed package; HF/footnote callers must pass it through explicitly since their input is a content array, not a full `Document`. Falls back to the OOXML default (720 twips) when null. |
| styles? | StyleDefinitions | Style definitions for resolving paragraph styles |
UnderlineAttrsinterfaceSource ↗
Underline mark attributes
interface UnderlineAttrs| Member | Type | Summary |
|---|---|---|
| color? | TextColorAttrs | |
| style? | UnderlineStyle |
Type aliases (2)
BorderPresettypeSource ↗
Cell-border commands. Each command applies a preset / individual side / color / width to the cells targeted by the current selection (single cursor cell or active CellSelection).
All four commands use the shared buildTableGrid lookup to find each cell's neighbours in the grid, then sync the matching edge on the adjacent cell — Google-Docs style edge-symmetric border editing.
Schema-free: only attribute updates via tr.setNodeMarkup.
type BorderPreset = 'all' | 'outside' | 'inside' | 'none';SelectionChangeCallbacktypeSource ↗
Callback type for selection changes
type SelectionChangeCallback = (context: SelectionContext) => void;Variables (30)
alignCenterconstSource ↗
alignCenter: CommandalignJustifyconstSource ↗
alignJustify: CommandalignLeftconstSource ↗
alignLeft: CommandalignRightconstSource ↗
alignRight: CommandclearFontFamilyconstSource ↗
clearFontFamily: CommandclearFontSizeconstSource ↗
clearFontSize: CommandclearFormattingconstSource ↗
Clear all text formatting (remove all marks)
clearFormatting: CommandclearHighlightconstSource ↗
clearHighlight: CommandclearStyleconstSource ↗
clearStyle: CommandclearTextColorconstSource ↗
clearTextColor: CommanddecreaseListLevelconstSource ↗
decreaseListLevel: CommanddocumentContextKeyconstSource ↗
documentContextKey: PluginKey<DocumentContext>documentStylesKeyconstSource ↗
documentStyles plugin — makes the document's StyleResolver reachable from ProseMirror commands.
Styles otherwise flow one way (Document → PM) at load time: toProseDoc bakes resolved formatting into nodes and discards the resolver. Some commands need the live style table though — the Enter handler looks up a paragraph style's w:next to switch to body text after a heading. This plugin parks the resolver in plugin state so those commands can read it via getDocumentStyleResolver(state).
A sibling documentContext plugin (below) carries the extra document-level context the table-insert command needs — the theme and the settings w:defaultTableStyle — without changing this resolver plugin's shape.
The host (React HiddenProseMirror / HiddenHeaderFooterPMs, Vue useDocxEditor) passes the same styles it hands to toProseDoc and adds these plugins when creating the EditorState. When absent, style-aware commands fall back to their style-agnostic behavior.
documentStylesKey: PluginKey<StyleResolver | null>generateTOCconstSource ↗
generateTOC: CommandincreaseListLevelconstSource ↗
increaseListLevel: CommandinsertPageBreakconstSource ↗
Insert a page break at the current cursor position. Always ensures a paragraph follows the page break and places the cursor there.
insertPageBreak: CommandremoveHyperlinkconstSource ↗
removeHyperlink: CommandremoveListconstSource ↗
removeList: CommandschemaconstSource ↗
schema: prosemirror_model.Schema<any, any>selectionTrackerKeyconstSource ↗
Plugin key for accessing selection tracker state
selectionTrackerKey: PluginKey<SelectionContext>setLtrconstSource ↗
setLtr: CommandsetRtlconstSource ↗
setRtl: CommandtoggleBoldconstSource ↗
toggleBold: CommandtoggleBulletListconstSource ↗
toggleBulletList: CommandtoggleItalicconstSource ↗
toggleItalic: CommandtoggleNumberedListconstSource ↗
toggleNumberedList: CommandtoggleStrikeconstSource ↗
toggleStrike: CommandtoggleSubscriptconstSource ↗
toggleSubscript: CommandtoggleSuperscriptconstSource ↗
toggleSuperscript: CommandtoggleUnderlineconstSource ↗
toggleUnderline: Command