Developer guide

Customize the Word editor

Configure the interface and connect application actions through public options. Build a custom Editor package when you need to change the source.

Start with Editor options

Install @onodocs/editor and use the embedding guide for the host, loading and cleanup. Omitting toolbar keeps the complete ribbon. A toolbar list selects the tool identifiers your workflow needs; toolbar: false hides it for a custom application interface.

Use fonts and styles to choose UI entries. A font name does not load a font file; configure document font resources separately. allowedModes limits the available interface modes, while your application enforces authorization. See EditorOptions.

Add an application action

import { createEditor } from "@onodocs/editor";

export function createWorkflowEditor(container: HTMLElement, submit: (bytes: Uint8Array) => Promise<void>, onError: (error: unknown) => void) {
  return createEditor({
    container,
    fonts: ["Arial", "Georgia", "Times New Roman"],
    allowedModes: ["view", "edit", "review"],
    onError,
    commands: [{
      id: "submitForReview",
      label: "Submit for review",
      modes: ["edit", "review"],
      ribbon: { tab: "Workflow", group: "Application" },
      async execute(editor) { await submit(await editor.save()); }
    }]
  });
}

Supply an empty host, an asynchronous submit(bytes) that acknowledges your application operation, and a visible error handler. Open a document with await editor.open(file, file.name) or create one with await editor.newDocument(). Dispose on unmount.

This adds a Workflow tab to the ordinary editor. The button captures the current DOCX; your callback decides where it goes. For autosave and dirty-state handling, use application sessions. If you restrict the toolbar, include custom command IDs in that list.

Typed example source. Use editor.execute(command) and editor.review(command) for edits with undo history. Direct document edits bypass that history.

Theme the interface

#editor {
  height: 80vh;
  min-height: 24rem;
  --onodocs-accent: #2557a7;
  --onodocs-background: #ffffff;
  --onodocs-toolbar-background: #f3f5f8;
  --onodocs-color: #202733;
}

Set inherited CSS properties on the editor host. Keep document formatting in the document APIs. Interface colors do not change the authored page colors or exported output. Check contrast, focus and narrow layouts after changing the theme.

Connect services and panels

writing accepts host proofing, rewriting and synonym callbacks. dictation connects a host speech provider. Only configured provider tools are exposed; the host controls when selected text leaves the device. Read Aloud uses available local voices.

Mount application panels beside the editor and connect them through its public selection, view and command APIs. The Agent integration uses this pattern. Keep the host empty for Editor to manage and dispose both the panel and editor when leaving.

Build from the public source

git clone https://github.com/onodocs/onodocs.git
cd onodocs
npm --prefix packages/editor run build

Use Node.js 22.18 or newer. The build installs its dependencies and prints the resulting archive path and installation command. It builds against published SDK/Canvas packages and keeps generated files outside the checkout.

For a maintained fork, choose your own package name and version, install its archive in your application, and update imports while preserving entry-point suffixes. See the source map and build instructions. Keep document work on exported SDK/Canvas APIs.

Keep the licensing boundary clear

MIT covers OnoDocs-authored Editor code and build files; preserve copyright and third-party notices. SDK and Canvas retain their own production and redistribution terms. A source fork does not change those dependencies’ licenses. See licensing.