Skip to content

Commit 146d775

Browse files
committed
fix: strip trailing spaces from RichTextInput user messages
1 parent 53caff7 commit 146d775

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

src/lib/components/chat/Chat.svelte

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3002,14 +3002,14 @@
30023002
saveDraft(data, $chatId);
30033003
}
30043004
}}
3005-
on:submit={async (e) => {
3006-
clearDraft($chatId);
3007-
if (e.detail || files.length > 0) {
3008-
await tick();
3005+
on:submit={async (e) => {
3006+
clearDraft($chatId);
3007+
if (e.detail || files.length > 0) {
3008+
await tick();
30093009

3010-
submitHandler(e.detail.replaceAll('\n\n', '\n'));
3011-
}
3012-
}}
3010+
submitHandler(e.detail);
3011+
}
3012+
}}
30133013
/>
30143014

30153015
<div
@@ -3046,13 +3046,13 @@
30463046
saveDraft(data);
30473047
}
30483048
}}
3049-
on:submit={async (e) => {
3050-
clearDraft();
3051-
if (e.detail || files.length > 0) {
3052-
await tick();
3053-
submitHandler(e.detail.replaceAll('\n\n', '\n'));
3054-
}
3055-
}}
3049+
on:submit={async (e) => {
3050+
clearDraft();
3051+
if (e.detail || files.length > 0) {
3052+
await tick();
3053+
submitHandler(e.detail);
3054+
}
3055+
}}
30563056
/>
30573057
</div>
30583058
{/if}

src/lib/components/common/RichTextInput.svelte

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@
105105
}
106106
});
107107
108+
// Emit a plain newline for <br> instead of the default " \n" (Markdown hard-break)
109+
turndownService.addRule('br', {
110+
filter: 'br',
111+
replacement: () => '\n'
112+
});
113+
108114
import { onMount, onDestroy, tick, getContext } from 'svelte';
109115
import { createEventDispatcher } from 'svelte';
110116

0 commit comments

Comments
 (0)