@eigenpal/docx-editor-core/prosemirror/conversion
Document Conversion Utilities
Bidirectional conversion between Document (DOCX) and ProseMirror document.
Functions(7)
createEmptyDoc
Create an empty ProseMirror document
declare function createEmptyDoc(): Node;footnoteToProseDoc
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;Convert a ProseMirror document to our Document type
declare function fromProseDoc(pmDoc: Node, baseDocument?: Document): Document;proseDocToBlocks
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): BlockContent[];Convert a Document to a ProseMirror document
declare function toProseDoc(document: Document, options?: ToProseDocOptions): Node;updateDocumentContent
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)
ToProseDocOptions
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 |