Browser editor and framework-neutral engine for OOXML .docx documents.
English · 简体中文 · Português (Brasil)
stella ·
npm ·
Issues ·
Discord
folio
Folio is an embeddable Word-document editor for web applications. Pass it a
.docx as a File, Blob, ArrayBuffer, or Uint8Array; it renders editable,
paginated content in the browser and returns a .docx when the user saves.
Use the React, Vue, or Nuxt editor in an application, or use folio-core
directly for parsing, editing, layout, and document review without a UI.
Install
bun add @stll/folio-react react react-dom use-intl
@stll/folio-core is installed with the React editor.
React quick start
import { useState } from "react";
import { IntlProvider } from "use-intl";
import { DocxEditor } from "@stll/folio-react";
import { getFolioMessages } from "@stll/folio-react/messages";
import "@stll/folio-react/standalone.css";
const DOCX_MIME =
"application/vnd.openxmlformats-officedocument.wordprocessingml.document";
const downloadDocx = (buffer: ArrayBuffer) => {
const url = URL.createObjectURL(new Blob([buffer], { type: DOCX_MIME }));
const link = document.createElement("a");
link.href = url;
link.download = "edited.docx";
document.body.append(link);
link.click();
link.remove();
URL.revokeObjectURL(url);
};
export function Editor() {
const [file, setFile] = useState<File | null>(null);
return (
<IntlProvider locale="en" messages={getFolioMessages("en")}>
<input
type="file"
accept=".docx"
onChange={(event) => setFile(event.currentTarget.files?.[0] ?? null)}
/>
{file && (
<DocxEditor
accessibleName="Document editor"
documentBuffer={file}
author="Editor"
onSave={downloadDocx}
/>
)}
</IntlProvider>
);
}
The editor toolbar calls onSave with the updated DOCX bytes. You can also hold
a DocxEditorRef and call await editorRef.current?.save() yourself.
What it handles
- Paginated text, formatting, lists, tables, images, sections, headers, and
footers
- Comments, footnotes, and tracked changes that Microsoft Word can review,
accept, or reject
- DOCX round trips that preserve untouched package parts and unsupported OOXML
- Editing modes, find, page setup, document outline, and save hooks
- Bundled messages for 18 locales, including right-to-left editor chrome
Choose a package