Add Cut to menus (#2511)

Co-authored-by: Zen Tang <zen@wayve.ai>
This commit is contained in:
Zen Tang 2020-12-12 05:54:34 -06:00 committed by GitHub
parent ae15380a9f
commit 1a134a88bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 5 deletions

View file

@ -873,8 +873,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
if (isWritableElement(event.target)) {
return;
}
this.copyAll();
this.actionManager.executeAction(actionDeleteSelected);
this.cutAll();
event.preventDefault();
});
@ -886,6 +885,11 @@ class App extends React.Component<ExcalidrawProps, AppState> {
event.preventDefault();
});
private cutAll = () => {
this.copyAll();
this.actionManager.executeAction(actionDeleteSelected);
};
private copyAll = () => {
copyToClipboard(this.scene.getElements(), this.state);
};
@ -3621,6 +3625,10 @@ class App extends React.Component<ExcalidrawProps, AppState> {
ContextMenu.push({
options: [
{
label: t("labels.cut"),
action: this.cutAll,
},
navigator.clipboard && {
label: t("labels.copy"),
action: this.copyAll,

View file

@ -240,6 +240,10 @@ export const ShortcutsDialog = ({ onClose }: { onClose?: () => void }) => {
]}
isOr={true}
/>
<Shortcut
label={t("labels.cut")}
shortcuts={[getShortcutKey("CtrlOrCmd+X")]}
/>
<Shortcut
label={t("labels.copy")}
shortcuts={[getShortcutKey("CtrlOrCmd+C")]}