File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed
Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change 1313 document . execCommand ( 'copy' ) ;
1414 document . body . removeChild ( textArea ) ;
1515 }
16- const codeBlockElements = document . getElementsByClassName ( 'copyable' ) ;
17- for ( let i = 0 ; i < codeBlockElements . length ; i ++ ) {
18- const block = codeBlockElements [ i ] ;
16+ for ( const block of document . getElementsByClassName ( 'copyable' ) ) {
1917 const copyIcon = new Image ( 16 , 16 ) ;
2018 copyIcon . setAttribute ( 'src' , './assets/copy-icon.svg' ) ;
2119 copyIcon . setAttribute ( 'alt' , 'copy' ) ;
2220 copyIcon . setAttribute ( 'title' , 'copy to clipboard' ) ;
2321 block . insertBefore ( copyIcon , block . children [ 0 ] ) ;
24- copyIcon . addEventListener ( 'click' , ( block ) => {
22+ copyIcon . addEventListener ( 'click' , ( ) => {
2523 const text = block . getElementsByTagName ( 'pre' ) [ 0 ] . innerText ;
2624 copyTextToClipboard ( text ) ;
2725 } ) ;
You can’t perform that action at this time.
0 commit comments