@stesura/docx-react
DOCX toolbar buttons for @stesura/docx. Most hosts only need docxUIExtension:
import { docxUIExtension } from '@stesura/docx-react'
<StesuraEditor uiExtensions={[docxUIExtension]} />Exports
| Export | What it is |
|---|---|
docxUIExtension | Adds DocxGroup to the editor’s Export tab |
DocxGroup | Toolbar group with the import and export buttons |
DocxImportButton | Replaces 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 |
DocxExportButton | Downloads the document as .docx. Enabled in every editor mode |
DocxExportButtonProps | fileName?: 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 unresolvedsrcand amissing_imagewarning is shown. See File & Image Uploads. - Comments on import. Threads are created through the comment adapter’s
createThread. Replies needaddComment, and resolved state needsresolveThread; the adapter creates everything as the current user, so the original authors and dates go in each thread’smetadata.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 withdeleteThread, 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