Skip to main content
The editor plugin is a component that opens, edits and saves Word, PowerPoint, Excel and PDF files inside your own site. Everything runs in the user’s browser: the file isn’t uploaded anywhere to be edited. This is useful for:
  • Letting users touch up a document your agent just created with Doconda, without leaving your product.
  • Reviewing contracts or reports with comments and tracked changes, saved in Office’s own format.
  • Co-editing the same file in real time (see real-time co-editing).
  • Asking an AI assistant (the ✨ button) for changes in plain words, in Word, Excel and PowerPoint (see AI assistant).
The plugin is bought separately from the API, per organization: a monthly, yearly or one-time plan, with a 7-day free trial. On localhost it works without a licence. See licence and domains.

Install

1

Point npm at Doconda

With an active licence, go to Editor in the dashboard and copy your npm token. Save it as the environment variable DOCONDA_NPM_TOKEN (on your machine and in your CI), and add this .npmrc to your project:
2

Install it

3

Import it

Import @doconda/editor for React (a React 19 component) or @doconda/editor/element for any other framework (a <doconda-editor> tag, see below).
A released version never changes, so your lockfile keeps your project and your CI on the same code until you update with npm update @doconda/editor.
The npm token is secret: keep it in an environment variable, never in the repo. The .npmrc above has no secret and can be committed. The token stops working when the licence stops being active, and every download carries a mark that identifies your organization.

Open a file

The editor opens the file at src with its toolbar, ready to edit. It takes the height of its container, so give the container a height.
  • src is a link the browser can download: a .docx, .pptx, .xlsx or .pdf from your own site, or from a server that allows it with CORS.
  • The format comes from the link’s extension. If the link has none, set format to "word", "markdown", "cell" (Excel), "slide" (PowerPoint) or "pdf".
  • licenseKey is your licence key (ek_eu_… or ek_us_…), from Editor. On localhost you can leave it out.
  • Users can also drop a file onto the editor.
To open a Doconda document, download it on your server (doconda.documents.download(id, "docx")) and serve it from a route of yours, or pass the bytes in file. The links from GET /documents/{id}/outputs don’t work as src: your site can’t read them from the browser, and they expire after 5 minutes.

Other formats

  • .md opens in the Markdown editor, .txt in the Word one and .csv in the Excel one; they’re saved in their own format.
  • Older and other formats are converted when opened, with a Compatibility mode note, and saved as .docx, .xlsx or .pptx (.xlsm for an .xls with macros). What doesn’t convert is listed in a bar above the document.
Password-protected .doc, .xls and .ppt files ask for the password. An open PDF can be converted to Word, Excel or PowerPoint from the File menu.

Markdown

A .md or .markdown file (or format="markdown") opens in the Markdown editor: the text with no pages, and only what Markdown keeps (headings, bold, italic, strikethrough, inline code, lists, quotes, code blocks, horizontal rules, tables, images, links and footnotes). The <> button shows the Markdown text to edit it by hand. save() returns Markdown; the File menu also downloads Word, text or PDF. To open a .md with all of Word’s tools, set format="word".

Content-Security-Policy

The PDF editor carries everything it needs (pdf.js, its fonts and character tables) and downloads it only when a PDF opens. Converting a PDF to Excel or PowerPoint downloads PDFium as WebAssembly (about 2 MB compressed), only when you convert. If your site sets a Content-Security-Policy:
  • Add blob: to worker-src for PDFs.
  • Add 'wasm-unsafe-eval' to script-src for PDF to Excel or PowerPoint.

Angular, Vue or plain JavaScript

Without React, use the <doconda-editor> tag. It works in Angular, Vue, Svelte and in a page with no framework:
  • Attributes: src, file-name, format, license-key, license-url, locale, preset, author, spell-lang, read-only and simple.
  • Other props: set them as an object on the options property, for example editor.options = { file, theme, collab }.
  • Events: doconda-ready, doconda-change, doconda-content-change (detail is { origin }), doconda-save (detail is the file’s bytes), doconda-dirty-change (detail is true or false) and doconda-error (detail is the error code).
  • Methods: editor.save(format?), editor.open(file, name) and editor.print(), as on the ref. They throw until doconda-ready fires. editor.editor gives the rest (run, actions, engine).
  • Dependencies: the tag brings its own React. If your package manager doesn’t install peer dependencies (Yarn), add react and react-dom 19 or later.
  • Angular: add CUSTOM_ELEMENTS_SCHEMA to the component’s schemas. Vue: mark the tag as a custom element with compilerOptions.isCustomElement: (tag) => tag === "doconda-editor".

Open from memory or with headers

If you already have the file (from an <input type="file"> or your API), pass it in file as a File, Blob, ArrayBuffer or Uint8Array. Put its name in fileName: the format comes from it.
If the link needs authentication, requestInit is passed as is to fetch:
If the file can’t be downloaded, onError receives editor_download_failed.

Save

Ask for the edited file through a ref:
save() returns a Uint8Array in the file’s own format. With a format, it exports: "png" is the current page. The ref also has open(file, name) (opens another file), replace(bytes) (replaces the document, also for everyone in the room), print(), contentVersion() (whether anything changed, without exporting), peers() (who is in the room), run(id) (presses a button by its ID), actions(), engine() (the engine, for advanced use), discard() (throws away the recovery copy; see below) and assistant (see AI assistant). To react when the user saves (Ctrl/Cmd+S or File → Save), pass onSave, which receives the file’s bytes. Without onSave, the editor saves to the file on the computer or downloads it.
onDirtyChange receives true when there are unsaved changes and false once they’re saved. Behavior to be aware of:
  • While editing, the editor keeps a recovery copy in this browser for 7 days. If the tab closes without saving, it offers to recover it next time. Set autosave={false} to turn it off. When the user chooses to throw their changes away, call discard() on the ref before closing the editor, so the copy isn’t offered later.
  • Closing or reloading the page with unsaved changes asks for confirmation. Set warnOnClose={false} to turn it off.
  • With collab or readOnly, no recovery copy is kept.

Save back to Doconda

To save the file over the same Doconda document, send it with the document’s revision to your server, and from there to PUT /documents/{id}/file. Doconda then makes its new PDF and change report.
If someone saved in between, the request fails with 409 revision_conflict instead of overwriting their changes.
Keep the API key on your server, never in the browser. Check there that the user may edit that document.

What it can do

The File menu downloads in other formats: Word to Markdown, text, EPUB, web page (.zip), PDF or PNG; Excel to CSV, PDF or PNG; PowerPoint and PDF to PDF or PNG (the current page, or every page in a .zip). What the editor can’t edit is saved as is: styles, charts, notes or parts of the file it doesn’t touch aren’t lost.

Comments

All four editors have threaded comments: select something, leave a comment, others reply, and it’s marked resolved. Comments are saved inside the file in Office’s format, so they show the same in Word, Excel, PowerPoint or a PDF reader, and come back when the file reopens in the editor. The comment toolbar button adds one, signed with author. Comments the file already has always show: removing comment from toolbar (see customize) only removes the add button.

Spelling and collaboration

  • Spelling: the editor ships no dictionaries. Pass a checker in spell: an object with check(words, lang) (one true or false per word) and suggest(word, lang), plus optional add(word, lang) for the user’s dictionary and languages() for the language picker. Any of them may return a promise; for example, wrap nspell with a Hunspell dictionary. Word and PowerPoint underline misspelled words and offer suggestions on right-click. spellLang is the language of text that doesn’t declare its own.
  • Real-time editing: with collab, several people edit the same document at once, on Doconda’s server (collab={{ token, user }}, included in the licence) or on yours (collab={{ url, user }}). See real-time co-editing.

Props

Next steps

Customize the editor

Colours, language, toolbar, your own buttons and the AI assistant.

Co-edit in real time

Several people on the same file, on Doconda’s server or yours.

Set up the licence

Plans, domains, assistant edits and errors.