From a65c1a620613f5869ace1b3d59ecbbc90e5c5a2e Mon Sep 17 00:00:00 2001 From: XuluWarrior Date: Mon, 23 Sep 2024 01:35:33 +0200 Subject: [PATCH] Clear editor file menu item --- src/main/commands.ts | 4 ++++ src/main/menus.ts | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/commands.ts b/src/main/commands.ts index f999792..6170ec2 100644 --- a/src/main/commands.ts +++ b/src/main/commands.ts @@ -29,3 +29,7 @@ export async function importFile() { } } } + +export async function clearEditor() { + BrowserWindow.getFocusedWindow()!.webContents.send('update-spec', '') +} diff --git a/src/main/menus.ts b/src/main/menus.ts index 941a317..7b25def 100644 --- a/src/main/menus.ts +++ b/src/main/menus.ts @@ -1,6 +1,6 @@ import { Menu, shell } from 'electron' -import { importFile } from "./commands"; +import { clearEditor, importFile } from "./commands"; const isMac = process.platform === 'darwin' @@ -13,6 +13,10 @@ const template = [ label: 'Import file', click: importFile }, + { + label: 'Clear editor', + click: clearEditor + }, { type: 'separator' }, isMac ? { role: 'close' } : { role: 'quit' } ]