New

docx-editor 1.x has shipped. Vue support, i18n, agents. Read the migration guide →

API Referencev1.0.2

@eigenpal/docx-editor-core/prosemirror/conversion

Document Conversion Utilities

Bidirectional conversion between Document (DOCX) and ProseMirror document.

Functions(7)

Create an empty ProseMirror document

declare function createEmptyDoc(): Node;

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: Array<Paragraph | Table>, options?: ToProseDocOptions & {
    theme?: Theme | null;
}): Node;

Convert a ProseMirror document to our Document type

declare function fromProseDoc(pmDoc: Node, baseDocument?: Document): Document;

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: Array<Paragraph | Table>, options?: ToProseDocOptions & {
    theme?: Theme | null;
}): Node;

Convert a ProseMirror document back to an array of Paragraph/Table blocks. Used for converting edited header/footer PM content back to the document model.

declare function proseDocToBlocks(pmDoc: Node): (Paragraph | Table)[];

Convert a Document to a ProseMirror document

declare function toProseDoc(document: Document, options?: ToProseDocOptions): Node;

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;

Interfaces(1)

Options for document conversion

interface ToProseDocOptions
MemberTypeSummary
styles?StyleDefinitionsStyle definitions for resolving paragraph styles