Include TextMarkers in copy paste operation

Hi,

I am working on a text editor with some user applied formatting (bold, colors and such). I am trying to implement copy pasting of text including markers.

Is there some clever way of doing that in CodeMirror?
If not my idea goes like this:

  1. Hook into the copy event and get the selected text including markers into a copy buffer
  2. Hook into paste event and insert copied text and apply copied marks (where position of marks is transformed with current cursor location) at desired location.
  3. Handle all kinds of edge cases (pasting on top of some selected text, and what not)

How does that sound?

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 "paste" and "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).

Thank you very much for the pointers.
You and CodeMirror are awesome :clap: