mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Show shortcut context menu (#2501)
Co-authored-by: rene_mbp <harryloveslearning@googlemail.com> Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
parent
9cfe7b45e5
commit
94fe1ff6e6
6 changed files with 163 additions and 58 deletions
|
@ -4,8 +4,13 @@ import clsx from "clsx";
|
|||
import { Popover } from "./Popover";
|
||||
|
||||
import "./ContextMenu.scss";
|
||||
import {
|
||||
getShortcutFromShortcutName,
|
||||
ShortcutName,
|
||||
} from "../actions/shortcuts";
|
||||
|
||||
type ContextMenuOption = {
|
||||
shortcutName: ShortcutName;
|
||||
label: string;
|
||||
action(): void;
|
||||
};
|
||||
|
@ -38,10 +43,15 @@ const ContextMenu = ({ options, onCloseRequest, top, left }: Props) => {
|
|||
className="context-menu"
|
||||
onContextMenu={(event) => event.preventDefault()}
|
||||
>
|
||||
{options.map(({ action, label }, idx) => (
|
||||
<li key={idx} onClick={onCloseRequest}>
|
||||
{options.map(({ action, shortcutName, label }, idx) => (
|
||||
<li data-testid={shortcutName} key={idx} onClick={onCloseRequest}>
|
||||
<button className="context-menu-option" onClick={action}>
|
||||
{label}
|
||||
<div>{label}</div>
|
||||
<div>
|
||||
{shortcutName
|
||||
? getShortcutFromShortcutName(shortcutName)
|
||||
: ""}
|
||||
</div>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue