Skip to content

Commit 31e8f02

Browse files
committed
1009393: Modified the code snippets
1 parent a7f224b commit 31e8f02

6 files changed

Lines changed: 73 additions & 85 deletions

File tree

Document-Processing/Word/Word-Processor/javascript-es5/how-to/change-document-view.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ domainurl: ##DomainURL##
1414

1515
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

2121
>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/).
@@ -24,8 +24,8 @@ let docEdit: DocumentEditor = new DocumentEditor({ layoutType: 'Continuous'});
2424

2525
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

3131
>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-context-menu.md

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,30 @@ Document Editor allows you to add custom option in context menu. It can be achie
1818

1919
The following code shows how to add custom option in context menu.
2020

21-
```ts
22-
let documentEditor: DocumentEditor = new DocumentEditor({
23-
isReadOnly: false, serviceUrl: 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/'
21+
```js
22+
var documentEditor = new ej.documenteditor.DocumentEditor({
23+
isReadOnly: false,
24+
serviceUrl: 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/'
2425
});
2526
documentEditor.enableAllModules();
2627
documentEditor.appendTo('#DocumentEditor');
2728
//Creating custom menu items
28-
let menuItems: MenuItemModel[] = [
29+
var menuItems = [
2930
{
3031
text: 'Search In Google',
3132
id: 'search_in_google',
3233
iconCss: 'e-icons e-de-ctnr-find'
33-
}];
34+
}
35+
];
3436
//Adding custom options
3537
documentEditor.contextMenu.addCustomMenu(menuItems, false);
3638
//To handle contextmenu select event
37-
documentEditor.customContextMenuSelect = (args: CustomContentMenuEventArgs): void => {
38-
let item: string = args.id;
39-
let id: string = documentEditor.element.id;
39+
documentEditor.customContextMenuSelect = function (args) {
40+
var item = args.id;
41+
var id = documentEditor.element.id;
4042
switch (item) {
4143
case id + 'search_in_google':
42-
let searchContent: string = documentEditor.selection.text;
44+
var searchContent = documentEditor.selection.text;
4345
if (!documentEditor.selection.isEmpty && /\S/.test(searchContent)) {
4446
window.open('http://google.com/search?q=' + searchContent);
4547
}
@@ -56,19 +58,21 @@ Document Editor allows you to customize the added custom option and also to hide
5658

5759
The following code shows how to hide default context menu and add custom option in context menu.
5860

59-
```ts
60-
let documentEditor: DocumentEditor = new DocumentEditor({
61-
isReadOnly: false, serviceUrl: 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/'
61+
```js
62+
var documentEditor = new ej.documenteditor.DocumentEditor({
63+
isReadOnly: false,
64+
serviceUrl: 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/'
6265
});
6366
documentEditor.enableAllModules();
6467
documentEditor.appendTo('#DocumentEditor');
6568
//Creating custom menu items
66-
let menuItems: MenuItemModel[] = [
69+
var menuItems = [
6770
{
6871
text: 'Search In Google',
6972
id: 'search_in_google',
7073
iconCss: 'e-icons e-de-ctnr-find'
71-
}];
74+
}
75+
];
7276
//Adding custom options
7377
documentEditor.contextMenu.addCustomMenu(menuItems, true);
7478
```
@@ -77,37 +81,38 @@ documentEditor.contextMenu.addCustomMenu(menuItems, true);
7781

7882
The following code shows how to hide/show added custom option in context menu using the [`customContextMenuBeforeOpen`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/beforeOpenCloseCustomContentMenuEventArgs/).
7983

80-
```ts
81-
let documentEditor: DocumentEditor = new DocumentEditor({
84+
```js
85+
var documentEditor = new ej.documenteditor.DocumentEditor({
8286
isReadOnly: false, serviceUrl: 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/'
8387
});
8488
documentEditor.enableAllModules();
8589
documentEditor.appendTo('#DocumentEditor');
8690
//Creating custom menu items
87-
let menuItems: MenuItemModel[] = [
91+
var menuItems = [
8892
{
8993
text: 'Search In Google',
9094
id: 'search_in_google',
9195
iconCss: 'e-icons e-de-ctnr-find'
92-
}];
96+
}
97+
];
9398
//Adding custom options
9499
documentEditor.contextMenu.addCustomMenu(menuItems, false);
95100
//To show/hide custom menu item
96-
documentEditor.customContextMenuBeforeOpen = (args: BeforeOpenCloseCustomContentMenuEventArgs): void => {
97-
let search: HTMLElement = document.getElementById(args.ids[0]);
101+
documentEditor.customContextMenuBeforeOpen = function (args) {
102+
var search = document.getElementById(args.ids[0]);
98103
search.style.display = 'none';
99-
let searchContent: string = documentEditor.selection.text;
104+
var searchContent = documentEditor.selection.text;
100105
if ((!documentEditor.selection.isEmpty) && (/\S/.test(searchContent))) {
101106
search.style.display = 'block';
102107
}
103108
};
104109
//To handle contextmenu select event
105-
documentEditor.customContextMenuSelect = (args: CustomContentMenuEventArgs): void => {
106-
let item: string = args.id;
107-
let id: string = documentEditor.element.id;
110+
documentEditor.customContextMenuSelect = function (args) {
111+
var item = args.id;
112+
var id = documentEditor.element.id;
108113
switch (item) {
109114
case id + 'search_in_google':
110-
let searchContent: string = documentEditor.selection.text;
115+
var searchContent = documentEditor.selection.text;
111116
if (!documentEditor.selection.isEmpty && /\S/.test(searchContent)) {
112117
window.open('http://google.com/search?q=' + searchContent);
113118
}
@@ -135,18 +140,10 @@ Document Editor allows you to customize the Context Menu with sub-menu items. It
135140

136141
The following code shows how to add a sub items in the custom option in context menu in Document Editor Container.
137142

138-
```ts
139-
import {
140-
DocumentEditorContainer,
141-
Toolbar,
142-
} from '@syncfusion/ej2-documenteditor';
143-
import { MenuItemModel } from '@syncfusion/ej2-navigations';
144-
145-
//Inject require modules.
146-
DocumentEditorContainer.Inject(Toolbar);
143+
```js
147144

148145
// creating Custom Options
149-
let menuItems: MenuItemModel[] = [
146+
var menuItems = [
150147
{
151148
text: 'Form field',
152149
id: 'form field',
@@ -155,34 +152,34 @@ let menuItems: MenuItemModel[] = [
155152
{
156153
text: 'Text form',
157154
id: 'Text form',
158-
iconCss: 'e-icons e-de-textform',
155+
iconCss: 'e-icons e-de-textform'
159156
},
160157
{
161158
text: 'Check box',
162159
id: 'Check box',
163-
iconCss: 'e-icons e-de-checkbox-form',
160+
iconCss: 'e-icons e-de-checkbox-form'
164161
},
165162
{
166163
text: 'Drop down',
167164
id: 'Drop down',
168-
iconCss: 'e-icons e-de-dropdownform',
169-
},
170-
],
171-
},
165+
iconCss: 'e-icons e-de-dropdownform'
166+
}
167+
]
168+
}
172169
];
170+
173171
//Initialize Document Editor component.
174-
let container: DocumentEditorContainer = new DocumentEditorContainer({
172+
var container = new ej.documenteditor.DocumentEditorContainer({
175173
enableToolbar: true,
176-
height: '590px',
174+
height: '590px'
177175
});
178176

179177
//Open the default document in `created` event.
180178
container.created = function () {
181179
// adding Custom Options
182180
container.documentEditor.contextMenu.addCustomMenu(menuItems, false, true);
183181
};
182+
184183
//Render Document Editor Container component.
185184
container.appendTo('#DocumentEditor');
186-
187-
188185
```

Document-Processing/Word/Word-Processor/javascript-es5/how-to/customize-tool-bar.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,35 @@ DocumentEditorContainer allows you to customize(add, show, hide, enable, and dis
2020

2121
* Enable, Disable - Toolbar items can be enabled or disable using [`enableItems`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor-container/toolbar/#enableItems)
2222

23-
```ts
24-
let toolItem: CustomToolbarItemModel = {
23+
```js
24+
var toolItem = {
2525
prefixIcon: "e-de-ctnr-lock",
2626
tooltipText: "Disable Image",
2727
text: onWrapText("Disable Image"),
2828
id: "Custom"
2929
};
30-
3130
//Initialize Document Editor Container component with custom toolbar item.
32-
let container: DocumentEditorContainer = new DocumentEditorContainer({
31+
var container = new ej.documenteditor.DocumentEditorContainer({
3332
toolbarItems: [toolItem, 'Undo', 'Redo', 'Separator', 'Image', 'Table', 'Hyperlink', 'Bookmark', 'TableOfContents', 'Separator', 'Header', 'Footer', 'PageSetup', 'PageNumber', 'Break', 'InsertFootnote', 'InsertEndnote', 'Separator', 'Find', 'Separator', 'Comments', 'TrackChanges', 'Separator', 'LocalClipboard', 'RestrictEditing', 'Separator', 'FormFields', 'UpdateFields','ContentControl']
3433
});
3534
container.appendTo('#container');
3635
//To handle custom toolbar click event.
37-
container.toolbarClick = (args: ClickEventArgs): void => {
36+
container.toolbarClick = function (args) {
3837
switch (args.item.id) {
3938
case 'Custom':
4039
//Disable image toolbar item.
4140
container.toolbar.enableItems(4, false);
4241
break;
4342
}
4443
};
45-
46-
function onWrapText(text: string): string {
47-
let content: string = '';
48-
const index: number = text.lastIndexOf(' ');
49-
44+
function onWrapText(text) {
45+
var content = '';
46+
var index = text.lastIndexOf(' ');
5047
if (index !== -1) {
5148
content = text.slice(0, index) + "<div class='e-de-text-wrap'>" + text.slice(index + 1) + "</div>";
5249
} else {
5350
content = text;
5451
}
55-
5652
return content;
5753
}
5854
```

Document-Processing/Word/Word-Processor/javascript-es5/how-to/deploy-document-editor-component-for-mobile.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,29 @@ Hence, it is recommended to switch the Document editor component as read-only in
1818

1919
The following example code illustrates how to deploy Document Editor component for Mobile.
2020

21-
```ts
21+
```js
2222
//Initialize Document Editor Container component.
23-
import { DocumentEditorContainer, Toolbar } from '@syncfusion/ej2-documenteditor';
2423

25-
DocumentEditorContainer.Inject(Toolbar);
26-
let container: DocumentEditorContainer = new DocumentEditorContainer({
24+
var container = new ej.documenteditor.DocumentEditorContainer({
2725
enableToolbar: true, height: '590px'
2826
});
2927
container.serviceUrl = 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/';
3028
container.appendTo('#DocumentEditor');
3129

3230
//To detect the device
33-
let isMobileDevice: bool = /Android|Windows Phone|webOS/i.test(navigator.userAgent);
31+
var isMobileDevice = /Android|Windows Phone|webOS/i.test(navigator.userAgent);
3432

35-
container.documentChange = () => {
33+
container.documentChange = function () {
3634
if (isMobileDevice) {
3735
container.restrictEditing = true;
38-
setTimeout(() => {
36+
setTimeout(function () {
3937
container.documentEditor.fitPage("FitPageWidth");
4038
}, 50);
4139
}
4240
else {
4341
container.restrictEditing = false;
4442
}
45-
}
43+
};
4644
```
4745

4846
> 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.

Document-Processing/Word/Word-Processor/javascript-es5/how-to/disable-optimized-text-measuring.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ If you want the Document editor component to retain the document pagination (dis
1818

1919
The following example code illustrates how to disable optimized text measuring improvement in `DocumentEditorContainer` instance.
2020

21-
```ts
22-
import { DocumentEditorContainer, Toolbar } from '@syncfusion/ej2-documenteditor';
21+
```js
2322

24-
DocumentEditorContainer.Inject(Toolbar);
25-
26-
let container: DocumentEditorContainer = new DocumentEditorContainer({ enableToolbar: true, height: '590px' });
23+
var container = new ej.documenteditor.DocumentEditorContainer({
24+
enableToolbar: true,
25+
height: '590px'
26+
});
2727

2828
// Disable optimized text measuring improvement
2929
container.documentEditorSettings = { enableOptimizedTextMeasuring: false };
@@ -37,10 +37,9 @@ container.appendTo('#container');
3737

3838
The following example code illustrates how to disable optimized text measuring improvement in `DocumentEditor` instance.
3939

40-
```ts
41-
import { DocumentEditor } from '@syncfusion/ej2-documenteditor';
40+
```js
4241

43-
let documenteditor: DocumentEditor = new DocumentEditor({ isReadOnly: false, height: '370px', serviceUrl: 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/' });
42+
var documenteditor = new ej.documenteditor.DocumentEditor({ isReadOnly: false, height: '370px', serviceUrl: 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/' });
4443

4544
documenteditor.enableAllModules();
4645

Document-Processing/Word/Word-Processor/javascript-es5/how-to/open-document-by-address.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,18 @@ In this article, we are going to see how to open a document from URL in Document
1616

1717
please refer below example for client-side code
1818

19-
```ts
19+
```js
2020
//Initialize Document Editor Container component.
21-
let container: DocumentEditorContainer = new DocumentEditorContainer();
22-
21+
var container = new ej.documenteditor.DocumentEditorContainer();
2322
container.appendTo('#DocumentEditorContainer');
24-
25-
document.getElementById('import').addEventListener('click', () => {
26-
let http: XMLHttpRequest = new XMLHttpRequest();
23+
document.getElementById('import').addEventListener('click', function () {
24+
var http = new XMLHttpRequest();
2725
//add your url in which you want to open document inside the ""
28-
let content = { fileUrl: "" };
29-
let baseurl: string = "/api/documenteditor/ImportFileURL";
26+
var content = { fileUrl: "" };
27+
var baseurl = "/api/documenteditor/ImportFileURL";
3028
http.open("POST", baseurl, true);
3129
http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
32-
http.onreadystatechange = () => {
30+
http.onreadystatechange = function () {
3331
if (http.readyState === 4) {
3432
if (http.status === 200 || http.status === 304) {
3533
//open the SFDT text in Document Editor

0 commit comments

Comments
 (0)