Skip to content

Commit 5fe3bdf

Browse files
Added sample for Selective Tools Registration
1 parent d6e4c45 commit 5fe3bdf

4 files changed

Lines changed: 93 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: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
//Register only with needed tools
12+
tools: [ 'getDocumentBookmarks', 'getSelectionText', 'find', 'findAll', 'goToPage' ]
13+
};
14+
let container;
15+
16+
React.useEffect(() => {
17+
if(container){
18+
container.documentEditor.documentName = 'WebMCP Tool Demo';
19+
}
20+
document.title = 'WebMCP Tool Demo - DocumentEditorContainer';
21+
}, []);
22+
23+
return (
24+
<div style={{ height: 'calc(100vh - 16px)' }}>
25+
<DocumentEditorContainerComponent
26+
id="container"
27+
ref={(scope) => { container = scope; }}
28+
// Use the following service URL only for demo purposes
29+
serviceUrl="https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/"
30+
height="100%"
31+
enableToolbar={true}
32+
toolbarMode="Ribbon"
33+
enableWebMcp={true}
34+
webMcpSettings={webMcpSettings}
35+
>
36+
</DocumentEditorContainerComponent>
37+
</div>
38+
);
39+
};
40+
export default WebMCPApp;
41+
createRoot(document.getElementById('sample')).render(<WebMCPApp />);

0 commit comments

Comments
 (0)