Document Editor

Developers · Embed

Embed a Document Editor in Your Web App

Add a DOCX, XLSX, PPTX and CSV editor to your product with a single iframe and a postMessage API. Your app keeps auth, file access and upload — the editor just edits, and never sees your users' tokens.

Open the live demo →

The editor runs entirely in the browser with the OnlyOffice WebAssembly engine, so documents are rendered and edited on the client — you don't stand up a document server. The recommended pattern keeps a clean boundary: the parent app handles authentication, fetching and saving; the iframe handles editing only. Tokens, cookies and business APIs stay in your app.

Add it with one iframe

<iframe
  id="documentEditor"
  src="https://edit.chaxus.com/?embed=1&embedOrigin=https://your-app.example.com"
  style="width: 100%; height: 720px; border: 0"
></iframe>

Then talk to it over postMessage. Every command takes an id so you can match it to the reply, and every editor event is a document:* message:

// open a file your app already fetched (auth stays with you)
iframe.contentWindow.postMessage(
  { id, type: 'document:open-buffer', payload: { fileName: 'report.xlsx', buffer } },
  'https://edit.chaxus.com'
);

// ask for the edited file back, then upload it yourself
iframe.contentWindow.postMessage({ id, type: 'document:save', payload: { targetExt: 'XLSX' } }, editorOrigin);
// → editor replies with { type: 'document:saved', payload: { fileName, file } }

What you get

How it works

  1. Add the iframe pointing at the editor with ?embed=1, sized to your layout.
  2. Wait for the document:ready event, then send document:open-url, open-file or open-buffer.
  3. The user edits in place; the file never leaves the browser unless your app sends it somewhere.
  4. Send document:save; the editor returns the edited file via document:saved, which your app uploads with its own auth.
Open source & self-hostable. Under AGPL-3.0 — read the code, run your own copy, and see exactly how the boundary works: github.com/ranuts/document. Full API reference: docs/embed-api.md.

Frequently asked questions

How do I embed the document editor?

Add one iframe pointing at the editor with ?embed=1, then drive it with a postMessage API to open and save documents. A working demo is at /embed-demo.html.

Does the editor see my users' auth tokens?

No. Auth, file fetching and upload stay in your app — your app fetches the file with its own credentials and passes the bytes to the editor, so tokens and cookies never enter the iframe.

Which file formats can the embedded editor handle?

DOCX, XLSX, PPTX and CSV, edited client-side with the OnlyOffice WebAssembly engine. The save command exports to XLSX, DOCX, PPTX or CSV.

Can I self-host it or use it white-label?

Yes. It's open source under AGPL-3.0 and ships as static files, so you can host your own copy and embed it under your own domain.

How do I restrict which site can talk to the editor?

Add embedOrigin to the iframe URL to lock messaging to a specific origin, and verify event.origin in your own message handler.