Skip to content

Commit b27cc01

Browse files
Algorithm5838github-actions[bot]
authored andcommitted
fix: strip trailing spaces from RichTextInput user messages
1 parent e7f21bf commit b27cc01

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
@@ -3007,14 +3007,14 @@
30073007
saveDraft(data, $chatId);
30083008
}
30093009
}}
3010-
on:submit={async (e) => {
3011-
clearDraft($chatId);
3012-
if (e.detail || files.length > 0) {
3013-
await tick();
3010+
on:submit={async (e) => {
3011+
clearDraft($chatId);
3012+
if (e.detail || files.length > 0) {
3013+
await tick();
30143014

3015-
submitHandler(e.detail.replaceAll('\n\n', '\n'));
3016-
}
3017-
}}
3015+
submitHandler(e.detail);
3016+
}
3017+
}}
30183018
/>
30193019

30203020
<div
@@ -3051,13 +3051,13 @@
30513051
saveDraft(data);
30523052
}
30533053
}}
3054-
on:submit={async (e) => {
3055-
clearDraft();
3056-
if (e.detail || files.length > 0) {
3057-
await tick();
3058-
submitHandler(e.detail.replaceAll('\n\n', '\n'));
3059-
}
3060-
}}
3054+
on:submit={async (e) => {
3055+
clearDraft();
3056+
if (e.detail || files.length > 0) {
3057+
await tick();
3058+
submitHandler(e.detail);
3059+
}
3060+
}}
30613061
/>
30623062
</div>
30633063
{/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)