File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -45,19 +45,19 @@ <h1 class="card-title fs-3">
4545</ div >
4646
4747< script >
48- <!-- clipboard.js code -->
4948
5049var allCodeBlocksElements = $ ( "code" ) ;
5150
5251allCodeBlocksElements . each ( function ( i ) {
5352
5453if ( $ ( this ) . parents ( '.listingblock' ) . length ) {
5554
56- var currentId = "codeblock" + ( i + 1 ) ;
57- $ ( this ) . attr ( 'id' , currentId ) ;
55+ var code = $ ( this ) . text ( ) . split ( / \n / ) ;
56+ for ( var idx = 0 ; idx < code . length ; idx ++ ) { code [ idx ] = code [ idx ] . replace ( "$ " , "" ) }
57+
5858 //trigger
59- var clipButton = '<button class="btn" data-clipboard-target="# ' + currentId + '"><img src="https://clipboardjs.com/assets/images/clippy.svg" width="13" alt="Copy to clipboard"></button>' ;
60- $ ( this ) . after ( clipButton ) ;
59+ var clipButton = '<button class="btn" data-clipboard-text=" ' + code . join ( "\n" ) + '"><img src="https://clipboardjs.com/assets/images/clippy.svg" width="13" alt="Copy to clipboard"></button>' ;
60+ $ ( this ) . parent ( ) . before ( clipButton ) ;
6161 }
6262}
6363) ;
You can’t perform that action at this time.
0 commit comments