Word JS API Parity (Office.js for the Web)
Microsoft Word JS API (Office.js) parity for React. Same Range, comments, search, tracked changes verbs. Parity enforced at compile time.
The bridge mirrors a documented subset of the Microsoft Word JS API (Office.js). Parity is enforced at compile time via the exported WordCompatBridge interface: if EditorBridge drifts from the contract, typecheck fails.
The result is a familiar surface for anyone migrating from a Word add-in. Most call sites map one-to-one.
Mapping
| Microsoft Word JS API | Agent API equivalent |
|---|---|
Range (stable handle) | paraId: string |
body.search(text) → Ranges | findText(query, opts) → FoundMatch[] |
range.insertComment(text) | addComment({ paraId, text, search? }) |
comment.reply(text) | replyTo(commentId, { text }) |
comment.resolved = true | resolveComment(commentId) |
range.insertText(text, location) | proposeChange({ paraId, search, replaceWith }) (three modes via empty-string semantics) |
document.getSelection() | getSelection() → SelectionInfo | null |
range.scrollIntoView() | scrollTo(paraId) |
commentCollection.getItems() | getComments(filter?) |
body.paragraphs.getItems() | getContent(opts?) |
document.body.text | getContentAsText(opts?) |
revisionCollection.getItems() | getChanges(filter?) |
Document.onContentChanged.add(...) | onContentChange(listener) |
Document.onSelectionChanged.add(...) | onSelectionChange(listener) |
Intentional differences
- Tracked changes are always suggestions. The human keeps the final accept/reject.
Range.context.sync()is unnecessary. Every call is one PM transaction.Rangeis a plain{ paraId, search? }JSON value, so it survivesJSON.stringifyand works for tool calls and MCP transports. Office.jsRangeis stateful and tied to a singleRequestContext.
The compile-time contract
WordCompatBridge is exported from the package root. EditorBridge is asserted to satisfy it. Drop or rename a method that's part of the public Word API mirror and tsc fails the build of the package itself.
import type { WordCompatBridge } from '@eigenpal/docx-editor-agents';
import type { EditorBridge } from '@eigenpal/docx-editor-agents/bridge';
// Internal to the package; users don't write this themselves:
const _check: WordCompatBridge = {} as EditorBridge;The contract documents the public surface; the WordCompatBridge JSDoc is the canonical reference for what's mirrored, what's intentionally different, and what's deliberately out of scope (formatting verbs like Range.font.bold, paragraph creation, table mutation, headers/footers, customXmlParts).
Microsoft Word add-in alternative
Teams maintaining a Microsoft Word add-in often want the same review or copilot experience on the web without forcing users into Word. The agent toolkit is the migration path: the verbs match, tracked changes round-trip, and the rendered editor lives in a React app you already deploy.
Related
- Tool catalog: the fourteen tools whose surfaces this parity contract describes.
- Live editor: use the parity verbs against a running
<DocxEditor>. - Headless
DocxReviewer: same verbs, server-side. - Bring your own agent: wire any LLM provider to the parity surface.