New

docx-editor 1.x has shipped. Vue support, i18n, agents. Read the migration guide →

API Referencev1.3.3

@eigenpal/docx-editor-core/prosemirror/utils/extractTrackedChanges

Walk the PM doc once and derive (a) the tracked-change list and (b) a comment→revision overlap map for threading. Adjacent entries from the same revision are merged; deletion+insertion pairs from the same author/date become a single `replacement` entry (matches Word's UX for replace ops).

Pure function — no React, no Vue, no side effects. Single O(N) walk over text nodes. Consumers building custom sidebars should prefer the adapter-specific wrappers (`useTrackedChanges` in `@eigenpal/docx-editor-react/hooks` and `@eigenpal/docx-editor-vue/composables`), which add the memoization and reactivity layer. Reach for the core function directly for server-side analysis or test fixtures.

Functions(1)

Walk the PM doc and extract every tracked change as a flat list of `TrackedChangeEntry` plus a comment→revision overlap map. Adjacent inline marks coalesce by `(type, revisionId, author, date)`; a deletion immediately followed by an insertion (same author + same date) collapses into a single `replacement` entry; paragraph-mark cards (`paragraphMarkInsertion` / `paragraphMarkDeletion`) are hidden when an inline entry already covers their revision triple (one Accept clears every site of one conceptual change).

Pure and deterministic. Returns `EMPTY_RESULT` on null state.

declare function extractTrackedChanges(state: EditorState | null): TrackedChangesResult;
```ts
import { extractTrackedChanges } from '@eigenpal/docx-editor-core/prosemirror/utils/extractTrackedChanges';

const { entries, commentToRevision } = extractTrackedChanges(view.state);
for (const e of entries) {
  console.log(e.type, e.author, e.text);
}
```

Interfaces(1)

Output of [extractTrackedChanges](extractTrackedChanges).

interface TrackedChangesResult
MemberTypeSummary
commentToRevisionMap<number, number>Map of `commentId -> revisionId` for comments whose range overlaps a tracked-change mark. Consumers (DocxEditor's threading effect) use this to thread comments under their tracked change.
entriesTrackedChangeEntry[]Tracked-change entries, sorted by document position, with adjacent same-revision entries merged.