Copy text to clipboard when readonly is set to cursor

#1

Is it possible to copy text to clipboard when the readOnly: “nocursor”, is set in this way, or am I missing something. I would like to add a copy to clipboard button like google has here https://developers.google.com/blockly/guides/modify-blockly/web/building#generators and let the users manually select the code and copy it.

Right now when I select the code and right click on it the copy method isn’t availible neither does ctrl + C do anything.

#2

readOnly: "nocursor" is a disaster and is going away in the next major version. It indeed doesn’t allow CodeMirror’s keybindings to fire, because you can’t focus the editor. I’m not sure why the context menu is also broken, but indeed, it appears to be.

#3

myCodeMirror.setOption(“readOnly”, true); does the trick for me. Thanks!

1 Like
#4

thank you. readOnly set true work for me… :slight_smile: