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
This commit is contained in:
Shibo Lyu 2025-04-12 03:56:22 +08:00
parent a5ae23b229
commit 39de2176fa

View file

@ -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;
}
}