Skip to content
Document Authoring DA  API Docs v1.20.0
npmGitHub

RevisionCollectionNEW

RevisionCollection:

Document-root collection for querying and deciding pending revisions.

RevisionCollection is the entry point for programmatic tracked-change workflows. all() returns pending revisions in document order: body first, followed by effective headers and footers in revision-engine enumeration order. Decided revisions leave the collection; there is no status field.

Collection decisions apply directly even inside a review transaction. Adjudication is not itself tracked. Select by ID, author, paragraph-local text range, or all pending revisions. A range selects revision IDs whose anchors overlap the input range on the same text surface; omitting its range uses the whole TextView.

A deletion hidden by a review transaction has a zero-length anchor and does not overlap a non-empty range. Select such a revision by item, ID, author, or { all: true }.

Pass expand: 'contiguous' to use the engine’s contiguity expansion. IDs added by expansion appear in the returned decided array. Refusals are returned as data and never throw.

Move revisions do not appear in the collection because DOCX import maps moves to insertion and deletion pairs.

Inspect and accept all pending insertions from one author:

const revisions = draft.revisions();
const insertions = revisions.all({ author: 'Ana', type: 'insertion' });
for (const revision of insertions) {
console.log(revision.preview, revision.story, revision.anchors);
}
const result = revisions.accept({ ids: insertions.map(({ id }) => id) });
console.log(result.decided, result.refused);

Accept revisions intersecting a text range and expand to contiguous changes:

const firstBlock = draft.body().content().blocklevels()[0];
if (firstBlock?.type === 'paragraph') {
const textView = firstBlock.asTextView();
const match = textView.searchText('review this clause');
if (match) {
draft.revisions().accept(
{ range: { textView, range: match.range } },
{ expand: 'contiguous' },
);
}
}

all(options?): Revision[]

Returns pending revisions in document order.

RevisionQueryOptions

Optional author, type, and story filters

Revision[]

Pending revisions matching the query options

Results contain body revisions first, followed by effective headers and footers. Supplied query filters are combined. Decided revisions are absent.


accept(selector, options?): RevisionDecisionResult

Accepts the selected pending revisions.

RevisionSelector

Revision IDs, author, text range, or all pending revisions

RevisionDecisionOptions

Optional contiguous-expansion behavior

RevisionDecisionResult

IDs decided by the operation and any non-throwing refusals


reject(selector, options?): RevisionDecisionResult

Rejects the selected pending revisions.

RevisionSelector

Revision IDs, author, text range, or all pending revisions

RevisionDecisionOptions

Optional contiguous-expansion behavior

RevisionDecisionResult

IDs decided by the operation and any non-throwing refusals