feat: response shortcuts (#2705)

This commit is contained in:
Liyas Thomas
2022-09-30 19:32:09 +05:30
committed by GitHub
parent 06a8d62dfe
commit 938f940f90
40 changed files with 307 additions and 107 deletions

View File

@@ -32,6 +32,9 @@ export type HoppAction =
| "settings.theme.light" // Use light theme
| "settings.theme.dark" // Use dark theme
| "settings.theme.black" // Use black theme
| "response.preview.toggle" // Toggle response preview
| "response.file.download" // Download response as file
| "response.copy" // Copy response to clipboard
type BoundActionList = {
// eslint-disable-next-line no-unused-vars

View File

@@ -23,7 +23,7 @@ type Key =
| "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t"
| "u" | "v" | "w" | "x" | "y" | "z" | "0" | "1" | "2" | "3"
| "4" | "5" | "6" | "7" | "8" | "9" | "up" | "down" | "left"
| "right" | "/" | "?"
| "right" | "/" | "?" | "."
/* eslint-enable */
type ModifierBasedShortcutKey = `${ModifierKeys}-${Key}`
@@ -58,6 +58,9 @@ export const bindings: {
"alt-d": "navigation.jump.documentation",
"alt-m": "navigation.jump.profile",
"alt-s": "navigation.jump.settings",
"ctrl-shift-p": "response.preview.toggle",
"ctrl-j": "response.file.download",
"ctrl-.": "response.copy",
}
/**
@@ -130,6 +133,9 @@ function getPressedKey(ev: KeyboardEvent): Key | null {
// Check if question mark
if (val === "/") return "/"
// Check if period
if (val === ".") return "."
// If no other cases match, this is not a valid key
return null
}

View File

@@ -79,6 +79,19 @@ export default [
},
],
},
{
section: "shortcut.response.title",
shortcuts: [
{
keys: [getPlatformSpecialKey(), "J"],
label: "shortcut.response.download",
},
{
keys: [getPlatformSpecialKey(), "."],
label: "shortcut.response.copy",
},
],
},
{
section: "shortcut.navigation.title",
shortcuts: [