Чото поменял

This commit is contained in:
2023-11-20 18:00:24 +03:00
parent 6f147ca8b7
commit e164248d9c
7 changed files with 167 additions and 49 deletions

10
src/textObserverPlugin.ts Normal file
View File

@@ -0,0 +1,10 @@
import { ViewPlugin, ViewUpdate } from '@codemirror/view'
export const textObserverPlugin = (callback: (text: string) => void) =>
ViewPlugin.define(() => ({
update(update: ViewUpdate) {
if (update.docChanged) {
callback(update.state.doc.toString())
}
},
}))