From fcc3d9ed2b1b291043c8b2247494f5e46c793b9d Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 29 Sep 2025 22:45:38 -0500 Subject: [PATCH] fix: non rich text input copy --- src/lib/components/common/RichTextInput.svelte | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/components/common/RichTextInput.svelte b/src/lib/components/common/RichTextInput.svelte index dae14f9682..a97b53741b 100644 --- a/src/lib/components/common/RichTextInput.svelte +++ b/src/lib/components/common/RichTextInput.svelte @@ -1035,10 +1035,15 @@ if (!event.clipboardData) return false; if (richText) return false; // Let ProseMirror handle normal copy in rich text mode - const plain = editor.getText(); - const html = editor.getHTML(); + const { state } = view; + const { from, to } = state.selection; - event.clipboardData.setData('text/plain', plain.replaceAll('\n\n', '\n')); + // Only take the selected text & HTML, not the full doc + const plain = state.doc.textBetween(from, to, '\n'); + const slice = state.doc.cut(from, to); + const html = editor.schema ? editor.getHTML(slice) : editor.getHTML(); // depending on your editor API + + event.clipboardData.setData('text/plain', plain); event.clipboardData.setData('text/html', html); event.preventDefault();