Even in the demo, you are able to select or highlight lines of code if selecting and dragging vertically from the right of the code editor. This largely seems like an unexpected behavior. Is there a way to prevent any selection of the code if the cursor is outside of the editor itself?
Note that Firefox, for example, doesn’t have this problem. It is Chrome’s native behavior to put the selection in an editable element when you click next to it, and other editable elements work the same way there. So though I agree it’s weird, I don’t think it is worth adding a custom kludge to CodeMirror to try to detect and revert it.
Not that I know of. The editor itself only notices that the selection is suddenly inside of it (it never gets the mouse event), and that may have happened by who knows what kind of valid user action, so this seems difficult to work around.