diff --git a/src/components/ui/EditorToolbar.tsx b/src/components/ui/EditorToolbar.tsx index 25fd1ee5..fb93cd5a 100644 --- a/src/components/ui/EditorToolbar.tsx +++ b/src/components/ui/EditorToolbar.tsx @@ -7,6 +7,7 @@ import { Popover } from "@headlessui/react" import type { ICommand } from "~/editor" import { useTranslation } from "~/lib/i18n/client" +import { isMacOS } from "~/lib/utils" import { Tooltip } from "./Tooltip" @@ -22,6 +23,12 @@ enum ToolbarMode { type IToolbarItemProps = ICommand & { view?: EditorView } +const keyDisplay = (shortcut?: { key?: string }) => { + return shortcut?.key + ? `(${shortcut?.key.replace("Mod", isMacOS() ? "⌘" : "Ctrl")})` + : "" +} + const ToolbarItemWithPopover = ({ name, icon, @@ -29,6 +36,7 @@ const ToolbarItemWithPopover = ({ execute, ui, view, + shortcut, }: IToolbarItemProps) => { const { t } = useTranslation("dashboard") let [popoverButtonRef, setPopoverButtonRef] = @@ -44,7 +52,11 @@ const ToolbarItemWithPopover = ({ {({ open }: { open: boolean }) => ( <> - + { const renderToolbar = useCallback( (mode: ToolbarMode) => // eslint-disable-next-line react/display-name - ({ name, icon, label, execute, ui }: ICommand) => { + ({ name, icon, label, execute, ui, shortcut }: ICommand) => { return ui ? ( { execute={execute} ui={ui} view={view} + shortcut={shortcut} /> ) : ( - +