diff --git a/src/lib/components/common/RichTextInput.svelte b/src/lib/components/common/RichTextInput.svelte index 3f4925277..c9c8101c3 100644 --- a/src/lib/components/common/RichTextInput.svelte +++ b/src/lib/components/common/RichTextInput.svelte @@ -191,9 +191,14 @@ onTransaction: () => { // force re-render so `editor.isActive` works as expected editor = editor; - const newValue = turndownService.turndown( - preserveBreaks ? editor.getHTML().replace(/

<\/p>/g, '
') : editor.getHTML() - ); + const newValue = turndownService + .turndown( + (preserveBreaks + ? editor.getHTML().replace(/

<\/p>/g, '
') + : editor.getHTML() + ).replace(/ {2,}/g, (m) => m.replace(/ /g, '\u00a0')) + ) + .replace(/\u00a0/g, ' '); if (value !== newValue) { value = newValue; @@ -332,9 +337,14 @@ $: if ( editor && value !== - turndownService.turndown( - preserveBreaks ? editor.getHTML().replace(/

<\/p>/g, '
') : editor.getHTML() - ) + turndownService + .turndown( + (preserveBreaks + ? editor.getHTML().replace(/

<\/p>/g, '
') + : editor.getHTML() + ).replace(/ {2,}/g, (m) => m.replace(/ /g, '\u00a0')) + ) + .replace(/\u00a0/g, ' ') ) { editor.commands.setContent( marked.parse(value.replaceAll(`\n
`, `
`), {