Skip to Content
API Referencedocx-react

@stesura/docx-react

DOCX toolbar buttons for @stesura/docx. Most hosts only need docxUIExtension:

import { docxUIExtension } from '@stesura/docx-react' <StesuraEditor uiExtensions={[docxUIExtension]} />

Exports

ExportWhat it is
docxUIExtensionAdds DocxGroup to the editor’s Export tab
DocxGroupToolbar group with the import and export buttons
DocxImportButtonReplaces the document with a picked .docx (also .docm, .dotx, .dotm). Edit mode only: review mode blocks it too, because a whole-document replace has no suggestion form
DocxExportButtonDownloads the document as .docx. Enabled in every editor mode
DocxExportButtonPropsfileName?: the download name. .docx is appended and the name sanitized. Defaults to the document’s first heading, then a localized “document”

The buttons read the bound editor from context, so they only work inside the editor’s provider tree. Warnings show as a toast summary, with the full list logged to the console.

Host wiring

  • Images on import. Embedded images are uploaded through the editor’s onFileUpload, so the document stores URLs. Without it they become base64 data URLs. The exception is a mount whose image policy forbids inline images (collab): there the image keeps an unresolved src and a missing_image warning is shown. See File & Image Uploads.
  • Comments on import. Threads are created through the comment adapter’s createThread. Replies need addComment, and resolved state needs resolveThread; the adapter creates everything as the current user, so the original authors and dates go in each thread’s metadata.docx. With no comment adapter mounted, the anchors are removed (the text stays) and a warning is shown. If the import is abandoned partway, the threads already created are deleted with deleteThread, when the adapter has it.
  • Comments on export. Threads come from the comment adapter’s getThreadsForExport. With no adapter, or none that implements it, the file has no comments.
Last updated on