I’m creating an editor with EditorView.editable.of(false) but would like to retain CTRL+A to select all text. Any way to retain that keymap function?
1 Like
By default, uneditable elements aren’t focusable, and thus won’t receive any direct keyboard events. You could add a EditorView.contentAttributes.of({tabindex: "0"}) extension and see if that helps.
1 Like
That did it! Thanks marijn !
1 Like
Just posting here to note that this is absolutely the right solution if you need to still have CodeMirror keybindings while in EditorState.readOnly.of(true) and/or EditorView.editable.of(false). Perfect for still allowing users to select text easily and trigger panels like search.
With readOnly.of(true) you don’t need to set the tabindex (selection still works). And also I don’t think there’s any point in disabling editable if you’re already setting readOnly and want to enable selection.