Two owners, one document.

Only one of them gets to write it.

ANGULAR FORM
holds a copy of the text,
and nothing else
form.value = "const a = 1;"
every edit
×
caret 10 → 0
THE DOCUMENT
const a = 1;
caret at 10
positions map through the change set
lives inside
CODEMIRROR EDITORSTATE
holds the document,
changed only by transactions
view.state.doc view.dispatch({ changes })
caret at 10, after a minimal change: 10|after a whole-document replace: 0
and when the component goes an EditorView registers outside its own element — selectionchange on the document, resize, scroll and a print handler on the media query, and one scroll handler on every ancestor, up to html — until something calls view.destroy()
Angular 22.1.7 · @codemirror/view 6.43.12 · caret offsets asserted by the demo's tests
gdhami.net