(shortcut: string, platform: string)
| 31 | }); |
| 32 | |
| 33 | const parseShortcut = (shortcut: string, platform: string) => { |
| 34 | if (!shortcut || typeof shortcut !== "string") { |
| 35 | console.warn("Invalid shortcut provided:", shortcut); |
| 36 | return []; |
| 37 | } |
| 38 | |
| 39 | const specialKeyMap = getSpecialKeyMap(platform); |
| 40 | return shortcut |
| 41 | .split(",") |
| 42 | .map((combo) => |
| 43 | combo |
| 44 | .trim() |
| 45 | .split(" ") |
| 46 | .filter((key) => key) |
| 47 | .map((key) => { |
| 48 | const lowerKey = key.toLowerCase(); |
| 49 | if (metaKeys.includes(lowerKey)) return getMetaKeyLabel(); |
| 50 | if (altKeys.includes(lowerKey)) return getAltKeyLabel(); |
| 51 | return specialKeyMap[lowerKey] || capitalizeKey(key); |
| 52 | }), |
| 53 | ) |
| 54 | .filter((combo) => combo.length > 0); |
| 55 | }; |
| 56 | |
| 57 | const capitalizeKey = (key: string) => |
| 58 | key.charAt(0).toUpperCase() + key.slice(1).toLowerCase(); |
no test coverage detected