Skip to content

Commit c676a30

Browse files
1064603: Added the multi-instance and auditing-and-restrictions sample- #37
1 parent d6e4c45 commit c676a30

8 files changed

Lines changed: 237 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "webmcp-react-docx-editor",
3+
"version": "1.0.0",
4+
"private": true,
5+
"dependencies": {
6+
"@syncfusion/ej2-react-documenteditor": "*",
7+
"@syncfusion/ej2-tailwind3-theme": "*",
8+
"react": "^19.1.0",
9+
"react-dom": "^19.1.0",
10+
"react-scripts": "5.0.1"
11+
},
12+
"scripts": {
13+
"start": "react-scripts start",
14+
"build": "react-scripts build"
15+
},
16+
"browserslist": {
17+
"production": [
18+
">0.2%",
19+
"not dead",
20+
"not op_mini all"
21+
],
22+
"development": [
23+
"last 1 chrome version",
24+
"last 1 firefox version",
25+
"last 1 safari version"
26+
]
27+
}
28+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<meta name="description" content="Essential JS 2 React Components" />
8+
<meta name="author" content="Syncfusion" />
9+
<script type="text/javascript">
10+
if (/MSIE \d|Trident.*rv:/.test(navigator.userAgent)) {
11+
document.write('<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.5.1/bluebird.min.js"><\/script>');
12+
}
13+
</script>
14+
</head>
15+
16+
<body>
17+
<div id="container">
18+
<div id="sample"></div>
19+
</div>
20+
</body>
21+
22+
</html>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import "../node_modules/@syncfusion/ej2-tailwind3-theme/styles/document-editor/index.css";
2+
@import "../node_modules/@syncfusion/ej2-tailwind3-theme/styles/document-editor-container/index.css";
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { createRoot } from 'react-dom/client';
2+
import * as React from 'react';
3+
import { DocumentEditorContainerComponent, Ribbon } from '@syncfusion/ej2-react-documenteditor';
4+
import './index.css';
5+
DocumentEditorContainerComponent.Inject(Ribbon);
6+
7+
// tslint:disable:max-line-length
8+
const WebMCPApp = () => {
9+
let webMcpSettings = {
10+
name: 'container'
11+
};
12+
let container;
13+
14+
React.useEffect(() => {
15+
if(container){
16+
container.documentEditor.documentName = 'WebMCP Tool Demo';
17+
}
18+
document.title = 'WebMCP Tool Demo - DocumentEditorContainer';
19+
}, []);
20+
21+
const beforeWebMcpToolExecute = (args) => {
22+
const { toolName, toolArgs } = args;
23+
24+
console.log(`[WebMCP] Executing: ${toolName}`, toolArgs);
25+
26+
const commandName = toolName?.includes('_')
27+
? toolName.substring(toolName.indexOf('_') + 1)
28+
: toolName;
29+
30+
if (commandName === 'saveDocument') {
31+
args.cancel = true;
32+
args.cancellationResponse = 'The saveDocument operation has been restricted.';
33+
}
34+
};
35+
36+
return (
37+
<div style={{ height: 'calc(100vh - 16px)' }}>
38+
<DocumentEditorContainerComponent
39+
id="container"
40+
ref={(scope) => { container = scope; }}
41+
serviceUrl="https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/"
42+
height="100%"
43+
enableToolbar={true}
44+
toolbarMode="Ribbon"
45+
enableWebMcp={true}
46+
webMcpSettings={webMcpSettings}
47+
beforeWebMcpToolExecute={beforeWebMcpToolExecute}
48+
>
49+
</DocumentEditorContainerComponent>
50+
</div>
51+
);
52+
};
53+
export default WebMCPApp;
54+
createRoot(document.getElementById('sample')).render(<WebMCPApp />);

‎webmcp/multi-instance/package.json‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "webmcp-react-docx-editor",
3+
"version": "1.0.0",
4+
"private": true,
5+
"dependencies": {
6+
"@syncfusion/ej2-react-documenteditor": "*",
7+
"@syncfusion/ej2-tailwind3-theme": "*",
8+
"react": "^19.1.0",
9+
"react-dom": "^19.1.0",
10+
"react-scripts": "5.0.1"
11+
},
12+
"scripts": {
13+
"start": "react-scripts start",
14+
"build": "react-scripts build"
15+
},
16+
"browserslist": {
17+
"production": [
18+
">0.2%",
19+
"not dead",
20+
"not op_mini all"
21+
],
22+
"development": [
23+
"last 1 chrome version",
24+
"last 1 firefox version",
25+
"last 1 safari version"
26+
]
27+
}
28+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<meta name="description" content="Essential JS 2 React Components" />
8+
<meta name="author" content="Syncfusion" />
9+
<script type="text/javascript">
10+
if (/MSIE \d|Trident.*rv:/.test(navigator.userAgent)) {
11+
document.write('<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.5.1/bluebird.min.js"><\/script>');
12+
}
13+
</script>
14+
</head>
15+
16+
<body>
17+
<div id="container">
18+
<div id="sample"></div>
19+
</div>
20+
</body>
21+
22+
</html>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import "../node_modules/@syncfusion/ej2-tailwind3-theme/styles/document-editor/index.css";
2+
@import "../node_modules/@syncfusion/ej2-tailwind3-theme/styles/document-editor-container/index.css";
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { createRoot } from 'react-dom/client';
2+
import * as React from 'react';
3+
import {
4+
DocumentEditorContainerComponent,
5+
Ribbon
6+
} from '@syncfusion/ej2-react-documenteditor';
7+
import './index.css';
8+
9+
DocumentEditorContainerComponent.Inject(Ribbon);
10+
11+
const WebMCPApp = () => {
12+
const webMcpSettings1 = {
13+
name: 'documentEditor1'
14+
};
15+
16+
const webMcpSettings2 = {
17+
name: 'documentEditor2'
18+
};
19+
20+
let container1;
21+
let container2;
22+
23+
React.useEffect(() => {
24+
if (container1) {
25+
container1.documentEditor.documentName = 'Document 1';
26+
}
27+
28+
if (container2) {
29+
container2.documentEditor.documentName = 'Document 2';
30+
}
31+
32+
document.title = 'WebMCP Multi-instance Demo - DocumentEditorContainer';
33+
}, []);
34+
35+
return (
36+
<div
37+
style={{
38+
display: 'flex',
39+
width: '100%',
40+
gap: '10px',
41+
height: 'calc(100vh - 16px)'
42+
}}
43+
>
44+
<div style={{ width: '50%' }}>
45+
<DocumentEditorContainerComponent
46+
id="container1"
47+
ref={(scope) => {
48+
container1 = scope;
49+
}}
50+
serviceUrl="https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/"
51+
height="100%"
52+
enableToolbar={true}
53+
toolbarMode="Ribbon"
54+
enableWebMcp={true}
55+
webMcpSettings={webMcpSettings1}
56+
/>
57+
</div>
58+
59+
<div style={{ width: '50%' }}>
60+
<DocumentEditorContainerComponent
61+
id="container2"
62+
ref={(scope) => {
63+
container2 = scope;
64+
}}
65+
serviceUrl="https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/"
66+
height="100%"
67+
enableToolbar={true}
68+
toolbarMode="Ribbon"
69+
enableWebMcp={true}
70+
webMcpSettings={webMcpSettings2}
71+
/>
72+
</div>
73+
</div>
74+
);
75+
};
76+
77+
export default WebMCPApp;
78+
79+
createRoot(document.getElementById('sample')).render(<WebMCPApp />);

0 commit comments

Comments
 (0)