# docx-editor-track-changes

> Word editor shows tracked changes with accept and reject controls and a revision color dropdown.

**Framework:** angular  **Component:** DocxEditor  **Variant:** track-changes

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/angular/docx-editor-track-changes.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-angular-documenteditor @syncfusion/ej2-angular-dropdowns @syncfusion/ej2-angular-buttons @syncfusion/ej2-angular-popups
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/docx-editor-track-changes/docx-editor.component.html

```html
<div class="control-section">
    <div class="row">
        <div class="col-lg-10">
            <div id="default_title_bar" class="e-de-ctn-title"></div>
            <div style="display:block; height: calc(100vh - 230px);">
                <ejs-documenteditorcontainer #documenteditor_default [enableToolbar]=true id="container" [enableTrackChanges]=true [locale]="culture" [toolbarMode]="'Ribbon'" (created)="onCreate()" [showPropertiesPane]=false
                    (documentChange)="onDocumentChange()" height="100%" [serviceUrl]="hostUrl"  style="display:block;" userColor="#b70f34" currentUser = "Nancy Davolio" [fileMenuItems]="fileMenuItems" (fileMenuItemClick)="fileMenuItemClick($event)"></ejs-documenteditorcontainer>
            </div>
        </div>
        <div class="col-lg-2 property-section">
            <div style="padding-top: 20px;">
                <b>Revision Color Settings</b>
            </div>
            <div style="margin-top: 15px;">
                <div style="padding-top: 10px;">
                    <label style="display: block; margin-bottom: 5px; font-weight: 500;">Insertion:</label>
                    <ejs-dropdownlist
                        id="insertion-color"
                        #insertionDrop
                        [dataSource]="revisionColorData"
                        [fields]="fields"
                        value="byAuthor"
                        placeholder="Insertion"
                        floatLabelType="Never"
                        width="100%"
                        (change)="onColorChange()"
                    ></ejs-dropdownlist>
                </div>
                <div style="padding-top: 10px;">
                    <label style="display: block; margin-bottom: 5px; font-weight: 500;">Deletion:</label>
                    <ejs-dropdownlist
                        id="deletion-color"
                        #deletionDrop
                        [dataSource]="revisionColorData"
                        [fields]="fields"
                        value="byAuthor"
                        placeholder="Deletion"
                        floatLabelType="Never"
                        width="100%"
                        (change)="onColorChange()"
                    ></ejs-dropdownlist>
                </div>
                <div style="padding-top: 10px;">
                    <label style="display: block; margin-bottom: 5px; font-weight: 500;">Inserted Rows:</label>
                    <ejs-dropdownlist
                        id="inserted-rows-color"
                        #insertedRowsDrop
                        [dataSource]="revisionColorData"
                        [fields]="fields"
                        value="byAuthor"
                        placeholder="Inserted Rows"
                        floatLabelType="Never"
                        width="100%"
                        (change)="onColorChange()"
                    ></ejs-dropdownlist>
                </div>
                <div style="padding-top: 10px;">
                    <label style="display: block; margin-bottom: 5px; font-weight: 500;">Deleted Rows:</label>
                    <ejs-dropdownlist
                        id="deleted-rows-color"
                        #deletedRowsDrop
                        [dataSource]="revisionColorData"
                        [fields]="fields"
                        value="byAuthor"
                        placeholder="Deleted Rows"
                        floatLabelType="Never"
                        width="100%"
                        (change)="onColorChange()"
                    ></ejs-dropdownlist>
                </div>
            </div>
            <div style="padding-top: 15px; margin-bottom: 10px;">
                <button
                    ejs-button
                    id="apply-btn"
                    #applyBtn
                    cssClass="e-primary"
                    [disabled]="isApplyDisabled"
                    (click)="onApply()"
                >
                    Apply
                </button>
            </div>
        </div>
    </div>
</div>
<style>
    @import '../style.css';
#documenteditor_title_contentEditor {
        height: 26px;
        max-width: 75%;
        width: auto;
        overflow: hidden;
        display: inline-block;
        padding-left: 4px;
        padding-right: 4px;
        margin: 5px;
    }

    .single-line {
        cursor: text !important;
        outline: none;
    }

    #default_title_bar {
        height: 36px;
        line-height: 26px;
        width: 100%;
        font-size: 12px;
        padding-left: 15px;
        padding-right: 10px;
        font-family: inherit;
		box-sizing: border-box;
    }

    [class^="e-de-icon-"],
    [class*=" e-de-icon-"] {
        font-family: 'Sample brower icons' !important;
    }

    .e-de-icon-Print:before {
        content: "\e723";
    }

    .e-de-icon-Download:before {
        content: "\e728";
    }

    /** sample level font icons ends*/
</style>
<script>
    window.onbeforeunload = function () {
        return 'Want to save your changes?';
    };    
</script>
```

### src/components/docx-editor-track-changes/docx-editor.component.ts

```typescript
import { Component, ViewEncapsulation, ViewChild } from '@angular/core';
import { ToolbarService, RibbonService, DocumentEditorContainerComponent, LayoutType, DocumentEditorContainerModule } from '@syncfusion/ej2-angular-documenteditor';
import { DropDownListModule, DropDownListComponent } from '@syncfusion/ej2-angular-dropdowns';
import { ButtonModule, ButtonComponent } from '@syncfusion/ej2-angular-buttons';
import { TitleBar } from '../title-bar';
import { trackchanges, WEB_API_ACTION } from '../datasource/docx-editor-data';
import { isNullOrUndefined } from '@syncfusion/ej2-base';

import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-angular-popups';

/**
 * Document Editor Component
 */
@Component({
    selector: 'control-content',
    templateUrl: 'docx-editor.component.html',
    encapsulation: ViewEncapsulation.None,
    providers: [ToolbarService, RibbonService],
    standalone: true,
    imports: [DocumentEditorContainerModule, DropDownListModule, ButtonModule]
})
export class TrackChangesComponent {
    public hostUrl: string = 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/';
    @ViewChild('documenteditor_default')
    public container!: DocumentEditorContainerComponent;
    @ViewChild('insertionDrop')
    public insertionDrop!: DropDownListComponent;
    @ViewChild('deletionDrop')
    public deletionDrop!: DropDownListComponent;
    @ViewChild('insertedRowsDrop')
    public insertedRowsDrop!: DropDownListComponent;
    @ViewChild('deletedRowsDrop')
    public deletedRowsDrop!: DropDownListComponent;
    @ViewChild('applyBtn')
    public applyBtn!: ButtonComponent;

    public isApplyDisabled: boolean = true;
    public fields: Object = { text: 'Text', value: 'Value' };
    public revisionColorData: { [key: string]: Object }[] = [
        { Text: 'By author', Value: 'byAuthor' },
        { Text: 'Blue', Value: '#0000FF' },
        { Text: 'Red', Value: '#FF0000' },
        { Text: 'Pink', Value: '#FFC0CB' },
        { Text: 'Yellow', Value: '#FFFF00' }
    ];

    public culture: string = 'en-US';
    titleBar!: TitleBar;
    layoutType: LayoutType = "Continuous";

    public fileMenuItems: any = [
        'New',
        'Open',
        {
            text: 'Export',
            id: 'custom_item',
            iconCss: 'e-icons e-export',
            items: [
                { id: 'sfdt', text: 'Syncfusion Document Text (*.sfdt)' },
                { id: 'docx', text: 'Word Document (*.docx)' },
                { id: 'dotx', text: 'Word Template (*.dotx)' },
                { id: 'text', text: 'Plain Text (*.txt)' },
                { id: 'pdf', text: 'PDF (*.pdf)' },
                { id: 'html', text: 'HyperText Markup Language (*.html)' },
                { id: 'rtf', text: 'Rich Text Format (*.rtf)' },
                { id: 'md', text: 'Markdown (*.md)' },
                { id: 'odt', text: 'OpenDocument Text (*.odt)' },
                { id: 'wordml', text: 'Word XML Document (*.xml)' }
            ],
        },
        'Print',
    ];

    public fileMenuItemClick(args: any): void {
        if (args.item.id) {
            let value: string = args.item.id;
            switch (value) {
                case 'docx':
                this.container.documentEditor.save('Sample', 'Docx');
                break;
                case 'sfdt':
                this.container.documentEditor.save('Sample', 'Sfdt');
                break;
                case 'text':
                this.container.documentEditor.save('Sample', 'Txt');
                break;
                case 'dotx':
                this.container.documentEditor.save('Sample', 'Dotx');
                break;
                case 'pdf':
                this.formatSave('Pdf');
                break;
                case 'html':
                this.formatSave('Html');
                break;
                case 'odt':
                this.formatSave('Odt');
                break;
                case 'md':
                this.formatSave('Md');
                break;
                case 'rtf':
                this.formatSave('Rtf');
                break;
                case 'wordml':
                this.formatSave('Xml');
                break;
            }
        }
    }

    public formatSave(type: string): void {
        createSpinner({
            target: document.getElementById('container')!,
        });
        showSpinner(document.getElementById('container')!);
        let format: string = type;
        let url = this.container.documentEditor.serviceUrl + 'Export';
        let http = new XMLHttpRequest();
        http.open('POST', url);
        http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
        http.responseType = 'blob'; // Set the responseType to 'blob' to handle binary data

        // Prepare data to send
        let sfdt = {
            Content: this.container.documentEditor.serialize(),
            Filename: this.container.documentEditor.documentName,
            Format: '.' + format,
        };

        // Set up event listener for the response
        http.onload = () => {
            if (http.status === 200) {
                // Handle the response blob here
                let responseData = http.response;

                // Create a Blob URL for the response data
                let blobUrl = URL.createObjectURL(responseData);

                // Create a link element and trigger the download
                let downloadLink = document.createElement('a');
                downloadLink.href = blobUrl;
                downloadLink.download = this.container.documentEditor.documentName + '.' + format.toLowerCase();
                document.body.appendChild(downloadLink);
                hideSpinner(document.getElementById('container')!);
                downloadLink.click();

                // Cleanup: Remove the link and revoke the Blob URL
                document.body.removeChild(downloadLink);
                URL.revokeObjectURL(blobUrl);
            } else {
                // Handle errors
                console.error('Request failed with status:', http.status);
                hideSpinner(document.getElementById('container')!);
            }
        };

        // Send the request with JSON.stringify(sfdt) as the request body
        http.send(JSON.stringify(sfdt));
    }

    onCreate(): void {
        let titleBarElement: HTMLElement = document.getElementById('default_title_bar')!;
        this.titleBar = new TitleBar(titleBarElement, this.container.documentEditor, true);
        this.container.documentEditor.open(JSON.stringify(trackchanges));
        this.container.documentEditor.documentName = 'Track Changes';
        this.container.documentEditorSettings.showRuler = true;
        this.titleBar.updateDocumentTitle();
        this.titleBar.showButtons(false);
    }
    onDocumentChange(): void {
        if (!isNullOrUndefined(this.titleBar)) {
            this.titleBar.updateDocumentTitle();
        }
       this.container.documentEditor.focusIn();
    }

    public onColorChange(): void {
        this.isApplyDisabled = false;
        if (this.applyBtn) {
            this.applyBtn.disabled = false;
        }
    }

    public onApply(): void {
        if (this.container) {
            this.container.documentEditorSettings.revisionSettings = {
                insertRevisionColor: this.insertionDrop?.value as string,
                deleteRevisionColor: this.deletionDrop?.value as string,
                insertedRowColor: this.insertedRowsDrop?.value as string,
                deletedRowColor: this.deletedRowsDrop?.value as string
            };
        }
    }
}

```
