Skip to content

Commit d4b09eb

Browse files
Added sample for Selective Tools Registration in TS DOCX Editor WebMCP
1 parent 5bbfc5b commit d4b09eb

12 files changed

Lines changed: 243 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
node_modules/

‎webmcp/selective-tools-registration/e2e/index.spec.js‎

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
exports.config = {
2+
3+
allScriptsTimeout: 11000,
4+
5+
capabilities: {
6+
'browserName': 'chrome'
7+
},
8+
9+
framework: 'jasmine',
10+
11+
jasmineNodeOpts: {
12+
defaultTimeoutInterval: 10000
13+
},
14+
directConnect: true,
15+
16+
onPrepare: function() {
17+
browser.waitForAngularEnabled(false);
18+
},
19+
20+
specs: ['./*.spec.js']
21+
};
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
'use strict';
2+
3+
var gulp = require('gulp');
4+
5+
/**
6+
* Compile TypeScript to JS
7+
*/
8+
gulp.task('compile', function (done) {
9+
var webpack = require('webpack');
10+
var webpackStream = require('webpack-stream');
11+
gulp.src(['./src/app/app.ts']).pipe(webpackStream({
12+
config: require('./webpack.config.js')
13+
}, webpack))
14+
.pipe(gulp.dest('./dist'))
15+
.on('end', function () {
16+
done();
17+
});
18+
});
19+
20+
/**
21+
* Testing spec files
22+
*/
23+
var protractor = require('gulp-protractor').protractor;
24+
var webdriver_standalone = require('gulp-protractor').webdriver_standalone;
25+
var webdriver_update = require('gulp-protractor').webdriver_update_specific;
26+
27+
gulp.task('e2e-serve', webdriver_standalone);
28+
29+
gulp.task('e2e-webdriver-update', webdriver_update({
30+
webdriverManagerArgs: ['--ie', '--edge']
31+
}));
32+
33+
gulp.task('e2e-test', gulp.series('compile', function (done) {
34+
var browserSync = require('browser-sync');
35+
var bs = browserSync.create('Essential JS 2');
36+
var options = {
37+
server: {
38+
baseDir: [
39+
'./dist/',
40+
],
41+
directory: true
42+
},
43+
ui: false,
44+
open: false,
45+
notify: false
46+
};
47+
bs.init(options, function () {
48+
gulp.src(['./spec/**/*.spec.js'])
49+
.pipe(protractor({
50+
configFile: 'e2e/protractor.conf.js'
51+
}))
52+
.on('error', function (e) {
53+
console.error('Error: ' + e.message);
54+
done();
55+
process.exit(1);
56+
})
57+
.on('end', function () {
58+
done();
59+
process.exit(0);
60+
});
61+
});
62+
}));
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Essential JS 2 library is available under the Syncfusion Essential Studio program, and can be licensed either under the Syncfusion Community License Program or the Syncfusion commercial license.
2+
3+
To be qualified for the Syncfusion Community License Program you must have a gross revenue of less than one (1) million U.S. dollars ($1,000,000.00 USD) per year and have less than five (5) developers in your organization, and agree to be bound by Syncfusion’s terms and conditions.
4+
5+
Customers who do not qualify for the community license can contact sales@syncfusion.com for commercial licensing options.
6+
7+
Under no circumstances can you use this product without (1) either a Community License or a commercial license and (2) without agreeing and abiding by Syncfusion’s license containing all terms and conditions.
8+
9+
The Syncfusion license that contains the terms and conditions can be found at
10+
https://www.syncfusion.com/content/downloads/syncfusion_license.pdf
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "ej2-quickstart",
3+
"version": "0.0.1",
4+
"description": "Essential JS 2 typescript quick start application",
5+
"author": "Syncfusion Inc.",
6+
"license": "SEE LICENSE IN license",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/syncfusion/ej2-quickstart.git"
10+
},
11+
"scripts": {
12+
"start": "webpack serve --mode development",
13+
"build": "webpack --mode production",
14+
"serve": "gulp e2e-serve",
15+
"test": "gulp e2e-test",
16+
"update-webdriver": "gulp e2e-webdriver-update"
17+
},
18+
"devDependencies": {
19+
"ajv": "^8.11.2",
20+
"browser-sync": "^2.18.12",
21+
"css-loader": "^6.7.2",
22+
"esbuild": "^0.28.1",
23+
"esbuild-loader": "^4.5.0",
24+
"gulp": "*",
25+
"gulp-protractor": "*",
26+
"gulp-typescript": "*",
27+
"html-webpack-plugin": "^5.5.0",
28+
"jasmine": "^2.6.0",
29+
"mini-css-extract-plugin": "^2.7.0",
30+
"typescript": "*",
31+
"webpack": "^5.75.0",
32+
"webpack-cli": "^5.0.0",
33+
"webpack-dev-server": "^5.2.1",
34+
"webpack-stream": "^7.0.0"
35+
},
36+
"dependencies": {
37+
"@syncfusion/ej2": "*",
38+
"@syncfusion/ej2-documenteditor": "*",
39+
"@syncfusion/ej2-tailwind3-theme": "*"
40+
}
41+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { DocumentEditorContainer, Toolbar, Ribbon, WebMcpDocumentEditor } from '@syncfusion/ej2-documenteditor';
2+
3+
// Inject required modules
4+
DocumentEditorContainer.Inject(Toolbar, Ribbon, WebMcpDocumentEditor);
5+
6+
// Initialize DocumentEditorContainer with WebMCP enabled
7+
let webMcpSettings: any = {
8+
name: 'container',
9+
tools: [ 'getDocumentBookmarks', 'getSelectionText', 'find', 'findAll', 'goToPage' ] //Register only with needed tools
10+
};
11+
12+
let container: DocumentEditorContainer = new DocumentEditorContainer({
13+
height: '590px',
14+
enableWebMcp: true,
15+
webMcpSettings: webMcpSettings, // Enable WebMCP tools
16+
toolbarMode: 'Ribbon'
17+
});
18+
19+
// Set service URL for document operations
20+
container.serviceUrl = 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/';
21+
22+
// Append to container element
23+
container.appendTo('#container');
24+
25+
// Update document title
26+
document.title = 'WebMCP Tool Demo - DocumentEditorContainer';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<title>DOCXEditor_WebMcp</title>
6+
<meta charset="utf-8" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
8+
<meta name="description" content="Essential JS 2" />
9+
<meta name="author" content="Syncfusion" />
10+
<link rel="shortcut icon" href="resources/favicon.ico" />
11+
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
12+
</head>
13+
14+
<body>
15+
<div id="container"></div>
16+
</body>
17+
18+
</html>
6.42 KB
Binary file not shown.
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";

0 commit comments

Comments
 (0)