I have checked the soucecode, seems key events only works when editorView’s editable is true.
However I would like to keep the ‘Mod-A’ shortcut to select the document in readonly mode (editable: false) just as what it does in editable mode
any ideas ?
editable: false, the
contenteditable attribute on the document node is removed, which by default makes the browser disable keyboard focus for the element. When the node isn’t focused, it doesn’t even receive keyboard events, so it’s hard to implement any keybindings for it.
You could use the
attributes prop to add a
tabIndex=0 attribute to your editor to make it focusable. But this might lead to some other key bindings also firing, and if those do change the document,
editable: false (which works only on the DOM) level won’t stop them.
wow, thanks a lot !
I am wandering that i should accomplish that by createRange and getSelection API when it’s readonly.