Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
feat: response shortcuts (#2705)
Liyas Thomas938f940f9041
diff --git a/packages/hoppscotch-app/locales/af.json b/packages/hoppscotch-app/locales/af.jsonindex 5ab5d0e48..3ff994a6a 100644--- a/packages/hoppscotch-app/locales/af.json+++ b/packages/hoppscotch-app/locales/af.json@@ -502,6 +502,11 @@"send_request": "Stuur versoek","title": "Versoek"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/ar.json b/packages/hoppscotch-app/locales/ar.jsonindex 7cee606c6..db59fb5d2 100644--- a/packages/hoppscotch-app/locales/ar.json+++ b/packages/hoppscotch-app/locales/ar.json@@ -502,6 +502,11 @@"send_request": "ارسل طلب","title": "طلب"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "انتقل الى الوضع الأسود","dark": "انتقل الى الوضع الليلي",diff --git a/packages/hoppscotch-app/locales/ca.json b/packages/hoppscotch-app/locales/ca.jsonindex 239debb03..2da437f38 100644--- a/packages/hoppscotch-app/locales/ca.json+++ b/packages/hoppscotch-app/locales/ca.json@@ -502,6 +502,11 @@"send_request": "Enviar sol.licitud","title": "Sol·licitud"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/cn.json b/packages/hoppscotch-app/locales/cn.jsonindex c268adc5e..27c5e1bbd 100644--- a/packages/hoppscotch-app/locales/cn.json+++ b/packages/hoppscotch-app/locales/cn.json@@ -502,6 +502,11 @@"send_request": "发送请求","title": "请求"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "切换为黑色主题","dark": "切换为深色主题",diff --git a/packages/hoppscotch-app/locales/cs.json b/packages/hoppscotch-app/locales/cs.jsonindex fa850e55a..6430f3db3 100644--- a/packages/hoppscotch-app/locales/cs.json+++ b/packages/hoppscotch-app/locales/cs.json@@ -502,6 +502,11 @@"send_request": "Poslat žádost","title": "Žádost"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/da.json b/packages/hoppscotch-app/locales/da.jsonindex 5c813b9f1..eb034e2e7 100644--- a/packages/hoppscotch-app/locales/da.json+++ b/packages/hoppscotch-app/locales/da.json@@ -502,6 +502,11 @@"send_request": "Send anmodning","title": "Anmodning"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/de.json b/packages/hoppscotch-app/locales/de.jsonindex 9bf978f9d..fff35452a 100644--- a/packages/hoppscotch-app/locales/de.json+++ b/packages/hoppscotch-app/locales/de.json@@ -502,6 +502,11 @@"send_request": "Anfrage senden","title": "Anfrage"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Auf Schwarzes Design wechseln","dark": "Auf Dunkles Design wechseln",diff --git a/packages/hoppscotch-app/locales/el.json b/packages/hoppscotch-app/locales/el.jsonindex bfac3c8c3..fc0bf9c62 100644--- a/packages/hoppscotch-app/locales/el.json+++ b/packages/hoppscotch-app/locales/el.json@@ -502,6 +502,11 @@"send_request": "Στείλε αίτημα","title": "Αίτηση"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/en.json b/packages/hoppscotch-app/locales/en.jsonindex 26027f384..6233d2bf9 100644--- a/packages/hoppscotch-app/locales/en.json+++ b/packages/hoppscotch-app/locales/en.json@@ -502,6 +502,11 @@"send_request": "Send Request","title": "Request"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/es.json b/packages/hoppscotch-app/locales/es.jsonindex e6db50a23..d22c83b4e 100644--- a/packages/hoppscotch-app/locales/es.json+++ b/packages/hoppscotch-app/locales/es.json@@ -502,6 +502,11 @@"send_request": "Enviar petición","title": "Petición"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Cambiar el tema al modo negro","dark": "Cambiar el tema al modo oscuro",diff --git a/packages/hoppscotch-app/locales/fi.json b/packages/hoppscotch-app/locales/fi.jsonindex 4968969d8..8ba2df54b 100644--- a/packages/hoppscotch-app/locales/fi.json+++ b/packages/hoppscotch-app/locales/fi.json@@ -502,6 +502,11 @@"send_request": "Lähetä pyyntö","title": "Pyyntö"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/fr.json b/packages/hoppscotch-app/locales/fr.jsonindex 48cecdc4b..d6514aa0c 100644--- a/packages/hoppscotch-app/locales/fr.json+++ b/packages/hoppscotch-app/locales/fr.json@@ -502,6 +502,11 @@"send_request": "Envoyer la requête","title": "Requête"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/he.json b/packages/hoppscotch-app/locales/he.jsonindex d5aa97bae..5640c8712 100644--- a/packages/hoppscotch-app/locales/he.json+++ b/packages/hoppscotch-app/locales/he.json@@ -502,6 +502,11 @@"send_request": "שלח בקשה","title": "בַּקָשָׁה"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/hu.json b/packages/hoppscotch-app/locales/hu.jsonindex 24cf3e127..0ea08dcae 100644--- a/packages/hoppscotch-app/locales/hu.json+++ b/packages/hoppscotch-app/locales/hu.json@@ -502,6 +502,11 @@"send_request": "Kérés elküldése","title": "Kérés"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Téma átváltása fekete módra","dark": "Téma átváltása sötét módra",diff --git a/packages/hoppscotch-app/locales/it.json b/packages/hoppscotch-app/locales/it.jsonindex 36f6ed6b5..8e289bc7c 100644--- a/packages/hoppscotch-app/locales/it.json+++ b/packages/hoppscotch-app/locales/it.json@@ -502,6 +502,11 @@"send_request": "Invia richiesta","title": "Richiesta"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/ja.json b/packages/hoppscotch-app/locales/ja.jsonindex be84f3921..0287c1f67 100644--- a/packages/hoppscotch-app/locales/ja.json+++ b/packages/hoppscotch-app/locales/ja.json@@ -502,6 +502,11 @@"send_request": "Send Request","title": "Request"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/ko.json b/packages/hoppscotch-app/locales/ko.jsonindex 1beed9791..58a8365a8 100644--- a/packages/hoppscotch-app/locales/ko.json+++ b/packages/hoppscotch-app/locales/ko.json@@ -502,6 +502,11 @@"send_request": "요청 보내기","title": "요청"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "검은 테마로 전환","dark": "어두운 테마로 전환",diff --git a/packages/hoppscotch-app/locales/nl.json b/packages/hoppscotch-app/locales/nl.jsonindex 6c982fbba..8f90e455b 100644--- a/packages/hoppscotch-app/locales/nl.json+++ b/packages/hoppscotch-app/locales/nl.json@@ -502,6 +502,11 @@"send_request": "Verstuur verzoek","title": "Verzoek"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/no.json b/packages/hoppscotch-app/locales/no.jsonindex 81be98b73..b85a8ef43 100644--- a/packages/hoppscotch-app/locales/no.json+++ b/packages/hoppscotch-app/locales/no.json@@ -502,6 +502,11 @@"send_request": "Send forespørsel","title": "Be om"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/pl.json b/packages/hoppscotch-app/locales/pl.jsonindex 3666f65ad..71db539da 100644--- a/packages/hoppscotch-app/locales/pl.json+++ b/packages/hoppscotch-app/locales/pl.json@@ -502,6 +502,11 @@"send_request": "Wyślij żądanie","title": "Żądania"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/pt-br.json b/packages/hoppscotch-app/locales/pt-br.jsonindex 246e97707..76e897a30 100644--- a/packages/hoppscotch-app/locales/pt-br.json+++ b/packages/hoppscotch-app/locales/pt-br.json@@ -502,6 +502,11 @@"send_request": "Enviar requisição","title": "Solicitar"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Trocar para o tema preto","dark": "Trocar para o tema escuro",diff --git a/packages/hoppscotch-app/locales/pt.json b/packages/hoppscotch-app/locales/pt.jsonindex f47431c1c..dd7820c56 100644--- a/packages/hoppscotch-app/locales/pt.json+++ b/packages/hoppscotch-app/locales/pt.json@@ -502,6 +502,11 @@"send_request": "Enviar pedido","title": "Solicitar"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/ro.json b/packages/hoppscotch-app/locales/ro.jsonindex e6a7d4af6..fba7ee83a 100644--- a/packages/hoppscotch-app/locales/ro.json+++ b/packages/hoppscotch-app/locales/ro.json@@ -502,6 +502,11 @@"send_request": "Trimite cerere","title": "Cerere"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/ru.json b/packages/hoppscotch-app/locales/ru.jsonindex 90ff50715..3b3424968 100644--- a/packages/hoppscotch-app/locales/ru.json+++ b/packages/hoppscotch-app/locales/ru.json@@ -502,6 +502,11 @@"send_request": "Послать запрос","title": "Запрос"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/sr.json b/packages/hoppscotch-app/locales/sr.jsonindex fbff192b2..fcda83dde 100644--- a/packages/hoppscotch-app/locales/sr.json+++ b/packages/hoppscotch-app/locales/sr.json@@ -502,6 +502,11 @@"send_request": "Пошаљите упит","title": "Захтев"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/sv.json b/packages/hoppscotch-app/locales/sv.jsonindex ea760a824..8fcddb7db 100644--- a/packages/hoppscotch-app/locales/sv.json+++ b/packages/hoppscotch-app/locales/sv.json@@ -502,6 +502,11 @@"send_request": "Skicka förfrågan","title": "Begäran"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/tr.json b/packages/hoppscotch-app/locales/tr.jsonindex d87484696..002e7f1d3 100644--- a/packages/hoppscotch-app/locales/tr.json+++ b/packages/hoppscotch-app/locales/tr.json@@ -502,6 +502,11 @@"send_request": "İstek gönder","title": "İstek"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Temayı siyah mod olarak ayarla","dark": "Temayı karanlık mod olarak ayarla",diff --git a/packages/hoppscotch-app/locales/tw.json b/packages/hoppscotch-app/locales/tw.jsonindex daf4b5c86..d6c203372 100644--- a/packages/hoppscotch-app/locales/tw.json+++ b/packages/hoppscotch-app/locales/tw.json@@ -502,6 +502,11 @@"send_request": "傳送請求","title": "請求"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "將主題切換至黑色模式","dark": "將主題切換至暗色模式",diff --git a/packages/hoppscotch-app/locales/uk.json b/packages/hoppscotch-app/locales/uk.jsonindex ea9ba1101..d5c8d4f6a 100644--- a/packages/hoppscotch-app/locales/uk.json+++ b/packages/hoppscotch-app/locales/uk.json@@ -502,6 +502,11 @@"send_request": "Відправляти запит","title": "Запит"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/locales/vi.json b/packages/hoppscotch-app/locales/vi.jsonindex c08a3353f..48432f52e 100644--- a/packages/hoppscotch-app/locales/vi.json+++ b/packages/hoppscotch-app/locales/vi.json@@ -502,6 +502,11 @@"send_request": "Gửi yêu cầu","title": "Yêu cầu"},+ "response": {+ "copy": "Copy response to clipboard",+ "download": "Download response as file",+ "title": "Response"+ },"theme": {"black": "Switch theme to black mode","dark": "Switch theme to dark mode",diff --git a/packages/hoppscotch-app/src/components/lenses/ResponseBodyRenderer.vue b/packages/hoppscotch-app/src/components/lenses/ResponseBodyRenderer.vueindex e1255a43a..9aae6fe5d 100644--- a/packages/hoppscotch-app/src/components/lenses/ResponseBodyRenderer.vue+++ b/packages/hoppscotch-app/src/components/lenses/ResponseBodyRenderer.vue@@ -3,7 +3,6 @@v-if="response"v-model="selectedLensTab"styles="sticky z-10 bg-primary top-lowerPrimaryStickyFold"- render-inactive-tabs><SmartTabv-for="(lens, index) in validLenses"diff --git a/packages/hoppscotch-app/src/components/lenses/renderers/HTMLLensRenderer.vue b/packages/hoppscotch-app/src/components/lenses/renderers/HTMLLensRenderer.vueindex b2a1c6d14..00ff13e20 100644--- a/packages/hoppscotch-app/src/components/lenses/renderers/HTMLLensRenderer.vue+++ b/packages/hoppscotch-app/src/components/lenses/renderers/HTMLLensRenderer.vue@@ -17,24 +17,28 @@/><ButtonSecondaryv-if="response.body"- v-tippy="{ theme: 'tooltip' }"- :title="+ v-tippy="{ theme: 'tooltip', allowHTML: true }"+ :title="`${previewEnabled ? t('hide.preview') : t('response.preview_html')- "+ } <xmp>${getSpecialKey()}</xmp><xmp>Shift</xmp><xmp>P</xmp>`":icon="!previewEnabled ? IconEye : IconEyeOff"@click.prevent="togglePreview"/><ButtonSecondaryv-if="response.body"- v-tippy="{ theme: 'tooltip' }"- :title="t('action.download_file')"+ v-tippy="{ theme: 'tooltip', allowHTML: true }"+ :title="`${t(+ 'action.download_file'+ )} <xmp>${getSpecialKey()}</xmp><xmp>J</xmp>`":icon="downloadIcon"@click="downloadResponse"/><ButtonSecondaryv-if="response.body"- v-tippy="{ theme: 'tooltip' }"- :title="t('action.copy')"+ v-tippy="{ theme: 'tooltip', allowHTML: true }"+ :title="`${t(+ 'action.copy'+ )} <xmp>${getSpecialKey()}</xmp><xmp>.</xmp>`":icon="copyIcon"@click="copyResponse"/>@@ -70,6 +74,8 @@ import {import { useCodemirror } from "@composables/codemirror"import { useI18n } from "@composables/i18n"import type { HoppRESTResponse } from "~/helpers/types/HoppRESTResponse"+import { defineActionHandler } from "~/helpers/actions"+import { getPlatformSpecialKey as getSpecialKey } from "~/helpers/platformutils"const t = useI18n()@@ -105,6 +111,10 @@ useCodemirror(environmentHighlights: true,}))++defineActionHandler("response.preview.toggle", () => togglePreview())+defineActionHandler("response.file.download", () => downloadResponse())+defineActionHandler("response.copy", () => copyResponse())</script><style lang="scss" scoped>diff --git a/packages/hoppscotch-app/src/components/lenses/renderers/ImageLensRenderer.vue b/packages/hoppscotch-app/src/components/lenses/renderers/ImageLensRenderer.vueindex ce3b6e167..8c177bf1a 100644--- a/packages/hoppscotch-app/src/components/lenses/renderers/ImageLensRenderer.vue+++ b/packages/hoppscotch-app/src/components/lenses/renderers/ImageLensRenderer.vue@@ -9,9 +9,11 @@<div class="flex"><ButtonSecondaryv-if="response.body"- v-tippy="{ theme: 'tooltip' }"- :title="t('action.download_file')"- :icon="downloadIcon === 'download' ? IconDownload : IconCheck"+ v-tippy="{ theme: 'tooltip', allowHTML: true }"+ :title="`${t(+ 'action.download_file'+ )} <xmp>${getSpecialKey()}</xmp><xmp>J</xmp>`"+ :icon="downloadIcon"@click="downloadResponse"/></div>@@ -25,92 +27,76 @@</div></template>-<script lang="ts">-import IconDownload from "~icons/lucide/download"-import IconCheck from "~icons/lucide/check"+<script setup lang="ts">import { useI18n } from "@composables/i18n"-import { useToast } from "@composables/toast"-import { defineComponent } from "vue"+import { defineActionHandler } from "~/helpers/actions"+import { getPlatformSpecialKey as getSpecialKey } from "~/helpers/platformutils"+import { computed, onMounted, ref, watch } from "vue"+import { HoppRESTResponse } from "~/helpers/types/HoppRESTResponse"+import { useDownloadResponse } from "~/composables/lens-actions"+import { flow, pipe } from "fp-ts/function"+import * as S from "fp-ts/string"+import * as RNEA from "fp-ts/ReadonlyNonEmptyArray"+import * as A from "fp-ts/Array"+import * as O from "fp-ts/Option"+import { objFieldMatches } from "~/helpers/functional/object"-export default defineComponent({- props: {- response: { type: Object, default: () => ({}) },- },- setup() {- return {- t: useI18n(),- toast: useToast(),- IconDownload,- IconCheck,- }- },- data() {- return {- imageSource: "",- downloadIcon: "download",- }- },- computed: {- responseType() {- return (- this.response.headers.find(- (h) => h.key.toLowerCase() === "content-type"- ).value || ""+const t = useI18n()++const props = defineProps<{+ response: HoppRESTResponse & { type: "success" | "fail" }+}>()++const imageSource = ref("")++const responseType = computed(() =>+ pipe(+ props.response,+ O.fromPredicate(objFieldMatches("type", ["fail", "success"] as const)),+ O.chain(+ // Try getting content-type+ flow(+ (res) => res.headers,+ A.findFirst((h) => h.key.toLowerCase() === "content-type"),+ O.map(flow((h) => h.value, S.split(";"), RNEA.head, S.toLowerCase)))- .split(";")[0]- .toLowerCase()- },- },- watch: {- response: {- immediate: true,- handler() {- this.imageSource = ""+ ),+ O.getOrElse(() => "text/plain")+ )+)- const buf = this.response.body- const bytes = new Uint8Array(buf)- const blob = new Blob([bytes.buffer])+const { downloadIcon, downloadResponse } = useDownloadResponse(+ responseType.value,+ computed(() => props.response.body)+)- const reader = new FileReader()- reader.onload = ({ target }) => {- this.imageSource = target.result- }- reader.readAsDataURL(blob)- },- },- },- mounted() {- this.imageSource = ""+watch(props.response, () => {+ imageSource.value = ""+ const buf = props.response.body+ const bytes = new Uint8Array(buf)+ const blob = new Blob([bytes.buffer])- const buf = this.response.body- const bytes = new Uint8Array(buf)- const blob = new Blob([bytes.buffer])+ const reader = new FileReader()+ reader.onload = ({ target }) => {+ // target.result will always be string because we're using FileReader.readAsDataURL+ imageSource.value = target!.result as string+ }+ reader.readAsDataURL(blob)+})++onMounted(() => {+ imageSource.value = ""+ const buf = props.response.body+ const bytes = new Uint8Array(buf)+ const blob = new Blob([bytes.buffer])- const reader = new FileReader()- reader.onload = ({ target }) => {- this.imageSource = target.result- }- reader.readAsDataURL(blob)- },- methods: {- downloadResponse() {- const dataToWrite = this.response.body- const file = new Blob([dataToWrite], { type: this.responseType })- const a = document.createElement("a")- const url = URL.createObjectURL(file)- a.href = url- // TODO get uri from meta- a.download = `${url.split("/").pop().split("#")[0].split("?")[0]}`- document.body.appendChild(a)- a.click()- this.downloadIcon = "check"- this.toast.success(this.t("state.download_started"))- setTimeout(() => {- document.body.removeChild(a)- URL.revokeObjectURL(url)- this.downloadIcon = "download"- }, 1000)- },- },+ const reader = new FileReader()+ reader.onload = ({ target }) => {+ // target.result will always be string because we're using FileReader.readAsDataURL+ imageSource.value = target!.result as string+ }+ reader.readAsDataURL(blob)})++defineActionHandler("response.file.download", () => downloadResponse())</script>diff --git a/packages/hoppscotch-app/src/components/lenses/renderers/JSONLensRenderer.vue b/packages/hoppscotch-app/src/components/lenses/renderers/JSONLensRenderer.vueindex ce762fa7f..eff3b1df7 100644--- a/packages/hoppscotch-app/src/components/lenses/renderers/JSONLensRenderer.vue+++ b/packages/hoppscotch-app/src/components/lenses/renderers/JSONLensRenderer.vue@@ -28,15 +28,19 @@/><ButtonSecondaryv-if="response.body"- v-tippy="{ theme: 'tooltip' }"- :title="t('action.download_file')"+ v-tippy="{ theme: 'tooltip', allowHTML: true }"+ :title="`${t(+ 'action.download_file'+ )} <xmp>${getSpecialKey()}</xmp><xmp>J</xmp>`":icon="downloadIcon"@click="downloadResponse"/><ButtonSecondaryv-if="response.body"- v-tippy="{ theme: 'tooltip' }"- :title="t('action.copy')"+ v-tippy="{ theme: 'tooltip', allowHTML: true }"+ :title="`${t(+ 'action.copy'+ )} <xmp>${getSpecialKey()}</xmp><xmp>.</xmp>`":icon="copyIcon"@click="copyResponse"/>@@ -215,6 +219,8 @@ import {useResponseBody,useDownloadResponse,} from "@composables/lens-actions"+import { defineActionHandler } from "~/helpers/actions"+import { getPlatformSpecialKey as getSpecialKey } from "~/helpers/platformutils"const t = useI18n()@@ -358,6 +364,9 @@ const toggleFilterState = () => {filterQueryText.value = ""toggleFilter.value = !toggleFilter.value}++defineActionHandler("response.file.download", () => downloadResponse())+defineActionHandler("response.copy", () => copyResponse())</script><style lang="scss" scoped>diff --git a/packages/hoppscotch-app/src/components/lenses/renderers/PDFLensRenderer.vue b/packages/hoppscotch-app/src/components/lenses/renderers/PDFLensRenderer.vueindex cb2e9fce4..2f5c89aae 100644--- a/packages/hoppscotch-app/src/components/lenses/renderers/PDFLensRenderer.vue+++ b/packages/hoppscotch-app/src/components/lenses/renderers/PDFLensRenderer.vue@@ -9,8 +9,10 @@<div class="flex"><ButtonSecondaryv-if="response.body"- v-tippy="{ theme: 'tooltip' }"- :title="t('action.download_file')"+ v-tippy="{ theme: 'tooltip', allowHTML: true }"+ :title="`${t(+ 'action.download_file'+ )} <xmp>${getSpecialKey()}</xmp><xmp>J</xmp>`":icon="downloadIcon"@click="downloadResponse"/>@@ -30,6 +32,8 @@ import VuePdfEmbed from "vue-pdf-embed"import { useI18n } from "@composables/i18n"import { useDownloadResponse } from "@composables/lens-actions"import { HoppRESTResponse } from "~/helpers/types/HoppRESTResponse"+import { defineActionHandler } from "~/helpers/actions"+import { getPlatformSpecialKey as getSpecialKey } from "~/helpers/platformutils"const t = useI18n()@@ -51,4 +55,6 @@ const { downloadIcon, downloadResponse } = useDownloadResponse("application/pdf",computed(() => props.response.body))++defineActionHandler("response.file.download", () => downloadResponse())</script>diff --git a/packages/hoppscotch-app/src/components/lenses/renderers/RawLensRenderer.vue b/packages/hoppscotch-app/src/components/lenses/renderers/RawLensRenderer.vueindex 02ef2963f..5dc4f648c 100644--- a/packages/hoppscotch-app/src/components/lenses/renderers/RawLensRenderer.vue+++ b/packages/hoppscotch-app/src/components/lenses/renderers/RawLensRenderer.vue@@ -17,15 +17,19 @@/><ButtonSecondaryv-if="response.body"- v-tippy="{ theme: 'tooltip' }"- :title="t('action.download_file')"+ v-tippy="{ theme: 'tooltip', allowHTML: true }"+ :title="`${t(+ 'action.download_file'+ )} <xmp>${getSpecialKey()}</xmp><xmp>J</xmp>`":icon="downloadIcon"@click="downloadResponse"/><ButtonSecondaryv-if="response.body"- v-tippy="{ theme: 'tooltip' }"- :title="t('action.copy')"+ v-tippy="{ theme: 'tooltip', allowHTML: true }"+ :title="`${t(+ 'action.copy'+ )} <xmp>${getSpecialKey()}</xmp><xmp>.</xmp>`":icon="copyIcon"@click="copyResponse"/>@@ -52,6 +56,8 @@ import {useCopyResponse,} from "@composables/lens-actions"import { objFieldMatches } from "~/helpers/functional/object"+import { defineActionHandler } from "~/helpers/actions"+import { getPlatformSpecialKey as getSpecialKey } from "~/helpers/platformutils"const t = useI18n()@@ -107,4 +113,7 @@ useCodemirror(environmentHighlights: true,}))++defineActionHandler("response.file.download", () => downloadResponse())+defineActionHandler("response.copy", () => copyResponse())</script>diff --git a/packages/hoppscotch-app/src/components/lenses/renderers/XMLLensRenderer.vue b/packages/hoppscotch-app/src/components/lenses/renderers/XMLLensRenderer.vueindex 7a490cb26..a43b256e2 100644--- a/packages/hoppscotch-app/src/components/lenses/renderers/XMLLensRenderer.vue+++ b/packages/hoppscotch-app/src/components/lenses/renderers/XMLLensRenderer.vue@@ -17,15 +17,19 @@/><ButtonSecondaryv-if="response.body"- v-tippy="{ theme: 'tooltip' }"- :title="t('action.download_file')"+ v-tippy="{ theme: 'tooltip', allowHTML: true }"+ :title="`${t(+ 'action.download_file'+ )} <xmp>${getSpecialKey()}</xmp><xmp>J</xmp>`":icon="downloadIcon"@click="downloadResponse"/><ButtonSecondaryv-if="response.body"- v-tippy="{ theme: 'tooltip' }"- :title="t('action.copy')"+ v-tippy="{ theme: 'tooltip', allowHTML: true }"+ :title="`${t(+ 'action.copy'+ )} <xmp>${getSpecialKey()}</xmp><xmp>.</xmp>`":icon="copyIcon"@click="copyResponse"/>@@ -46,6 +50,8 @@ import {useDownloadResponse,useCopyResponse,} from "@composables/lens-actions"+import { defineActionHandler } from "~/helpers/actions"+import { getPlatformSpecialKey as getSpecialKey } from "~/helpers/platformutils"const t = useI18n()@@ -88,4 +94,7 @@ useCodemirror(environmentHighlights: true,}))++defineActionHandler("response.file.download", () => downloadResponse())+defineActionHandler("response.copy", () => copyResponse())</script>diff --git a/packages/hoppscotch-app/src/helpers/actions.ts b/packages/hoppscotch-app/src/helpers/actions.tsindex 33dbba42b..89f43640e 100644--- a/packages/hoppscotch-app/src/helpers/actions.ts+++ b/packages/hoppscotch-app/src/helpers/actions.ts@@ -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 clipboardtype BoundActionList = {// eslint-disable-next-line no-unused-varsdiff --git a/packages/hoppscotch-app/src/helpers/keybindings.ts b/packages/hoppscotch-app/src/helpers/keybindings.tsindex 6dcf16cf4..f754e1ab3 100644--- a/packages/hoppscotch-app/src/helpers/keybindings.ts+++ b/packages/hoppscotch-app/src/helpers/keybindings.ts@@ -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 markif (val === "/") return "/"+ // Check if period+ if (val === ".") return "."+// If no other cases match, this is not a valid keyreturn null}diff --git a/packages/hoppscotch-app/src/helpers/shortcuts.ts b/packages/hoppscotch-app/src/helpers/shortcuts.tsindex 626f0b96f..182f49674 100644--- a/packages/hoppscotch-app/src/helpers/shortcuts.ts+++ b/packages/hoppscotch-app/src/helpers/shortcuts.ts@@ -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: [