@docx-editor.dev/editor-api

v2.36.0 · 3 published subpaths with full TypeScript signatures and JSDoc.

Live agent demo

Describe a document. The agent drafts it through the live editor API, then proposes later edits as tracked changes. For the walkthrough, see Build a DOCX agent.

Subpaths

Package root

Work is described against proxy objects and nothing reaches the document until context.sync(), which sends one ordered batch and either applies all of it or none of it. Reading a property nobody asked for is an error rather than a silent undefined.

This entry needs no browser. It opens DOCX bytes, drives them, and saves them back, so a server, a worker or a build script can import the package name and get the whole API.

Functions (4)

getReviewItemRangefunctionSource ↗

The range a review item covers, by the key the editor's review queue gives it.

Pass the key of an item from editor.getReviewItems() or useReview().items. A tracked change resolves to the characters it covers. A paired replacement key resolves to one range over both its deletion and its insertion. A comment or reply resolves to the range its thread is anchored to. The range is a snapshot like any other.

To act on the card's own change, use [getReviewItemRevisions](getReviewItemRevisions). [Range.revisions](Range.revisions) on this range also lists nested or adjacent changes that the range overlaps.

A key that names nothing in the document, such as one whose change was already accepted, or a comment with no anchor in the document, fails the sync with ItemNotFound. Use [getReviewItemRangeOrNullObject](getReviewItemRangeOrNullObject) to test for that instead. A custom node's key refuses with NotSupported at the call.

This is a DocxEditor addition. Office.js has no review queue and no key for a revision.

declare function getReviewItemRange(context: RequestContext, key: string): Range;
Read the words a comment card is about 


```ts
import { getReviewItemRange } from '@docx-editor.dev/editor-api/browser';

const key = item.key; // From useReview().items or editor.getReviewItems().
const text = await runtime.run(async (context) => {
  const range = getReviewItemRange(context, key);
  range.load('text');
  await context.sync();
  return range.text;
});
```

getReviewItemRangeOrNullObjectfunctionSource ↗

The range a review item covers, or a null object when the key names nothing.

The same lookup as [getReviewItemRange](getReviewItemRange). A key that names nothing in the document answers a range whose isNullObject is true after the sync, instead of failing it.

This is a DocxEditor addition. Office.js has no review queue and no key for a revision.

declare function getReviewItemRangeOrNullObject(context: RequestContext, key: string): Range;
Skip a card whose change another reviewer already resolved 


```ts
import { getReviewItemRangeOrNullObject } from '@docx-editor.dev/editor-api/browser';

const key = item.key; // From useReview().items or editor.getReviewItems().
await runtime.run(async (context) => {
  const range = getReviewItemRangeOrNullObject(context, key);
  range.load('text');
  await context.sync();

  if (range.isNullObject) return;
  console.log(range.text);
});
```

getReviewItemRevisionsfunctionSource ↗

The tracked changes a review card stands for, by the key the editor's review queue gives it.

Pass the key of a revision item from editor.getReviewItems() or useReview().items. The collection holds that change only, or the deletion and the insertion of a paired replacement. Unlike [Range.revisions](Range.revisions) on the card's range, it never holds a nested or adjacent change by another author.

A key that names nothing in the document, such as one whose change was already resolved, loads an empty collection, and acceptAll() or rejectAll() on it refuses with InvalidObjectPath. A comment or custom node key refuses with NotSupported at the call. resolve() and setAuthor() refuse with NotSupported on this collection.

This is a DocxEditor addition. Office.js has no review queue and no key for a revision.

declare function getReviewItemRevisions(context: RequestContext, key: string): RevisionCollection;
Accept the change a review card shows 


```ts
import { getReviewItemRevisions } from '@docx-editor.dev/editor-api/browser';

const key = item.key; // From useReview().items or editor.getReviewItems().
await runtime.run(async (context) => {
  getReviewItemRevisions(context, key).acceptAll();
  await context.sync();
});
```

isDocxEditorErrorfunctionSource ↗

Whether a caught value is one of ours.

By name as well as by instanceof: a consumer can end up with two copies of this module (a bundle plus a dependency's), and an instanceof that fails across them would send a perfectly ordinary PropertyNotLoaded down a consumer's unexpected-error path.

declare function isDocxEditorError(value: unknown): value is DocxEditorError;

Classes (45)

Body_2class

A story: the main body of a document, a header or footer variant, or a note's body — and everything in it in reading order.

Its paragraphs are the DOCUMENT'S, not just the top level's. A paragraph inside a table cell, or inside a table inside a cell, or inside a block-level content control, is an ordinary editable paragraph and appears here, exactly as it does in Word's own paragraph collection. A collection listing only direct children would describe a smaller document than the one on screen.

[Body.clear](Body.clear) leaves one empty paragraph, matching what Word produces when a reader selects everything and deletes. A body that already holds no paragraph reports InvalidArgument rather than inventing a block.

declare class Body extends ModelObject
MemberTypeSummary
bookmarksBookmarkCollectionEvery bookmark declared in this story, in document order.
clearEmpty the story, leaving one empty paragraph behind.
contentControlsContentControlCollectionThe content controls this story holds, in document order — the OUTERMOST ones.
endnotesNoteItemCollectionEndnotes referenced within this body, in reference order.
fieldsFieldCollectionFields within this body.
fontFontThe character formatting of the whole story: what all of it agrees on, and what a write sets.
footnotesNoteItemCollectionFootnotes referenced within this body, in reference order.
getCommentsThe comments anchored in this story, in document order. Replies hang off the comment.
getRangeThe whole body or one edge. Await sync before addressing the returned range.
inlinePicturesInlinePictureCollectionInline pictures within this body.
insertParagraphAdd a paragraph at the start or the end of the story. Answers the new paragraph. You can load the returned paragraph in the same sync. Editing it needs a sync first.
insertTableInsert a rectangular table at the start or the end of this body. TrackMineOnly marks rows, cell marks, and values inserted, as `Range.insertTable` does. Sync before configuring the returned table. A table inside a table cell refuses.
insertTextWrite text over the whole story, or at either edge of it. Answers the text's own range.
listsListCollectionEvery list this story holds, in the order their numbers first appear.
paragraphsParagraphCollectionEvery paragraph in this story in reading order, at every depth.
revisionsRevisionCollectionThe tracked changes in this story that this API can publish as typed objects, in document order.
shapesShapeCollectionFloating and inline shapes in this body, such as text boxes and pictures.
stylestringThe paragraph style, by the name a reader sees in the styles gallery.
tablesTableCollectionTop-level tables within this body or table cell.
textstringThe whole story's text.

BookmarkclassSource ↗

A name a document gives to a stretch of itself.

A bookmark IS its name. OOXML writes it as a pair of markers around the text, and the name is the only thing identifying it — so this object is a name plus the range those markers currently enclose. A bookmark whose markers left with the text they surrounded refuses rather than answering where they used to be.

start and end are absent by design: they are document-wide character offsets, the coordinate space this API does not maintain.

declare class Bookmark extends ModelObject implements PromisedItem
MemberTypeSummary
deleteDelete this bookmark. The text it marks stays.
namestringThe name the document declares this bookmark with.
rangeRangeThe text the bookmark's markers enclose.
selectPut the reader's selection on the bookmark and navigate the editor viewport to it.

BookmarkCollectionclassSource ↗

The bookmarks of a story or a range, as of the batch that loaded them.

Like every collection here, items is the LOADED answer rather than a live view: bookmarks added after the load are not in it, and reaching them means loading again.

declare class BookmarkCollection extends HandleCollection<Bookmark>

ClientObjectclassSource ↗

The base every document proxy extends.

A proxy is three things and no more: the context it belongs to, the path that says whether it can be addressed, and the properties a completed load filled in.

A RELEASED proxy still answers what it already knew. Reading a property loaded before the run ended is served from memory, because that value is a copy the consumer already holds — it is not a reach into a document. Anything that would talk to the document (load, a write, a method) refuses with InvalidObjectPath. The line is "does this need the document", not "does this look like a read".

declare abstract class ClientObject implements RuntimeManagedObject
MemberTypeSummary
(constructor)Constructs a new instance of the `ClientObject` class
contextRequestContextThe context this object currently belongs to.
handleThe handle to address this object with, or `InvalidObjectPath`.
isNullObjectbooleanWhether this object turned out not to exist.
loadQueue the reads that fill in the selected properties.
onLoadWhat this kind of object does with a resolved load request.
requireAddressableThe check every call that talks to the document makes first.
requireUsablePathPermit queued read dependencies and optional scalar loads; refuse released proxies.

ClientResultclassSource ↗

A value a queued method promised to produce, readable after the next sync().

Deliberately not a Promise. A method call inside a batch has not been sent yet, so there is no pending work to await and nothing that could resolve on its own — awaiting one would deadlock a consumer who then never calls sync(). A result is a box that stays EMPTY until the sync fills it, and reading it early is ValueNotLoaded rather than undefined flowing onwards into something that misinterprets it.

RevisionCollection.resolve returns a ClientResult with the resolved and skipped decisions.

declare class ClientResult<T>

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the ClientResult class.

MemberTypeSummary
isLoadedbooleanWhether the sync that fills this has happened.
valueTThe value, once a `sync()` has filled it in.

Comment_2class

A comment: a conversation about a stretch of the document, not a single remark.

[Comment.replies](Comment.replies) holds the answers, and resolving is a property of the whole thread — assigning resolved marks this comment and everything answering it, which is what Word's own pane does.

authorEmail and a writable content are absent: CT_Comment records only an author and initials (Word's addresses live in people.xml, which this API does not read), and a body rewrite is not an operation the canonical write path offers. The comment's text is published as text.

declare class Comment extends CommentBase
MemberTypeSummary
getRangeThe words the comment is about.
repliesCommentReplyCollectionThe answers to this comment, in document order.
replyAnswer the comment, over the same words it is anchored to.
resolvedbooleanWhether the thread is resolved.

CommentCollectionclassSource ↗

The comments on a document, story or range, as of the batch that loaded them.

declare class CommentCollection extends HandleCollection<Comment>
MemberTypeSummary
getFirstThe first comment. `ItemNotFound` at the sync if there are none.

CommentReplyclassSource ↗

One answer in a comment thread.

Authored over the parent comment's own range, because that is where the conversation is anchored and OOXML gives a reply no other place to be. Resolving is a property of the whole thread rather than of any one reply — see [Comment.resolved](Comment.resolved).

declare class CommentReply extends CommentBase

CommentReplyCollectionclassSource ↗

The replies to one comment, in thread order, as of the batch that loaded them.

declare class CommentReplyCollection extends HandleCollection<CommentReply>
MemberTypeSummary
getFirstThe first reply. `ItemNotFound` at the sync if nobody answered.

ContentControlclassSource ↗

A part of a document a template marked as a field.

A control is NOT its w:id. The attribute is optional in OOXML and unique nowhere, so a document may hold one control with no id and two with the same one. This object is addressed by an opaque host-minted handle instead, and [ContentControl.id](ContentControl.id) is answered as METADATA — a label the file wrote, empty where it wrote none. getById still exists, because a template author knows their own numbering, and it answers the first match in document order rather than refusing.

A control's contents are not its value. text reads the characters; setValue writes in the vocabulary the control's own type accepts — a declared item for a dropdown, an ISO date for a date picker, a state for a checkbox — because writing "true" into a checkbox's runs would produce a document whose glyph and whose w14:checked disagree.

declare class ContentControl extends ModelObject implements PromisedItem
MemberTypeSummary
cannotDeletebooleanWhether the control refuses to be deleted.
cannotEditbooleanWhether the control's contents refuse to be edited. Resolved like `cannotDelete`.
contentControlsContentControlCollectionThe controls INSIDE this one, in document order.
deleteRemove the control.
getRangeThe stretch of the story the control's content covers.
idstringThe `w:id` the file wrote, as a string, and `''` where it wrote none.
insertTextPut text into the control: over what it holds, or at one end of it. Supports text-like controls. Date, checkbox, and other typed controls refuse with NotSupported.
isBoundbooleanWhether the control currently declares an OOXML data binding.
paragraphsParagraphCollectionThe paragraphs the control holds. Empty for an inline control, which holds none.
placeholderShownbooleanWhether the control is showing its prompt rather than a value (`w:showingPlcHdr`).
setValueWrite the control's value.
subtypestringWhat kind of control it is: `plainText`, `dropDownList`, `checkbox`, `date`, …
tagstring`w:tag` — the machine-readable label a template puts on a field. `''` where absent.
temporarybooleanWhether the control removes its own wrapper on the first content edit (`w:temporary`).
textstringThe characters the control encloses, as the document reads them.
titlestring`w:alias` — what Word's UI calls the control's title. `''` where absent.

ContentControlCollectionclassSource ↗

The content controls of a document, story or range, as of the batch that loaded them.

getById answers the first match in document order, because w:id is optional in OOXML and unique nowhere — see [ContentControl](ContentControl) for why choosing predictably beats refusing.

declare class ContentControlCollection extends HandleCollection<ContentControl>
MemberTypeSummary
getByIdThe first control carrying one `w:id`, or `ItemNotFound` where the scope holds none.
getByTagEvery control in the scope carrying one tag, in document order.
getByTitleEvery control in the scope carrying one title, in document order.
getFirstThe first control. `ItemNotFound` at the sync if the scope holds none.
getFirstOrNullObjectThe first control, or an object that says `isNullObject` where there is none.

Document_2class

The document: the root every other object is reached from.

Deliberately thin. A document here is not a bag of content — it is the thing that HAS stories. It publishes the main story as [Document.body](Document.body), plus that story's paragraphs directly as document.paragraphs, because that is how source-compatible code walks a document.

Reached once per [RequestContext](RequestContext) and memoized: context.document is the same object every time, so a property loaded through one reference reads back through any other.

declare class Document extends ModelObject
```ts
await runtime.run(async (context) => {
  const paragraphs = context.document.paragraphs;
  paragraphs.load('items');
  await context.sync();

  for (const paragraph of paragraphs.items) paragraph.load('text');
  await context.sync();

  for (const paragraph of paragraphs.items) console.log(paragraph.text);
});
```


 The first sync retrieves the collection's items. Once those items are available, the second sync retrieves each paragraph's text.
MemberTypeSummary
bodyBodyThe main story.
changeTrackingModeChangeTrackingMode | 'Off' | 'TrackAll' | 'TrackMineOnly'Tracking for this automation runtime. Load 'changeTrackingMode' explicitly before reading. Document.load() keeps an empty default property set across hosts. Assignments take effect at sync. TrackMineOnly tracks this runtime's inline text edits using its configured author. TrackAll is unsupported. Browser tracked writes require the review module; this setting does not change the editor UI mode. Unsupported tracked mutation kinds refuse; the setting is session-local and is not saved as a document-wide policy.
commentsCommentCollectionThe comments anchored in the main story, in document order.
compareRefuses with `NotSupported` at the sync: the document model has no file system. Read the file yourself and call [Document.compareFromBase64](Document.compareFromBase64).
compareFromBase64Compare this document (the original) with the revised document in `base64File`, and record the differences as tracked changes in this document.
contentControlsContentControlCollectionThe content controls of the main story, in document order — the outermost ones.
deleteBookmarkDelete the bookmark with this name, compared without case, from whichever story declares it. The text stays. A name no bookmark has changes nothing.
endnotesNoteItemCollectionThe document's endnotes, in the order its notes part writes them.
footnotesNoteItemCollectionThe document's footnotes, in the order its notes part writes them.
getBookmarkRangeThe range of the bookmark with this name, compared without case. The main text is searched first, then headers, footers and notes. `ItemNotFound` at the sync when no bookmark has the name.
getBookmarkRangeOrNullObjectLike [Document.getBookmarkRange](Document.getBookmarkRange), but a missing bookmark answers a null object.
getStylesThe styles the document defines, of every kind, in the order its styles part writes them. Each call answers a new collection; load it before reading `items`.
paragraphsParagraphCollectionThe main story's paragraphs, in reading order.
propertiesDocumentPropertiesCore document metadata. Reads require load; writes commit at sync.
removeDocumentInformationRemove standard core, extended, and custom document-property parts in one sync. Only DocumentProperties is supported. Tracking and collaboration refuse with NotSupported. This command must be the only write in its sync. It does not anonymize document content.
removeDocumentInformation
revisionsRevisionCollectionThe tracked changes of the main-body story that this API can publish as typed objects.
sectionsSectionCollectionThe document's sections, in document order.

DocumentPropertiesclassSource ↗

Core document properties. Load explicit names before reads; assignments commit at sync. Values are XML-safe strings of at most 4096 characters. Tracked writes are unsupported. Individual dates and custom properties are unsupported. Document.removeDocumentInformation can remove property parts. Collaborative writes require an existing core-properties part. Create properties before joining collaboration when the input omits that part.

declare class DocumentProperties extends ModelObject
MemberTypeSummary
authorstringDocument author metadata, separate from the revision author. Load before reading; assign before sync.
categorystringDocument category metadata. Load before reading; assign before sync.
commentsstringDocument description metadata, separate from review comments. Load before reading; assign before sync.
keywordsstringDocument search keywords. Load before reading; assign before sync.
lastAuthorstringLast saved author, from cp:lastModifiedBy. Load before reading.
onLoad
subjectstringDocument subject metadata. Load before reading; assign before sync.
titlestringDocument title metadata. Load before reading; assign before sync.

DocxEditorErrorclassSource ↗

Every refusal this runtime throws.

Branch on [DocxEditorError.code](DocxEditorError.code), never on the message. Codes are stable public API — added rather than repurposed — so a consumer that handles PropertyNotLoaded by loading and syncing again keeps working across versions.

Nothing from the engine appears in the message. Host rejection reasons, opaque handle refs and offset ranges are all withheld: a ref in a message is a name a consumer can start depending on, and a store's rejection reason would become a documented one the moment somebody matched on it. What a consumer gets instead is a stable code, a fixed sentence, and target — the consumer-facing path they wrote themselves.

declare class DocxEditorError extends Error
```ts
try {
  await context.sync();
} catch (error) {
  if (isDocxEditorError(error) && error.code === 'StaleDocument') {
    // Re-read, re-anchor, and reconsider: someone else changed the document first.
  }
}
```
MemberTypeSummary
(constructor)Constructs a new instance of the `DocxEditorError` class
actualRevision?numberFor `StaleDocument`: the revision the document was actually at.
codeDocxEditorErrorCodeWhich refusal this is. Stable across versions; the thing to branch on.
debugInfoDocxEditorDebugInfoDebug details, as Office.js `OfficeExtension.Error.debugInfo` has them. `innerError` names the engine's reason with a stable diagnostic code and a fixed hint, when there is one.
expectedRevision?numberFor `StaleDocument`: the revision the context had last read at, when the refused batch wrote. Absent for a batch that only read, on every host.
limit?DocxEditorErrorInit['limit']For `ResourceLimitExceeded`: the resource limit that prevented opening.
target?stringConsumer-facing path of the object or property involved, when there is one to name.

FieldclassSource ↗

An inert Word field. Code writes and evaluation support PAGE and NUMPAGES. A field inside a pending tracked insertion reads, but refuses code writes and updateResult until accepted. Its cached result reads and writes through [Field.result](Field.result).

declare class Field extends ModelObject implements PromisedItem
MemberTypeSummary
codestring
deleteRemove this field, including its cached result. Other fields remain inert and unchanged.
onLoad
resultRangeThe field's cached result, as a range. Two members work on it: `text` (with `load('text')`, or `field.load('result')`) reads the result, and `insertText(text, 'Replace')` replaces it with plain text and marks the field `w:dirty`, so a reader that evaluates fields recomputes it. The instruction never changes and is never evaluated. Untracked, the field must sit outside every revision. With `TrackMineOnly`, the field must be your own pending insertion, and the result joins it. Every other range member, and every other insert location, refuses with `NotImplemented` and `edit.field-result-unsupported`.
updateResultCompute a cached result using actual host pagination. Missing pagination refuses explicitly.

FieldCollectionclassSource ↗

Fields contained within a body or range.

declare class FieldCollection extends ItemCollection<Field>
MemberTypeSummary
addressAt
getFirst
getFirstOrNullObject
getLast
getLastOrNullObject
itemAt
listing
promised
size

FontclassSource ↗

The character formatting of whatever it belongs to: a story, a stretch of one, or a paragraph.

A font has no identity of its own — it is a view onto its owner's characters and shares its owner's path, so a font reached from a deleted paragraph's range refuses at the same moment the range does rather than holding a stale address.

Reading is AGREEMENT, and null means "no agreed value": every run the owner covers says bold, or the answer is null. Null is also the answer when nothing in range authors the property at all. Both are one answer on purpose, because this API reads what the document AUTHORS rather than what the style cascade computes — a heading whose bold comes from styles.xml reads null. Answering the cascade would let a caller read an inherited value, write it straight back, and silently freeze it into the paragraph as if the author had chosen it.

Assignments within one sync() are ONE write: font.bold = true; font.size = 12 accumulates into a single run-property operation. That is required, not an optimisation — a run-property write carries the run's whole property bag, so a second write planned from the same pre-batch tree would carry a bag the first had already superseded, which the host refuses with ConflictingChanges.

declare class Font extends ModelObject
MemberTypeSummary
boldboolean | nullWhether every character agrees it is bold, or `null` where they do not.
colorstring | null`#RRGGBB`. `null` where the characters disagree, or where the colour is `auto`.
highlightColorstring | nullExact Word palette color, returned as #RRGGBB. Null clears highlighting.
italicboolean | nullWhether every run in range is italic. `null` where they disagree or none says.
namestring | nullThe typeface name the characters state, or `null` where they do not agree on one.
onLoadOne read for every property asked for.
sizenumber | nullPoints.
strikeThroughboolean | null
subscriptboolean | null
superscriptboolean | null
underlinestring | nullOffice underline styles. Mixed, Hidden, and DotLine refuse at sync.

InlinePictureclassSource ↗

An inline PNG or JPEG picture. Measurements use points.

declare class InlinePicture extends ModelObject implements PromisedItem
MemberTypeSummary
altTextDescriptionstring
deleteDelete this picture. Shared media relationships remain preserved.
heightnumber
lockAspectRatioboolean
onLoad
widthnumber

InlinePictureCollectionclassSource ↗

Inline pictures within a body or range. Load items before enumeration.

declare class InlinePictureCollection extends ItemCollection<InlinePicture>
MemberTypeSummary
addressAt
getFirst
getFirstOrNullObject
getLast
getLastOrNullObject
itemAt
listing
promised
size

ListclassSource ↗

A list: the set of paragraphs sharing one numbering id.

A list is not an ELEMENT. OOXML has no list — it has paragraphs that each name a w:numId, and a list is the set that name the same one. So [List.id](List.id) is that number, [List.paragraphs](List.paragraphs) is the set, and a list exists exactly as long as some paragraph is still in it.

declare class List extends ModelObject implements PromisedItem
MemberTypeSummary
getLevelParagraphsThe list's paragraphs at one level, in reading order.
idnumberThe `w:numId` the list's paragraphs share — the document's own identity for the list.
insertParagraphAdd a numbered paragraph to the list, at its start or its end.
paragraphsParagraphCollectionEvery paragraph in the list, in reading order.
setLevelBulletSet a level's bullet glyph. Custom bullets require a Unicode character code.
setLevelBullet
setLevelIndentsSet text indent and relative first-line indent in points. Negative relative values create hanging indents.
setLevelNumberingSet decimal, letter, Roman, or unnumbered markers. Numeric format entries identify zero-based levels.
setLevelNumbering
setLevelStartingNumberSet the starting counter for this list instance without changing other lists.

ListCollectionclassSource ↗

The lists in a story, as of the batch that loaded them.

declare class ListCollection extends HandleCollection<List>
MemberTypeSummary
getByIdThe list with one `w:numId`, or `ItemNotFound` where the story has none.
getFirstThe first list. `ItemNotFound` at the sync if the story has none.

ListItemclassSource ↗

A paragraph's membership of a list: which list, and at what level.

listString (the "3." or "iv)" a reader sees) and siblingIndex are absent because they are PAINTED, not authored — computed during layout by a counter that walks the story applying numbering.xml, its abstract-numbering indirection, restarts and overrides. Answering them here would mean a second counter that disagrees with the one on screen the first time a document overrides a level.

declare class ListItem extends ModelObject
MemberTypeSummary
levelnumberHow deeply the item is nested: zero for a top-level item, up to eight.

NoteItemclassSource ↗

One footnote or endnote: text that belongs to the document but not to its flow.

A note IS a story. Its [NoteItem.body](NoteItem.body) is an ordinary [Body](Body) — paragraphs, formatting, styles, the same operations — laid out at the foot of a page or the end of the document rather than in the column, so everything the object model can do to the main story it can do to a note without a second vocabulary.

delete() removes the reference too. A note's body and the citation that reached it are one thing to a reader, and deleting the body alone would leave a mark pointing at nothing. The engine spells that as a package-level transaction, which is why it travels alone in its batch.

declare class NoteItem extends ModelObject implements PromisedItem
MemberTypeSummary
bodyBodyThe note's own story.
deleteRemove the note and every reference to it.
getNextThe next note of the same kind. `ItemNotFound` at the sync when this is the last one.
textstringThe note's plain text.
typeNoteItemTypeWhether this is a footnote or an endnote.

NoteItemCollectionclassSource ↗

The notes of one kind, in the order the notes part writes them.

DocxEditor's own collection type: the pinned reference fixture does not carry Word.NoteItemCollection, so it is not measured for conformance — recorded as an omission in compat/manifest.json — while NoteItem itself is. Without it a note would be unreachable, which is the one thing worse than an unmeasured collection.

declare class NoteItemCollection extends HandleCollection<NoteItem>
MemberTypeSummary
getFirstThe first note. `ItemNotFound` at the sync if the document has none of this kind.

PageSetupclassSource ↗

The page a section is laid out on: paper size, margins, and orientation.

This is w:sectPr — everything a caller usually wants from a section lives here rather than on [Section](Section) itself, which is mostly navigation.

declare class PageSetup extends ModelObject
MemberTypeSummary
bottomMarginnumberPoints.
leftMarginnumberPoints.
orientationPageOrientation | 'Portrait' | 'Landscape'Which way round the page is.
pageHeightnumberPoints.
pageWidthnumberPoints.
rightMarginnumberPoints.
topMarginnumberPoints.

ParagraphclassSource ↗

One paragraph: what it says, what it is, and the ways it can be changed.

Identity is the document's own. [Paragraph.uniqueLocalId](Paragraph.uniqueLocalId) is the w14:paraId the file carries — the value Word writes, and the one commentsExtended.xml and coauthoring merges already anchor to — never a position in a collection. Deleting the paragraph above this one does not change it, which is the point: an agent that read a document, thought about it, and now wants to write to "the paragraph I was looking at" cannot express that with an index. A paragraph the file gave no id gets one deterministically at open, so the same bytes always answer the same identities and saving writes them back.

A structural edit owns its paragraph for the batch: delete(), split() and insertParagraph() change what offsets mean, so a second call in the same sync() that also touches this paragraph is refused with ConflictingChanges rather than planned against coordinates that have stopped describing it. Two syncs get both edits, each exactly as asked.

declare class Paragraph extends ModelObject implements PromisedItem
MemberTypeSummary
alignmentParagraphAlignmentHow the paragraph's lines are aligned, or `Unknown` where it authors no alignment.
attachToListJoin an existing list at a zero-based nesting level.
clearEmpty this paragraph's text, leaving the paragraph itself where it is.
contentControlsContentControlCollectionThe content controls in this paragraph, in document order, at any nesting depth.
deleteRemove this paragraph and everything in it.
detachFromListRemove numbering while preserving the paragraph's text and other formatting.
firstLineIndentnumberPoints. Negative for a hanging indent — the first line starting left of the rest.
fontFontThe character formatting of this paragraph's characters, and of its paragraph mark.
getRangeAddress this paragraph's content or an endpoint. Sync before using the returned range.
getReviewedTextThis paragraph's text as if every pending tracked change were accepted (`Current`, the default) or rejected (`Original`). The document does not change.
getReviewedTextThis paragraph's text as if every pending tracked change were accepted (`Current`, the default) or rejected (`Original`). The document does not change.
getTextRangesSplit this paragraph into ranges that each end after one of `endingMarks`, such as `[' ']` for words. Takes the same arguments and follows the same rules as `Range.getTextRanges`.
insertParagraphAdd a paragraph beside this one. Answers the new paragraph. You can load the returned paragraph in the same sync. Editing it needs a sync first.
insertTableInsert a rectangular table before or after this paragraph. TrackMineOnly marks rows, cell marks, and values inserted, as `Range.insertTable` does. Sync before configuring the returned table. A table inside a table cell refuses.
insertTextWrite text over this paragraph or at either edge of it. Answers the written text's range.
leftIndentnumberPoints.
lineSpacingnumberPoints between the paragraph's lines.
listListThe list this paragraph is in.
listItemListItemWhere this paragraph sits in its list. Reading `level` on a paragraph in none refuses.
readingOrderParagraphReadingOrderThe direction the paragraph reads in: `LeftToRight` or `RightToLeft`.
rightIndentnumberPoints.
shapesShapeCollectionFloating and inline shapes in this paragraph, such as text boxes and pictures.
spaceAfternumberPoints below the paragraph.
spaceBeforenumberPoints above the paragraph.
splitBreak this paragraph at every occurrence of any delimiter.
startNewListStart a new independent bullet list with this paragraph. Sync before using the returned list.
stylestringThe paragraph style, by the name a reader sees in the styles gallery.
textstringThis paragraph's text. Readable after `load('text')` and a `sync()`.
uniqueLocalIdstringThe document's own identity for this paragraph.

ParagraphCollectionclassSource ↗

The paragraphs of a story, a range, or a list, as of the batch that loaded them.

Contains paragraphs at every depth — inside table cells, nested tables, and block-level content controls — matching Word's own collection rather than only the owner's direct children.

One of the two collections whose members are not plain handles: the pieces a [Paragraph.split](Paragraph.split) answers are filled in by the split's own command rather than by a separate listing read.

Load the paragraphs and a property of each in one sync with an items/ path, such as paragraphs.load('items/text').

declare class ParagraphCollection extends ItemCollection<Paragraph>
MemberTypeSummary
getFirstThe first paragraph. `ItemNotFound` at the sync if the collection holds none.
getFirstOrNullObjectThe first paragraph, or an object that will report `isNullObject`.
getLastThe last paragraph. `ItemNotFound` at the sync if the collection holds none.
getLastOrNullObjectThe last paragraph, or an object that will report `isNullObject`.

Range_2class

A stretch of a story: two endpoints, each a paragraph and a UTF-16 offset.

A range is a SNAPSHOT, not a tracked region. Its endpoints name the paragraphs they were found in and the offsets they were found at, so it stays meaningful across edits ELSEWHERE in the document and becomes an explicit InvalidObjectPath refusal once one of its paragraphs is gone. What it deliberately does not do is follow edits INSIDE itself: once its paragraph gains a word at offset 0, a range over "alpha" fails with StaleDocument when used, rather than reading or editing whatever now sits at offsets 0..5. Edits after the range, and formatting changes, keep it valid. Word's own ranges do move, by keeping a live region in the document; this API has none, and pretending otherwise would answer text from a place the caller was not looking at.

That is also why start and end are absent rather than unimplemented — they are document-wide character positions, a different addressing scheme from this API's paragraph identity plus UTF-16 offset. Ask a range for its [Range.paragraphs](Range.paragraphs) instead.

declare class Range extends ModelObject implements PromisedItem
MemberTypeSummary
bookmarksBookmarkCollectionThe bookmarks whose text this range overlaps, in document order.
clearClear this range's content, preserving the surrounding structure.
contentControlsContentControlCollectionThe content controls this range overlaps, in document order, at any nesting depth.
deleteDelete range content.
expandToA new range from the start of whichever range starts first to the end of whichever ends last. This range does not change.
fieldsFieldCollectionFields fully contained within this range.
fontFontThe character formatting of the characters this range covers.
getBookmarksThe names of the bookmarks in or overlapping this range, in document order.
getRangeThe whole range, its content, or one of its endpoints, as a range. The default is `Whole`.
getReviewedTextThis range's text as if every pending tracked change were accepted (`Current`, the default) or rejected (`Original`). The document does not change.
getReviewedTextThis range's text as if every pending tracked change were accepted (`Current`, the default) or rejected (`Original`). The document does not change.
getTextRangesSplit this range into ranges that each end after one of `endingMarks`, such as `[' ']` for words or `['.', '!', '?']` for sentences. A paragraph end always ends a range.
inlinePicturesInlinePictureCollectionInline pictures fully contained within this snapshot range.
insertBookmarkAdd a bookmark around this range, or at its position when the range is empty.
insertBreakLine, page, and next-page section breaks are supported; other types refuse at sync. With `TrackMineOnly`, each is a tracked insertion that reject removes. A tracked `SectionNext` refuses with `NotSupported` where the next section does not start on a new page.
insertCommentCreate a top-level comment anchored to exactly this range.
insertContentControlWrap this single-paragraph range in a rich-text, plain-text, or date-picker content control. Await sync before configuring the returned control. Other types explicitly refuse. TrackMineOnly supports nonempty ordinary text outside collaboration. Existing revisions and empty tracked ranges refuse with NotSupported.
insertFieldInsert an inert field: Page, NumPages, Ref, PageRef, NoteRef, Seq, StyleRef, Date, Time, Empty with a whole instruction of one of those types, or TOC with supported switches. `text` holds the field arguments. The instruction is never evaluated, and the cached result is empty. Fields that fetch, embed, link, run, or prompt refuse with `InvalidArgument` (`edit.field-unsupported`). With `TrackMineOnly`, the field is one tracked insertion; tracked TOC creation refuses.
insertFieldInsert an inert field: Page, NumPages, Ref, PageRef, NoteRef, Seq, StyleRef, Date, Time, Empty with a whole instruction of one of those types, or TOC with supported switches. `text` holds the field arguments. The instruction is never evaluated, and the cached result is empty. Fields that fetch, embed, link, run, or prompt refuse with `InvalidArgument` (`edit.field-unsupported`). With `TrackMineOnly`, the field is one tracked insertion; tracked TOC creation refuses.
insertInlinePictureFromBase64Insert a bounded PNG/JPEG image. Sync before configuring the returned picture.
insertOoxmlInsert one equation from OOXML: a Flat OPC package (`pkg:package`) whose document part holds one paragraph with exactly one inline `m:oMath` and, around it, plain runs. Other OOXML refuses with `NotSupported` or `InvalidArgument` and `edit.ooxml-unsupported`, and nothing is inserted. With `TrackMineOnly`, the equation is one tracked insertion. Returns the range the inserted content occupies.
insertParagraphAdd a paragraph before or after the one this range starts or ends in. You can load the returned paragraph in the same sync. Editing it needs a sync first.
insertTableInsert a rectangular table before or after this range. TrackMineOnly marks rows, cell marks, and values inserted; when a paragraph splits, see the guide. Sync before configuring the returned table. Nested table authoring refuses.
insertTextWrite text at or over this range. Answers the range the written text occupies. Await `context.sync()` before loading or addressing that returned range.
paragraphsParagraphCollectionThe paragraphs this range covers, in reading order.
revisionsRevisionCollectionThe tracked changes whose characters this range overlaps, in document order.
selectPut the reader's selection on this range and navigate the editor viewport to it.
stylestringThe paragraph style of the paragraphs this range covers, by name. A read answers the name they all agree on, which always writes back to the same style, or `null` where there is no such name. A write applies a style the document defines and never creates one: list the names with `context.document.getStyles()` and assign the `nameLocal` of a `Paragraph` style; character, table, and list names are refused.
tablesTableCollectionTables contained by this range, in document order.
textstringThe text between this range's endpoints.

RangeCollectionclassSource ↗

Ranges a read produced — the hits of a search, or the pieces a split answered.

Its members are SPANS rather than handles, which is what separates it from the handle-backed collections: each item carries its own paragraph-plus-offset endpoints instead of an opaque host-minted id.

Load the ranges and a property of each in one sync with an items/ path, such as results.load('items/text').

declare class RangeCollection extends ItemCollection<Range>
MemberTypeSummary
getFirstThe first range. `ItemNotFound` at the sync if nothing matched.
getFirstOrNullObjectThe first range, or an object that will report `isNullObject`.
getLastThe last range. `ItemNotFound` at the sync if nothing matched.

RequestContextclassSource ↗

What a run hands its callback: one queue, one document, one sync at a time.

sync() commits all queued commands in one atomic transaction. Supported read-derived proxy dependencies can require additional read-only transport calls before that commit. These reads and the final write share one revision; a concurrent change refuses the sync. A read on an object that a write in the same sync returns (the range insertText wrote, the paragraph insertParagraph created) is answered after that commit, on the revision it produced. If that read fails, the writes stay applied and sync() rejects with the read's error code, with debugInfo.innerError.code edit.read-after-commit: read again, and do not apply the same edit again. A write on such an object requires a separate sync.

Conditional writes come from the same place. A context that has READ from the document remembers the revision it read at, and a later batch that writes goes out conditional on it, failing StaleDocument if the document moved. That is what stops a decision made from a cached read being applied to a document that has since changed — the hazard the read-decide-write shape of any batching API invites. A context that has read nothing has nothing to be stale about, so its writes go out unconditionally.

declare class RequestContext
MemberTypeSummary
capabilitiesDocumentCapabilitiesWhat the document host behind this context can do.
documentDocumentThe document this run is against.
syncResolve read prerequisites, then commit queued writes atomically and hydrate answers.
trackedObjectsTrackedObjectsObjects kept addressable past the run that created them. See [TrackedObjects](TrackedObjects).

RevisionclassSource ↗

One tracked change.

A row is listed as Insert or Delete, and a cell or tracked numbering by its own type. A structural card with no single type, such as table grid history, is omitted rather than shipped with an unpublishable type. That listing is not the collection decision set: see [RevisionCollection](RevisionCollection).

declare class Revision extends ModelObject implements PromisedItem
MemberTypeSummary
acceptKeep the change, in one transaction, with every part of it: both halves of a move or a cell merge, and the changes inside content it removes, such as another author's insertion in a deleted row. Rejecting a formatting change restores the earlier properties, so another author's change inside the replaced properties, such as tracked numbering, goes with it.
authorstringWho proposed the change.
dateDate | nullWhen they proposed it, or `null` where the file recorded no valid date.
rangeRangeThe words the change covers. Each read returns the same proxy, so a load on it is kept.
rejectUndo the change, likewise in one transaction and with the same rules as [Revision.accept](Revision.accept).
typeRevisionTypeWhat kind of change it is, by Word's own name for it.

RevisionCollectionclassSource ↗

The tracked changes on a document, story or range, as of the batch that loaded them.

items omits a structural card with no single revision type; see [Revision](Revision). On a story's collection, acceptAll / rejectAll still resolve every store-resolvable revision in the story and refuse atomically if any read-only or otherwise unsupported revision remains. On [Range.revisions](Range.revisions) and getReviewItemRevisions, they resolve the changes the range overlaps or the key names, and resolve and setAuthor refuse with NotSupported.

declare class RevisionCollection extends HandleCollection<Revision>
MemberTypeSummary
acceptAllKeep every change in this story, as ONE decision and one undo unit.
rejectAllUndo every change, likewise as one decision.
resolveResolve eligible revisions in this story and report skipped decisions after sync. Omit revisions to include unsupported decisions and history absent from items. Named revisions resolve as single `accept()` or `reject()` calls on them would, except that a row kept for a nested table is reported as `retained-structure` while the other named changes resolve, where a single call refuses whole. Pass an empty array to select nothing. Duplicate objects resolve once; stale targets are reported as unknown-revision. This must be the only write in its sync batch. Unlike acceptAll/rejectAll, unsupported decisions do not block independent changes. A collection from `Range.revisions` or `getReviewItemRevisions` refuses this call with `NotSupported`.
setAuthorAttribute changes in this story to another author. The changes stay pending.

SectionclassSource ↗

One section: the document's layout, not its content.

Everything a caller usually wants — paper size, margins, orientation — is on [Section.pageSetup](Section.pageSetup). The section itself is mostly navigation: the story it governs, the header and footer stories it declares, and the section after it.

getHeader and getFooter answer a body that may not exist yet. A section with no first-page header inherits the previous section's. When no section declares one, the answer is an empty body: every read on it answers as an empty story, and asking does not create the part. The first text written into it creates the header or footer; asking alone would make a READ write to the document, and a header that exists only because it was asked about is a header the author never added.

declare class Section extends ModelObject implements PromisedItem
MemberTypeSummary
bodyBodyThe story this section governs.
getFooterThe footer story, or a virtual empty body created by its first content insertion.
getHeaderThe header story, or a virtual empty body created by its first content insertion.
getNextThe next section. `ItemNotFound` at the sync when this is the last one.
pageSetupPageSetupThe page this section is laid out on.

SectionCollectionclassSource ↗

The sections of a document, in document order, as of the batch that loaded them.

declare class SectionCollection extends HandleCollection<Section>
MemberTypeSummary
getFirstThe first section. `ItemNotFound` at the sync if the document has none.

ShapeclassSource ↗

One floating or inline shape in a body or paragraph.

id, name and type are read-only. [Shape.body](Shape.body) exposes a supported shape's own text story, including text-bearing geometric shapes. Other shapes refuse body access.

declare class Shape extends ModelObject implements PromisedItem
MemberTypeSummary
bodyBodyThe shape's own text story in the main body, a header, or a footer. Shapes in notes or nested text boxes refuse body access with `InvalidArgument` at the sync. Shapes without their own supported text story also refuse access.
idnumberThe shape's id in the document.
namestringThe shape's name in the document.
typeShapeTypeThe shape's type.

ShapeCollectionclassSource ↗

The floating and inline shapes in a body or paragraph, in reading order.

declare class ShapeCollection extends ItemCollection<Shape>
MemberTypeSummary
getByTypesThe shapes of the given types, in the same order.
getFirstThe first shape. `ItemNotFound` at the sync when there is none.
getFirstOrNullObjectThe first shape, or a null object when there is none.

StyleclassSource ↗

One style the document's styles part defines. Every property is read-only and needs a load before it is read; load() with no arguments reads them all.

nameLocal is the name the styles part declares. Only a style whose type is Paragraph can be assigned to paragraph.style, range.style, or body.style; those setters refuse character, table, and list style names. Table.style accepts the nameLocal of a listed table style.

declare class Style extends ModelObject
Offer the paragraph styles a reader would see 


```ts
const styles = context.document.getStyles();
styles.load('items/nameLocal,items/type,items/visibility,items/unhideWhenUsed,items/priority');
await context.sync();

// Keep hidden styles that unhide once used, such as heading 2, so they can be applied too.
// Many styles share priority 99, so sort by name next for a stable order.
const choices = styles.items
  .filter((style) => style.type === 'Paragraph' && (style.visibility || style.unhideWhenUsed))
  .sort((a, b) => a.priority - b.priority || a.nameLocal.localeCompare(b.nameLocal))
  .map((style) => style.nameLocal);
```
MemberTypeSummary
baseStylestringThe name of the style this one is based on: a listed style of the same kind. An empty string when the style states none or names any other style. Read-only here.
builtInbooleanFalse when the styles part marks the style as custom.
linkedbooleanWhether the style is linked to its partner: a paragraph style to a listed character style, or a character style to a listed paragraph style. Other kinds, and links to the same kind or to itself, read false.
nameLocalstringThe name the styles part declares. Assign it to `paragraph.style` only when `type` is `Paragraph`; the paragraph `style` setters refuse other kinds. A built-in name reads as the part writes it, such as `heading 1`, and the setters accept it that way. The setters and `getByNameOrNullObject` compare names without case, so `Heading 1` finds `heading 1`; compare names the same way rather than with `===`.
nextParagraphStylestringThe name of the style for the paragraph after this one: always a listed paragraph style. A paragraph style that states no next style names itself. An empty string for other kinds, and where the next style it names is not a listed paragraph style. Read-only here.
prioritynumberThe sort order of the style among recommended styles; lower comes first. 99 when the styles part states no priority. Read-only here.
quickStylebooleanWhether the style is in the quick style gallery. False when not stated. Read-only here.
typeStyleType | 'Character' | 'List' | 'Paragraph' | 'Table'The kind of style. A numbering style reads as `List`. Only `Paragraph` names are accepted by the paragraph, range, and body `style` setters.
unhideWhenUsedbooleanWhether a hidden style becomes visible once it is used. False when not stated. Read-only here.
visibilitybooleanWhether the style shows as a recommended style. False when the styles part marks it semi-hidden or hidden; true when it marks neither. Read-only here.

StyleCollectionclassSource ↗

The styles a document defines, of every kind, in the order its styles part writes them, as of the sync that loaded them.

The listing holds paragraph, character, table, and list styles. The paragraph.style, range.style, and body.style setters accept paragraph style names only; they refuse character, table, and list names. Check type before assigning a nameLocal. Every listed paragraph style applies through those setters. Styles with no name, an invalid name, or an unknown kind are not listed. A document with no styles part lists none.

load() with no arguments, or load('items'), reads every property of each style in the same sync. Name items/ paths to read fewer, such as styles.load('items/nameLocal,items/type').

declare class StyleCollection extends ModelObject
MemberTypeSummary
getByNameOrNullObjectThe style with this name, or an object that reports `isNullObject` after the sync. Reading `isNullObject` needs no property load; properties loaded on the object before that sync are answered by the same lookup.
getCountThe number of listed styles, of every kind, readable after the next sync.
itemsreadonly Style[]The styles this collection was loaded with. `PropertyNotLoaded` before a synced load.

TableclassSource ↗

A canonical table. Reads require load() and sync().

declare class Table extends ModelObject implements PromisedItem
MemberTypeSummary
addColumnsAdd columns at an edge. Values are row-major; new columns initially copy the nearest edge width.
addRowsAdd rows at an edge. Sync before configuring the returned rows; omitted values create empty cells. Ordinary edge rows can belong to a table with unrelated merged headers. TrackMineOnly records native row insertion revisions, including supplied initial values.
columnCountnumberNumber of columns in the rectangular grid. Load before reading.
deleteDelete this table and its contents through the canonical document transaction.
deleteColumnsDelete consecutive columns from a zero-based index. Defaults to one column.
deleteRowsDelete consecutive rows from a zero-based index. Defaults to one row. Tracking requires one row without a pending deletion to remain and refuses pending row or cell structure revisions.
getCellAddress a cell by zero-based row and column. Read-derived operations may share its next sync.
headerRowCountnumberNumber of consecutive leading rows repeated as table headers.
mergeCellsMerge the rectangle that the cells at `(topRow, firstCell)` and `(bottomRow, lastCell)` span into one cell. Cell indexes count the cells of each row, as `rows.items[r].cells` lists them, so a merged cell counts once. `bottomRow` must not be above `topRow`; either cell can lie further left. The rectangle grows to whole merged cells; a cell that crosses its edge, or a rectangle of one cell, refuses with `InvalidArgument` and the diagnostic code `edit.table-merge-not-rectangle`. The merged cell keeps every non-empty cell's content in reading order. The returned cell's `value`, `shadingColor`, and `verticalAlignment` can share the sync; a text edit in the table refuses with `ConflictingChanges` until a sync, because the merge moves paragraphs between cells. With tracking off, a pending cell revision refuses with `NotImplemented`. `TrackMineOnly` merges only inside the author's own proposed table, whose insertion the new shape joins; any other table refuses with `NotSupported` and `edit.tracked-structure-unsupported`.
onLoad
rowCountnumberNumber of rows. Load this property before reading it.
rowsTableRowCollectionStable row collection. Load `items`, then sync before reading its elements.
stylestringThe table style, by its display name. Writes must name a table style the document defines: list the names with `context.document.getStyles()` and assign the `nameLocal` of a style whose `type` is `Table`; paragraph, character, and list names are refused. A read answers the name that writes back to the same style, or an empty string where the table has no style or no name of its style writes back to it.
valuesstring[][]Cell text by row. Writes require the current dimensions and ordinary cell text. TrackMineOnly records text revisions outside collaboration; collaborative tracked writes refuse.

TableCellclassSource ↗

A table cell. Column width uses points and changes the whole grid column.

declare class TableCell extends ModelObject implements PromisedItem
MemberTypeSummary
bodyBodyA body scoped to this cell for text, ranges, formatting, and nested table navigation.
columnWidthnumberWidth in points. A write affects the whole grid column, not only this cell.
onLoad
shadingColorstringCell background as a supported color string.
splitSplit this cell into `rowCount` rows and `columnCount` columns of equal width. Counts run from 1 to 63. A cell merged over several rows splits only into a divisor of them; a one-row cell adds rows to the table. Counts the cell cannot take, such as columns narrower than the minimum width, refuse with `InvalidArgument` and the diagnostic code `edit.table-split-unsupported`. `TrackMineOnly` splits only inside the author's own proposed table, as `Table.mergeCells` does; any other table refuses with `NotSupported`.
valuestringPlain cell text. Replacing complex content refuses; use the scoped body for targeted edits. TrackMineOnly records text revisions outside collaboration; collaborative tracked writes refuse.
verticalAlignmentVerticalAlignment | 'Top' | 'Center' | 'Bottom' | 'Mixed'Top, Center, or Bottom. Mixed is a read state and cannot be assigned.

TableCellCollectionclassSource ↗

A loaded collection of TableCell objects.

declare class TableCellCollection extends HandleCollection<TableCell>
MemberTypeSummary
getFirstReturn the first item; an empty collection raises ItemNotFound at sync.
getFirstOrNullObjectReturn the first item or a null object. Check isNullObject after sync.
itemAt
listing
promised

TableCollectionclassSource ↗

A loaded collection of Table objects.

declare class TableCollection extends HandleCollection<Table>
MemberTypeSummary
getFirstReturn the first item; an empty collection raises ItemNotFound at sync.
getFirstOrNullObjectReturn the first item or a null object. Check isNullObject after sync.
itemAt
listing
promised

TableRowclassSource ↗

A row with stable identity. Its cells follow document order.

declare class TableRow extends ModelObject implements PromisedItem
MemberTypeSummary
cellsTableCellCollectionStable cell collection for this row. Load `items` and sync before reading.
insertRowsInsert ordinary rows before or after this row. Sync before using the returned rows. Unrelated merged headers remain unchanged. Merged source rows and crossing merges refuse. TrackMineOnly records native row insertion revisions, including initial values.

TableRowCollectionclassSource ↗

A loaded collection of TableRow objects.

declare class TableRowCollection extends HandleCollection<TableRow>
MemberTypeSummary
getFirstReturn the first item; an empty collection raises ItemNotFound at sync.
getFirstOrNullObjectReturn the first item or a null object. Check isNullObject after sync.
itemAt
listing
promised

TrackedObjectsclassSource ↗

The objects a context keeps addressable beyond the run that created them.

An ordinary proxy stops being usable when its run ends. Tracking one keeps its address alive so a later run(object, callback) can adopt it, and untracking releases it — which matters for long-lived callers, since a tracked object is a document reference that will not be collected on its own.

declare class TrackedObjects

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the TrackedObjects class.

MemberTypeSummary
addKeep these objects usable after this run ends.
removeStop keeping them: they are released when this run ends, like any other object.

Interfaces (21)

CommitPreviewOptionsinterfaceSource ↗

Options for [DocumentPreview.commit](DocumentPreview.commit).

interface CommitPreviewOptions
```ts
await preview.commit({ rebase: true });
```
MemberTypeSummary
rebase?booleanWhen the live document moved after the preview began, replay the preview on the current document instead of refusing. Ranges follow the text they name, so an edit elsewhere, even earlier in the same paragraph, rebases. The replay still refuses with `StaleDocument`, and writes nothing, when a replayed read answers differently or a write would overwrite text that changed: a search finds a different number of matches, text the preview read now reads otherwise, or the range, paragraph, or span a write replaces or formats holds other text. Omitted or false, any move refuses.

CreateServerOptionsinterfaceSource ↗

How DocxEditor.createServer opens a document.

Opening DOCX bytes is a bounded parse: decompression-ratio and size caps, part and relationship path validation, DTD- and entity-free XML. Malformed input returns InvalidArgument. Resource refusals return ResourceLimitExceeded, with limit identifying the exceeded cap. File-controlled details and internal parser messages are never included.

The bounded parse is complete when this promise resolves. The runtime does not retain the caller's Uint8Array, so the caller may reuse or transfer that input buffer afterward.

interface CreateServerOptions
MemberTypeSummary
author?stringWho comments and tracked text edits written by this runtime are recorded as.
limits?DocumentLimitsBudgets for the bounded reader — archive size, part count, and XML elements.
modules?readonly EditorModule[]Capability modules to register. Collaboration attaches only through a collaboration contribution on this list. A module with `onDiagnostic`, such as a telemetry module, receives the anonymous diagnostics of this runtime: the open, and each refused batch with a known reason.
pagination?ServerPaginationOptionsFont-aware pagination required to calculate PAGE/NUMPAGES fields headlessly.
revisionTextView?RevisionTextViewRevision view for ordinary Office-compatible `text` loads and `search()` calls.

DocumentCapabilitiesinterfaceSource ↗

Capabilities exposed by a DocxEditor runtime, frozen for its lifetime.

interface DocumentCapabilities
MemberTypeSummary
documentbooleanThere is a document to address at all. False for a browser host between mounts.
eventsbooleanThe host raises document events.
layoutbooleanThe host lays the document out, so paginated positions are meaningful.
previewboolean`preview()` is offered: true for a runtime over a live browser editor, false for a server runtime, which has no page to show a preview in.
saveboolean`save()` is offered — true for a server runtime, false for one borrowing an editor.
scrollingbooleanThe host can be scrolled to a position.
selectionbooleanThe host has a user selection to read or move.

DocumentCompareOptionsinterfaceSource ↗

Options of Document.compareFromBase64.

Supported: authorName, compareTarget (CompareTargetCurrent only), detectFormatChanges, and removeDateAndTime. addToRecentFiles and ignoreAllComparisonWarnings are accepted and have no effect: there is no recent-files list and no warning prompt. true for removePersonalInformation refuses with NotSupported.

interface DocumentCompareOptions
MemberTypeSummary
addToRecentFiles?booleanAccepted; there is no recent-files list. Default `true`.
authorName?stringAuthor of the revisions. Default: the revised document's author, else `Comparison`.
compareTarget?CompareTarget | 'CompareTargetCurrent' | 'CompareTargetNew' | 'CompareTargetSelected'Where the result goes. Default and only supported value: `CompareTargetCurrent`.
detectFormatChanges?booleanRecord formatting differences as revisions. Default `true`.
ignoreAllComparisonWarnings?booleanAccepted; there is no warning prompt. Default `false`.
removeDateAndTime?booleanWrite the revisions without dates. Default `false`.
removePersonalInformation?boolean`true` refuses with `NotSupported`. Default `false`.

DocumentLimitsinterfaceSource ↗

Resource budgets applied while opening DOCX bytes, subject to engine ceilings.

interface DocumentLimits
MemberTypeSummary
maxRelationships?numberMost relationships the package may declare.
maxXmlParts?numberMost XML parts the package may hold.
xml?DocumentXmlLimitsPer-part XML caps.
zip?DocumentZipLimitsArchive-level caps.

DocumentPreviewinterfaceSource ↗

Other wording, shown in the page over the live document until it is committed or discarded. Answered by [DocxEditorRuntime.preview](DocxEditorRuntime.preview).

This is DocxEditor infrastructure with no Office.js equivalent.

interface DocumentPreview<T = void>
```ts
const preview = await runtime.preview(async (context) => {
  context.document.changeTrackingMode = 'TrackMineOnly';
  const range = context.document.body.search('thirty (30) days').getFirst();
  range.insertText('forty-five (45) days', 'Replace');
  await context.sync();
});
preview.reveal(); // scroll to the counter-proposal
// The page shows it as a tracked change. The live document is unchanged.
if (userAccepted) await preview.commit();
else preview.discard();
```
MemberTypeSummary
commitWrite the preview to the live document as one undo step, then end the preview.
discardEnd the preview without writing anything. The page shows the live document again, with its selection, scroll position, and focus as they were. A tracking mode the callback set is discarded with the preview. Safe to call more than once and after `commit()`. Disposing the runtime that opened the preview discards it too.
onStatusChangedBe told when [DocumentPreview.status](DocumentPreview.status) changes: to `stale` when the live document moves, and to `ended` once. Returns a function that removes the listener.
resultTWhat the callback answered, as `run()` answers its callback's value. Return plain data from the callback, never a proxy: proxies end with the callback.
revealScroll the page to the first paragraph of the document body the preview changed. Answers false, scrolling nothing, when the preview has ended or changed no body paragraph: an edit only in a header, a footer, or a note is not found.
statusDocumentPreviewStatusWhere the preview is in its life. Read it at any time; it changes without a sync.

DocumentXmlLimitsinterfaceSource ↗

Resource limits for each parsed XML part.

interface DocumentXmlLimits
MemberTypeSummary
maxBytesnumberMost bytes any one XML part may be.
maxElements?numberMost elements any one XML part may contain. Defaults to the engine budget (10,000,000); callers may raise it up to the engine ceiling (50,000,000).

DocumentZipLimitsinterfaceSource ↗

Resource limits for the DOCX archive.

interface DocumentZipLimits
MemberTypeSummary
maxEntriesnumberMost entries the archive may contain.
maxRatio?numberHighest tolerated ratio of the archive's total uncompressed bytes to its own byte length — the zip-bomb guard. Applies once the total exceeds 8 MiB, so a small archive is never refused for compressing well.
maxTotalBytesnumberMost bytes the archive may decompress to in total.

DocxEditorDebugInfointerfaceSource ↗

Debug details in the shape of Office.js OfficeExtension.DebugInfo.

interface DocxEditorDebugInfo
MemberTypeSummary
codeDocxEditorErrorCodeThe same code as [DocxEditorError.code](DocxEditorError.code).
errorLocation?stringThe consumer-facing path of the object or property involved, when there is one.
innerError?DocxEditorInnerErrorWhy the engine refused, when it knows a specific reason. Handle the outer `code`; read `innerError.message` to tell a person or a model what to change.
messagestringThe same message as the error's own.

DocxEditorErrorInitinterfaceSource ↗

The fields a [DocxEditorError](DocxEditorError) is constructed from.

interface DocxEditorErrorInit
MemberTypeSummary
actualRevision?numberThe revision the document was actually at, for `StaleDocument`.
codeDocxEditorErrorCodeWhich refusal this is. The stable thing to branch on.
diagnostic?DiagnosticCodeThe engine's public diagnostic code for this refusal, when it has one. It becomes `debugInfo.innerError`.
expectedRevision?numberThe revision the context had read at, for `StaleDocument`.
limit?'zip.maxEntries' | 'zip.maxTotalBytes' | 'zip.maxRatio' | 'xml.maxBytes' | 'xml.maxElements' | 'xml.maxDepth' | 'maxXmlParts' | 'maxRelationships'The resource limit exceeded while opening a document.
target?stringThe consumer-facing path of the object or property involved — `document.body.text`, not a handle. Omitted when there is nothing to name.

DocxEditorInnerErrorinterfaceSource ↗

Why the engine refused, as a public diagnostic code with its fixed hint.

interface DocxEditorInnerError
MemberTypeSummary
codeDiagnosticCodeA stable public diagnostic code, such as `edit.tracked-drawing-delete-unsupported`.
messagestringThe fixed hint for the code: the cause, then the action. Never document content.

DocxEditorNamespaceinterfaceSource ↗

The entry point, as much of it as works without an editor.

An object rather than a TypeScript namespace: a namespace with runtime members is a declaration-merging construct that does not survive being re-exported through a bundler as predictably, and DocxEditor.createServer reads the same either way.

Import from @docx-editor.dev/editor-api/browser for the same namespace plus createBrowser.

interface DocxEditorNamespace
MemberTypeSummary
createCollaborativeA DOM-free runtime over one experimental collaboration replica.
createServerA runtime over DOCX bytes. Additionally offers `save()`.

DocxEditorRuntimeinterfaceSource ↗

A runtime: one document host, many runs.

Runs are ISOLATED, not serialized. Every [DocxEditorRuntime.run](DocxEditorRuntime.run) gets its own context and its own queue, so two runs cannot interleave into one batch, and a run started inside another run works instead of waiting for a lock its own caller holds. Batches are still ordered — each sync() commits writes atomically; read dependencies can use additional read-only batches.

Disposal is final: [DocxEditorRuntime.dispose](DocxEditorRuntime.dispose) releases the host once and is safe to call again, and every later run fails with RuntimeDisposed.

interface DocxEditorRuntime
MemberTypeSummary
capabilitiesDocumentCapabilitiesWhat the document host behind this runtime can do. Frozen at construction.
disposeRelease the host. Idempotent.
previewShow other wording in the page without writing it, until the answered preview is committed or discarded.
runRun one batch of work against the document. Answers with the callback's value.
runRun one batch of work, adopting objects a previous run tracked.
runRun one batch of work with options, such as an editor history group.

DocxEditorServerRuntimeinterfaceSource ↗

A runtime over DOCX bytes rather than a live editor — what DocxEditor.createServer answers.

Adds [DocxEditorServerRuntime.save](DocxEditorServerRuntime.save) to the shared contract, because a server runtime owns its document and can serialize it; a browser runtime borrows the editor's and cannot.

interface DocxEditorServerRuntime extends DocxEditorRuntime
MemberTypeSummary
saveThe current document as a fresh, caller-owned DOCX byte array.

EditorModuleinterfaceSource ↗

Capability module accepted by [createServer](createServer). Collaboration attaches through a collaboration contribution. Other contributions are ignored here.

interface EditorModule
MemberTypeSummary
collaboration?CollaborationModuleContribution
idstring
onDiagnostic?(event: RuntimeDiagnostic) => voidTold about this runtime's anonymous diagnostics: the open, and each refused batch with a known reason. A telemetry module's listener fits here unchanged.
review?{ readonly compareDocuments?: CompareDocumentsEngine; }Review contribution. Its compare engine enables `Document.compareFromBase64`; the rest of the contribution is ignored here.

LoadQueryOptionsinterfaceSource ↗

The object form of load(...): which properties, and how much of a collection.

An unknown key, a non-integer top, a property name that is not an identifier, or a value of the wrong type is refused as InvalidArgument here, naming the option — a misspelled key is the difference between "load selected properties" and "load nothing", which would otherwise surface as a PropertyNotLoaded much later at a call that looks correct.

interface LoadQueryOptions
MemberTypeSummary
expand?string | readonly string[]Reserved for Office.js source compatibility. Navigation-property expansion is not supported yet: a non-empty value is refused as `InvalidArgument`. Omit it or pass an empty array.
select?string | readonly string[]Which properties to load.
skip?numberFor a collection: skip this many items first.
top?numberFor a collection: at most this many items.

RevisionAuthorOptionsinterfaceSource ↗

Options for [RevisionCollection.setAuthor](RevisionCollection.setAuthor).

interface RevisionAuthorOptions
MemberTypeSummary
date?DateThe date to record. Omit it to keep each change's own date.

RevisionAuthorSelectioninterfaceSource ↗

Select every change these authors made, for [RevisionCollection.setAuthor](RevisionCollection.setAuthor). Matches w:author exactly.

interface RevisionAuthorSelection
MemberTypeSummary
authorsreadonly string[]

RunOptionsinterfaceSource ↗

Options for [DocxEditorRuntime.run](DocxEditorRuntime.run), passed before the callback.

This is DocxEditor infrastructure, not part of the Office.js object model: the Office.js run function has no options and no undo grouping.

interface RunOptions
```ts
// One review decision, one undo step: the editor's writes and every sync of the run.
const decision = editor.beginHistoryGroup();
try {
  const resolved = editor.exec(
    { type: 'resolveAllReviewChanges', action: 'reject', keys },
    { historyGroup: decision }
  );
  if (!resolved.ok) throw new Error(resolved.reason);
  await runtime.run({ historyGroup: decision }, async (context) => {
    const ranges = context.document.body.search('30 days');
    ranges.load('items');
    await context.sync();
    const target = ranges.items[0];
    if (!target) throw new Error('The document has no "30 days" text.');
    const replaced = target.insertText('45 days', 'Replace');
    await context.sync();
    replaced.insertComment('Counter-proposal: 45 days.');
    await context.sync();
  });
} finally {
  decision.end();
}
```
MemberTypeSummary
historyGroup?HistoryGroupMake every write this run commits part of an open editor history group, so one undo reverts them together with the group's other writes.
previousObjects?ClientObject | readonly ClientObject[]Objects a previous run tracked, adopted by this run. The same as the object argument.

SearchOptionsinterfaceSource ↗

How a search is narrowed.

Every flag is honoured or REFUSED — never quietly ignored. A search that accepted matchWildcards and then ran a plain-text scan would answer the wrong offsets to a caller who edits at them, so the unimplemented options reach the host and come back as NotSupported.

They are declared here rather than left off the type because omitting them would make { matchWildcards: true } a compile error in code that is otherwise source-compatible with Word. The honest answer to that code is a runtime refusal naming the option, not a type error naming the interface.

interface SearchOptions
MemberTypeSummary
ignorePunct?booleanNot implemented; `true` is refused with `NotSupported`.
ignoreSpace?booleanNot implemented; `true` is refused with `NotSupported`.
matchCase?booleanMatch the query's case. Off by default, like Word's Find.
matchWholeWord?booleanOnly match where the query stands alone as a word.
matchWildcards?booleanNot implemented; `true` is refused with `NotSupported`.

ServerPaginationOptionsinterfaceSource ↗

Explicit measurement inputs for headless field calculation.

interface ServerPaginationOptions extends AutomationPaginationOptions

Type aliases (23)

BesideLocationtypeSource ↗

Which side of a paragraph or a range a new paragraph goes on.

type BesideLocation = Extract<RangeInsertTextLocation, 'Before' | 'After'>;

BodyInsertParagraphLocationtypeSource ↗

Where a story accepts a paragraph. Start/End mean "before the first"/"after the last".

type BodyInsertParagraphLocation = Extract<RangeInsertTextLocation, 'Start' | 'End'>;

BodyInsertTextLocationtypeSource ↗

Where a story accepts text: over all of it, or at either edge.

type BodyInsertTextLocation = Extract<RangeInsertTextLocation, 'Replace' | 'Start' | 'End'>;

ContentControlLockStatetypeSource ↗

The lock a control carries. ST_Lock, spelled as the schema spells it.

type ContentControlLockState = 'unlocked' | 'sdtLocked' | 'contentLocked' | 'sdtContentLocked';

ContentControlSubtypetypeSource ↗

The control types this API can create. Picture and repeating section are deferred.

type ContentControlSubtype = 'richText' | 'plainText' | 'dropDownList' | 'comboBox' | 'date';

ContentControlValuetypeSource ↗

What a control's own type accepts as a value.

A discriminated union rather than unknown: a dropdown and a checkbox do not take the same kind of thing, and a single setValue(value: string) would have to guess what 'true' means to a date picker.

type ContentControlValue = {
    readonly kind: 'text';
    readonly text: string;
} | {
    readonly kind: 'listItem';
    readonly value: string;
} | {
    readonly kind: 'checkbox';
    readonly checked: boolean;
}
/** `YYYY-MM-DD`, or a full ISO-8601 instant. */
 | {
    readonly kind: 'date';
    readonly iso: string;
};

CreateCollaborativeOptionstypeSource ↗

Options for [createCollaborative](createCollaborative).

type CreateCollaborativeOptions = CreateServerOptions;

DocumentPreviewStatustypeSource ↗

Where a [DocumentPreview](DocumentPreview) is in its life.

- active: the page shows the preview, and the live document has not moved since the preview began. - stale: the live document moved after the preview began: a collaboration peer edited it, or a local write landed while the callback ran. The page still shows the preview. commit() refuses with StaleDocument; commit({ rebase: true }) replays it on the current document instead. - ended: the preview was committed, discarded, or ended because its runtime was disposed or the editor loaded, detached, or remounted. The page shows the live document. Final.

type DocumentPreviewStatus = 'active' | 'stale' | 'ended';
```ts
preview.onStatusChanged((status) => {
  applyButton.textContent = status === 'stale' ? 'Apply to the current text' : 'Apply';
});
```

DocxEditorErrorCodetypeSource ↗

What went wrong, as a value a consumer may branch on.

type DocxEditorErrorCode = 
/** A property was read before a `load(...)` for it completed in a `sync()`. */
'PropertyNotLoaded'
/** A `ClientResult` value was read before the sync that fills it. */
 | 'ValueNotLoaded'
/**
 * The object cannot be addressed, in one of three ways.
 *
 * NOT YET: an item accessor answers a proxy the read that names it has not answered for, and it
 * becomes usable at the next `sync()`. NOT ANY MORE: its run ended and nothing tracked it, which
 * is terminal. GONE: the document no longer holds the object, because an edit removed or merged
 * it; `debugInfo.innerError.code` is then `edit.stale-target` and the message says so. One
 * code because from a consumer's side all three are "this object cannot be used here"; the
 * message says which one, because the fix for one is not the fix for the others.
 */
 | 'InvalidObjectPath'
/** The object still belongs to a run that has not finished, so it cannot be handed over. */
 | 'ObjectInUse'
/** An argument or load option this API does not accept. */
 | 'InvalidArgument'
/** Opening the document exceeded a bounded reader resource limit. */
 | 'ResourceLimitExceeded'
/** The collection has no such item — `getFirst()` on an empty one. */
 | 'ItemNotFound'
/**
 * The call is outside the supported subset for this host, mode, or content, and nothing
 * changed. Examples: a server has no selection to move; `TrackMineOnly` has no tracked form
 * for the operation; the OOXML or the field result holds content the subset does not take.
 *
 * Never retry the same call. Read `debugInfo.innerError.code` for the rule, then choose a
 * supported call, another mode, or other content.
 */
 | 'NotSupported'
/**
 * The member or rule is one this API does not implement for the target, and nothing changed.
 * Examples: a range member that a field result does not support; a tracked edit that touches
 * your own pending change or another author's pending structural change.
 *
 * Never retry the same call. Read `debugInfo.innerError.code` for the rule, then read the
 * target again and edit a different range, decide the pending change first, or use another
 * member.
 */
 | 'NotImplemented'
/**
 * Two calls in one batch make claims on the same paragraph that cannot both hold.
 *
 * A batch is one transaction planned against the state at its start, which stops being
 * unambiguous once two calls restructure the same paragraph. Split them across two `sync()`
 * calls and each gets exactly what it asked for.
 */
 | 'ConflictingChanges'
/** The request context's `run` has finished, so it can no longer be used. */
 | 'InvalidRequestContext'
/** The runtime was disposed. Every later operation fails this way. */
 | 'RuntimeDisposed'
/**
 * The request was built from an older read, so nothing was applied: another writer moved the
 * document, or a range's text moved since the range was read, including by this context's own
 * earlier sync. Read again before retrying.
 */
 | 'StaleDocument'
/** The host is live but holds no document right now — an editor between mounts. */
 | 'DocumentUnavailable'
/**
 * A preview is open over the editor, so it refuses this write or a second preview. Commit or
 * discard the open preview first. Browser runtime only.
 */
 | 'PreviewActive'
/** The preview has ended — committed, discarded, or replaced by a remount — so it cannot commit. */
 | 'PreviewEnded'
/** The document refused the change, or answered something this runtime cannot use. */
 | 'GeneralException';

FieldTypeLiteraltypeSource ↗

String forms of Office field types.

type FieldTypeLiteral = `${FieldType}`;

HeaderFooterTypetypeSource ↗

Which header or footer of a section: Word's own three variants.

type HeaderFooterType = 'Primary' | 'FirstPage' | 'EvenPages';

LoadOptiontypeSource ↗

Everything load(...) accepts: one property name, several, or a [LoadQueryOptions](LoadQueryOptions) object.

type LoadOption = string | readonly string[] | LoadQueryOptions;
```ts
paragraph.load('text');
paragraph.load(['text', 'style']);
paragraphs.load({ select: 'items', top: 5 });
paragraphs.load('items/text,items/style');
```


 On a collection, `items/<property>` loads `items` and that property on each item in the same `context.sync()`. A property name without the `items/` prefix means the same thing on a collection, so `paragraphs.load('text')` equals `paragraphs.load('items/text')`.  

Only one level of navigation is supported. A deeper path, such as `items/font/bold`, and a navigation path on an object that is not a collection, such as `font/bold`, are refused as `InvalidArgument`, with the path as the error's `target`. Load the navigation object itself instead, for example `paragraph.font.load('bold')` for each item.

NoteItemTypetypeSource ↗

Which kind of note: Word's own two.

type NoteItemType = 'Footnote' | 'Endnote';

ParagraphAlignmenttypeSource ↗

Paragraph alignment values readable and writable through this object model.

type ParagraphAlignment = Alignment | 'Mixed' | 'Unknown' | 'Left' | 'Centered' | 'Right' | 'Justified';

ParagraphInsertTextLocationtypeSource ↗

Where a paragraph accepts text: over all of it, or at either edge of it.

type ParagraphInsertTextLocation = Extract<RangeInsertTextLocation, 'Replace' | 'Start' | 'End'>;

ParagraphReadingOrdertypeSource ↗

A paragraph's base direction, as [Paragraph.readingOrder](Paragraph.readingOrder) reads and writes it.

type ParagraphReadingOrder = 'LeftToRight' | 'RightToLeft';

PreviewCallbacktypeSource ↗

What [DocxEditorRuntime.preview](DocxEditorRuntime.preview) hands its callback: an ordinary request context whose reads and writes address the preview, not the live document.

Write it as you would write the final edit, from data you already have. The editor stays editable while the callback runs, so a callback that waits on a model call lets the document move under it, and the preview then starts stale. Ask the model first, then preview.

Text and formatting edits work in the body, headers, footers, and notes. The callback cannot write tables, pictures, fields, lists, hyperlinks, content controls, or page setup, create or delete headers, footers, or notes, or move the selection: context.sync() refuses those with NotSupported. Comments are written in the body only, as in run().

type PreviewCallback<T = void> = (context: RequestContext) => Promise<T>;
```ts
const proposal = await model.propose(clauseText); // before the preview, not inside it
const preview = await runtime.preview(async (context) => {
  context.document.changeTrackingMode = 'TrackMineOnly';
  const range = context.document.body.search(proposal.find).getFirst();
  range.insertText(proposal.replace, 'Replace');
  await context.sync();
});
```

RangeInsertTextLocationtypeSource ↗

Where a range accepts text. See Range#insertText for what Before/Start mean here.

type RangeInsertTextLocation = 'Replace' | 'Start' | 'End' | 'Before' | 'After';

RevisionTextViewtypeSource ↗

The tracked-revision view used by this runtime's ordinary Office-compatible text reads.

allMarkup preserves the historical behavior. original matches Word's Original review view: pending deletions remain visible and pending insertions stay hidden.

This is a DocxEditor runtime option. It is not part of the Office.js object model.

type RevisionTextView = 'allMarkup' | 'original';

RevisionTypetypeSource ↗

Word's own names for a kind of change.

The WHOLE upstream vocabulary, because a declaration says what a caller may be handed and a caller switching on it should not have to be told which subset this engine happens to produce. Nine of these occur as published objects: Insert, Delete, Property, MovedFrom, MovedTo, CellInsertion, CellDeletion, CellMerge and ParagraphNumber. A structural card with no single type, such as table grid history, is omitted from items; collection-wide decisions still resolve every store-resolvable revision. See compat/manifest.json.

type RevisionType = 'None' | 'Insert' | 'Delete' | 'Property' | 'ParagraphNumber' | 'DisplayField' | 'Reconcile' | 'Conflict' | 'Style' | 'Replace' | 'ParagraphProperty' | 'TableProperty' | 'SectionProperty' | 'StyleDefinition' | 'MovedFrom' | 'MovedTo' | 'CellInsertion' | 'CellDeletion' | 'CellMerge' | 'CellSplit' | 'ConflictInsert' | 'ConflictDelete';

RunCallbacktypeSource ↗

What a run callback is given, and what it may answer with.

type RunCallback<T> = (context: RequestContext) => Promise<T>;

RuntimeDiagnostictypeSource ↗

A diagnostic from a headless runtime: the open, and each refused batch. Each one is also a valid EditorDiagnostic, so a telemetry module written for the editor receives these unchanged.

type RuntimeDiagnostic = {
    readonly schemaVersion: number;
    readonly editorSessionId: string;
    readonly time: number;
} & ({
    readonly kind: 'document.open';
    readonly outcome: 'opened';
    readonly sizeBucket: ByteSizeBucket;
    readonly durationMs: number;
} | {
    readonly kind: 'document.open';
    readonly outcome: 'rejected';
    readonly code: DocumentOpenDiagnosticCode;
    readonly sizeBucket?: ByteSizeBucket;
    readonly cause?: string;
    readonly part?: DocumentPartKind;
    readonly errorName?: DiagnosticErrorName;
} | {
    readonly kind: 'edit.rejected';
    readonly code: EditDiagnosticCode;
    readonly origin: 'automation';
    readonly tracked: boolean;
    readonly cause?: string;
    readonly errorName?: DiagnosticErrorName;
    readonly stage?: 'automation';
} | {
    readonly kind: 'review.skipped';
    readonly code: ReviewDiagnosticCode;
    readonly count: number;
    readonly operation?: ReviewOperation;
    readonly cause?: string;
});

SelectionMode_2type

Where a selection lands: over the range, or collapsed to one of its edges.

type SelectionMode = 'Select' | 'Start' | 'End';

Enums (17)

AlignmentenumSource ↗

Paragraph alignment vocabulary. Mixed and unknown are read states, not authoring modes.

declare enum Alignment
MemberTypeSummary
centered
justified
left
mixed
right
unknown

BreakTypeenumSource ↗

Office break vocabulary; enum presence does not imply support for every break kind.

declare enum BreakType
MemberTypeSummary
line
next
page
sectionContinuous
sectionEven
sectionNext
sectionOdd

ChangeTrackingModeenumSource ↗

Tracking policy vocabulary. Unsupported policies fail explicitly at sync.

declare enum ChangeTrackingMode
MemberTypeSummary
off
trackAll
trackMineOnly

ChangeTrackingVersionenumSource ↗

Which version of tracked text getReviewedText reads: as if every pending revision were rejected (Original) or accepted (Current).

declare enum ChangeTrackingVersion
MemberTypeSummary
current
original

CompareTargetenumSource ↗

Where a document compare puts its result. Only CompareTargetCurrent is supported: the revisions go into the document the call is made on.

declare enum CompareTarget
MemberTypeSummary
compareTargetCurrent
compareTargetNew
compareTargetSelected

ContentControlTypeenumSource ↗

Content-control kinds, including the read subtypes that insertion does not accept.

declare enum ContentControlType
MemberTypeSummary
buildingBlockGallery
checkBox
comboBox
datePicker
dropDownList
group
picture
plainText
plainTextInline
plainTextParagraph
repeatingSection
richText
richTextInline
richTextParagraphs
richTextTable
richTextTableCell
richTextTableRow
unknown

FieldTypeenumSource ↗

Office field types. This runtime authors Page, NumPages, Ref, PageRef, NoteRef, Seq, StyleRef, Date, Time, TOC, and Empty with an instruction of one of those types.

declare enum FieldType
MemberTypeSummary
addin
addressBlock
advance
ask
author
autoText
autoTextList
barCode
bibliography
bidiOutline
citation
comments
compare
createDate
data
database
date
displayBarcode
docProperty
docVariable
editTime
embedded
empty
eq
expression
fileName
fileSize
fillIn
formCheckbox
formDropdown
formText
gotoButton
greetingLine
if
import
include
includePicture
includeText
index
info
keywords
lastSavedBy
listNum
macroButton
mergeBarcode
mergeField
mergeRec
mergeSeq
next
nextIf
noteRef
numChars
numPages
numWords
ocx
others
page
pageRef
print
printDate
private
quote
rd
ref
revNum
saveDate
section
sectionPages
seq
set
shape
skipIf
styleRef
subject
subscriber
symbol
ta
tc
template
time
title
toa
toc
undefined
userAddress
userInitials
userName
xe

InsertLocationenumSource ↗

Locations used by Office-shaped insertion calls. Each call validates its allowed subset.

declare enum InsertLocation
MemberTypeSummary
after
before
end
replace
start

ListBulletenumSource ↗

Supported Word bullet styles.

declare enum ListBullet
MemberTypeSummary
arrow
checkmark
custom
diamonds
hollow
solid
square

ListNumberingenumSource ↗

Supported Word numbering styles.

declare enum ListNumbering
MemberTypeSummary
arabic
lowerLetter
lowerRoman
none
upperLetter
upperRoman

PageOrientationenumSource ↗

Physical page orientation.

declare enum PageOrientation
MemberTypeSummary
landscape
portrait

RangeLocationenumSource ↗

Which part of an object a getRange call answers. Each call validates its allowed subset; Range.getRange supports Whole, Content, Start, and End.

declare enum RangeLocation
MemberTypeSummary
after
before
content
end
start
whole

RemoveDocInfoTypeenumSource ↗

Document information categories. Only DocumentProperties removal is supported.

declare enum RemoveDocInfoType
MemberTypeSummary
all
atMentions
commentReactions
comments
contentType
documentIntelligence
documentManagementPolicy
documentProperties
documentServerProperties
documentTasks
documentWorkspace
emailHeader
inkAnnotations
removePersonalInformation
revisions
routingSlip
sendForReview
taskpaneWebExtensions
template
versions

ShapeTypeenumSource ↗

Word's shape types. Supported text-bearing shapes expose their own body.

declare enum ShapeType
MemberTypeSummary
canvas
geometricShape
group
picture
textBox
unsupported

StyleTypeenumSource ↗

The kind of a style.

declare enum StyleType
MemberTypeSummary
characterA character style. The paragraph `style` setters refuse its name.
listA numbering style, which defines list formatting. The paragraph `style` setters refuse its name.
paragraphA paragraph style, which `paragraph.style` accepts by its `nameLocal`.
tableA table style. The paragraph `style` setters refuse its name; `Table.style` accepts its `nameLocal`.

UnderlineTypeenumSource ↗

Office.js underline values. Unsupported runtime modes refuse at sync.

declare enum UnderlineType
MemberTypeSummary
dashLine
dashLineHeavy
dashLineLong
dashLineLongHeavy
dotDashLine
dotDashLineHeavy
dotLine
dotted
dottedHeavy
double
hidden
mixed
none
single
thick
twoDotDashLine
twoDotDashLineHeavy
wave
waveDouble
waveHeavy
word

VerticalAlignmentenumSource ↗

Vertical placement of content within a table cell. Mixed cannot be authored.

declare enum VerticalAlignment
MemberTypeSummary
bottom
center
mixed
top

Variables (1)

DocxEditorconstSource ↗

The entry point: open a document and get a runtime to work against.

Import from @docx-editor.dev/editor-api/browser for the same namespace plus createBrowser, which borrows a live editor instead of owning bytes.

DocxEditor: DocxEditorNamespace
```ts
import { DocxEditor } from '@docx-editor.dev/editor-api';

const runtime = await DocxEditor.createServer(bytes, { author: 'Payroll bot' });
await runtime.run(async (context) => {
  const body = context.document.body;
  body.load('text');
  await context.sync();
});
const saved = await runtime.save();
```