From 0d111f3a7938d435a64eac239bf9811a1fcbc78b Mon Sep 17 00:00:00 2001 From: 01zulfi <85733202+01zulfi@users.noreply.github.com> Date: Tue, 22 Jul 2025 10:22:48 +0500 Subject: [PATCH] web: use keys from common/keybindings in command palette dialog Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com> --- .../command-palette/command-palette-dialog.tsx | 17 ++++++++++++++--- packages/common/src/utils/keybindings.ts | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/web/src/dialogs/command-palette/command-palette-dialog.tsx b/apps/web/src/dialogs/command-palette/command-palette-dialog.tsx index 8688570fb..a8d8fd941 100644 --- a/apps/web/src/dialogs/command-palette/command-palette-dialog.tsx +++ b/apps/web/src/dialogs/command-palette/command-palette-dialog.tsx @@ -17,7 +17,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -import { debounce, usePromise } from "@notesnook/common"; +import { + debounce, + formatKey, + keybindings, + usePromise +} from "@notesnook/common"; import { EVENTS, fuzzy, Note, Notebook, Reminder, Tag } from "@notesnook/core"; import { Box, Button, Flex, Input, Text } from "@theme-ui/components"; import { useCallback, useEffect, useRef, useState } from "react"; @@ -539,7 +544,10 @@ function getCommandPaletteHelp(isCommandMode: boolean) { ...(isCommandMode ? [ { - key: isMac() ? "⌘P" : "Ctrl+P", + key: keybindings.openQuickOpen + .keys(IS_DESKTOP_APP) + .map((k) => formatKey(k, isMac(), "+")) + .join(" / "), description: strings.quickOpen() } ] @@ -553,7 +561,10 @@ function getCommandPaletteHelp(isCommandMode: boolean) { description: strings.createNewNote() }, { - key: isMac() ? "⌘K" : "Ctrl+K", + key: keybindings.openCommandPalette + .keys(IS_DESKTOP_APP) + .map((k) => formatKey(k, isMac(), "+")) + .join(" / "), description: strings.commandPalette() } ]) diff --git a/packages/common/src/utils/keybindings.ts b/packages/common/src/utils/keybindings.ts index 72362a5d0..35ffc040d 100644 --- a/packages/common/src/utils/keybindings.ts +++ b/packages/common/src/utils/keybindings.ts @@ -410,9 +410,9 @@ export function macify(key: string) { .replace(/mod/gi, "Command"); } -export function formatKey(key: string, isMac = false) { +export function formatKey(key: string, isMac = false, separator = " ") { return key - .replace(/\+|-/g, " ") + .replace(/\+|-/g, separator) .replace(/\bcommand\b/gi, isMac ? "⌘" : "Command") .replace(/\bctrl\b/gi, isMac ? "⌘" : "Ctrl") .replace(/\bshift\b/gi, "⇧")