editable.of(false) with CTRL+A

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.

Example