2020-01-12 02:22:03 +04:00
|
|
|
import { Action } from "./types";
|
2020-02-16 22:54:50 +01:00
|
|
|
import { deleteSelectedElements, isSomeElementSelected } from "../scene";
|
2020-01-12 02:22:03 +04:00
|
|
|
import { KEYS } from "../keys";
|
2020-02-21 08:17:20 -05:00
|
|
|
import { ToolButton } from "../components/ToolButton";
|
|
|
|
import React from "react";
|
|
|
|
import { trash } from "../components/icons";
|
|
|
|
import { t } from "../i18n";
|
2020-01-12 02:22:03 +04:00
|
|
|
|
|
|
|
export const actionDeleteSelected: Action = {
|
|
|
|
name: "deleteSelectedElements",
|
2020-02-01 15:49:18 +04:00
|
|
|
perform: (elements, appState) => {
|
2020-01-12 02:22:03 +04:00
|
|
|
return {
|
2020-01-24 12:04:54 +02:00
|
|
|
elements: deleteSelectedElements(elements),
|
2020-02-01 15:49:18 +04:00
|
|
|
appState: { ...appState, elementType: "selection", multiElement: null },
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|
|
|
|
},
|
2020-01-21 01:14:10 +02:00
|
|
|
contextItemLabel: "labels.delete",
|
2020-01-12 02:22:03 +04:00
|
|
|
contextMenuOrder: 3,
|
2020-02-16 22:54:50 +01:00
|
|
|
commitToHistory: (_, elements) => isSomeElementSelected(elements),
|
2020-01-24 12:04:54 +02:00
|
|
|
keyTest: event => event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE,
|
2020-02-21 08:17:20 -05:00
|
|
|
PanelComponent: ({ updateData }) => (
|
|
|
|
<ToolButton
|
|
|
|
type="button"
|
|
|
|
icon={trash}
|
|
|
|
title={t("labels.delete")}
|
|
|
|
aria-label={t("labels.delete")}
|
|
|
|
onClick={() => updateData(null)}
|
|
|
|
/>
|
|
|
|
),
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|