Products Technologies Demo Docs Blog Support Company

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.

Track Changes: Show 'Original' and 'No Markup'

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 TrackedChanged, you can retrieve the timestamp, the kind of the change, position, text, highlight colors and the associated author name.

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:

Track changes in Text Control

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.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Also See

This post references the following in the documentation:

  • Javascript: TrackedChange Object
  • Javascript: TrackedChangeCollection.getItem Method
  • Javascript: TrackedChangeCollection Object
  • Javascript: TrackedChangeCollection.remove Method
  • Javascript: TXTextControl.loadDocument Method

GitHub

Download and Fork This Sample on GitHub

We proudly host our sample code on github.com/TextControl.

Please fork and contribute.

Download ZIP

Open on GitHub

Open in Visual Studio

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.

Learn more about Angular

Related Posts

AngularASP.NETJavaScript

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…


AngularASP.NETJavaScript

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…


AngularASP.NETJavaScript

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…


AngularASP.NETJavaScript

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…