|
| 1 | +# TypeScript DOCX Editor – Compare Original and Revised Documents |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +This repository contains a TypeScript sample that demonstrates how to compare two Word documents side-by-side using the Syncfusion<sup style="font-size:70%">®</sup> [JavaScript (ES6) DOCX Editor](https://www.syncfusion.com/docx-editor-sdk/javascript-docx-editor?utm_source=github&utm_medium=listing&utm_campaign=github-github-documenteditor-examples) (Document Editor). The sample lets users upload an original and a revised document, compare them through the Document Editor web service, and review the result with revision tracking – all inside two side-by-side editors. |
| 6 | + |
| 7 | +### Features |
| 8 | + |
| 9 | +- Upload an original Word document. |
| 10 | +- Upload a revised Word document. |
| 11 | +- Compare both documents. |
| 12 | +- View tracked revisions in the comparison result. |
| 13 | +- Switch between: |
| 14 | + - Original vs Compared document |
| 15 | + - Original vs Revised document |
| 16 | +- Synchronized scrolling between the two editors. |
| 17 | +- Download the comparison result as a DOCX file. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +# How to Run the Application |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | + |
| 25 | +Before running the sample, ensure the following software is installed: |
| 26 | + |
| 27 | +- [Node.js](https://nodejs.org/) (LTS) |
| 28 | +- [npm](https://www.npmjs.com/) |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## Configuration |
| 33 | + |
| 34 | +No additional configuration is required. |
| 35 | + |
| 36 | +This sample is already configured to use the online Syncfusion Document Editor service: |
| 37 | + |
| 38 | +```ts |
| 39 | +const serviceUrl = |
| 40 | + "https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/"; //only for demo purpose. |
| 41 | +``` |
| 42 | + |
| 43 | +Since the application consumes the hosted web service, you do **not** need to download, build, or run any ASP.NET Core Web API project. |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## Install Dependencies |
| 48 | + |
| 49 | +Open the project folder in a terminal and install the required packages. |
| 50 | + |
| 51 | +```bash |
| 52 | +npm install |
| 53 | +``` |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## Run the Application |
| 58 | + |
| 59 | +Start the TypeScript development server (webpack-dev-server). |
| 60 | + |
| 61 | +```bash |
| 62 | +npm start |
| 63 | +``` |
| 64 | + |
| 65 | +The application will launch in your default browser. |
| 66 | + |
| 67 | +If it does not open automatically, browse to: |
| 68 | + |
| 69 | +``` |
| 70 | +http://localhost:4000 |
| 71 | +``` |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## Build the Application |
| 76 | + |
| 77 | +Generate a production build in the `dist/` folder. |
| 78 | + |
| 79 | +```bash |
| 80 | +npm run build |
| 81 | +``` |
| 82 | + |
| 83 | +--- |
| 84 | + |
| 85 | +## Verify the Sample |
| 86 | + |
| 87 | +1. Launch the application. |
| 88 | +2. Click **Choose file** under **Original document** and select a DOCX (or SFDT) file. |
| 89 | +3. Click **Choose file** under **Revised document** and select another version of the same document. |
| 90 | +4. Click **Compare**. |
| 91 | +5. The application sends both documents to the online Document Editor service. |
| 92 | +6. The comparison result is displayed in the right-side editor with tracked revisions. |
| 93 | +7. Toggle between: |
| 94 | + - **Show comparison results with tracked changes** (Original vs Compared) |
| 95 | + - Uncheck the option to show **Original vs Revised** |
| 96 | +8. Review insertions, deletions, and formatting changes using the Document Editor revision features. |
| 97 | +9. Use the **Download Result Document** button to save the right-side editor's contents as a DOCX file. |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## Demo |
| 102 | + |
| 103 | +<p align="center"> |
| 104 | + <img |
| 105 | + src="images/compare-documents-demo-typescript-docx-editor.png" |
| 106 | + alt="TypeScript DOCX Editor Compare Documents Demo" |
| 107 | + width="1000" /> |
| 108 | +</p> |
| 109 | + |
| 110 | +--- |
| 111 | + |
| 112 | +# Project Workflow |
| 113 | + |
| 114 | +The application follows the workflow below: |
| 115 | + |
| 116 | +1. User uploads the original document. |
| 117 | +2. User uploads the revised document. |
| 118 | +3. Both documents are sent to the Syncfusion online Document Editor service. |
| 119 | +4. The service: |
| 120 | + - Imports the DOCX files. |
| 121 | + - Compares both documents. |
| 122 | + - Generates a document with tracked revisions. |
| 123 | +5. The comparison result is returned in SFDT format. |
| 124 | +6. The TypeScript application loads the original document in the left editor. |
| 125 | +7. The compared document (or revised document) is loaded in the right editor for side-by-side review. |
| 126 | + |
| 127 | +``` |
| 128 | +Original DOCX |
| 129 | + │ |
| 130 | + │ |
| 131 | + ▼ |
| 132 | +TypeScript Application |
| 133 | + │ |
| 134 | + │ |
| 135 | + ▼ |
| 136 | +Syncfusion Online Document Editor Service |
| 137 | + │ |
| 138 | + ├── Import Original |
| 139 | + ├── Import Revised |
| 140 | + └── Compare Documents |
| 141 | + │ |
| 142 | + ▼ |
| 143 | + Compared SFDT Document |
| 144 | + │ |
| 145 | + ▼ |
| 146 | +TypeScript DOCX Editor |
| 147 | + │ |
| 148 | + ├── Left Editor → Original |
| 149 | + └── Right Editor → Compared / Revised |
| 150 | +``` |
| 151 | + |
| 152 | +--- |
| 153 | + |
| 154 | +# Project Files |
| 155 | + |
| 156 | +| Path | Description | |
| 157 | +|------|-------------| |
| 158 | +| `src/app/app.ts` | Main TypeScript entry point that wires up the two editors and the compare UI. | |
| 159 | +| `src/index.html` | Application HTML host. | |
| 160 | +| `src/styles/styles.css` | Styles for the editor toolbar, upload controls, and loading overlay. | |
| 161 | +| `src/resources/favicon.ico` | Application favicon. | |
| 162 | +| `webpack.config.js` | Webpack 5 configuration used by `npm start` and `npm run build`. | |
| 163 | +| `tsconfig.json` | TypeScript compiler options. | |
| 164 | +| `package.json` | npm metadata and scripts. | |
| 165 | + |
| 166 | +--- |
| 167 | + |
| 168 | +# Resources |
| 169 | + |
| 170 | +- **Product page:** [Syncfusion® JavaScript (ES6) DOCX Editor](https://www.syncfusion.com/docx-editor-sdk/javascript-docx-editor?utm_source=github&utm_medium=listing&utm_campaign=github-github-documenteditor-examples) |
| 171 | + |
| 172 | +- **Documentation:** [Syncfusion® JavaScript (ES6) DOCX Editor - Documentation](https://help.syncfusion.com/document-processing/word/word-processor/javascript-es6/overview?utm_source=github&utm_medium=listing&utm_campaign=github-github-documenteditor-examples) |
| 173 | + |
| 174 | +- **Online demo:** [Syncfusion® JavaScript (ES6) DOCX Editor - Online demo](https://document.syncfusion.com/demos/docx-editor/javascript/#/material3/document-editor/default.html?utm_source=github&utm_medium=listing&utm_campaign=github-github-documenteditor-examples) |
| 175 | + |
| 176 | +# Support and feedback |
| 177 | + |
| 178 | +For any other queries, reach our [Syncfusion® support team](https://support.syncfusion.com/?utm_source=github&utm_medium=listing&utm_campaign=github-github-documenteditor-examples) or post the queries through the [community forums](https://www.syncfusion.com/forums?utm_source=github&utm_medium=listing&utm_campaign=github-github-documenteditor-examples). |
| 179 | + |
| 180 | +Request new feature through [Syncfusion® feedback portal](https://www.syncfusion.com/feedback?utm_source=github&utm_medium=listing&utm_campaign=github-github-documenteditor-examples). |
| 181 | + |
| 182 | +# License |
| 183 | + |
| 184 | +This is a commercial product and requires a paid license for possession or use. Syncfusion's licensed software, including this component, is subject to the terms and conditions of [Syncfusion's EULA](https://www.syncfusion.com/license/studio/syncfusion_essential_studio_eula.pdf?utm_source=github&utm_medium=listing&utm_campaign=github-github-documenteditor-examples). You can purchase a license [here](https://www.syncfusion.com/sales/products?utm_source=github&utm_medium=listing&utm_campaign=github-github-documenteditor-examples) or start a free 30-day trial [here](https://www.syncfusion.com/account/manage-trials/start-trials?utm_source=github&utm_medium=listing&utm_campaign=github-github-documenteditor-examples). |
0 commit comments