**Background**
[r1322513](https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CodeMirror/+/1322513) adds a new reusable Vue component for a CodeMirror editor. This works great but to fully satisfy WikiLambda's needs (T400015), we need `readonly` as a Vue prop, meaning it can change during an editing session. Currently, the core [CodeMirror class](https://doc.wikimedia.org/CodeMirror/master/js/js/CodeMirror.html) checks the `readonly` property of the textarea only //once//, meaning we need to rebuild the entire editor if a client wants to change the read-only state.
Overall this is [not deemed a major issue](https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CodeMirror/+/1322513/comment/fe0166d4_7ec8ef7b/), as if it comes down to it, the editor can simply be re-created when the `readonly` prop changes.
**Solution**
Let's rework [CodeMirror#readOnly](https://doc.wikimedia.org/CodeMirror/master/js/js/CodeMirror.html#readOnly) to be a [compartment](https://codemirror.net/examples/config/#compartments). Conveniently most functionality that comes with or without read-only is already an [Extension](https://codemirror.net/docs/ref/#state.Extension), so that can easily be encompassed within the `readOnly` compartment. [applyLinter()](https://doc.wikimedia.org/CodeMirror/master/js/js/CodeMirror.html#applyLinter) meanwhile only needs to pull from the EditorState as opposed to the getter.