Procházet zdrojové kódy

refac: copy behaviour

Timothy Jaeryang Baek před 1 týdnem
rodič
revize
7bae9053ac
1 změnil soubory, kde provedl 13 přidání a 0 odebrání
  1. 13 0
      src/lib/components/common/RichTextInput.svelte

+ 13 - 0
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;
 					}
 				}
 			},