ab176937e6
* Add touch support * Mock media query * Mock media query pt 2 * Fix tests * Allow installing as an app on iOS * Fix type error * Math.hypot * delete and finalize buttons, hint viewer * skip failing tests * skip the rest of the failing tests * Hide the selected shape actions when nothing is selected * Don’t go into mobile view on short-but-wide viewports * lol
31 lines
996 B
TypeScript
31 lines
996 B
TypeScript
import { Action } from "./types";
|
|
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";
|
|
|
|
export const actionDeleteSelected: Action = {
|
|
name: "deleteSelectedElements",
|
|
perform: (elements, appState) => {
|
|
return {
|
|
elements: deleteSelectedElements(elements),
|
|
appState: { ...appState, elementType: "selection", multiElement: null },
|
|
};
|
|
},
|
|
contextItemLabel: "labels.delete",
|
|
contextMenuOrder: 3,
|
|
commitToHistory: (_, elements) => isSomeElementSelected(elements),
|
|
keyTest: event => event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE,
|
|
PanelComponent: ({ updateData }) => (
|
|
<ToolButton
|
|
type="button"
|
|
icon={trash}
|
|
title={t("labels.delete")}
|
|
aria-label={t("labels.delete")}
|
|
onClick={() => updateData(null)}
|
|
/>
|
|
),
|
|
};
|