Office.js compatibility

Compare the supported Word JavaScript API subset, known differences, and unavailable APIs.

@docx-editor.dev/editor-api implements a subset of the Word JavaScript API object model. You can reuse code based on objects such as Document, Body, Paragraph, and Range.

You must replace the Office host setup. You must also account for the differences on this page.

Compatibility matrix

Supported subset means that the listed objects and operations work. It does not mean that every Office.js member in that area works.

AreaStatusImplementedLimits
Batches and object lifecycleSupported subsetload(), sync(), context.trackedObjects, isNullObject, and null-object accessorsItem accessors need one extra sync(). Navigation expansion does not work.
Document and bodySupported subsetDocument.body, paragraphs, comments, revisions, sections, content controls, body text, styles, search, clear, and insertionThe package does not provide Office.onReady or Word.run.
Paragraphs and rangesSupported subsetRead text, insert or replace text, insert paragraphs, clear, delete, split, search, style, hyperlinks, and selectionThe API does not expose document-wide start or end offsets.
SearchPartialPlain-text search, matchCase, and matchWholeWordignorePunct, ignoreSpace, and matchWildcards compile but refuse true with NotSupported.
Font formattingPartialbold, italic, color, name, and sizeunderline and Office.js highlightColor do not exist. Mixed, unspecified, or inherited style values return null.
Paragraph formattingSupported subsetStyle, alignment, first-line indent, left indent, right indent, line spacing, space before, and space afterThe API exposes these values on Paragraph. It does not expose the full ParagraphFormat object.
ListsPartialList discovery, list paragraphs, levels, and paragraph insertionThe API does not expose list marker text, sibling indexes, or picture levels.
BookmarksPartialDiscover bookmarks, read names and ranges, and select bookmarksThe API does not support bookmark deletion or document-wide bookmark offsets.
Sections and page setupPartialSection bodies, headers, footers, page size, orientation, and marginsA missing header or footer returns ItemNotFound. A read never creates a part.
Footnotes and endnotesSupported subsetEnumerate notes, read note bodies and text, move to the next note, and delete notesUse document.footnotes and document.endnotes. These accessors differ from Office.js.
Comments and repliesPartialRead, create, reply, resolve, delete, and get the comment rangeWrites need an explicit author. Browser writes also need the Pro review module and an editable document. Comment body replacement does not work.
Tracked changesPartialRead actionable revisions, get their ranges, and accept or reject one revision or all revisionsThe collection omits unsupported structural revision types. A collection-wide decision refuses the full batch if unsupported markup remains.
Content controlsPartialCommon properties, nested controls, lookup by id, tag, or title, text insertion, deletion, ranges, and typed value writesThe API does not expose typed Office.js subtype objects. Writes to custom XML-bound controls refuse.
HyperlinksPartialRead or write Range.hyperlinkStandalone Hyperlink and HyperlinkCollection objects do not exist.
TablesUnavailableThe editor can display tablesThe editing API does not expose Table, TableCollection, or TableCell.
Images and shapesUnavailableThe editor can display supported document graphicsThe editing API does not expose InlinePicture, picture list levels, Shape, or canvases.

Differences that affect existing code

Office.js behaviorDocxEditor behaviorRequired change
Office.onReady and Word.run open a batch.Your application creates a server or browser runtime.Use DocxEditor.createServer(bytes) or DocxEditor.createBrowser(editor).
An item accessor returns a usable proxy immediately.getFirst(), getLast(), and null-object forms resolve after sync().Add one sync() before you load or change the returned object.
A collection can load item properties with paths such as items/text.A collection loads its items only.Load the collection, sync, load each item, then sync again.
LoadQueryOptions.expand loads navigation properties.A non-empty expand value throws InvalidArgument.Load each navigation object or collection directly.
sync() can return a pass-through value.sync() returns Promise<void>.Keep pass-through values in local state.
The Office host supplies the signed-in comment author.DocxEditor has no ambient account identity.Pass { author } when you create the runtime.
Comment and revision dates have the Date type.Invalid or missing file dates return null.Narrow the nullable Date before you use it.
Font reads use concrete values.Mixed, unspecified, or inherited style values return null.Narrow the value before you reuse it in a write.
Range.select() runs inside Word.Selection needs an attached browser editor.Check runtime.capabilities.selection. A server runtime returns NotSupported.
Header and footer getters can create missing parts.Getters only return existing or inherited parts.Handle ItemNotFound when no part exists.
ContentControl.id is a number.ContentControl.id is a string because DOCX ids can be missing or repeated.Do not use the file id as a unique numeric key.
ContentControl.subtype uses Word interface terms.ContentControl.subtype uses DOCX control terms.Handle values such as plainText, dropDownList, and checkbox.

The extra item-accessor sync looks like this:

const results = context.document.body.search('Total');
await context.sync();

const first = results.getFirst();
await context.sync();

first.insertText('TOTAL', 'Replace');
await context.sync();

Common DocxEditor additions

These common members extend the Office.js-shaped subset.

MemberPurpose
Body.bookmarksEnumerates bookmarks in one body story.
Body.revisionsEnumerates revisions in one body story.
Document.footnotes and Document.endnotesEnumerate document notes.
NoteItem.textReads the same plain text as note.body.text.
ContentControlCollection.getByTag() and getByTitle()Finds controls without a file id.
ContentControl.setValue()Writes values for text, checkbox, date, and list controls.
ContentControl.isBoundReports whether custom XML binding exists.
ContentControl.subtypeReports the control type with DOCX terms.
Comment.text and CommentReply.textRead comment text without replacing the comment body.
Paragraph.uniqueLocalIdReads the paragraph identity for the active runtime.

Body.bookmarks and Body.revisions only cover that body's story. They do not combine the main body, headers, footers, and notes.

ContentControl.isBound is a preflight check. sync() checks the binding again before it applies a write.

APIs that do not exist

Code that uses these APIs fails during TypeScript compilation.

APIAvailable alternative
Table, TableCollection, TableCellNo editing API alternative.
InlinePicture, picture list levelsNo editing API alternative.
Shape and canvasesNo editing API alternative.
Repeating-section and picture content-control objectsUse common ContentControl members for other control kinds.
ContentControl.xmlMappingUse ContentControl.isBound to detect a binding. Bound writes still refuse.
Hyperlink, HyperlinkCollectionUse Range.hyperlink for one range.
Body.getHtml(), Body.getOoxml(), Paragraph.getText()Load Body.text or Paragraph.text. No OOXML or HTML result exists.
BookmarkCollection.exists()Load the collection and inspect its items.
Font.underline, Office.js Font.highlightColorNo editing API alternative.
Range.start, Range.end, Bookmark.start, Bookmark.endUse ranges and paragraph text.

Migrate an add-in

  1. Replace Word.run() with a runtime from DocxEditor.createServer() or DocxEditor.createBrowser().
  2. Keep the existing load() and sync() pattern.
  3. Add the extra syncs listed in Differences that affect existing code.
  4. Check the compatibility matrix for every object your add-in uses.
  5. Handle typed refusals such as NotSupported, NotImplemented, and ItemNotFound.

How compatibility is checked

The repository keeps a reviewed manifest of supported Word API symbols. CI compares the authored TypeScript declarations with a pinned @types/office-js reference. CI also compiles representative Word code against the DocxEditor declarations.

The package does not include Microsoft's declarations. Installation, tests, and builds do not fetch them.

Next steps

On this page