| 1460 | } |
| 1461 | |
| 1462 | function toCodeMirrorKey(combo) { |
| 1463 | if (!combo) return null; |
| 1464 | const parts = combo.endsWith("-") |
| 1465 | ? [...combo.slice(0, -1).split("-").filter(Boolean), "-"] |
| 1466 | : combo |
| 1467 | .split("-") |
| 1468 | .map((part) => part.trim()) |
| 1469 | .filter(Boolean); |
| 1470 | const modifiers = []; |
| 1471 | let key = null; |
| 1472 | |
| 1473 | parts.forEach((part, index) => { |
| 1474 | const lower = part.toLowerCase(); |
| 1475 | if (MODIFIER_MAP[lower]) { |
| 1476 | const mod = MODIFIER_MAP[lower]; |
| 1477 | if (!modifiers.includes(mod)) modifiers.push(mod); |
| 1478 | return; |
| 1479 | } |
| 1480 | |
| 1481 | if (ARROW_KEY_MAP[lower]) { |
| 1482 | key = ARROW_KEY_MAP[lower]; |
| 1483 | return; |
| 1484 | } |
| 1485 | |
| 1486 | if (SPECIAL_KEY_MAP[lower]) { |
| 1487 | key = SPECIAL_KEY_MAP[lower]; |
| 1488 | return; |
| 1489 | } |
| 1490 | |
| 1491 | if (part.length === 1 && /[a-z]/i.test(part)) { |
| 1492 | key = part.length === 1 ? part.toLowerCase() : part; |
| 1493 | return; |
| 1494 | } |
| 1495 | |
| 1496 | key = part; |
| 1497 | }); |
| 1498 | |
| 1499 | if (!key) return modifiers.join("-") || null; |
| 1500 | return modifiers.length ? `${modifiers.join("-")}-${key}` : key; |
| 1501 | } |
| 1502 | |
| 1503 | function rebuildKeymap() { |
| 1504 | const bindings = []; |