mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
feat(shortcut): Keyboard Navigation (#168)
* chore: remove sliding menu * feat(ui): sheet * feat: shortcut component * chore: register new shortcut component to layout * fix: react attr naming * fix: set default to false for shortcut * feat(store): keydown-manager * feat(hooks): keyboard manager * chore: use util from base for la-editor * chore: use util from base for minimal-tiptap-editor * chore(utils): keyboard * chore: use new keyboard manager * fix: uniqueness of certain component * feat: global key handler * chore: implement new key handler
This commit is contained in:
@@ -55,11 +55,7 @@ export function getShortcutKey(key: string): ShortcutKeyResult {
|
||||
} else if (lowercaseKey === "alt") {
|
||||
return isMacOS() ? { symbol: "⌥", readable: "Option" } : { symbol: "Alt", readable: "Alt" }
|
||||
} else if (lowercaseKey === "shift") {
|
||||
return { symbol: "⇧", readable: "Shift" }
|
||||
} else if (lowercaseKey === "control") {
|
||||
return { symbol: "⌃", readable: "Control" }
|
||||
} else if (lowercaseKey === "windows" && !isMacOS()) {
|
||||
return { symbol: "Win", readable: "Windows" }
|
||||
return isMacOS() ? { symbol: "⇧", readable: "Shift" } : { symbol: "Shift", readable: "Shift" }
|
||||
} else {
|
||||
return { symbol: key.toUpperCase(), readable: key }
|
||||
}
|
||||
@@ -68,21 +64,3 @@ export function getShortcutKey(key: string): ShortcutKeyResult {
|
||||
export function getShortcutKeys(keys: string[]): ShortcutKeyResult[] {
|
||||
return keys.map(key => getShortcutKey(key))
|
||||
}
|
||||
|
||||
export function getSpecialShortcut(shortcutName: string): ShortcutKeyResult[] {
|
||||
if (shortcutName === "expandToolbar") {
|
||||
return isMacOS()
|
||||
? [getShortcutKey("control"), getShortcutKey("mod"), getShortcutKey("n")]
|
||||
: [getShortcutKey("mod"), getShortcutKey("windows"), getShortcutKey("n")]
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
|
||||
export function formatShortcut(shortcutKeys: ShortcutKeyResult[]): string {
|
||||
return shortcutKeys.map(key => key.symbol).join("")
|
||||
}
|
||||
|
||||
export function formatReadableShortcut(shortcutKeys: ShortcutKeyResult[]): string {
|
||||
return shortcutKeys.map(key => key.readable).join(" + ")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user