@open-egretta/lexical-export-docx
v0.0.4
Published
Export Lexical editor content to .docx format
Downloads
269
Readme
@open-egretta/lexical-export-docx
Export Lexical editor content to .docx format.
Installation
npm install @open-egretta/lexical-export-docxRequires lexical >= 0.41.0 as a peer dependency.
Usage
Inside a React component
import { exportDocx } from "@open-egretta/lexical-export-docx";
// editor is a LexicalEditor instance
const blob = await exportDocx(editor);
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "document.docx";
a.click();
URL.revokeObjectURL(url);From JSON (SSR / Node.js)
import { exportDocxFromJSON } from "@open-egretta/lexical-export-docx";
import type { SerializedEditorState } from "lexical";
const json: SerializedEditorState = {
/* ... */
};
const blob = await exportDocxFromJSON(json);API
exportDocx(editor: LexicalEditor): Promise<Blob>
Reads the current editor state and returns a .docx Blob. Use this inside a React component where you have access to the LexicalEditor instance.
exportDocxFromJSON(json: SerializedEditorState): Promise<Blob>
Converts a serialized editor state directly to a .docx Blob. Has zero dependency on the Lexical runtime — suitable for SSR, testing, and Node.js environments.
Supported nodes
| Node | Details |
| ----------- | --------------------------- |
| paragraph | Plain paragraph |
| heading | h1 – h6 |
| text | Bold, italic, underline, strikethrough, subscript, superscript, highlight |
| list | Bullet and numbered, nested |
| link | Hyperlink (inline) |
| table | Rows, cells, header rows, col/row span |
License
MIT
