From 39de2176faabbb1ad8fd3bf31870aa688b472747 Mon Sep 17 00:00:00 2001 From: Shibo Lyu Date: Sat, 12 Apr 2025 03:56:22 +0800 Subject: [PATCH] fix: State reference in RichTextInput dispatchTransaction Use editorView.state instead of closed-over state variable to ensure we're always working with the latest editor state --- src/lib/components/RichTextInput/ClientInput.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/components/RichTextInput/ClientInput.svelte b/src/lib/components/RichTextInput/ClientInput.svelte index c36135b..e48767e 100644 --- a/src/lib/components/RichTextInput/ClientInput.svelte +++ b/src/lib/components/RichTextInput/ClientInput.svelte @@ -27,11 +27,11 @@ { mount: domEl }, { state, - dispatchTransaction: (tr) => { - const newState = state.apply(tr); + dispatchTransaction(tr) { + const newState = editorView.state.apply(tr); editorView.updateState(newState); - onDocChange?.(newState.doc); + onDocChange?.(newState.doc); isEmpty = newState.doc.textContent.length === 0; } }