0fd3fb4b5b
* Disable text selection * Set content-editable=plaintext-only to disable Touch Bar formatting buttons * Enlarge resize handle tap targets for pen/touch * Make the lock button a button in mobile mode * Use icons instead of Unicode characters; add an alternate toolbar for creating multipoint lines * Allow buttons to hide themselves * Fix heuristic for showing shape actions * Refactor icons * Fix label for edit button * Switch edit button icon * Remove lock button on mobile * Add language selector on mobile * Fix showing edit button on mobile * Fix showing edit button on mobile, part 2 * Fix handle touch regions * Fix scroll-back button position * Allow using the text tool on a text object to start editing it * Fix deletion of last point in line
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
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: ({ elements, updateData }) => (
|
|
<ToolButton
|
|
type="button"
|
|
icon={trash}
|
|
title={t("labels.delete")}
|
|
aria-label={t("labels.delete")}
|
|
onClick={() => updateData(null)}
|
|
visible={isSomeElementSelected(elements)}
|
|
/>
|
|
),
|
|
};
|