|
| 1 | +# JavaScript (ES6) / TypeScript DOCX Editor – Compare Original and Revised Documents |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +This repository contains a TypeScript application that demonstrates how to compare two Word documents using the Syncfusion<sup style="font-size:70%">®</sup> [JavaScript DOCX Editor](https://www.syncfusion.com/docx-editor-sdk/javascript-docx-editor?utm_source=github&utm_medium=listing&utm_campaign=github-javascript-es6-docx-editor-examples) (Document Editor). The sample allows users to upload an original and a revised document, compare them using the Document Editor web service, and view the comparison results with revision tracking. |
| 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 | + |
| 17 | +--- |
| 18 | + |
| 19 | +# How to Run the Application |
| 20 | + |
| 21 | +## Prerequisites |
| 22 | + |
| 23 | +Before running the sample, ensure the following software is installed: |
| 24 | + |
| 25 | +- Node.js (LTS) |
| 26 | +- npm |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## Configuration |
| 31 | + |
| 32 | +No additional configuration is required. |
| 33 | + |
| 34 | +This sample is already configured to use the online Syncfusion Document Editor service: |
| 35 | + |
| 36 | +```ts |
| 37 | +const serviceUrl = |
| 38 | + "https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/"; //only for demo purpose. |
| 39 | +``` |
| 40 | + |
| 41 | +Since the application consumes the hosted web service, you do **not** need to download, build, or run any ASP.NET Core Web API project. |
| 42 | + |
| 43 | +--- |
| 44 | + |
| 45 | +## Install Dependencies |
| 46 | + |
| 47 | +Open the `Side-by-Side-Comparison` folder in a terminal and install the required packages. |
| 48 | + |
| 49 | +```bash |
| 50 | +npm install |
| 51 | +``` |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## Run the Application |
| 56 | + |
| 57 | +Start the webpack development server. |
| 58 | + |
| 59 | +```bash |
| 60 | +npm start |
| 61 | +``` |
| 62 | + |
| 63 | +The application will launch in your default browser. |
| 64 | + |
| 65 | +If it does not open automatically, browse to: |
| 66 | + |
| 67 | +``` |
| 68 | +http://localhost:4000 |
| 69 | +``` |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## Build the Application |
| 74 | + |
| 75 | +Generate a production build in the `dist/` folder. |
| 76 | + |
| 77 | +```bash |
| 78 | +npm run build |
| 79 | +``` |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## Verify the Sample |
| 84 | + |
| 85 | +1. Launch the application. |
| 86 | +2. Click **Choose file** under **Original document** and select a DOCX file. |
| 87 | +3. Click **Choose file** under **Revised document** and select another version of the same document. |
| 88 | +4. Click **Compare**. |
| 89 | +5. The application sends both documents to the online Document Editor service. |
| 90 | +6. The comparison result is displayed in the right-side editor with tracked revisions. |
| 91 | +7. Toggle between: |
| 92 | + - **Original vs Compared** |
| 93 | + - **Original vs Revised** |
| 94 | +8. Review insertions, deletions, and formatting changes using the Document Editor revision features. |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## Demo |
| 99 | + |
| 100 | +<p align="center"> |
| 101 | + <img |
| 102 | + src="images/compare-documents-demo-typescript-docx-editor.gif" |
| 103 | + alt="TypeScript DOCX Editor Compare Documents Demo" |
| 104 | + width="1000" /> |
| 105 | +</p> |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +# Project Workflow |
| 110 | + |
| 111 | +The application follows the workflow below: |
| 112 | + |
| 113 | +1. User uploads the original document. |
| 114 | +2. User uploads the revised document. |
| 115 | +3. Both documents are sent to the Syncfusion online Document Editor service. |
| 116 | +4. The service: |
| 117 | + - Imports the DOCX files. |
| 118 | + - Compares both documents. |
| 119 | + - Generates a document with tracked revisions. |
| 120 | +5. The comparison result is returned in SFDT format. |
| 121 | +6. The TypeScript application loads the original document in the left editor. |
| 122 | +7. The compared document (or revised document) is loaded in the right editor for side-by-side review. |
| 123 | + |
| 124 | +``` |
| 125 | +Original DOCX |
| 126 | + │ |
| 127 | + │ |
| 128 | + ▼ |
| 129 | + ┌──────────────────────────┐ |
| 130 | + │ Syncfusion Online Service │ |
| 131 | + ├──────────────────────────┤ |
| 132 | + │ ├── Import Original │ |
| 133 | + │ ├── Import Revised │ |
| 134 | + │ └── Compare Documents │ |
| 135 | + └──────────────────────────┘ |
| 136 | + │ |
| 137 | + ▼ |
| 138 | + Compared SFDT Document |
| 139 | + │ |
| 140 | + ▼ |
| 141 | + JavaScript DOCX Editor |
| 142 | + │ |
| 143 | + ├── Left Editor → Original |
| 144 | + └── Right Editor → Compared / Revised |
| 145 | +``` |
| 146 | + |
| 147 | +--- |
| 148 | + |
| 149 | +# Project Structure |
| 150 | + |
| 151 | +| Folder / File | Description | |
| 152 | +|---|---| |
| 153 | +| `src/app/app.ts` | Initializes the two Document Editor containers, handles file uploads, and manages the compare / download flow. | |
| 154 | +| `src/app/data.ts` | Default SFDT documents loaded into the editors when the sample starts. | |
| 155 | +| `src/index.html` | Page layout with upload area, action buttons, two editor panels, and loading indicator. | |
| 156 | +| `src/styles/styles.css` | Styles for the layout, overlay, and waiting indicator. | |
| 157 | +| `webpack.config.js` | Webpack configuration for bundling the TypeScript application. | |
| 158 | +| `tsconfig.json` | TypeScript compiler options. | |
| 159 | +| `package.json` | Project dependencies and npm scripts. | |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +# Resources |
| 164 | + |
| 165 | +- **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-javascript-es6-docx-editor-examples) |
| 166 | + |
| 167 | +- **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-javascript-es6-docx-editor-examples) |
| 168 | + |
| 169 | +- **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-javascript-es6-docx-editor-examples) |
| 170 | + |
| 171 | +# Support and feedback |
| 172 | + |
| 173 | +For any other queries, reach our [Syncfusion® support team](https://support.syncfusion.com/?utm_source=github&utm_medium=listing&utm_campaign=github-javascript-es6-docx-editor-examples) or post the queries through the [community forums](https://www.syncfusion.com/forums?utm_source=github&utm_medium=listing&utm_campaign=github-javascript-es6-docx-editor-examples). |
| 174 | + |
| 175 | +Request new feature through [Syncfusion® feedback portal](https://www.syncfusion.com/feedback?utm_source=github&utm_medium=listing&utm_campaign=github-javascript-es6-docx-editor-examples). |
| 176 | + |
| 177 | +# License |
| 178 | + |
| 179 | +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-javascript-es6-docx-editor-examples). You can purchase a license [here](https://www.syncfusion.com/sales/products?utm_source=github&utm_medium=listing&utm_campaign=github-javascript-es6-docx-editor-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-javascript-es6-docx-editor-examples). |
0 commit comments