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: use navigator clipboard to copy text is possible
Andrew Bastin369bca90fc40
diff --git a/helpers/utils/clipboard.ts b/helpers/utils/clipboard.tsindex 44dbcbf0b..6516652d8 100644--- a/helpers/utils/clipboard.ts+++ b/helpers/utils/clipboard.ts@@ -5,10 +5,14 @@* @param content The content to be copied*/export function copyToClipboard(content: string) {- const dummy = document.createElement("textarea")- document.body.appendChild(dummy)- dummy.value = content- dummy.select()- document.execCommand("copy")- document.body.removeChild(dummy)+ if (navigator.clipboard) {+ navigator.clipboard.writeText(content)+ } else {+ const dummy = document.createElement("textarea")+ document.body.appendChild(dummy)+ dummy.value = content+ dummy.select()+ document.execCommand("copy")+ document.body.removeChild(dummy)+ }}