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;"
THE DOCUMENT
const a = 1;
caret at 10
positions map through the change set
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()