From 7bae9053acf1f10ea8d93be1bfc6e3d8d9c9c99c Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sun, 28 Sep 2025 17:10:11 -0500 Subject: [PATCH] refac: copy behaviour --- src/lib/components/common/RichTextInput.svelte | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lib/components/common/RichTextInput.svelte b/src/lib/components/common/RichTextInput.svelte index b30beb0a7e..dae14f9682 100644 --- a/src/lib/components/common/RichTextInput.svelte +++ b/src/lib/components/common/RichTextInput.svelte @@ -1030,6 +1030,19 @@ // For all other cases, let ProseMirror perform its default paste behavior. view.dispatch(view.state.tr.scrollIntoView()); return false; + }, + copy: (view, event: ClipboardEvent) => { + 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(); + + event.clipboardData.setData('text/plain', plain.replaceAll('\n\n', '\n')); + event.clipboardData.setData('text/html', html); + + event.preventDefault(); + return true; } } },