Files
multica/packages/core/platform/keyboard.ts
Bohan Jiang daf0e935f6 fix(views): show Ctrl+K / Ctrl+Enter on non-Mac platforms (#2060)
The sidebar search trigger, quick-create-issue modal, and feedback modal
hardcoded the Mac glyphs (⌘, ↵) for their keyboard hints, so Windows and
Linux users always saw Mac shortcuts even though the underlying handlers
already accept metaKey || ctrlKey.

Extract a small platform helper (isMac, modKey, enterKey, formatShortcut)
in packages/core/platform/keyboard.ts and route all four affected sites
(plus the editor bubble menu, which had the same logic inlined) through
it, so non-Mac users see Ctrl+K, Ctrl+Enter, etc.

Closes multica-ai/multica#2056
2026-05-04 21:26:00 +08:00

25 lines
944 B
TypeScript

/**
* Coarse platform detection for keyboard-shortcut display.
*
* Eagerly evaluated at module load. On the server (no `navigator`) this
* resolves to `false`, so SSR always renders the non-Mac variant; on a
* real Mac the value is true after hydration. Acceptable trade-off for
* cosmetic shortcut hints — never gate functional behavior on this.
*/
export const isMac =
typeof navigator !== "undefined" && /Mac/.test(navigator.platform);
/** Modifier key label — ⌘ on Mac, "Ctrl" elsewhere. */
export const modKey: string = isMac ? "⌘" : "Ctrl";
/** Enter / return key label — ↵ on Mac, "Enter" elsewhere. */
export const enterKey: string = isMac ? "↵" : "Enter";
/**
* Join key labels for display. Mac compresses combos with no separator
* ("⌘K", "⌘↵"); other platforms use "+" ("Ctrl+K", "Ctrl+Enter").
*/
export function formatShortcut(...keys: string[]): string {
return keys.join(isMac ? "" : "+");
}