This is how I managed to catch changes to the document: (it’s TypeScript)
import { EditorState } from "@codemirror/basic-setup"
import { EditorView, ViewUpdate } from "@codemirror/view"
import { CodeMirrorSetup } from "./codemirrorsetup"; // Custom setup
this.edit = new EditorView({
state: EditorState.create({
doc: initial_text,
extensions: [
CodeMirrorSetup,
EditorView.updateListener.of((v:ViewUpdate) => {
if (v.docChanged) {
// Document changed
}
}) ]
}),
parent: this.element
});