Add shortcut description to right click + add Suppr shortcut + Fix next selection after deletion

This commit is contained in:
Eric NGUYEN 2022-10-04 16:51:24 +02:00
parent 4e3c5d71fd
commit d580890b9d
6 changed files with 87 additions and 9 deletions

View file

@ -16,6 +16,9 @@ export interface IMenuAction {
/** title to show on hover */
title?: string
/** description of the shortcut */
shortcut?: string
/** function to be called on button click */
action: (target: HTMLElement) => void
}
@ -101,6 +104,7 @@ export function Menu(props: IMenuProps): JSX.Element {
className={'contextmenu-item'}
text={action.text}
title={action.title}
shortcut={action.shortcut}
onClick={() => action.action(target)} />);
});
};

View file

@ -4,15 +4,18 @@ interface IMenuItemProps {
className?: string
text: string
title?: string
shortcut?: string
onClick: () => void
}
export function MenuItem(props: IMenuItemProps): JSX.Element {
return (
<button type="button"
className={props.className}
className={`flex place-content-between ${props.className ?? ''}`}
title={props.title}
onClick={() => props.onClick()}>{props.text}
onClick={() => props.onClick()}>
{props.text}
<span dangerouslySetInnerHTML={{ __html: props.shortcut ?? '' }} />
</button>
);
}