Skip to content

Commit d6e4c45

Browse files
Merge pull request #20 from SyncfusionExamples/webmcp-sample-basic
Fix with WebMCP settings and moved to Getting started sub page
2 parents 4c55dab + d62cffe commit d6e4c45

6 files changed

Lines changed: 39 additions & 133 deletions

File tree

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# WebMCP Integration with Syncfusion React DOCX Editor
1+
# WebMCP Example - Syncfusion® React DOCX Editor (Document Editor)
22

33
## Introduction
44

@@ -10,7 +10,6 @@ The sample enables WebMCP support in the `DocumentEditorContainerComponent`, ret
1010

1111
- Integrates WebMCP with the Syncfusion React DOCX Editor.
1212
- Enables WebMCP tools using `enableWebMcp`.
13-
- Retrieves the WebMCP tools available from the document editor.
1413

1514
## WebMCP Tool Handling
1615

@@ -20,33 +19,6 @@ The sample enables WebMCP using:
2019
enableWebMcp={true}
2120
```
2221

23-
After the Document Editor is created, the available WebMCP tools are retrieved using:
24-
25-
```javascript
26-
container.getWebMcpTools();
27-
```
28-
29-
The sample also handles the `beforeWebMcpToolExecute` event to identify document-modifying operations.
30-
31-
The following operations require user confirmation before execution:
32-
33-
- `saveDocument`
34-
- `configureDocumentEditorSettings`
35-
- `replaceAll`
36-
- `insertText`
37-
- `paste`
38-
- `insertBookmark`
39-
- `enforceProtection`
40-
- `stopProtection`
41-
- `insertField`
42-
- `insertEditingRegion`
43-
- `formatCharacter`
44-
- `formatParagraph`
45-
- `insertImage`
46-
- `insertHyperlink`
47-
48-
This provides an additional confirmation step before WebMCP tools perform potentially destructive or modifying operations on the document.
49-
5022
## How to Run the Sample
5123

5224
### Prerequisites
@@ -60,10 +32,6 @@ Make sure the following are installed:
6032

6133
Download or clone this repository and navigate to the project directory:
6234

63-
```bash
64-
cd WebMCP-React-DOCX-Editor
65-
```
66-
6735
### 2. Install dependencies
6836

6937
Install the required npm packages:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
return (
22+
<div style={{ height: 'calc(100vh - 16px)' }}>
23+
<DocumentEditorContainerComponent
24+
id="container"
25+
ref={(scope) => { container = scope; }}
26+
serviceUrl="https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/"
27+
height="100%"
28+
enableToolbar={true}
29+
toolbarMode="Ribbon"
30+
enableWebMcp={true}
31+
webMcpSettings={webMcpSettings}
32+
>
33+
</DocumentEditorContainerComponent>
34+
</div>
35+
);
36+
};
37+
export default WebMCPApp;
38+
createRoot(document.getElementById('sample')).render(<WebMCPApp />);

‎webmcp/src/index.jsx‎

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)