Skip to content

Commit 7879349

Browse files
Merge pull request #2222 from syncfusion-content/809971-JS5-revamp
(documentation)1008846: ES5 code revamp
2 parents 825ddff + 9835e81 commit 7879349

21 files changed

Lines changed: 356 additions & 374 deletions

Document-Processing/Word/Word-Processor/javascript-es5/comments.md

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Document Editor allows you to add comments to documents. You can add, navigate a
1616

1717
Comments can be inserted to the selected text.
1818

19-
```ts
19+
```js
2020
//Add new commnt in the document.
2121
documentEditor.editor.insertComment('Test comment');
2222
```
@@ -47,7 +47,7 @@ documentEditor.editor.insertComment('Hello world', commentProperties);
4747

4848
## Add a Reply Comment with Date, Author, and Status
4949

50-
Reply comments can be inserted into the parent comment with a specified date, author using [`insertReplyComment`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/editor#insertreplycomment/).
50+
Reply comments can be inserted into the parent comment with a specified date, author using [`insertReplyComment`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/editor#insertreplycomment).
5151

5252
{% highlight js %}
5353
// In this example, a comment with the text "Hello world"
@@ -73,7 +73,7 @@ documentEditor.editor.insertReplyComment(comment.id, 'Hello world', commentPrope
7373

7474
## Get Comments
7575

76-
Document Editor allows to get the comments along with its reply and comment properties using [`getComments`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#getComments/).
76+
Document Editor allows to get the comments along with its reply and comment properties using [`getComments`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#getComments).
7777

7878
{% highlight js %}
7979
//Get Comments in the document along with the properties author, date, status.
@@ -85,7 +85,7 @@ var commentInfo = container.documentEditor.getComments();
8585

8686
Next and previous comments can be navigated using the below code snippet.
8787

88-
```ts
88+
```js
8989
//Navigate to next comment
9090
documentEditor.selection.navigateNextComment();
9191

@@ -96,7 +96,7 @@ documentEditor.selection.navigatePreviousComment();
9696

9797
## Delete comment
9898

99-
Current comment can be be deleted using [`deleteComment`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/editor#deletecomment/).
99+
Current comment can be be deleted using [`deleteComment`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/editor#deletecomment).
100100

101101

102102
{% highlight js %}
@@ -117,7 +117,7 @@ container.documentEditor.editor.deleteComment(commentinfo[0].replies[0].id);
117117

118118
All the comments in the document can be deleted using the below code snippet.
119119

120-
```ts
120+
```js
121121
//Delete all the comments present in the current document.
122122
documentEditor.editor.deleteAllComments();
123123
```
@@ -126,25 +126,26 @@ documentEditor.editor.deleteAllComments();
126126

127127
Document Editor provides support for protecting the document with `CommentsOnly` protection. In this protection, user allowed to add or edit comments alone in the document.
128128

129-
Document editor provides an option to protect and unprotect document using [`enforceProtection`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/editor#enforceprotection/) and [`stopProtection`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/editor#stopprotection/) API.
129+
Document editor provides an option to protect and unprotect document using [`enforceProtection`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/editor#enforceprotection) and [`stopProtection`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/editor#stopprotection) API.
130130

131131
The following example code illustrates how to enforce and stop protection in Document editor container.
132132

133-
```ts
134-
let container: DocumentEditorContainer = new DocumentEditorContainer({
133+
```js
134+
135+
var container = new ej.documenteditor.DocumentEditorContainer({
135136
enableToolbar: true,
136-
height: '590px',
137+
height: '590px'
137138
});
138-
DocumentEditorContainer.Inject(Toolbar);
139-
container.serviceUrl =
140-
'http://localhost:5000/api/documenteditor/';
139+
ej.documenteditor.DocumentEditorContainer.Inject(ej.documenteditor.Toolbar);
140+
container.serviceUrl = 'http://localhost:5000/api/documenteditor/';
141141
container.appendTo('#container');
142142

143143
//enforce protection
144144
container.documentEditor.editor.enforceProtection('123', 'CommentsOnly');
145145

146146
//stop the document protection
147147
container.documentEditor.editor.stopProtection('123');
148+
148149
```
149150

150151
Comment only protection can be enabled in UI by using [Restrict Editing pane](./document-management#restrict-editing-pane)
@@ -159,28 +160,33 @@ Mention support displays a list of items that users can select or tag from the s
159160

160161
The following example illustrates how to enable mention support in Document Editor
161162

162-
```ts
163-
let mentionData: any = [
163+
```js
164+
var mentionData = [
164165
{ "Name": "Mary Kate", "EmailId": "marry@company.com" },
165166
{ "Name": "Andrew James", "EmailId": "james@company.com" },
166-
{ "Name": "Andrew Fuller", "EmailId": "andrew@company.com"}
167+
{ "Name": "Andrew Fuller", "EmailId": "andrew@company.com" }
167168
];
168-
let container: DocumentEditorContainer = new DocumentEditorContainer({ enableToolbar: true,height: '590px',
169-
// Enable mention support in document editor
170-
documentEditorSettings: {
171-
mentionSettings: { dataSource: mentionData, fields: { text: 'Name' }},
172-
}
169+
170+
var container = new ej.documenteditor.DocumentEditorContainer({
171+
enableToolbar: true,
172+
height: '590px',
173+
// Enable mention support in document editor
174+
documentEditorSettings: {
175+
mentionSettings: { dataSource: mentionData, fields: { text: 'Name' } }
176+
}
173177
});
174-
DocumentEditorContainer.Inject(Toolbar);
178+
179+
ej.documenteditor.DocumentEditorContainer.Inject(ej.documenteditor.Toolbar);
175180
container.serviceUrl = 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/';
176181
container.appendTo('#container');
182+
177183
```
178184

179185
> The Web API hosted link `https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/` utilized in the Document Editor's serviceUrl property is intended solely for demonstration and evaluation purposes. For production deployment, please host your own web service with your required server configurations. You can refer and reuse the [GitHub Web Service example](https://github.com/SyncfusionExamples/EJ2-DocumentEditor-WebServices) or [Docker image](https://hub.docker.com/r/syncfusion/word-processor-server) for hosting your own web service and use for the serviceUrl property.
180186
181187
## Events
182188

183-
DocumentEditor provides [beforeCommentAction](https://ej2.syncfusion.com/javascript/documentation/api/document-editor-container#beforecommentaction/) event, which is triggered on comment actions like Post, edit, reply, resolve and reopen. This event provides an opportunity to perform custom logic on comment actions like Post, edit, reply, resolve and reopen. The event handler receives the [CommentActionEventArgs](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/commentActionEventArgs/) object as an argument, which allows access to information about the comment.
189+
DocumentEditor provides [beforeCommentAction](https://ej2.syncfusion.com/javascript/documentation/api/document-editor-container#beforecommentaction) event, which is triggered on comment actions like Post, edit, reply, resolve and reopen. This event provides an opportunity to perform custom logic on comment actions like Post, edit, reply, resolve and reopen. The event handler receives the [CommentActionEventArgs](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/commentActionEventArgs) object as an argument, which allows access to information about the comment.
184190

185191
To demonstrate a specific use case, let’s consider an example where we want to restrict the delete functionality based on the author’s name. The following code snippet illustrates how to allow only the author of a comment to delete:
186192

Document-Processing/Word/Word-Processor/javascript-es5/export.md

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,20 @@ The following example shows how to export document as text document (.txt).
131131

132132
Document Editor also supports API to store the document into a blob. Refer to the following sample to export document into blob in client-side.
133133

134-
```ts
135-
import { DocumentEditor, FormatType, WordExport, SfdtExport } from '@syncfusion/ej2-documenteditor';
134+
```js
136135

137-
//Inject require modules for Export.
138-
DocumentEditor.Inject(WordExport, SfdtExport);
139-
140-
let documenteditor: DocumentEditor = new DocumentEditor({ enableSfdtExport: true, enableWordExport: true, enableTextExport: true });
136+
var documenteditor = new ej.documenteditor.DocumentEditor({ enableSfdtExport: true, enableWordExport: true, enableTextExport: true });
141137

142138
documenteditor.appendTo('#DocumentEditor');
143139

144140
documenteditor.open(sfdt);
145141

146-
document.getElementById('export').addEventListener('click', () => {
147-
//Export the current document as `Blob` object.
148-
documenteditor.saveAsBlob('Docx').then((exportedDocument: Blob) => {
149-
// The blob can be processed further
150-
});
142+
document.getElementById('export').addEventListener('click', function () {
143+
// Export the current document as `Blob` object.
144+
documenteditor.saveAsBlob('Docx').then(function (exportedDocument) {
145+
// The blob can be processed further
146+
});
151147
});
152-
153148
```
154149

155150
For instance, to export the document as Rich Text Format file, implement an ASP.NET MVC web API controller using DocIO library by passing the DOCX blob. Refer to the following code example.
@@ -173,57 +168,57 @@ For instance, to export the document as Rich Text Format file, implement an ASP.
173168

174169
In client-side, you can consume this web service and save the document as Rich Text Format (.rtf) file. Refer to the following example.
175170

176-
```ts
177-
document.getElementById('export').addEventListener('click', () => {
178-
//Expor the document as `Blob` object.
179-
documenteditor.saveAsBlob('Docx').then((exportedDocument: Blob) => {
171+
```js
172+
document.getElementById('export').addEventListener('click', function () {
173+
// Expor the document as `Blob` object.
174+
documenteditor.saveAsBlob('Docx').then(function (exportedDocument) {
180175
// The blob can be processed further
181-
let formData: FormData = new FormData();
176+
var formData = new FormData();
182177
formData.append('fileName', 'sample.docx');
183178
formData.append('data', exportedDocument);
184179
saveAsRtf(formData);
185180
});
186181
});
187182

188-
function saveAsRtf(formData: FormData): void {
189-
//Send the blob object to server to process further.
190-
let httpRequest: XMLHttpRequest = new XMLHttpRequest();
183+
function saveAsRtf(formData) {
184+
// Send the blob object to server to process further.
185+
var httpRequest = new XMLHttpRequest();
191186
httpRequest.open('POST', '/api/DocumentEditor/ExportAsRtf', true);
192-
httpRequest.onreadystatechange = () => {
187+
httpRequest.onreadystatechange = function () {
193188
if (httpRequest.readyState === 4) {
194189
if (httpRequest.status === 200 || httpRequest.status === 304) {
195190
if (!(!navigator.msSaveBlob)) {
196191
navigator.msSaveBlob(httpRequest.response, 'sample.rtf');
197192
} else {
198-
let downloadLink: HTMLAnchorElement = document.createElementNS('http://www.w3.org/1999/xhtml', 'a') as HTMLAnchorElement;
193+
var downloadLink = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
199194
download('sample.rtf', 'rtf', httpRequest.response, downloadLink, 'download' in downloadLink);
200195
}
201196
} else {
202197
console.error(httpRequest.response);
203198
}
204199
}
205-
}
200+
};
206201
httpRequest.responseType = 'blob';
207202
httpRequest.send(formData);
208203
}
209204

210-
//Download the document in client side.
211-
function download(fileName: string, extension: string, buffer: Blob, downloadLink: HTMLAnchorElement, hasDownloadAttribute: Boolean): void {
205+
// Download the document in client side.
206+
function download(fileName, extension, buffer, downloadLink, hasDownloadAttribute) {
212207
if (hasDownloadAttribute) {
213208
downloadLink.download = fileName;
214-
let dataUrl: string = window.URL.createObjectURL(buffer);
209+
var dataUrl = window.URL.createObjectURL(buffer);
215210
downloadLink.href = dataUrl;
216-
let event: MouseEvent = document.createEvent('MouseEvent');
211+
var event = document.createEvent('MouseEvent');
217212
event.initEvent('click', true, true);
218213
downloadLink.dispatchEvent(event);
219-
setTimeout((): void => {
214+
setTimeout(function () {
220215
window.URL.revokeObjectURL(dataUrl);
221216
dataUrl = undefined;
222217
});
223218
} else {
224219
if (extension !== 'docx' && extension !== 'xlsx') {
225-
let url: string = window.URL.createObjectURL(buffer);
226-
let isPopupBlocked: Window = window.open(url, '_blank');
220+
var url = window.URL.createObjectURL(buffer);
221+
var isPopupBlocked = window.open(url, '_blank');
227222
if (!isPopupBlocked) {
228223
window.location.href = url;
229224
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: post
3-
title: Change document view in JavaScript (ES5) Document editor control | Syncfusion
3+
title: Change document view in JavaScript (ES5) Document editor | Syncfusion
44
description: Learn here all about Change document view in Syncfusion JavaScript (ES5) Document editor control of Syncfusion Essential JS 2 and more.
55
platform: document-processing
66
control: Change document view
@@ -12,20 +12,20 @@ domainurl: ##DomainURL##
1212

1313
## How to change the document view in DocumentEditor component
1414

15-
DocumentEditor allows you to change the view to web layout and print using the [`layoutType`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#layouttype/) property with the supported [`LayoutType`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/layoutType/).
15+
DocumentEditor allows you to change the view to web layout and print using the [`layoutType`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#layouttype) property with the supported [`LayoutType`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/layoutType).
1616

17-
```ts
18-
let docEdit: DocumentEditor = new DocumentEditor({ layoutType: 'Continuous'});
17+
```js
18+
var docEdit = new ej.documenteditor.DocumentEditor({ layoutType: 'Continuous'});
1919
```
2020

21-
>Note: Default value of [`layoutType`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#layouttype/) in DocumentEditor component is [`Pages`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/layoutType/).
21+
>Note: Default value of [`layoutType`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#layouttype) in DocumentEditor component is [`Pages`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/layoutType).
2222
2323
## How to change the document view in DocumentEditorContainer component
2424

25-
DocumentEditorContainer component allows you to change the view to web layout and print using the [`layoutType`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#layouttype/) property with the supported [`LayoutType`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/layoutType/).
25+
DocumentEditorContainer component allows you to change the view to web layout and print using the [`layoutType`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#layouttype) property with the supported [`LayoutType`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/layoutType).
2626

27-
```ts
28-
let container: DocumentEditorContainer = new DocumentEditorContainer({ layoutType: "Continuous" });
27+
```js
28+
var container = new ej.documenteditor.DocumentEditorContainer({ layoutType: "Continuous" });
2929
```
3030

31-
>Note: Default value of [`layoutType`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#layouttype/) in DocumentEditorContainer component is [`Pages`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/layoutType/).
31+
>Note: Default value of [`layoutType`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#layouttype) in DocumentEditorContainer component is [`Pages`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/layoutType).

Document-Processing/Word/Word-Processor/javascript-es5/how-to/customize-color-picker.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: post
3-
title: Customize color picker in JavaScript (ES5) Document editor control | Syncfusion
3+
title: Customize color picker in JavaScript(ES5) Document Editor | Syncfusion
44
description: Learn here all about Customize color picker in Syncfusion JavaScript (ES5) Document editor control of Syncfusion Essential JS 2 and more.
55
platform: document-processing
66
control: Customize Color Picker
@@ -10,14 +10,14 @@ domainurl: ##DomainURL##
1010

1111
# Customize color picker in JavaScript (ES5) Document editor control
1212

13-
Document editor provides an options to customize the color picker using [`colorPickerSettings`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/documentEditorSettingsModel#colorpickersettings/) in Document editor settings. The color picker offers customization options for default appearance, by allowing selection between Picker or Palette mode, for font and border colors."
13+
Document editor provides an options to customize the color picker using [`colorPickerSettings`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/documentEditorSettingsModel#colorpickersettings) in Document editor settings. The color picker offers customization options for default appearance, by allowing selection between Picker or Palette mode, for font and border colors."
1414

15-
Similarly, you can use [`documentEditorSettings`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#documenteditorsettings/) property for DocumentEditor also.
15+
Similarly, you can use [`documentEditorSettings`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#documenteditorsettings) property for DocumentEditor also.
1616

1717
The following example code illustrates how to Customize the color picker in Document editor container.
1818

19-
```ts
20-
let container: DocumentEditorContainer = new DocumentEditorContainer({ enableToolbar: true,height: '590px',
19+
```js
20+
var documenteditorContainer = new ej.documenteditor.DocumentEditorContainer({ enableToolbar: true,height: '590px',
2121
//Customizing options for color picker.
2222
documentEditorSettings: {
2323
colorPickerSettings: { mode: 'Palette', modeSwitcher: true, showButtons: true },

0 commit comments

Comments
 (0)