Skip to content
Snippets Groups Projects
Commit 270d9ed2 authored by Aaron Dötsch's avatar Aaron Dötsch
Browse files

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.
parent ee98de85
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,11 @@ export function addInputHandler(handler) { ...@@ -20,7 +20,11 @@ export function addInputHandler(handler) {
} }
}; };
const paste = (e) => { 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("keydown", keydown);
window.addEventListener("paste", paste); window.addEventListener("paste", paste);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment