Skip to content

Commit

Permalink
Remove open from clipboard menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeichestakov committed May 9, 2024
1 parent d03a292 commit 02a4373
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions src/createMenu.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,23 @@
import {
app,
clipboard,
dialog,
Menu,
MenuItem,
MenuItemConstructorOptions,
} from 'electron';
import { baseUrl, isProduction } from './constants';
import { isProduction } from './constants';
import { createWindow } from './createWindow';
import { isMac } from './platform';

const replUrlRegExp = new RegExp(`${baseUrl}/@[^/]+/.+`);

const newWindowMenuItem = {
label: 'New Window',
accelerator: 'CommandOrControl+Shift+N',
click: () => createWindow(),
};

const openReplFromClipboardMenuItem = {
label: 'Open Repl URL from Clipboard',
click: () => {
const clipboardText = clipboard.readText();
const isReplUrl = replUrlRegExp.test(clipboardText);

if (isReplUrl) {
createWindow({ url: clipboardText });
} else {
dialog.showMessageBox({
type: 'warning' as const,
message: 'The URL in Clipboard is not a Repl URL',
});
}
},
};

export function createDockMenu(): Menu {
const menu = new Menu();

menu.append(new MenuItem(newWindowMenuItem));
menu.append(new MenuItem(openReplFromClipboardMenuItem));

return menu;
}
Expand Down Expand Up @@ -72,7 +50,6 @@ export function createApplicationMenu(): Menu {
label: 'File',
submenu: [
newWindowMenuItem,
openReplFromClipboardMenuItem,
{ type: 'separator' },
isMac() ? { role: 'close' } : { role: 'quit' },
],
Expand Down

0 comments on commit 02a4373

Please sign in to comment.