722c498abe
* Bump prettier from 1.19.1 to 2.0.1 Bumps [prettier](https://github.com/prettier/prettier) from 1.19.1 to 2.0.1. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/1.19.1...2.0.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Update formatting Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Panayiotis Lipiridis <lipiridis@gmail.com>
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { deleteSelectedElements, isSomeElementSelected } from "../scene";
|
|
import { KEYS } from "../keys";
|
|
import { ToolButton } from "../components/ToolButton";
|
|
import React from "react";
|
|
import { trash } from "../components/icons";
|
|
import { t } from "../i18n";
|
|
import { register } from "./register";
|
|
|
|
export const actionDeleteSelected = register({
|
|
name: "deleteSelectedElements",
|
|
perform: (elements, appState) => {
|
|
const {
|
|
elements: nextElements,
|
|
appState: nextAppState,
|
|
} = deleteSelectedElements(elements, appState);
|
|
return {
|
|
elements: nextElements,
|
|
appState: {
|
|
...nextAppState,
|
|
elementType: "selection",
|
|
multiElement: null,
|
|
},
|
|
commitToHistory: isSomeElementSelected(elements, appState),
|
|
};
|
|
},
|
|
contextItemLabel: "labels.delete",
|
|
contextMenuOrder: 3,
|
|
keyTest: (event) => event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE,
|
|
PanelComponent: ({ elements, appState, updateData }) => (
|
|
<ToolButton
|
|
type="button"
|
|
icon={trash}
|
|
title={t("labels.delete")}
|
|
aria-label={t("labels.delete")}
|
|
onClick={() => updateData(null)}
|
|
visible={isSomeElementSelected(elements, appState)}
|
|
/>
|
|
),
|
|
});
|