From f5aebbb99a811497fc8c7709d6f46b9bd2ce1292 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 14 Jun 2023 22:49:21 +0200 Subject: [PATCH] [#91] Add Copy-to-Clipboard button to secret URL closes #91 Signed-off-by: Knut Ahlers --- src/app.vue | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/app.vue b/src/app.vue index 07e2bd3..7e94ba1 100644 --- a/src/app.vue +++ b/src/app.vue @@ -130,13 +130,20 @@ readonly @focus="$refs.secretUrl.select()" /> - + + + + @@ -216,6 +223,10 @@ const passwordLength = 20 export default { computed: { + hasClipboard() { + return Boolean(navigator.clipboard && navigator.clipboard.writeText) + }, + secretUrl() { return [ window.location.href, @@ -229,6 +240,7 @@ export default { data() { return { + copyToClipboardSuccess: false, customize: {}, darkTheme: false, error: '', @@ -243,6 +255,16 @@ export default { }, methods: { + copySecretUrl() { + navigator.clipboard.writeText(this.secretUrl) + .then(() => { + this.copyToClipboardSuccess = true + window.setTimeout(() => { + this.copyToClipboardSuccess = false + }, 500) + }) + }, + // createSecret executes the secret creation after encrypting the secret createSecret() { if (this.secret.trim().length < 1) {