diff --git a/src/lib/components/common/Textarea.svelte b/src/lib/components/common/Textarea.svelte index 4c18ae195..254db2e4b 100644 --- a/src/lib/components/common/Textarea.svelte +++ b/src/lib/components/common/Textarea.svelte @@ -10,18 +10,49 @@ let textareaElement; + $: if (textareaElement) { + if (textareaElement.innerText !== value) { + textareaElement.innerText = value; + } + } + // Adjust height on mount and after setting the element. onMount(async () => { await tick(); }); + + // Handle paste event to ensure only plaintext is pasted + function handlePaste(event: ClipboardEvent) { + event.preventDefault(); // Prevent the default paste action + const clipboardData = event.clipboardData?.getData('text/plain'); // Get plaintext from clipboard + document.execCommand('insertText', false, clipboardData); // Insert plaintext into contenteditable + } -