@eclipse-glsp/vscode-integration-webview 0.9.0-next.ba9614af → 0.9.0-next.ecc539e1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -23,27 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
23
8
  var __metadata = (this && this.__metadata) || function (k, v) {
24
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
10
  };
26
- var __read = (this && this.__read) || function (o, n) {
27
- var m = typeof Symbol === "function" && o[Symbol.iterator];
28
- if (!m) return o;
29
- var i = m.call(o), r, ar = [], e;
30
- try {
31
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
32
- }
33
- catch (error) { e = { error: error }; }
34
- finally {
35
- try {
36
- if (r && !r.done && (m = i["return"])) m.call(i);
37
- }
38
- finally { if (e) throw e.error; }
39
- }
40
- return ar;
41
- };
42
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
43
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
44
- to[j] = from[i];
45
- return to;
46
- };
47
11
  Object.defineProperty(exports, "__esModule", { value: true });
48
12
  exports.GLSPVscodeDiagramServer = exports.localDispatchProperty = exports.receivedFromServerProperty = void 0;
49
13
  /********************************************************************************
@@ -61,76 +25,81 @@ exports.GLSPVscodeDiagramServer = exports.localDispatchProperty = exports.receiv
61
25
  *
62
26
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
63
27
  ********************************************************************************/
64
- var client_1 = require("@eclipse-glsp/client");
65
- var selection_service_1 = require("@eclipse-glsp/client/lib/features/select/selection-service");
66
- var inversify_1 = require("inversify");
67
- var sprotty_vscode_webview_1 = require("sprotty-vscode-webview");
28
+ const client_1 = require("@eclipse-glsp/client");
29
+ const selection_service_1 = require("@eclipse-glsp/client/lib/features/select/selection-service");
30
+ const inversify_1 = require("inversify");
31
+ const sprotty_vscode_webview_1 = require("sprotty-vscode-webview");
68
32
  exports.receivedFromServerProperty = '__receivedFromServer';
69
33
  exports.localDispatchProperty = '__localDispatch';
70
- var GLSPVscodeDiagramServer = /** @class */ (function (_super) {
71
- __extends(GLSPVscodeDiagramServer, _super);
72
- function GLSPVscodeDiagramServer() {
73
- return _super !== null && _super.apply(this, arguments) || this;
74
- }
75
- GLSPVscodeDiagramServer.prototype.initialize = function (registry) {
76
- var _this = this;
77
- client_1.registerDefaultGLSPServerActions(registry, this);
34
+ class GLSPVscodeDiagramServer extends sprotty_vscode_webview_1.VscodeDiagramServer {
35
+ initialize(registry) {
36
+ (0, client_1.registerDefaultGLSPServerActions)(registry, this);
78
37
  this.clientId = this.viewerOptions.baseDiv;
79
- window.addEventListener('message', function (message) {
80
- if ('data' in message && sprotty_vscode_webview_1.isActionMessage(message.data)) {
81
- _this.messageReceived(message.data);
38
+ window.addEventListener('message', message => {
39
+ if ('data' in message && (0, sprotty_vscode_webview_1.isActionMessage)(message.data)) {
40
+ this.messageReceived(message.data);
82
41
  }
83
42
  });
84
- };
85
- GLSPVscodeDiagramServer.prototype.handleLocally = function (action) {
86
- if (client_1.isSetEditModeAction(action)) {
43
+ window.addEventListener('copy', (e) => {
44
+ this.copyPasteHandler.handleCopy(e);
45
+ });
46
+ window.addEventListener('cut', (e) => {
47
+ this.copyPasteHandler.handleCut(e);
48
+ });
49
+ window.addEventListener('paste', (e) => {
50
+ this.copyPasteHandler.handlePaste(e);
51
+ });
52
+ }
53
+ handleLocally(action) {
54
+ if ((0, client_1.isSetEditModeAction)(action)) {
87
55
  return this.handleSetEditModeAction(action);
88
56
  }
89
- if (client_1.isDeleteElementOperation(action)) {
57
+ if ((0, client_1.isDeleteElementOperation)(action)) {
90
58
  return this.handleDeleteElementOperation(action);
91
59
  }
92
- return _super.prototype.handleLocally.call(this, action);
93
- };
94
- GLSPVscodeDiagramServer.prototype.messageReceived = function (data) {
95
- var _this = this;
96
- var object = typeof (data) === 'string' ? JSON.parse(data) : data;
97
- if (sprotty_vscode_webview_1.isActionMessage(object) && object.action) {
60
+ return super.handleLocally(action);
61
+ }
62
+ messageReceived(data) {
63
+ const object = typeof data === 'string' ? JSON.parse(data) : data;
64
+ if ((0, sprotty_vscode_webview_1.isActionMessage)(object) && object.action) {
98
65
  if (!object.clientId || object.clientId === this.clientId) {
99
66
  this.checkMessageOrigin(object);
100
67
  this.logger.log(this, 'receiving', object);
101
- this.actionDispatcher.dispatch(object.action).then(function () {
102
- _this.storeNewModel(object.action);
68
+ this.actionDispatcher.dispatch(object.action).then(() => {
69
+ this.storeNewModel(object.action);
103
70
  });
104
71
  }
105
72
  }
106
73
  else {
107
74
  this.logger.error(this, 'received data is not an action message', object);
108
75
  }
109
- };
110
- GLSPVscodeDiagramServer.prototype.checkMessageOrigin = function (message) {
111
- var isLocalDispatch = message[exports.localDispatchProperty] || false;
76
+ }
77
+ checkMessageOrigin(message) {
78
+ const isLocalDispatch = message[exports.localDispatchProperty] || false;
112
79
  if (!isLocalDispatch) {
113
80
  message.action[exports.receivedFromServerProperty] = true;
114
81
  }
115
- };
116
- GLSPVscodeDiagramServer.prototype.handleComputedBounds = function (action) {
82
+ }
83
+ handleComputedBounds(action) {
117
84
  return true;
118
- };
119
- GLSPVscodeDiagramServer.prototype.handleDeleteElementOperation = function (operation) {
120
- var _a;
85
+ }
86
+ handleDeleteElementOperation(operation) {
121
87
  if (operation.elementIds.length === 0) {
122
- (_a = operation.elementIds).push.apply(_a, __spreadArray([], __read(this.selectionService.getSelectedElementIDs())));
88
+ operation.elementIds.push(...this.selectionService.getSelectedElementIDs());
123
89
  }
124
90
  return true;
125
- };
126
- GLSPVscodeDiagramServer.prototype.handleSetEditModeAction = function (action) {
91
+ }
92
+ handleSetEditModeAction(action) {
127
93
  return action[exports.receivedFromServerProperty] !== true;
128
- };
129
- __decorate([
130
- inversify_1.inject(client_1.GLSP_TYPES.SelectionService),
131
- __metadata("design:type", selection_service_1.SelectionService)
132
- ], GLSPVscodeDiagramServer.prototype, "selectionService", void 0);
133
- return GLSPVscodeDiagramServer;
134
- }(sprotty_vscode_webview_1.VscodeDiagramServer));
94
+ }
95
+ }
96
+ __decorate([
97
+ (0, inversify_1.inject)(client_1.GLSP_TYPES.SelectionService),
98
+ __metadata("design:type", selection_service_1.SelectionService)
99
+ ], GLSPVscodeDiagramServer.prototype, "selectionService", void 0);
100
+ __decorate([
101
+ (0, inversify_1.inject)(client_1.GLSP_TYPES.ICopyPasteHandler),
102
+ __metadata("design:type", Object)
103
+ ], GLSPVscodeDiagramServer.prototype, "copyPasteHandler", void 0);
135
104
  exports.GLSPVscodeDiagramServer = GLSPVscodeDiagramServer;
136
105
  //# sourceMappingURL=glsp-vscode-diagramserver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"glsp-vscode-diagramserver.js","sourceRoot":"","sources":["../src/glsp-vscode-diagramserver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;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0B,CAAC,GAAG,IAAI,CAAC;SAC9D;IACL,CAAC;IAES,oBAAoB,CAAC,MAA4B;QACvD,OAAO,IAAI,CAAC;IAChB,CAAC;IAES,4BAA4B,CAAC,SAAiC;QACpE,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YACnC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,CAAC,CAAC;SAC/E;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAES,uBAAuB,CAAC,MAAyB;QACvD,OAAQ,MAAc,CAAC,kCAA0B,CAAC,KAAK,IAAI,CAAC;IAChE,CAAC;CACJ;AAvEwC;IAApC,IAAA,kBAAM,EAAC,mBAAU,CAAC,gBAAgB,CAAC;8BAA6B,oCAAgB;iEAAC;AAC5C;IAArC,IAAA,kBAAM,EAAC,mBAAU,CAAC,iBAAiB,CAAC;;iEAA+C;AAFxF,0DAwEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC"}
package/lib/index.js CHANGED
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
2
13
  /********************************************************************************
3
14
  * Copyright (c) 2020 EclipseSource and others.
4
15
  *
@@ -14,17 +25,6 @@
14
25
  *
15
26
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
27
  ********************************************************************************/
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
- };
27
- Object.defineProperty(exports, "__esModule", { value: true });
28
28
  __exportStar(require("./glsp-starter"), exports);
29
29
  __exportStar(require("./glsp-vscode-diagramserver"), exports);
30
30
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;AAElF,iDAA+B;AAC/B,8DAA4C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,iDAA+B;AAC/B,8DAA4C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-glsp/vscode-integration-webview",
3
- "version": "0.9.0-next.ba9614af",
3
+ "version": "0.9.0-next.ecc539e1",
4
4
  "description": "Integration of a GLSP diagram in a VS Code extensions (WebView part)",
5
5
  "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",
6
6
  "keywords": [
@@ -33,12 +33,12 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@eclipse-glsp/client": "next",
36
- "reflect-metadata": "^0.1.12",
37
36
  "sprotty-vscode-webview": "0.1.2"
38
37
  },
39
38
  "devDependencies": {
39
+ "reflect-metadata": "^0.1.13",
40
40
  "rimraf": "latest",
41
- "typescript": "latest"
41
+ "typescript": "^4.4.3"
42
42
  },
43
43
  "scripts": {
44
44
  "prepare": "yarn clean && yarn build && yarn lint",
@@ -0,0 +1,36 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2021 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ import { InitializeResult } from '@eclipse-glsp/client';
17
+ import { isString } from '@eclipse-glsp/protocol';
18
+
19
+ export const GLSPDiagramIdentifier = Symbol('GLSPDiagramIdentifier');
20
+
21
+ export interface GLSPDiagramIdentifier {
22
+ clientId: string;
23
+ diagramType: string;
24
+ uri: string;
25
+ initializeResult?: InitializeResult;
26
+ }
27
+
28
+ export function isDiagramIdentifier(object: any): object is GLSPDiagramIdentifier {
29
+ return (
30
+ object !== undefined &&
31
+ typeof object === 'object' &&
32
+ isString(object, 'clientId') &&
33
+ isString(object, 'diagramType') &&
34
+ isString(object, 'uri')
35
+ );
36
+ }
@@ -23,10 +23,7 @@ import { vscodeApi } from 'sprotty-vscode-webview/lib/vscode-api';
23
23
  * to the vscode API and/or node backend.
24
24
  */
25
25
  export class GLSPVscodeExtensionActionHandler implements IActionHandler, IActionHandlerInitializer {
26
-
27
- constructor(protected readonly actionKinds: string[],
28
- protected readonly diagramIdentifier: SprottyDiagramIdentifier) {
29
- }
26
+ constructor(protected readonly actionKinds: string[], protected readonly diagramIdentifier: SprottyDiagramIdentifier) {}
30
27
 
31
28
  initialize(registry: ActionHandlerRegistry): void {
32
29
  this.actionKinds.forEach(kind => registry.register(kind, this));
@@ -13,7 +13,16 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { DiagramServer, NavigateToExternalTargetAction, TYPES } from '@eclipse-glsp/client';
16
+ import {
17
+ configureServerActions,
18
+ DiagramServer,
19
+ ExportSvgAction,
20
+ NavigateToExternalTargetAction,
21
+ RequestClipboardDataAction,
22
+ SelectAction,
23
+ SetClipboardDataAction,
24
+ TYPES
25
+ } from '@eclipse-glsp/client';
17
26
  import { Container } from 'inversify';
18
27
  import {
19
28
  SprottyDiagramIdentifier,
@@ -22,17 +31,46 @@ import {
22
31
  VscodeDiagramWidget,
23
32
  VscodeDiagramWidgetFactory
24
33
  } from 'sprotty-vscode-webview';
25
-
34
+ import { GLSPDiagramIdentifier, isDiagramIdentifier } from './diagram-identifer';
26
35
  import { GLSPVscodeExtensionActionHandler } from './extension-action-handler';
27
36
  import { GLSPVscodeDiagramWidget } from './glsp-vscode-diagram-widget';
28
37
  import { GLSPVscodeDiagramServer } from './glsp-vscode-diagramserver';
29
38
 
30
39
  export abstract class GLSPStarter extends SprottyStarter {
31
- protected addVscodeBindings(container: Container, diagramIdentifier: SprottyDiagramIdentifier): void {
40
+ protected acceptDiagramIdentifier(): void {
41
+ console.log('Waiting for diagram identifier...');
42
+ const eventListener = (message: any): void => {
43
+ if (isDiagramIdentifier(message.data)) {
44
+ console.log(message);
45
+ if (this.container) {
46
+ const oldIdentifier = this.container.get<GLSPDiagramIdentifier>(GLSPDiagramIdentifier);
47
+ const newIdentifier = message.data as GLSPDiagramIdentifier;
48
+ oldIdentifier.diagramType = newIdentifier.diagramType;
49
+ oldIdentifier.uri = newIdentifier.uri;
50
+ const diagramWidget = this.container.get(VscodeDiagramWidget);
51
+ diagramWidget.requestModel();
52
+ } else {
53
+ console.log('...received...', message);
54
+ const diagramIdentifier = message.data as GLSPDiagramIdentifier;
55
+ this.container = this.createContainer(diagramIdentifier);
56
+ this.addVscodeBindings(this.container, diagramIdentifier);
57
+ if (diagramIdentifier.initializeResult) {
58
+ configureServerActions(diagramIdentifier.initializeResult, diagramIdentifier.diagramType, this.container);
59
+ }
60
+ this.container.get(VscodeDiagramWidget);
61
+ }
62
+ }
63
+ };
64
+ window.addEventListener('message', eventListener);
65
+ }
66
+
67
+ protected addVscodeBindings(container: Container, diagramIdentifier: GLSPDiagramIdentifier): void {
32
68
  container.bind(GLSPVscodeDiagramWidget).toSelf().inSingletonScope();
33
69
  container.bind(VscodeDiagramWidget).toService(GLSPVscodeDiagramWidget);
34
- container.bind(VscodeDiagramWidgetFactory).toFactory(
35
- context => () => context.container.get<GLSPVscodeDiagramWidget>(GLSPVscodeDiagramWidget));
70
+ container
71
+ .bind(VscodeDiagramWidgetFactory)
72
+ .toFactory(context => () => context.container.get<GLSPVscodeDiagramWidget>(GLSPVscodeDiagramWidget));
73
+ container.bind(GLSPDiagramIdentifier).toConstantValue(diagramIdentifier);
36
74
  container.bind(SprottyDiagramIdentifier).toConstantValue(diagramIdentifier);
37
75
  container.bind(GLSPVscodeDiagramServer).toSelf().inSingletonScope();
38
76
  container.bind(VscodeDiagramServer).toService(GLSPVscodeDiagramServer);
@@ -52,6 +90,12 @@ export abstract class GLSPStarter extends SprottyStarter {
52
90
  * All kinds of actions that should (also) be delegated to and handled by the vscode extension
53
91
  */
54
92
  protected get extensionActionKinds(): string[] {
55
- return [NavigateToExternalTargetAction.KIND];
93
+ return [
94
+ NavigateToExternalTargetAction.KIND,
95
+ RequestClipboardDataAction.KIND,
96
+ SetClipboardDataAction.KIND,
97
+ SelectAction.KIND,
98
+ ExportSvgAction.KIND
99
+ ];
56
100
  }
57
101
  }
@@ -13,13 +13,7 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import {
17
- DiagramServer,
18
- EnableToolPaletteAction,
19
- InitializeClientSessionAction,
20
- RequestModelAction,
21
- RequestTypeHintsAction
22
- } from '@eclipse-glsp/client';
16
+ import { DiagramServer, EnableToolPaletteAction, RequestModelAction, RequestTypeHintsAction } from '@eclipse-glsp/client';
23
17
  import { injectable } from 'inversify';
24
18
  import { VscodeDiagramWidget } from 'sprotty-vscode-webview';
25
19
 
@@ -29,11 +23,12 @@ export abstract class GLSPVscodeDiagramWidget extends VscodeDiagramWidget {
29
23
  if (this.modelSource instanceof DiagramServer) {
30
24
  this.modelSource.clientId = this.diagramIdentifier.clientId;
31
25
  }
32
- this.actionDispatcher.dispatch(new InitializeClientSessionAction(this.diagramIdentifier.clientId));
33
- this.actionDispatcher.dispatch(new RequestModelAction({
34
- sourceUri: decodeURI(this.diagramIdentifier.uri),
35
- diagramType: this.diagramIdentifier.diagramType
36
- }));
26
+ this.actionDispatcher.dispatch(
27
+ new RequestModelAction({
28
+ sourceUri: decodeURI(this.diagramIdentifier.uri),
29
+ diagramType: this.diagramIdentifier.diagramType
30
+ })
31
+ );
37
32
 
38
33
  this.actionDispatcher.dispatch(new RequestTypeHintsAction(this.diagramIdentifier.diagramType));
39
34
  this.actionDispatcher.dispatch(new EnableToolPaletteAction());
@@ -20,6 +20,7 @@ import {
20
20
  ComputedBoundsAction,
21
21
  DeleteElementOperation,
22
22
  GLSP_TYPES,
23
+ ICopyPasteHandler,
23
24
  isDeleteElementOperation,
24
25
  isSetEditModeAction,
25
26
  registerDefaultGLSPServerActions,
@@ -34,6 +35,7 @@ export const localDispatchProperty = '__localDispatch';
34
35
 
35
36
  export class GLSPVscodeDiagramServer extends VscodeDiagramServer {
36
37
  @inject(GLSP_TYPES.SelectionService) protected selectionService: SelectionService;
38
+ @inject(GLSP_TYPES.ICopyPasteHandler) protected copyPasteHandler: ICopyPasteHandler;
37
39
 
38
40
  initialize(registry: ActionHandlerRegistry): void {
39
41
  registerDefaultGLSPServerActions(registry, this);
@@ -43,6 +45,18 @@ export class GLSPVscodeDiagramServer extends VscodeDiagramServer {
43
45
  this.messageReceived(message.data);
44
46
  }
45
47
  });
48
+
49
+ window.addEventListener('copy', (e: ClipboardEvent) => {
50
+ this.copyPasteHandler.handleCopy(e);
51
+ });
52
+
53
+ window.addEventListener('cut', (e: ClipboardEvent) => {
54
+ this.copyPasteHandler.handleCut(e);
55
+ });
56
+
57
+ window.addEventListener('paste', (e: ClipboardEvent) => {
58
+ this.copyPasteHandler.handlePaste(e);
59
+ });
46
60
  }
47
61
 
48
62
  handleLocally(action: Action): boolean {
@@ -56,7 +70,7 @@ export class GLSPVscodeDiagramServer extends VscodeDiagramServer {
56
70
  }
57
71
 
58
72
  protected messageReceived(data: any): void {
59
- const object = typeof (data) === 'string' ? JSON.parse(data) : data;
73
+ const object = typeof data === 'string' ? JSON.parse(data) : data;
60
74
  if (isActionMessage(object) && object.action) {
61
75
  if (!object.clientId || object.clientId === this.clientId) {
62
76
  this.checkMessageOrigin(object);
@@ -91,5 +105,4 @@ export class GLSPVscodeDiagramServer extends VscodeDiagramServer {
91
105
  protected handleSetEditModeAction(action: SetEditModeAction): boolean {
92
106
  return (action as any)[receivedFromServerProperty] !== true;
93
107
  }
94
-
95
108
  }
package/src/index.ts CHANGED
@@ -13,6 +13,5 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
-
17
16
  export * from './glsp-starter';
18
17
  export * from './glsp-vscode-diagramserver';