@stesura/docx
DOCX import and export, framework-free. The toolbar buttons are in
@stesura/docx-react; behaviour and round-trip limits are in the
DOCX guide.
Import
importDocx
Parameters:| Name | Type | Default |
|---|---|---|
file | File | ArrayBuffer | |
schema | Schema<any, any> | |
options | DocxImportOptions |
DocxImportOptions
DocxImportResult
DocxImportError
Thrown by importDocx when the file isn’t a readable DOCX: wrong format, corrupt
archive, or over the size limits (50 MB, 200 MB decompressed, 5,000 entries). Its
message is written for end users.
ImportWarning
| Name | Type | Default |
|---|---|---|
type | ImportWarningType | |
message | string | |
element | string | |
position | number |
ImportWarningType
ImportedThread
A comment thread from the file. The doc’s comment anchors carry its id; create the
thread in your comments store and remap the anchors before mounting (see
Loading the result into an editor).
ImportedComment
ImportedImage
NumberingConfig
NumberingLevel.pStyle carries Word’s level→style back-link for
style-linked numbering.
NumberingLevel
Export
downloadDocx
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
comments | CommentsDocx[] | |
outputFileName | string |
generateDocxBuffer
Parameters:| Name | Type | Default |
|---|---|---|
state | EditorState | |
comments | CommentsDocx[] |
generateDocx
Returns the unpacked docx-js Document. It skips the post-pack stage: packing it
yourself loses comment threads, endnote options, section direction, style→level links
and validation. Prefer downloadDocx / generateDocxBuffer
(details).
| Name | Type | Default |
|---|---|---|
state | EditorState | |
comments | CommentsDocx[] |
GeneratedDocx
threadsToDocx
Parameters:| Name | Type | Default |
|---|---|---|
threads | Thread[] | |
schema | Schema<any, any> | |
resolveUserName | ResolveUserNameDisplay name for a mentioned user id. Optional: authors named in the same threads are the fallback, then the raw id. |
CommentsDocx
DocxValidationError
Thrown by downloadDocx / generateDocxBuffer when the packed file breaks a rule Word
enforces, instead of shipping a file Word would reject or repair. problems lists every
violation as a DocxProblem. This points to a serializer bug, not bad input.