Track Changes: Show 'Original' and 'No Markup'
The redlining feature is very helpful when working on the same document with multiple authors specifically with legal or healthcare documents where changes need to be tracked and safely logged. This article shows how to use JavaScript to accept or reject all changes.

The popular document collaboration redlining feature is very helpful when working on the same document with multiple authors specifically with legal or healthcare documents where changes need to be tracked and safely logged.
Using TX Text Control, track changes is fully programmable using the TX Text Control JavaScript API. For each Tracked
The API can be also used to control the workflow of a tracked document: You can accept single changes, reject changes or retrieve information about the change. This sample shows how to accept or reject all changes programmatically by simulating the markup preview views from MS Word:
- Original: Shows the original document without any changes (reject all).
- No markup: Shows the document how it would look like with all changes (accept all).
The following screen video shows the 3 different states:
The following code includes the switch/case instruction for the different buttons in the sample:
$("#trackedChangeState input:radio").change(function () {
switch ($(this).attr('id')) {
case "stateEdit":
reloadDocumentState()
break
case "stateOriginal":
trackChangesOriginal();
break;
case "stateNoMarkup":
trackChangesNoMarkup();
break;
}
});
Both Original and No markup call a function to store the current document in a variable in order to remove the changes. The Original rejects all changes and the No markup call accepts all changes:
function trackChangesOriginal() {
storeDocumentState();
removeAllChanges(false);
}
function trackChangesNoMarkup() {
storeDocumentState();
removeAllChanges(true);
}
The following method does the actual work and loops through all changes recursively in order to remove the change using the remove method:
function removeAllChanges(accept) {
TXTextControl.trackedChanges.getCount(count => {
if (count === 0) return;
// recursively loop through all changes
// and remove them
TXTextControl.trackedChanges.elementAt(0, element => {
TXTextControl.trackedChanges.remove(element, accept, deleted => {
if (deleted === true) removeAllChanges(accept);
});
});
});
}
When one of the preview states is selected, the editor is in a read only mode and switches back when Edit is clicked.
You can test this demo by downloading the sources from our GitHub repository.
Also See
This post references the following in the documentation:
- Javascript: Tracked
Change Object - Javascript: Tracked
Change Collection.get Item Method - Javascript: Tracked
Change Collection Object - Javascript: Tracked
Change Collection.remove Method - Javascript: TXText
Control.load Document Method
Download and Fork This Sample on GitHub
We proudly host our sample code on github.com/TextControl.
Please fork and contribute.
Requirements for this sample
- TX Text Control .NET Server X19 (trial sufficient), Visual Studio 2019
Angular
Integrate document processing, editing, sharing, collaboration, creation, electronic signatures, and PDF generation into your Angular Web applications.
Related Posts
JavaScript: Avoid Flickering and Visual Updates by Grouping Undo Steps
The JavaScript API can be used to group several steps into one undo action that can be undone with a single undo call. Additionally, those groups are visually updated at once to avoid screen…
AngularASP.NETDocument Collaboration
Adding Electronic and Digital Signatures to Documents in C# and Angular
TX Text Control provides a complete set of tools to add eletronic, legally binding signatures to documents including Adobe PDF and to digitally sign those documents with certificates. This article…
Using the Document Editor in SPA Applications using the removeFromDom Method
This article shows how to use the removeFromDom method to remove the Document Editor from the DOM when it is no longer needed. This is useful when the Document Editor is used in a Single Page…
Observe When the Reporting Preview Tab is Active Using MutationObserver
This article shows how to observe when the Reporting Preview tab is active using MutationObserver. The Reporting Preview tab is a feature of the TX Text Control Document Editor that allows you to…
Building an ASP.NET Core Backend Application to Host the Document Editor and…
This article explains how to create an ASP.NET Core backend application to host the Document Editor and Document Viewer. This backend application is required to provide the required functionality…