CodeMirror itself treats clipboard content as plain text. If you don't care about IE/Edge support, overriding copy and paste events isn't too hard. But it's probably safer to let CodeMirror run its default behavior and then fix things up right after (you can easily detect
"cut" by listening for changes with those strings as
origin property, but that doesn't work for copy, so there you should probably just listen to the DOM event and assume that the current selection is what's being copied).