From adda2e15c18401777e8822a50a3efa5bf2ec5157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Ondrejka?= Date: Fri, 27 Sep 2024 20:19:20 +0200 Subject: [PATCH] Added support for pasting text into the terminal --- frontend/src/components/Terminal.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/src/components/Terminal.vue b/frontend/src/components/Terminal.vue index 5452738..2e87241 100644 --- a/frontend/src/components/Terminal.vue +++ b/frontend/src/components/Terminal.vue @@ -129,6 +129,15 @@ export default { } // Fit the terminal width to the div container size after terminal is created. this.updateTerminalSize(); + + // Add paste event listener + this.terminal.textarea.addEventListener("paste", (event) => { + const textToPaste = event.clipboardData.getData("text").replace(/\n+$/, ""); + this.cursorPosition += textToPaste.length; + this.terminalInputBuffer += textToPaste; + console.debug("Paste text: " + textToPaste); + this.terminal.write(textToPaste); + }); }, unmounted() {