{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "docx-editor-track-changes",
  "framework": "react",
  "type": "registry:component",
  "component": "DocxEditor",
  "variant": "track-changes",
  "dependencies": [
    "@syncfusion/ej2-react-documenteditor",
    "@syncfusion/ej2-react-dropdowns",
    "@syncfusion/ej2-react-buttons",
    "@syncfusion/ej2-popups"
  ],
  "description": "Word editor shows tracked changes with accept and reject controls and a revision dropdown.",
  "meta": {
    "essentialStudioRelease": "2026 Volume 3 (v35.1.37)",
    "license": "commercial-or-community",
    "licenseNote": "The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md",
    "requiresLicenseKey": true,
    "requiresServerEndpoint": true,
    "platformIndex": "https://ai.syncfusion.com/react/llms.txt",
    "skillPack": "syncfusion/react-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/react/ts/docx-editor-track-changes.md"
  },
  "files": [
    {
      "target": "src/components/docx-editor-track-changes/DocxEditor.tsx",
      "content": "import { useEffect, useRef, useState } from 'react';\nimport { DocumentEditorContainerComponent, Ribbon, Toolbar } from '@syncfusion/ej2-react-documenteditor';\nimport { trackchanges } from '../datasource/docx-editor-data';\nimport { DropDownListComponent  } from '@syncfusion/ej2-react-dropdowns';\nimport { ButtonComponent } from '@syncfusion/ej2-react-buttons';\nimport { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';\nimport { TitleBar } from '../title-bar';\nimport '../default.component.css';\n\nDocumentEditorContainerComponent.Inject(Toolbar, Ribbon);\n\nconst TrackChanges = () => {\n    useEffect(() => {\n        rendereComplete();\n    }, [])\n    const hostUrl: string =\n        \"https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/\";\n    let container = useRef<DocumentEditorContainerComponent>(null);\n    let titleBar: TitleBar;\n    const onLoadDefault = (): void => {\n        if (!container.current) return;\n        container.current.documentEditor.open(JSON.stringify(trackchanges));\n        container.current.documentEditor.documentName = \"Track Changes\";\n        container.current.documentEditorSettings.showRuler = true;\n        container.current.documentEditor.showRestrictEditingPane(false);\n        titleBar.updateDocumentTitle();\n        container.current.documentChange = (): void => {\n            if (!container.current) return;\n            titleBar.updateDocumentTitle();\n            container.current.documentEditor.focusIn();\n        };\n    };\n    const rendereComplete = (): void => {\n        if (!container.current) return;\n        container.current.documentEditor.pageOutline = \"#E0E0E0\";\n        container.current.documentEditor.acceptTab = true;\n        container.current.documentEditor.resize();\n        const titleBarElement = document.getElementById(\"documenteditor_titlebar\");\n        if (titleBarElement) {\n            titleBar = new TitleBar(\n                titleBarElement,\n                container.current.documentEditor,\n                true\n            );\n        }\n        onLoadDefault();\n        titleBar.showButtons(false);\n    };\n    \n        const fileMenuItemClick = (args:any): void => {\n            if (!container.current) return;\n            if (args.item.id) {\n                let value: string = args.item.id;\n                let sampleName: string = container.current.documentEditor.documentName === '' ? 'sample' : container.current.documentEditor.documentName;\n                switch (value) {\n                    case 'docx':\n                        container.current.documentEditor.save(sampleName, 'Docx');\n                        break;\n                    case 'sfdt':\n                        container.current.documentEditor.save(sampleName, 'Sfdt');\n                        break;\n                    case 'text':\n                        container.current.documentEditor.save(sampleName, 'Txt');\n                        break;\n                    case 'dotx':\n                        container.current.documentEditor.save(sampleName, 'Dotx');\n                        break;\n                    case 'pdf':\n                        formatSaveLocal('Pdf');\n                        break;\n                    case 'html':\n                        formatSaveLocal('Html');\n                        break;\n                    case 'odt':\n                        formatSaveLocal('Odt');\n                        break;\n                    case 'md':\n                        formatSaveLocal('Md');\n                        break;\n                    case 'rtf':\n                        formatSaveLocal('Rtf');\n                        break;\n                    case 'wordml':\n                        formatSaveLocal('Xml');\n                        break;\n                }\n            }\n        }\n    \n        const formatSaveLocal = (type: string): void => {\n            if (!container.current) return;\n            createSpinner({\n                target: document.getElementById('container')!\n            });\n            showSpinner(document.getElementById('container')!);\n            let format: string = type;\n            let url = container.current.documentEditor.serviceUrl + 'Export';\n            let http = new XMLHttpRequest();\n            http.open('POST', url);\n            http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');\n            http.responseType = 'blob';\n\n            let sfdt = {\n                Content: container.current.documentEditor.serialize(),\n                Filename: container.current.documentEditor.documentName,\n                Format: '.' + format,\n            };\n\n            http.onload = (): void => {\n                if (http.status === 200) {\n                    if (!container.current) return;\n                    let responseData = http.response;\n                    let blobUrl = URL.createObjectURL(responseData);\n                    let downloadLink = document.createElement('a');\n                    downloadLink.href = blobUrl;\n                    downloadLink.download = container.current.documentEditor.documentName + '.' + format.toLowerCase();\n                    document.body.appendChild(downloadLink);\n                    hideSpinner(document.getElementById('container')!);\n                    downloadLink.click();\n                    document.body.removeChild(downloadLink);\n                    URL.revokeObjectURL(blobUrl);\n                } else {\n                    console.error('Request failed with status:', http.status);\n                    hideSpinner(document.getElementById('container')!);\n                }\n            };\n\n            http.send(JSON.stringify(sfdt));\n        }\n\n    // Track Changes revision color dropdown data\n    const revisionColorData: { Text: string; Value: string }[] = [\n        { Text: 'By author', Value: 'byAuthor' },\n        { Text: 'Blue', Value: '#0000FF' },\n        { Text: 'Red', Value: '#FF0000' },\n        { Text: 'Pink', Value: '#FFC0CB' },\n        { Text: 'Yellow', Value: '#FFFF00' }\n    ];\n\n    const insertionDrop = useRef<DropDownListComponent>(null);\n    const deletionDrop = useRef<DropDownListComponent>(null);\n    const insertedRowsDrop = useRef<DropDownListComponent>(null);\n    const deletedRowsDrop = useRef<DropDownListComponent>(null);\n    const applyBtnRef = useRef<ButtonComponent>(null);\n    const [isApplyDisabled, setIsApplyDisabled] = useState<boolean>(true);\n\n    const fields = { text: 'Text', value: 'Value' };\n\n    const onColorChange = (): void => {\n        setIsApplyDisabled(false);\n        if (applyBtnRef.current) {\n            applyBtnRef.current.disabled = false;\n        }\n    };\n\n    const onApply = (): void => {\n        if(container.current)\n            container.current.documentEditorSettings.revisionSettings = {\n                insertRevisionColor: insertionDrop.current?.value as string,\n                deleteRevisionColor: deletionDrop.current?.value as string,\n                insertedRowColor: insertedRowsDrop.current?.value as string,\n                deletedRowColor: deletedRowsDrop.current?.value as string\n        }\n    };\n    return (\n        <div className=\"control-pane\">\n        <div className='row'>\n            <div className=\"col-lg-10 control-section\">\n                <div id=\"documenteditor_titlebar\" className=\"e-de-ctn-title\"></div>\n                <div id=\"documenteditor_container_body\" style={{\"display\":\"block\", \"height\": \"calc(100vh - 230px)\"}}>\n                    <DocumentEditorContainerComponent\n                        id=\"container\"\n                        ref={container}\n                        style={{ display: \"block\" }}\n                        height={\"100%\"}\n                        toolbarMode= {\"Ribbon\"}\n                        serviceUrl={hostUrl}\n                        enableToolbar={true}\n                        locale=\"en-US\"\n                        fileMenuItems={['New', 'Open', {\n                            text: 'Export',\n                            id: 'custom_item',\n                            iconCss: 'e-icons e-export',\n                            items: [\n                                { id: 'sfdt', text: 'Syncfusion Document Text (*.sfdt)' },\n                                { id: 'docx', text: 'Word Document (*.docx)' },\n                                { id: 'dotx', text: 'Word Template (*.dotx)' },\n                                { id: 'text', text: 'Plain Text (*.txt)' },\n                                { id: 'pdf', text: 'PDF (*.pdf)' },\n                                { id: 'html', text: 'HyperText Markup Language (*.html)' },\n                                { id: 'rtf', text: 'Rich Text Format (*.rtf)' },\n                                { id: 'md', text: 'Markdown (*.md)' },\n                                { id: 'odt', text: 'OpenDocument Text (*.odt)' }, \n                                { id: 'wordml', text: 'Word XML Document (*.xml)' }\n                            ]\n                        }, 'Print']}\n                        fileMenuItemClick={fileMenuItemClick}\n                        showPropertiesPane={false}\n                        enableTrackChanges={true}\n                        userColor={\"#b70f34\"}\n                        currentUser={\"Nancy Davolio\"}\n                    />\n                </div>\n            </div>\n            <div className=\"col-lg-2 property-section\">\n                <div style={{ paddingTop: '20px' }}>\n                    <b>Revision Color Settings</b>\n                </div>\n                <div style={{ marginTop: '15px' }}>\n                    <div style={{ paddingTop: '10px' }}>\n                        <label style={{ display: 'block', marginBottom: '5px', fontWeight: 500 }}>Insertion:</label>\n                        <DropDownListComponent\n                            id=\"insertion-color\"\n                            ref={insertionDrop}\n                            dataSource={revisionColorData}\n                            fields={fields}\n                            value=\"byAuthor\"\n                            placeholder=\"Insertion\"\n                            floatLabelType=\"Never\"\n                            width=\"100%\"\n                            change={onColorChange.bind(this)}\n                        />\n                    </div>\n                    <div style={{ paddingTop: '10px' }}>\n                        <label style={{ display: 'block', marginBottom: '5px', fontWeight: 500 }}>Deletion:</label>\n                        <DropDownListComponent\n                            id=\"deletion-color\"\n                            ref={deletionDrop}\n                            dataSource={revisionColorData}\n                            fields={fields}\n                            value=\"byAuthor\"\n                            placeholder=\"Deletion\"\n                            floatLabelType=\"Never\"\n                            width=\"100%\"\n                            change={onColorChange.bind(this)}\n                        />\n                    </div>\n                    <div style={{ paddingTop: '10px' }}>\n                        <label style={{ display: 'block', marginBottom: '5px', fontWeight: 500 }}>Inserted Rows:</label>\n                        <DropDownListComponent\n                            id=\"inserted-rows-color\"\n                            ref={insertedRowsDrop}\n                            dataSource={revisionColorData}\n                            fields={fields}\n                            value=\"byAuthor\"\n                            placeholder=\"Inserted Rows\"\n                            floatLabelType=\"Never\"\n                            width=\"100%\"\n                            change={onColorChange.bind(this)}\n                        />\n                    </div>\n                    <div style={{ paddingTop: '10px' }}>\n                        <label style={{ display: 'block', marginBottom: '5px', fontWeight: 500 }}>Deleted Rows:</label>\n                        <DropDownListComponent\n                            id=\"deleted-rows-color\"\n                            ref={deletedRowsDrop}\n                            dataSource={revisionColorData}\n                            fields={fields}\n                            value=\"byAuthor\"\n                            placeholder=\"Deleted Rows\"\n                            floatLabelType=\"Never\"\n                            width=\"100%\"\n                            change={onColorChange.bind(this)}\n                        />\n                    </div>\n                </div>\n                <div style={{ paddingTop: '15px', marginBottom: '10px' }}>\n                    <ButtonComponent\n                        id=\"apply-btn\"\n                        ref={applyBtnRef}\n                        cssClass=\"e-primary\"\n                        disabled={isApplyDisabled}\n                        onClick={onApply.bind(this)}\n                    >\n                        Apply\n                    </ButtonComponent>\n                </div>\n            </div>\n            </div>\n        </div>\n    );\n}\nexport default TrackChanges;\n"
    }
  ]
}