From b0b15edfa333ca393774351aea5a8a0521ef51d8 Mon Sep 17 00:00:00 2001 From: Tobias Ortmayr Date: Mon, 24 Jun 2024 09:12:46 +0200 Subject: [PATCH] Remove contextMenuModule per default Remove context menu module for now as it is not supported in VS Code (https://github.com/eclipse-glsp/glsp/issues/414) and causes focus issues --- .../vscode-integration-webview/src/default-modules.ts | 5 +++-- .../vscode-integration-webview/src/glsp-diagram-widget.ts | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/vscode-integration-webview/src/default-modules.ts b/packages/vscode-integration-webview/src/default-modules.ts index 3045864..a5df19f 100644 --- a/packages/vscode-integration-webview/src/default-modules.ts +++ b/packages/vscode-integration-webview/src/default-modules.ts @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ -import { ModuleConfiguration } from '@eclipse-glsp/client'; +import { ModuleConfiguration, contextMenuModule } from '@eclipse-glsp/client'; import { vscodeCopyPasteModule } from './features/copyPaste/copy-paste-module'; import { vscodeDefaultModule } from './features/default/default-module'; import { vscodeExportModule } from './features/export/export-module'; @@ -30,5 +30,6 @@ export const VSCODE_DEFAULT_MODULES = [ ] as const; export const VSCODE_DEFAULT_MODULE_CONFIG: ModuleConfiguration = { - add: [...VSCODE_DEFAULT_MODULES] + add: [...VSCODE_DEFAULT_MODULES], + remove: [contextMenuModule] }; diff --git a/packages/vscode-integration-webview/src/glsp-diagram-widget.ts b/packages/vscode-integration-webview/src/glsp-diagram-widget.ts index d35b7b4..31d952b 100644 --- a/packages/vscode-integration-webview/src/glsp-diagram-widget.ts +++ b/packages/vscode-integration-webview/src/glsp-diagram-widget.ts @@ -73,9 +73,17 @@ export abstract class GLSPDiagramWidget { containerDiv.addEventListener('mouseleave', e => this.handleMouseLeave(e)); window.addEventListener('focus', e => this.handleFocusChange(e, true)); window.addEventListener('blur', e => this.handleFocusChange(e, false)); + window.addEventListener('contextmenu', e => this.handleContextMenu(e)); } } + handleContextMenu(e: MouseEvent): void { + // Prevent the default context menu for now + // Should be removed once we provide a proper context menu integration + e.preventDefault(); + window.focus(); + } + handleMouseEnter(e: MouseEvent): void { this.containerDiv?.classList.add('mouse-enter'); this.containerDiv?.classList.remove('mouse-leave');