Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove open from clipboard menu item #157

Merged
merged 1 commit into from
May 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading