Skip to content

Commit

Permalink
Only fire paste/delete actions if glsp has focus
Browse files Browse the repository at this point in the history
  • Loading branch information
ivy-lli committed Nov 27, 2023
1 parent aa4eae3 commit 35c52f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 6 additions & 4 deletions integration/eclipse/src/copy-paste/copy-paste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ export class IvyEclipseCopyPasteActionHandler implements IActionHandler {
}

handlePaste() {
// In the Eclipse Integration case, the server manages its own clipboard.
// Just pass an empty clipboard data to remain compliant with the API.
const clipboardData = {};
this.actionDispatcher.dispatch(PasteOperation.create({ clipboardData: clipboardData, editorContext: this.editorContext.get() }));
if (this.isDiagramActive()) {
// In the Eclipse Integration case, the server manages its own clipboard.
// Just pass an empty clipboard data to remain compliant with the API.
const clipboardData = {};
this.actionDispatcher.dispatch(PasteOperation.create({ clipboardData: clipboardData, editorContext: this.editorContext.get() }));
}
}

protected shouldCopy(): boolean {
Expand Down
8 changes: 7 additions & 1 deletion integration/eclipse/src/delete/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export class IvyInvokeDeleteActionHandler implements IActionHandler {
}

handleDelete(): void {
this.actionDispatcher.dispatch(DeleteElementOperation.create(this.editorContext.get().selectedElementIds));
if (this.isDiagramActive()) {
this.actionDispatcher.dispatch(DeleteElementOperation.create(this.editorContext.get().selectedElementIds));
}
}

protected isDiagramActive(): boolean {
return document.activeElement?.parentElement?.id === this.viewerOptions.baseDiv;
}
}

0 comments on commit 35c52f2

Please sign in to comment.