Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat(menu): cut/copy/paste support
Browse files Browse the repository at this point in the history
  • Loading branch information
TheReincarnator committed Dec 13, 2017
1 parent b61a33c commit 5411166
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions src/component/menu.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BrowserWindow, MenuItem, MenuItemConstructorOptions, remote, WebContents } from 'electron';
import { PageElement } from '../store/page/page_element';
import { Store } from '../store';
const { Menu, shell, app } = remote;

Expand Down Expand Up @@ -59,22 +60,56 @@ export function createMenu(store: Store): void {
{
label: '&Cut',
accelerator: 'CmdOrCtrl+X',
role: 'cut'
role: 'cut',
click: () => {
const selectedElement: PageElement | undefined = store.getSelectedElement();
if (selectedElement) {
store.setClipboardElement(selectedElement);
selectedElement.remove();
}
}
},
{
label: 'C&opy',
accelerator: 'CmdOrCtrl+C',
role: 'copy'
role: 'copy',
click: () => {
const selectedElement: PageElement | undefined = store.getSelectedElement();
if (selectedElement) {
store.setClipboardElement(selectedElement);
}
}
},
{
label: '&Paste',
accelerator: 'CmdOrCtrl+V',
role: 'paste'
role: 'paste',
click: () => {
const selectedElement: PageElement | undefined = store.getSelectedElement();
const clipboardElement: PageElement | undefined = store.getClipboardElement();
if (selectedElement && clipboardElement) {
selectedElement.addChild(clipboardElement.clone());
}
}
},
{
label: '&Select All',
accelerator: 'CmdOrCtrl+A',
role: 'selectall'
},
{
type: 'separator'
},
{
label: '&Delete',
accelerator: 'Del',
role: 'delete',
click: () => {
const selectedElement: PageElement | undefined = store.getSelectedElement();
if (selectedElement) {
selectedElement.remove();
}
}
}
]
},
Expand Down

0 comments on commit 5411166

Please sign in to comment.