mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-26 20:45:37 +02:00
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
25 lines
944 B
TypeScript
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 ? "" : "+");
|
|
}
|