New

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

API Referencev1.0.2

@eigenpal/docx-editor-core/docx/parser

Main Parser Orchestrator - Unified parseDocx function

Coordinates all sub-parsers to produce a complete Document model. Handles loading order, dependency resolution, and font preloading.

Parsing order: 1. Unzip DOCX package 2. Parse relationships 3. Parse theme (needed for style color/font resolution) 4. Parse styles (depends on theme) 5. Parse numbering 6. Parse document body (depends on styles, theme, numbering, rels) 7. Parse headers/footers (depends on styles, theme, numbering, rels) 8. Parse footnotes/endnotes (depends on styles, theme, numbering, rels) 9. Extract and load fonts 10. Build media file map 11. Assemble final Document

Functions(5)

Full parse - parse everything including fonts

declare function fullParseDocx(buffer: ArrayBuffer, onProgress?: ProgressCallback): Promise<Document>;

Get document summary without full parsing

declare function getDocxSummary(buffer: ArrayBuffer): Promise<{
    hasDocument: boolean;
    hasStyles: boolean;
    hasTheme: boolean;
    hasNumbering: boolean;
    headerCount: number;
    footerCount: number;
    mediaCount: number;
    variableCount: number;
}>;

Get template variables from a DOCX without full parsing Faster than full parse when you only need variables

declare function getDocxVariables(buffer: ArrayBuffer): Promise<string[]>;

Parse a DOCX file into a complete Document model

declare function parseDocx(input: DocxInput, options?: ParseOptions): Promise<Document>;

Quick parse - parse a DOCX without font loading Useful for quick content extraction or when fonts aren't needed

declare function quickParseDocx(buffer: ArrayBuffer): Promise<Document>;

Interfaces(1)

Parsing options

interface ParseOptions
MemberTypeSummary
detectVariables?booleanWhether to detect template variables (default: true)
onProgress?ProgressCallbackProgress callback for tracking parsing stages
parseHeadersFooters?booleanWhether to parse headers/footers (default: true)
parseNotes?booleanWhether to parse footnotes/endnotes (default: true)
preloadFonts?booleanWhether to preload fonts (default: true)

Type aliases(1)

Progress callback for tracking parsing stages

type ProgressCallback = (stage: string, percent: number) => void;