I use CodeMirror to display and let the user edit some SQL Code. The SQL code gets syntax highlighted. I want my user to select the SQL code and paste it (with markup!) inside another application for example Word. How can I accomplish this?
Copying from CodeMirror only copies the plain text. The highlighting is purely a display issue, the content is treated as just text. You could use something like the
runmode addon to create a syntax highlighted view that the user can copy from, but that won’t be editable.
rich text copy
Let’s be more specific… Top right the user enters his SQL query which get syntax highlighted. When they select this query with CTRL-A and do CTRL-C only the plain text gets copied to clipboard. When they paste into Word you will only get plain text.
In Notepad++ there’s a plugin called NppExport with the option copy RTF/HTML to clipboard. Then when you paste also the markup gets pasted.
Is there a way to accomplish the same thing in CodeMirror?
Not built in, but you could probably write your own copy event handler on top of
runmode that does something like this.
I guess I will have to read up on this then:
I am really baffled that no one(?) wants/needs this functionality since it’s not built-in?! All my users (in the thousand) complain with me that they can’t copy paste with markup.
Is this feature on your roadmap? If not could you give me some (more) pointers on how to code this myself?
I agree – this is absolutely critical for those of us making slides (keynote, powerpoint, etc) from codemirror code…