File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 5151 top : 5px ;
5252
5353 button {
54- border : none ;
54+ // border: none;
5555 background : #fff ;
5656 font-size : $font-size-medium ;
5757 color : $gray-darker ;
5858 cursor : pointer ;
59+ border : 1px solid #E5EAEA ;
60+ border-radius : 3px ;
61+ margin : 4px ;
62+ padding : 3px 5px ;
5963 }
6064 }
6165
Original file line number Diff line number Diff line change @@ -705,3 +705,33 @@ $(document).ready(function() {
705705 }
706706 } ) ;
707707} ) ;
708+
709+
710+
711+ $ ( document ) . ready ( function ( ) {
712+ $ ( "pre > code" ) . each ( function ( ) {
713+ const $code = $ ( this ) ;
714+ // Skip if it's already wrapped in a .code-snippet-area
715+ if ( $code . closest ( ".code-snippet-area" ) . length ) return ;
716+
717+ const $pre = $code . parent ( ) ;
718+ const $wrapper = $ ( '<div class="code-snippet-area"></div>' ) ;
719+ const $buttons = $ ( `
720+ <div class="code-snippet-buttons">
721+ <button class="copy-button">
722+ <i class="far fa-clone"></i>
723+ </button>
724+ </div>
725+ ` ) ;
726+
727+ $pre . wrap ( $wrapper ) ;
728+ $pre . before ( $buttons ) ;
729+ } ) ;
730+
731+ $ ( document ) . on ( "click" , ".copy-button" , function ( ) {
732+ const $button = $ ( this ) ;
733+ const $area = $button . closest ( ".code-snippet-area" ) ;
734+ const codeText = $area . find ( "code" ) . text ( ) . trim ( ) ;
735+ navigator . clipboard . writeText ( codeText )
736+ } ) ;
737+ } ) ;
You can’t perform that action at this time.
0 commit comments