]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/root-helpers/utils.ts
Translated using Weblate (Polish)
[github/Chocobozzz/PeerTube.git] / client / src / root-helpers / utils.ts
index de4e08bf593f03b8d7e001b420a71c1303b13563..e32187ddb0d5b9e5a8cbfe9375bdcc62252d2e98 100644 (file)
@@ -9,6 +9,18 @@ function objectToUrlEncoded (obj: any) {
   return str.join('&')
 }
 
+function copyToClipboard (text: string) {
+  const el = document.createElement('textarea')
+  el.value = text
+  el.setAttribute('readonly', '')
+  el.style.position = 'absolute'
+  el.style.left = '-9999px'
+  document.body.appendChild(el)
+  el.select()
+  document.execCommand('copy')
+  document.body.removeChild(el)
+}
+
 // Thanks: https://github.com/uupaa/dynamic-import-polyfill
 function importModule (path: string) {
   return new Promise((resolve, reject) => {
@@ -51,6 +63,7 @@ function wait (ms: number) {
 }
 
 export {
+  copyToClipboard,
   importModule,
   objectToUrlEncoded,
   wait