From 270d9ed2af24139f52693809e48c71fd2e8e566c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aaron=20D=C3=B6tsch?= <aaron@fsmpi.rwth-aachen.de> Date: Tue, 9 May 2023 17:16:17 +0200 Subject: [PATCH] Update key handler to support line breaks Until now the on paste event just read the text and passed that to the handler. Now it will read the text and then split it on line breaks, handling the lines individually. --- src/lib/inputhandler.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/inputhandler.js b/src/lib/inputhandler.js index e834fb1..8f30593 100644 --- a/src/lib/inputhandler.js +++ b/src/lib/inputhandler.js @@ -20,7 +20,11 @@ export function addInputHandler(handler) { } }; const paste = (e) => { - handler(e.clipboardData.getData("text")); + const text = e.clipboardData.getData("text"); + const lines = text.split("\n"); + for(const line of lines) + if(line.length > 0) + handler(line); }; window.addEventListener("keydown", keydown); window.addEventListener("paste", paste); -- GitLab