From b85cfdc90f0b4021b2bb871edf8b8f11d384feed Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 27 Nov 2024 19:26:05 -0800 Subject: [PATCH] refac: textarea --- src/lib/components/common/Textarea.svelte | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/components/common/Textarea.svelte b/src/lib/components/common/Textarea.svelte index dfac6389a..c073d84eb 100644 --- a/src/lib/components/common/Textarea.svelte +++ b/src/lib/components/common/Textarea.svelte @@ -26,7 +26,8 @@ event.preventDefault(); // Prevent the default paste action const clipboardData = event.clipboardData?.getData('text/plain'); // Get plaintext from clipboard - value = `${value}${clipboardData}`; // Append the plaintext to the current value + // Insert plaintext into the textarea + document.execCommand('insertText', false, clipboardData); } @@ -37,6 +38,10 @@ style="field-sizing: content; -moz-user-select: text !important;" on:input={() => { const text = textareaElement.innerText; + if (text.trim() === '\n') { + value = ''; + return; + } value = text.trim(); }} on:paste={handlePaste}