From bfdbb2df692d8a6741d5679d72d6b2ae57ed6d38 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 11 Dec 2024 14:07:25 -0800 Subject: [PATCH] fix: rich text input issue --- src/lib/components/common/RichTextInput.svelte | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib/components/common/RichTextInput.svelte b/src/lib/components/common/RichTextInput.svelte index c9c8101c3..57fbf567b 100644 --- a/src/lib/components/common/RichTextInput.svelte +++ b/src/lib/components/common/RichTextInput.svelte @@ -191,15 +191,19 @@ onTransaction: () => { // force re-render so `editor.isActive` works as expected editor = editor; - const newValue = turndownService + let newValue = turndownService .turndown( - (preserveBreaks - ? editor.getHTML().replace(/

<\/p>/g, '
') - : editor.getHTML() - ).replace(/ {2,}/g, (m) => m.replace(/ /g, '\u00a0')) + editor + .getHTML() + .replace(/

<\/p>/g, '
') + .replace(/ {2,}/g, (m) => m.replace(/ /g, '\u00a0')) ) .replace(/\u00a0/g, ' '); + if (!preserveBreaks) { + newValue = newValue.replace(//g, ''); + } + if (value !== newValue) { value = newValue;