fix: rich text input issue

This commit is contained in:
Timothy Jaeryang Baek 2024-12-11 14:07:25 -08:00
parent a495f68b58
commit bfdbb2df69

View File

@ -191,15 +191,19 @@
onTransaction: () => { onTransaction: () => {
// force re-render so `editor.isActive` works as expected // force re-render so `editor.isActive` works as expected
editor = editor; editor = editor;
const newValue = turndownService let newValue = turndownService
.turndown( .turndown(
(preserveBreaks editor
? editor.getHTML().replace(/<p><\/p>/g, '<br/>') .getHTML()
: editor.getHTML() .replace(/<p><\/p>/g, '<br/>')
).replace(/ {2,}/g, (m) => m.replace(/ /g, '\u00a0')) .replace(/ {2,}/g, (m) => m.replace(/ /g, '\u00a0'))
) )
.replace(/\u00a0/g, ' '); .replace(/\u00a0/g, ' ');
if (!preserveBreaks) {
newValue = newValue.replace(/<br\/>/g, '');
}
if (value !== newValue) { if (value !== newValue) {
value = newValue; value = newValue;