From 1be9627dd27ffe75957729a4a0d1682a98684f01 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 17 Apr 2026 14:57:49 +0900 Subject: [PATCH] refac --- src/lib/components/chat/Chat.svelte | 4 ++-- src/lib/components/common/RichTextInput.svelte | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index b7a724b675..c8f9694343 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -3011,7 +3011,7 @@ if (e.detail || files.length > 0) { await tick(); - submitHandler(e.detail.replaceAll('\n\n', '\n')); + submitHandler(e.detail); } }} /> @@ -3054,7 +3054,7 @@ clearDraft(); if (e.detail || files.length > 0) { await tick(); - submitHandler(e.detail.replaceAll('\n\n', '\n')); + submitHandler(e.detail); } }} /> diff --git a/src/lib/components/common/RichTextInput.svelte b/src/lib/components/common/RichTextInput.svelte index 4cdd8878f1..673e651c79 100644 --- a/src/lib/components/common/RichTextInput.svelte +++ b/src/lib/components/common/RichTextInput.svelte @@ -36,6 +36,18 @@ }); turndownService.escape = (string) => string; + // Produce single newlines between paragraphs instead of double. + // TipTap wraps every line in

tags; the default Turndown rule emits + // \n\n around each paragraph which then required a destructive + // replaceAll('\n\n','\n') that also wiped blank lines inside code blocks. + // This rule eliminates that hack so

 content is untouched.
+	turndownService.addRule('singleNewlineParagraphs', {
+		filter: 'p',
+		replacement: function (content) {
+			return '\n' + content + '\n';
+		}
+	});
+
 	// Use turndown-plugin-gfm for proper GFM table support
 	turndownService.use(gfm);
 
@@ -435,7 +447,6 @@
 
 	export const setText = (text: string) => {
 		if (!editor || !editor.view) return;
-		text = text.replaceAll('\n\n', '\n');
 
 		if (text === '') {
 			editor.commands.clearContent();