From 729632dc23ed3e182eb334b85d778c8daf03cd9f Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Fri, 30 Dec 2022 21:33:27 +0100 Subject: [PATCH] webapp: Workaround for copying console output to clipboard Hint:: clipboard.writeText is only available when using https mode or access from localhost --- webapp/src/views/ConsoleInfoView.vue | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/webapp/src/views/ConsoleInfoView.vue b/webapp/src/views/ConsoleInfoView.vue index 0160ce2..ba88e0b 100644 --- a/webapp/src/views/ConsoleInfoView.vue +++ b/webapp/src/views/ConsoleInfoView.vue @@ -116,14 +116,12 @@ export default defineComponent({ this.consoleBuffer = ""; }, copyConsole() { - navigator.clipboard.writeText(this.consoleBuffer).then( - () => { - console.log('clipboard successfully set'); - }, - () => { - console.error('clipboard write failed'); - } - ); + var input = document.createElement('textarea'); + input.innerHTML = this.consoleBuffer; + document.body.appendChild(input); + input.select(); + document.execCommand('copy'); + document.body.removeChild(input); } } });