Replace default edit menu with one that won't eat keyboard shortcuts (#274)

We only need global Cut/Copy/Paste accelerators on macOS. Linux and
Windows do these automatically. Additionally, having these accelerators
means that we can't use shortcuts like Ctrl+C in the terminal. This PR
removes these accelerators for every platform but macOS.
This commit is contained in:
Evan Simkowitz 2024-08-26 13:30:19 -07:00 committed by GitHub
parent 3777cd1eb0
commit 59a2b9b787
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -691,6 +691,43 @@ function getAppMenu() {
appMenu.push({
role: "quit",
});
const editMenu: Electron.MenuItemConstructorOptions[] = [
{
role: "undo",
accelerator: unamePlatform === "darwin" ? "Command+Z" : "",
},
{
role: "redo",
accelerator: unamePlatform === "darwin" ? "Command+Shift+Z" : "",
},
{
type: "separator",
},
{
role: "cut",
accelerator: unamePlatform === "darwin" ? "Command+X" : "",
},
{
role: "copy",
accelerator: unamePlatform === "darwin" ? "Command+C" : "",
},
{
role: "paste",
accelerator: unamePlatform === "darwin" ? "Command+V" : "",
},
{
role: "pasteAndMatchStyle",
accelerator: unamePlatform === "darwin" ? "Command+Shift+V" : "",
},
{
role: "delete",
},
{
role: "selectAll",
accelerator: unamePlatform === "darwin" ? "Command+A" : "",
},
];
const viewMenu: Electron.MenuItemConstructorOptions[] = [
{
role: "forceReload",
@ -763,6 +800,7 @@ function getAppMenu() {
},
{
role: "editMenu",
submenu: editMenu,
},
{
role: "viewMenu",