agent-ecosystem/src/renderer/utils/platformKeys.ts
iliya 5b0c7d13fc feat: add project editor with drag & drop file management
- Backend: ProjectFileService with file CRUD, search, git status, file watcher
- IPC: 12 editor channels with security validation and path containment
- Store: editorSlice with multi-tab management, draft persistence, conflict detection
- UI: CodeMirror 6 editor, file tree with DnD, search-in-files, context menus
- Move: fs.rename with EXDEV fallback, full path remapping across all caches
- Tests: comprehensive coverage for services, IPC handlers, store, and utilities
2026-02-28 23:40:41 +02:00

24 lines
823 B
TypeScript

/**
* Cross-platform keyboard shortcut display helpers.
*
* Mac shows symbols (cmd, shift, option, ctrl), Windows/Linux shows words (Ctrl+, Shift+, Alt+).
*/
function detectMac(): boolean {
if (typeof navigator === 'undefined') return false;
// Prefer userAgentData (modern API) over deprecated navigator.platform
const platform =
(navigator as Navigator & { userAgentData?: { platform?: string } }).userAgentData?.platform ??
navigator.userAgent;
return /mac/i.test(platform);
}
export const IS_MAC = detectMac();
/** Return platform-appropriate modifier prefix: "cmd" on Mac, "Ctrl+" on others */
export const MOD = IS_MAC ? '\u2318' : 'Ctrl+';
/** Return platform-appropriate shortcut string */
export function shortcutLabel(mac: string, other: string): string {
return IS_MAC ? mac : other;
}