@@ -35,6 +35,10 @@ import { createElement } from './modules/dom'
3535 }
3636} ) ( )
3737
38+ var cleanCallouts = function ( code ) {
39+ return code . replace ( / [ | \t ] + \n / g, '\n' ) . trimEnd ( )
40+ }
41+
3842document . addEventListener ( 'DOMContentLoaded' , function ( ) {
3943 var body = document . querySelectorAll ( 'body' )
4044 var ignore = [ 'gram' ]
@@ -46,11 +50,13 @@ document.addEventListener('DOMContentLoaded', function () {
4650 input = window . neo4jDocs . copyableCommand ( input )
4751 }
4852
49- input = input . replace ( / [ ] + \n / g, '\n' ) . trimEnd ( )
53+ input = cleanCallouts ( input )
54+
55+ // input = input.replace(/[ |\t]+\n/g, '\n').trimEnd()
5056
5157 return input
5258 }
53-
59+
5460 var copyToClipboard = function ( code , language ) {
5561 var textarea = document . createElement ( 'textarea' )
5662 textarea . value = cleanCode ( code , language )
@@ -75,6 +81,16 @@ document.addEventListener('DOMContentLoaded', function () {
7581 }
7682 }
7783
84+ // capture copy command
85+ let copyThis = document . querySelectorAll ( "pre code" )
86+ copyThis . forEach ( ( code ) => {
87+ code . addEventListener ( "copy" , ( e ) => {
88+ const selection = document . getSelection ( ) ;
89+ e . clipboardData . setData ( "text/plain" , cleanCallouts ( selection . toString ( ) ) )
90+ e . preventDefault ( )
91+ } ) ;
92+ } ) ;
93+
7894 function capitalizeFirstLetter ( string ) {
7995 return string . charAt ( 0 ) . toUpperCase ( ) + string . slice ( 1 )
8096 }
0 commit comments