Class: TrackedChangeManager

Core.Document.OfficeEditor. TrackedChangeManager


new TrackedChangeManager()

Manages tracked changes within an Office Editor document.
Example
const trackedChangeManager = instance.Core.documentViewer.getDocument().getOfficeEditor().getTrackedChangeManager();

Members


<static> TrackedChangeColorPreset

Preset values for tracked change colors.
Properties:
Name Type Description
NONE string Use no markup color.
AUTO string Use the author color (auto).

<static> TrackedChangeSelectionAction

The action associated with a tracked change selection event.
Properties:
Name Type Description
SELECTED string The tracked change was selected
DESELECTED string The tracked change was deselected

<static> TrackedChangeType

An enum representing the tracked change types in Office Editor.
Properties:
Name Type Description
INSERTED string inserted tracked changes
DELETED string deleted tracked changes
FORMATTED string formatted tracked changes

<static> TrackedChangeUpdateAction

The different action types for the trackedChangesUpdated event.
Properties:
Name Type Description
ADD string When the trackedChangesUpdated event is triggered due to adding a tracked change
DELETE string When the trackedChangesUpdated event is triggered due to deleting a tracked change
MODIFY string When the trackedChangesUpdated event is triggered due to modifying a tracked change

Methods


acceptTrackedChange(id)

Accepts a tracked change in the document.
Parameters:
Name Type Description
id number The numeric id of the tracked change to accept.
Returns:
Type
Promise.<void>
Example
const trackedChangeManager = instance.Core.documentViewer.getDocument().getOfficeEditor().getTrackedChangeManager();
await trackedChangeManager.acceptTrackedChange(3);

acceptTrackedChanges(ids)

Accepts multiple tracked changes in a single batch operation by an array of ids. This will pause rendering and show a loading modal until the entire operation is completed.
Parameters:
Name Type Description
ids Array.<number> An array of numeric tracked change ids to accept.
Returns:
Type
Promise.<void>
Example
// Accept all tracked changes in the document
const trackedChangeManager = instance.Core.documentViewer.getDocument().getOfficeEditor().getTrackedChangeManager();
const allChanges = await trackedChangeManager.getTrackedChanges();
await trackedChangeManager.acceptTrackedChanges(allChanges.map(c => c.id));

getTrackedChangeOOXMLIds()

Returns the mapping of tracked change IDs to OOXML tracked change IDs. OOXML is the Office Open XML representation used by Office documents. These IDs can be used to connect imported OOXML tracked changes to WebViewer tracked change IDs. OOXML IDs come from the source document and are not available for tracked changes created within WebViewer.

This is an experimental API intended for advanced users and may change in future releases.
Returns:
Map of tracked change ids to OOXML tracked change ids.
Type
Promise.<Map.<number, Array.<number>>>
Examples
// Lookup OOXML IDs for a specific tracked change.
const trackedChangeManager = instance.Core.documentViewer.getDocument().getOfficeEditor().getTrackedChangeManager();
const ooxmlIdsMap = await trackedChangeManager.getTrackedChangeOOXMLIds();
const trackedChangeId = 3;
const ooxmlIds = ooxmlIdsMap.get(trackedChangeId) || [];
// Build a reverse lookup from OOXML ID to tracked change ID.
const trackedChangeManager = instance.Core.documentViewer.getDocument().getOfficeEditor().getTrackedChangeManager();
const ooxmlIdsMap = await trackedChangeManager.getTrackedChangeOOXMLIds();
const ooxmlIdToTrackedChange = new Map();
for (const [trackedChangeId, ooxmlIds] of ooxmlIdsMap.entries()) {
  for (const ooxmlId of ooxmlIds) {
    ooxmlIdToTrackedChange.set(ooxmlId, trackedChangeId);
  }
}
const trackedChangeId = ooxmlIdToTrackedChange.get(42);

getTrackedChanges()

Returns an array of tracked change objects ordered by their position in the document.
Returns:
The tracked changes in the document
Type
Array.<Core.Document.OfficeEditor.TrackedChangeManager.TrackedChange>
Example
const trackedChangeManager = instance.Core.documentViewer.getDocument().getOfficeEditor().getTrackedChangeManager();
const trackedChanges = await trackedChangeManager.getTrackedChanges();
instance.Core.documentViewer.getDocument().addEventListener('trackedChangesUpdated', (trackedChange, action) => {
  console.log('Tracked change updated:', trackedChange, action);
});

moveCursorToTrackedChange(id)

Moves the main cursor to the start of the tracked change with the given id.
Parameters:
Name Type Description
id number The id of the tracked change to move to.
Deprecated:
Returns:
Type
Promise.<void>
Example
const trackedChangeManager = instance.Core.documentViewer.getDocument().getOfficeEditor().getTrackedChangeManager();
await trackedChangeManager.moveCursorToTrackedChange(3);

Navigates to the tracked change with the given id. Moves the main cursor to the start of the tracked change and scrolls the document to bring it into view.
Parameters:
Name Type Description
id number The id of the tracked change to navigate to.
Returns:
Type
Promise.<void>
Example
const trackedChangeManager = instance.Core.documentViewer.getDocument().getOfficeEditor().getTrackedChangeManager();
const trackedChanges = await trackedChangeManager.getTrackedChanges();
await trackedChangeManager.navigateToTrackedChange(trackedChanges[0].id);

rejectTrackedChange(id)

Rejects a tracked change in the document.
Parameters:
Name Type Description
id number The numeric id of the tracked change to reject.
Returns:
Type
Promise.<void>
Example
const trackedChangeManager = instance.Core.documentViewer.getDocument().getOfficeEditor().getTrackedChangeManager();
await trackedChangeManager.rejectTrackedChange(3);

rejectTrackedChanges(ids)

Rejects multiple tracked changes in a single batch operation by an array of ids. This will pause rendering and show a loading modal until the entire operation is completed.
Parameters:
Name Type Description
ids Array.<number> An array of numeric tracked change ids to reject.
Returns:
Type
Promise.<void>
Example
// Reject all tracked changes in the document
const trackedChangeManager = instance.Core.documentViewer.getDocument().getOfficeEditor().getTrackedChangeManager();
const allChanges = await trackedChangeManager.getTrackedChanges();
await trackedChangeManager.rejectTrackedChanges(allChanges.map(c => c.id));

selectTrackedChange(id)

Selects the tracked change with the given id. Any currently selected annotations will be deselected first to prevent multiselect. Fires the trackedChangeSelected event with a "selected" action.
Parameters:
Name Type Description
id number The id of the tracked change to select.
Returns:
Type
Promise.<void>
Example
const trackedChangeManager = instance.Core.documentViewer.getDocument().getOfficeEditor().getTrackedChangeManager();
await trackedChangeManager.selectTrackedChange(3);

Type Definitions


TrackedChange

Represents a tracked change in an Office Editor document.
Type:
  • Object
Properties:
Name Type Description
id number The id of the tracked change
type Core.Document.OfficeEditor.TrackedChangeManager.TrackedChangeType The type of the tracked change
author string The author of the tracked change
date Date The date of the tracked change
plaintext string The content of the tracked change to be inserted or deleted
getPagePositions function Returns a promise that resolves to an array of objects containing {pageNumber: number, rect: Core.Math.Rect} for each annotation related to the tracked change.

TrackedChangeColor

Type: