How can I create a readonly CodeMirror 6 view?
So far I have just been “rejecting” transactions that change the document, but that still shows the keyboard on Android.
I’ll probably end up implementing something similar to ProseMirror’s editable
prop. Could you say a bit more about what behavior you’re expecting from a read-only editor? Should it just not be focusable/editable at all? (You might already be able to do that by setting {contenteditable: "false"}
via contentAttributes
, but I haven’t tested.)
Setting contenteditable
essentially does what I want (still being able to select/copy/fold code without the view being focusable itself), but the selection is somehow not working reliably.
By “not working reliably”, do you mean state.selection
no longer tracks the DOM selection, or something else?
Dragging the cursor over some text doesn’t select it, only triple-clicking a line work.
state.selection
seems to update correctly (it does reflect the DOM selection).
Example: https://codesandbox.io/s/codemirror-next-contenteditable-1l4x3
Ah, right, because the editor doesn’t get focus anymore when uneditable, the selection code gets confused. Let’s continue this in this issue.