Skip to content

Commit 8748738

Browse files
Bold Create Agentsuriyaprakasamr
andcommitted
Add Side-by-Side-Comparison sample for TypeScript DOCX Editor
Adds a new sample under getting-started/Side-by-Side-Comparison that mirrors the React compare-documents sample on the SyncfusionExamples react-docx-editor-compare-documents repo, but built on the TypeScript / webpack template used by the existing getting-started app. Features: - Upload original and revised documents (DOCX / SFDT) - Compare using the hosted Syncfusion Document Editor service - Side-by-side view with synced scroll and tracked revisions - Toggle between Compared and Revised view, hide/show revisions pane - Download the result as DOCX Co-authored-by: suriyaprakasamr <302142999+suriyaprakasamr@users.noreply.github.com>
1 parent 4e041ae commit 8748738

12 files changed

Lines changed: 879 additions & 0 deletions

File tree

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
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%">&reg;</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:** &nbsp;&nbsp;[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)&nbsp;
166+
167+
- **Documentation:** &nbsp;&nbsp;[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)&nbsp;
168+
169+
- **Online demo:** &nbsp;&nbsp;[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)&nbsp;
170+
171+
# Support and feedback&nbsp;
172+
173+
For any other queries, reach our&nbsp;[Syncfusion® support team](https://support.syncfusion.com/?utm_source=github&utm_medium=listing&utm_campaign=github-javascript-es6-docx-editor-examples)&nbsp;or post the queries through the&nbsp;[community forums](https://www.syncfusion.com/forums?utm_source=github&utm_medium=listing&utm_campaign=github-javascript-es6-docx-editor-examples).&nbsp;
174+
175+
Request new feature through&nbsp;[Syncfusion® feedback portal](https://www.syncfusion.com/feedback?utm_source=github&utm_medium=listing&utm_campaign=github-javascript-es6-docx-editor-examples).&nbsp;
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&nbsp;[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&nbsp;license&nbsp;[here](https://www.syncfusion.com/sales/products?utm_source=github&utm_medium=listing&utm_campaign=github-javascript-es6-docx-editor-examples)&nbsp;or start a free 30-day trial&nbsp;[here](https://www.syncfusion.com/account/manage-trials/start-trials?utm_source=github&utm_medium=listing&utm_campaign=github-javascript-es6-docx-editor-examples).&nbsp;
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
'use strict';
2+
3+
var gulp = require('gulp');
4+
5+
/**
6+
* Compile TypeScript to JS
7+
*/
8+
gulp.task('compile', function (done) {
9+
var webpack = require('webpack');
10+
var webpackStream = require('webpack-stream');
11+
gulp.src(['./src/app/app.ts']).pipe(webpackStream({
12+
config: require('./webpack.config.js')
13+
}, webpack))
14+
.pipe(gulp.dest('./dist'))
15+
.on('end', function () {
16+
done();
17+
});
18+
});
19+
20+
/**
21+
* Testing spec files
22+
*/
23+
var protractor = require('gulp-protractor').protractor;
24+
var webdriver_standalone = require('gulp-protractor').webdriver_standalone;
25+
var webdriver_update = require('gulp-protractor').webdriver_update_specific;
26+
27+
gulp.task('e2e-serve', webdriver_standalone);
28+
29+
gulp.task('e2e-webdriver-update', webdriver_update({
30+
webdriverManagerArgs: ['--ie', '--edge']
31+
}));
32+
33+
gulp.task('e2e-test', gulp.series('compile', function (done) {
34+
var browserSync = require('browser-sync');
35+
var bs = browserSync.create('Essential JS 2');
36+
var options = {
37+
server: {
38+
baseDir: [
39+
'./dist/',
40+
],
41+
directory: true
42+
},
43+
ui: false,
44+
open: false,
45+
notify: false
46+
};
47+
bs.init(options, function () {
48+
gulp.src(['./spec/**/*.spec.js'])
49+
.pipe(protractor({
50+
configFile: 'e2e/protractor.conf.js'
51+
}))
52+
.on('error', function (e) {
53+
console.error('Error: ' + e.message);
54+
done();
55+
process.exit(1);
56+
})
57+
.on('end', function () {
58+
done();
59+
process.exit(0);
60+
});
61+
});
62+
}));
2.1 MB
Loading
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Essential JS 2 library is available under the Syncfusion Essential Studio program, and can be licensed either under the Syncfusion Community License Program or the Syncfusion commercial license.
2+
3+
To be qualified for the Syncfusion Community License Program you must have a gross revenue of less than one (1) million U.S. dollars ($1,000,000.00 USD) per year and have less than five (5) developers in your organization, and agree to be bound by Syncfusion’s terms and conditions.
4+
5+
Customers who do not qualify for the community license can contact sales@syncfusion.com for commercial licensing options.
6+
7+
Under no circumstances can you use this product without (1) either a Community License or a commercial license and (2) without agreeing and abiding by Syncfusion’s license containing all terms and conditions.
8+
9+
The Syncfusion license that contains the terms and conditions can be found at
10+
https://www.syncfusion.com/content/downloads/syncfusion_license.pdf
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "ej2-docx-editor-side-by-side-comparison",
3+
"version": "0.0.1",
4+
"description": "Syncfusion TypeScript DOCX Editor - Side by Side Document Comparison sample",
5+
"author": "Syncfusion Inc.",
6+
"license": "SEE LICENSE IN license",
7+
"scripts": {
8+
"start": "webpack serve --mode development",
9+
"build": "webpack --mode production",
10+
"serve": "gulp e2e-serve",
11+
"test": "gulp e2e-test",
12+
"update-webdriver": "gulp e2e-webdriver-update"
13+
},
14+
"devDependencies": {
15+
"ajv": "^8.17.1",
16+
"browser-sync": "^3.0.3",
17+
"css-loader": "^7.1.2",
18+
"gulp": "^5.0.0",
19+
"gulp-protractor": "^4.1.1",
20+
"gulp-typescript": "^6.0.0-alpha.1",
21+
"html-webpack-plugin": "^5.6.3",
22+
"jasmine": "^5.7.0",
23+
"mini-css-extract-plugin": "^2.9.2",
24+
"ts-loader": "^9.5.1",
25+
"typescript": "^5.6.3",
26+
"webpack": "^5.97.1",
27+
"webpack-cli": "^6.0.1",
28+
"webpack-dev-server": "^5.2.0",
29+
"webpack-stream": "^7.0.0"
30+
},
31+
"dependencies": {
32+
"@syncfusion/ej2-base": "*",
33+
"@syncfusion/ej2-buttons": "*",
34+
"@syncfusion/ej2-documenteditor": "*",
35+
"@syncfusion/ej2-tailwind3-theme": "*"
36+
}
37+
}

0 commit comments

Comments
 (0)