packages/document-api/src/contract/*.
Document API is currently alpha and subject to breaking changes.
Browse by namespace
| Namespace | Canonical ops | Aliases | Total surface | Reference |
|---|---|---|---|---|
| Core | 10 | 0 | 10 | Open |
| Blocks | 1 | 0 | 1 | Open |
| Capabilities | 1 | 0 | 1 | Open |
| Create | 6 | 0 | 6 | Open |
| Sections | 18 | 0 | 18 | Open |
| Format | 44 | 1 | 45 | Open |
| Styles | 1 | 0 | 1 | Open |
| Lists | 17 | 0 | 17 | Open |
| Comments | 5 | 0 | 5 | Open |
| Track Changes | 3 | 0 | 3 | Open |
| Query | 1 | 0 | 1 | Open |
| Mutations | 2 | 0 | 2 | Open |
| Paragraph Formatting | 17 | 0 | 17 | Open |
| Paragraph Styles | 2 | 0 | 2 | Open |
| Tables | 42 | 0 | 42 | Open |
| History | 3 | 0 | 3 | Open |
| Table of Contents | 10 | 0 | 10 | Open |
| Images | 13 | 0 | 13 | Open |
Available operations
The tables below are grouped by namespace.Core
| Operation | API member path | Description |
|---|---|---|
find | editor.doc.find(…) | Search the document for nodes matching type, text, or attribute criteria. |
getNode | editor.doc.getNode(…) | Retrieve a single node by target position. |
getNodeById | editor.doc.getNodeById(…) | Retrieve a single node by its unique ID. |
getText | editor.doc.getText(…) | Extract the plain-text content of the document. |
getMarkdown | editor.doc.getMarkdown(…) | Extract the document content as a Markdown string. |
getHtml | editor.doc.getHtml(…) | Extract the document content as an HTML string. |
info | editor.doc.info(…) | Return document metadata including revision, node count, and capabilities. |
insert | editor.doc.insert(…) | Insert content at a target position, or at the end of the document when target is omitted. Supports text (default), markdown, and html content types via the type field. |
replace | editor.doc.replace(…) | Replace content at a target position with new text or inline content. |
delete | editor.doc.delete(…) | Delete content at a target position. |
Blocks
| Operation | API member path | Description |
|---|---|---|
blocks.delete | editor.doc.blocks.delete(…) | Delete an entire block node (paragraph, heading, list item, table, image, or sdt) deterministically. |
Capabilities
| Operation | API member path | Description |
|---|---|---|
capabilities.get | editor.doc.capabilities() | Query runtime capabilities supported by the current document engine. |
Create
| Operation | API member path | Description |
|---|---|---|
create.paragraph | editor.doc.create.paragraph(…) | Create a new paragraph at the target position. |
create.heading | editor.doc.create.heading(…) | Create a new heading at the target position. |
create.sectionBreak | editor.doc.create.sectionBreak(…) | Create a section break at the target location with optional initial section properties. |
create.table | editor.doc.create.table(…) | Create a new table at the target position. |
create.tableOfContents | editor.doc.create.tableOfContents(…) | Insert a new table of contents at the target position. |
create.image | editor.doc.create.image(…) | Insert a new image at the target position. |
Sections
| Operation | API member path | Description |
|---|---|---|
sections.list | editor.doc.sections.list(…) | List sections in deterministic order with section-target handles. |
sections.get | editor.doc.sections.get(…) | Retrieve full section information by section address. |
sections.setBreakType | editor.doc.sections.setBreakType(…) | Set the section break type. |
sections.setPageMargins | editor.doc.sections.setPageMargins(…) | Set page-edge margins for a section. |
sections.setHeaderFooterMargins | editor.doc.sections.setHeaderFooterMargins(…) | Set header/footer margin distances for a section. |
sections.setPageSetup | editor.doc.sections.setPageSetup(…) | Set page size/orientation properties for a section. |
sections.setColumns | editor.doc.sections.setColumns(…) | Set column configuration for a section. |
sections.setLineNumbering | editor.doc.sections.setLineNumbering(…) | Enable or configure line numbering for a section. |
sections.setPageNumbering | editor.doc.sections.setPageNumbering(…) | Set page numbering format/start for a section. |
sections.setTitlePage | editor.doc.sections.setTitlePage(…) | Enable or disable title-page behavior for a section. |
sections.setOddEvenHeadersFooters | editor.doc.sections.setOddEvenHeadersFooters(…) | Enable or disable odd/even header-footer mode in document settings. |
sections.setVerticalAlign | editor.doc.sections.setVerticalAlign(…) | Set vertical page alignment for a section. |
sections.setSectionDirection | editor.doc.sections.setSectionDirection(…) | Set section text flow direction (LTR/RTL). |
sections.setHeaderFooterRef | editor.doc.sections.setHeaderFooterRef(…) | Set or replace a section header/footer reference for a variant. |
sections.clearHeaderFooterRef | editor.doc.sections.clearHeaderFooterRef(…) | Clear a section header/footer reference for a specific variant. |
sections.setLinkToPrevious | editor.doc.sections.setLinkToPrevious(…) | Set or clear link-to-previous behavior for a header/footer variant. |
sections.setPageBorders | editor.doc.sections.setPageBorders(…) | Set page border configuration for a section. |
sections.clearPageBorders | editor.doc.sections.clearPageBorders(…) | Clear page border configuration for a section. |
Format
| Operation | API member path | Description |
|---|---|---|
format.apply | editor.doc.format.apply(…) | Apply inline run-property patch changes to the target range with explicit set/clear semantics. |
format.bold | editor.doc.format.bold(…) | Set or clear the bold inline run property on the target text range. |
format.italic | editor.doc.format.italic(…) | Set or clear the italic inline run property on the target text range. |
format.strike | editor.doc.format.strike(…) | Set or clear the strike inline run property on the target text range. |
format.underline | editor.doc.format.underline(…) | Set or clear the underline inline run property on the target text range. |
format.highlight | editor.doc.format.highlight(…) | Set or clear the highlight inline run property on the target text range. |
format.color | editor.doc.format.color(…) | Set or clear the color inline run property on the target text range. |
format.fontSize | editor.doc.format.fontSize(…) | Set or clear the fontSize inline run property on the target text range. |
format.fontFamily | editor.doc.format.fontFamily(…) | Set or clear the fontFamily inline run property on the target text range. |
format.letterSpacing | editor.doc.format.letterSpacing(…) | Set or clear the letterSpacing inline run property on the target text range. |
format.vertAlign | editor.doc.format.vertAlign(…) | Set or clear the vertAlign inline run property on the target text range. |
format.position | editor.doc.format.position(…) | Set or clear the position inline run property on the target text range. |
format.dstrike | editor.doc.format.dstrike(…) | Set or clear the dstrike inline run property on the target text range. |
format.smallCaps | editor.doc.format.smallCaps(…) | Set or clear the smallCaps inline run property on the target text range. |
format.caps | editor.doc.format.caps(…) | Set or clear the caps inline run property on the target text range. |
format.shading | editor.doc.format.shading(…) | Set or clear the shading inline run property on the target text range. |
format.border | editor.doc.format.border(…) | Set or clear the border inline run property on the target text range. |
format.outline | editor.doc.format.outline(…) | Set or clear the outline inline run property on the target text range. |
format.shadow | editor.doc.format.shadow(…) | Set or clear the shadow inline run property on the target text range. |
format.emboss | editor.doc.format.emboss(…) | Set or clear the emboss inline run property on the target text range. |
format.imprint | editor.doc.format.imprint(…) | Set or clear the imprint inline run property on the target text range. |
format.charScale | editor.doc.format.charScale(…) | Set or clear the charScale inline run property on the target text range. |
format.kerning | editor.doc.format.kerning(…) | Set or clear the kerning inline run property on the target text range. |
format.vanish | editor.doc.format.vanish(…) | Set or clear the vanish inline run property on the target text range. |
format.webHidden | editor.doc.format.webHidden(…) | Set or clear the webHidden inline run property on the target text range. |
format.specVanish | editor.doc.format.specVanish(…) | Set or clear the specVanish inline run property on the target text range. |
format.rtl | editor.doc.format.rtl(…) | Set or clear the rtl inline run property on the target text range. |
format.cs | editor.doc.format.cs(…) | Set or clear the cs inline run property on the target text range. |
format.bCs | editor.doc.format.bCs(…) | Set or clear the bCs inline run property on the target text range. |
format.iCs | editor.doc.format.iCs(…) | Set or clear the iCs inline run property on the target text range. |
format.eastAsianLayout | editor.doc.format.eastAsianLayout(…) | Set or clear the eastAsianLayout inline run property on the target text range. |
format.em | editor.doc.format.em(…) | Set or clear the em inline run property on the target text range. |
format.fitText | editor.doc.format.fitText(…) | Set or clear the fitText inline run property on the target text range. |
format.snapToGrid | editor.doc.format.snapToGrid(…) | Set or clear the snapToGrid inline run property on the target text range. |
format.lang | editor.doc.format.lang(…) | Set or clear the lang inline run property on the target text range. |
format.oMath | editor.doc.format.oMath(…) | Set or clear the oMath inline run property on the target text range. |
format.rStyle | editor.doc.format.rStyle(…) | Set or clear the rStyle inline run property on the target text range. |
format.rFonts | editor.doc.format.rFonts(…) | Set or clear the rFonts inline run property on the target text range. |
format.fontSizeCs | editor.doc.format.fontSizeCs(…) | Set or clear the fontSizeCs inline run property on the target text range. |
format.ligatures | editor.doc.format.ligatures(…) | Set or clear the ligatures inline run property on the target text range. |
format.numForm | editor.doc.format.numForm(…) | Set or clear the numForm inline run property on the target text range. |
format.numSpacing | editor.doc.format.numSpacing(…) | Set or clear the numSpacing inline run property on the target text range. |
format.stylisticSets | editor.doc.format.stylisticSets(…) | Set or clear the stylisticSets inline run property on the target text range. |
format.contextualAlternates | editor.doc.format.contextualAlternates(…) | Set or clear the contextualAlternates inline run property on the target text range. |
format.strikethrough | editor.doc.format.strikethrough(…) | Convenience alias for format.strike with value: true. |
Styles
| Operation | API member path | Description |
|---|---|---|
styles.apply | editor.doc.styles.apply(…) | Apply document-level default style changes to the stylesheet (word/styles.xml). Targets docDefaults run and paragraph channels with set-style patch semantics. |
Lists
| Operation | API member path | Description |
|---|---|---|
lists.list | editor.doc.lists.list(…) | List all list nodes in the document, optionally filtered by scope. |
lists.get | editor.doc.lists.get(…) | Retrieve a specific list node by target. |
lists.insert | editor.doc.lists.insert(…) | Insert a new list at the target position. |
lists.create | editor.doc.lists.create(…) | Create a new list from one or more paragraphs, or convert existing paragraphs into a new list. |
lists.attach | editor.doc.lists.attach(…) | Convert non-list paragraphs to list items under an existing list sequence. |
lists.detach | editor.doc.lists.detach(…) | Remove numbering properties from list items, converting them to plain paragraphs. |
lists.indent | editor.doc.lists.indent(…) | Increase the indentation level of a list item. |
lists.outdent | editor.doc.lists.outdent(…) | Decrease the indentation level of a list item. |
lists.join | editor.doc.lists.join(…) | Merge two adjacent list sequences into one. |
lists.canJoin | editor.doc.lists.canJoin(…) | Check whether two adjacent list sequences can be joined. |
lists.separate | editor.doc.lists.separate(…) | Split a list sequence at the target item, creating a new sequence from that point forward. |
lists.setLevel | editor.doc.lists.setLevel(…) | Set the absolute nesting level (0..8) of a list item. |
lists.setValue | editor.doc.lists.setValue(…) | Set an explicit numbering value at the target item. Mid-sequence targets are atomically separated first. |
lists.continuePrevious | editor.doc.lists.continuePrevious(…) | Continue numbering from the nearest compatible previous list sequence. |
lists.canContinuePrevious | editor.doc.lists.canContinuePrevious(…) | Check whether the target sequence can continue numbering from a previous compatible sequence. |
lists.setLevelRestart | editor.doc.lists.setLevelRestart(…) | Set the restart behavior for a specific list level. |
lists.convertToText | editor.doc.lists.convertToText(…) | Convert list items to plain paragraphs, optionally prepending the rendered marker text. |
Comments
| Operation | API member path | Description |
|---|---|---|
comments.create | editor.doc.comments.create(…) | Create a new comment thread (or reply when parentCommentId is given). |
comments.patch | editor.doc.comments.patch(…) | Patch fields on an existing comment (text, target, status, or isInternal). |
comments.delete | editor.doc.comments.delete(…) | Remove a comment or reply by ID. |
comments.get | editor.doc.comments.get(…) | Retrieve a single comment thread by ID. |
comments.list | editor.doc.comments.list(…) | List all comment threads in the document. |
Track Changes
| Operation | API member path | Description |
|---|---|---|
trackChanges.list | editor.doc.trackChanges.list(…) | List all tracked changes in the document. |
trackChanges.get | editor.doc.trackChanges.get(…) | Retrieve a single tracked change by ID. |
trackChanges.decide | editor.doc.trackChanges.decide(…) | Accept or reject a tracked change (by ID or scope: all). |
Query
| Operation | API member path | Description |
|---|---|---|
query.match | editor.doc.query.match(…) | Deterministic selector-based search with cardinality contracts for mutation targeting. |
Mutations
| Operation | API member path | Description |
|---|---|---|
mutations.preview | editor.doc.mutations.preview(…) | Dry-run a mutation plan, returning resolved targets without applying changes. |
mutations.apply | editor.doc.mutations.apply(…) | Execute a mutation plan atomically against the document. |
Paragraph Formatting
| Operation | API member path | Description |
|---|---|---|
format.paragraph.resetDirectFormatting | editor.doc.format.paragraph.resetDirectFormatting(…) | Strip all direct paragraph formatting while preserving style reference, numbering, and section metadata. |
format.paragraph.setAlignment | editor.doc.format.paragraph.setAlignment(…) | Set paragraph alignment (justification) on a paragraph-like block. |
format.paragraph.clearAlignment | editor.doc.format.paragraph.clearAlignment(…) | Remove direct paragraph alignment, reverting to style-defined or default alignment. |
format.paragraph.setIndentation | editor.doc.format.paragraph.setIndentation(…) | Set paragraph indentation properties (left, right, firstLine, hanging) in twips. |
format.paragraph.clearIndentation | editor.doc.format.paragraph.clearIndentation(…) | Remove all direct paragraph indentation. |
format.paragraph.setSpacing | editor.doc.format.paragraph.setSpacing(…) | Set paragraph spacing properties (before, after, line, lineRule) in twips. |
format.paragraph.clearSpacing | editor.doc.format.paragraph.clearSpacing(…) | Remove all direct paragraph spacing. |
format.paragraph.setKeepOptions | editor.doc.format.paragraph.setKeepOptions(…) | Set keep-with-next, keep-lines-together, and widow/orphan control flags. |
format.paragraph.setOutlineLevel | editor.doc.format.paragraph.setOutlineLevel(…) | Set the paragraph outline level (0–9) or null to clear. |
format.paragraph.setFlowOptions | editor.doc.format.paragraph.setFlowOptions(…) | Set contextual spacing, page-break-before, and suppress-auto-hyphens flags. |
format.paragraph.setTabStop | editor.doc.format.paragraph.setTabStop(…) | Add or replace a tab stop at a given position. |
format.paragraph.clearTabStop | editor.doc.format.paragraph.clearTabStop(…) | Remove a tab stop at a given position. |
format.paragraph.clearAllTabStops | editor.doc.format.paragraph.clearAllTabStops(…) | Remove all tab stops from a paragraph. |
format.paragraph.setBorder | editor.doc.format.paragraph.setBorder(…) | Set border properties for a specific side of a paragraph. |
format.paragraph.clearBorder | editor.doc.format.paragraph.clearBorder(…) | Remove border for a specific side or all sides of a paragraph. |
format.paragraph.setShading | editor.doc.format.paragraph.setShading(…) | Set paragraph shading (background fill, pattern color, pattern type). |
format.paragraph.clearShading | editor.doc.format.paragraph.clearShading(…) | Remove all paragraph shading. |
Paragraph Styles
| Operation | API member path | Description |
|---|---|---|
styles.paragraph.setStyle | editor.doc.styles.paragraph.setStyle(…) | Set the paragraph style reference (w:pStyle) on a paragraph-like block. |
styles.paragraph.clearStyle | editor.doc.styles.paragraph.clearStyle(…) | Remove the paragraph style reference from a paragraph-like block. |
Tables
| Operation | API member path | Description |
|---|---|---|
tables.convertFromText | editor.doc.tables.convertFromText(…) | Convert a text range into a table. |
tables.delete | editor.doc.tables.delete(…) | Delete the target table from the document. |
tables.clearContents | editor.doc.tables.clearContents(…) | Clear the contents of the target table or cell range. |
tables.move | editor.doc.tables.move(…) | Move a table to a new position in the document. |
tables.split | editor.doc.tables.split(…) | Split a table into two tables at the target row. |
tables.convertToText | editor.doc.tables.convertToText(…) | Convert a table back to plain text. |
tables.setLayout | editor.doc.tables.setLayout(…) | Set the layout mode of the target table. |
tables.insertRow | editor.doc.tables.insertRow(…) | Insert a new row into the target table. |
tables.deleteRow | editor.doc.tables.deleteRow(…) | Delete a row from the target table. |
tables.setRowHeight | editor.doc.tables.setRowHeight(…) | Set the height of a table row. |
tables.distributeRows | editor.doc.tables.distributeRows(…) | Distribute row heights evenly across the target table. |
tables.setRowOptions | editor.doc.tables.setRowOptions(…) | Set options on a table row such as header repeat or page break. |
tables.insertColumn | editor.doc.tables.insertColumn(…) | Insert a new column into the target table. |
tables.deleteColumn | editor.doc.tables.deleteColumn(…) | Delete a column from the target table. |
tables.setColumnWidth | editor.doc.tables.setColumnWidth(…) | Set the width of a table column. |
tables.distributeColumns | editor.doc.tables.distributeColumns(…) | Distribute column widths evenly across the target table. |
tables.insertCell | editor.doc.tables.insertCell(…) | Insert a new cell into a table row. |
tables.deleteCell | editor.doc.tables.deleteCell(…) | Delete a cell from a table row. |
tables.mergeCells | editor.doc.tables.mergeCells(…) | Merge a range of table cells into one. |
tables.unmergeCells | editor.doc.tables.unmergeCells(…) | Unmerge a previously merged table cell. |
tables.splitCell | editor.doc.tables.splitCell(…) | Split a table cell into multiple cells. |
tables.setCellProperties | editor.doc.tables.setCellProperties(…) | Set properties on a table cell such as vertical alignment or text direction. |
tables.sort | editor.doc.tables.sort(…) | Sort table rows by a column value. |
tables.setAltText | editor.doc.tables.setAltText(…) | Set the alternative text description for a table. |
tables.setStyle | editor.doc.tables.setStyle(…) | Apply a named table style to the target table. |
tables.clearStyle | editor.doc.tables.clearStyle(…) | Remove the applied table style, reverting to defaults. |
tables.setStyleOption | editor.doc.tables.setStyleOption(…) | Toggle a conditional style option such as banded rows or first column. |
tables.setBorder | editor.doc.tables.setBorder(…) | Set border properties on a table or cell range. |
tables.clearBorder | editor.doc.tables.clearBorder(…) | Remove border formatting from a table or cell range. |
tables.applyBorderPreset | editor.doc.tables.applyBorderPreset(…) | Apply a border preset (e.g. all borders, outside only) to a table. |
tables.setShading | editor.doc.tables.setShading(…) | Set the background shading color on a table or cell range. |
tables.clearShading | editor.doc.tables.clearShading(…) | Remove shading from a table or cell range. |
tables.setTablePadding | editor.doc.tables.setTablePadding(…) | Set default cell padding for the entire table. |
tables.setCellPadding | editor.doc.tables.setCellPadding(…) | Set padding on a specific table cell or cell range. |
tables.setCellSpacing | editor.doc.tables.setCellSpacing(…) | Set the cell spacing for the target table. |
tables.clearCellSpacing | editor.doc.tables.clearCellSpacing(…) | Remove custom cell spacing from the target table. |
tables.get | editor.doc.tables.get(…) | Retrieve table structure and dimensions by locator. |
tables.getCells | editor.doc.tables.getCells(…) | Retrieve cell information for a table, optionally filtered by row or column. |
tables.getProperties | editor.doc.tables.getProperties(…) | Retrieve layout and style properties of a table. |
tables.getStyles | editor.doc.tables.getStyles(…) | List all table styles and the document-level default table style setting. |
tables.setDefaultStyle | editor.doc.tables.setDefaultStyle(…) | Set the document-level default table style (w:defaultTableStyle in settings.xml). |
tables.clearDefaultStyle | editor.doc.tables.clearDefaultStyle(…) | Remove the document-level default table style setting. |
History
| Operation | API member path | Description |
|---|---|---|
history.get | editor.doc.history.get(…) | Query the current undo/redo history state of the active editor. |
history.undo | editor.doc.history.undo(…) | Undo the most recent history-safe mutation in the active editor. |
history.redo | editor.doc.history.redo(…) | Redo the most recently undone action in the active editor. |
Table of Contents
| Operation | API member path | Description |
|---|---|---|
toc.list | editor.doc.toc.list(…) | List all tables of contents in the document. |
toc.get | editor.doc.toc.get(…) | Retrieve details of a specific table of contents. |
toc.configure | editor.doc.toc.configure(…) | Update the configuration switches of a table of contents. |
toc.update | editor.doc.toc.update(…) | Rebuild or refresh the materialized content of a table of contents. |
toc.remove | editor.doc.toc.remove(…) | Remove a table of contents from the document. |
toc.markEntry | editor.doc.toc.markEntry(…) | Insert a TC (table of contents entry) field at the target paragraph. |
toc.unmarkEntry | editor.doc.toc.unmarkEntry(…) | Remove a TC (table of contents entry) field from the document. |
toc.listEntries | editor.doc.toc.listEntries(…) | List all TC (table of contents entry) fields in the document body. |
toc.getEntry | editor.doc.toc.getEntry(…) | Retrieve details of a specific TC (table of contents entry) field. |
toc.editEntry | editor.doc.toc.editEntry(…) | Update the properties of a TC (table of contents entry) field. |
Images
| Operation | API member path | Description |
|---|---|---|
images.list | editor.doc.images.list(…) | List all images in the document. |
images.get | editor.doc.images.get(…) | Get details for a specific image by its stable ID. |
images.delete | editor.doc.images.delete(…) | Delete an image from the document. |
images.move | editor.doc.images.move(…) | Move an image to a new location in the document. |
images.convertToInline | editor.doc.images.convertToInline(…) | Convert a floating image to inline placement. |
images.convertToFloating | editor.doc.images.convertToFloating(…) | Convert an inline image to floating placement. |
images.setSize | editor.doc.images.setSize(…) | Set explicit width/height for an image. |
images.setWrapType | editor.doc.images.setWrapType(…) | Set the text wrapping type for a floating image. |
images.setWrapSide | editor.doc.images.setWrapSide(…) | Set which side(s) text wraps around a floating image. |
images.setWrapDistances | editor.doc.images.setWrapDistances(…) | Set the text-wrap distance margins for a floating image. |
images.setPosition | editor.doc.images.setPosition(…) | Set the anchor position for a floating image. |
images.setAnchorOptions | editor.doc.images.setAnchorOptions(…) | Set anchor behavior options for a floating image. |
images.setZOrder | editor.doc.images.setZOrder(…) | Set the z-order (relativeHeight) for a floating image. |

