File tree 1 file changed +8
-6
lines changed
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,13 @@ export function makeCodeCopyButton(): HTMLButtonElement {
8
8
}
9
9
10
10
export function initMarkupCodeCopy ( elMarkup : HTMLElement ) : void {
11
- const el = elMarkup . querySelector ( '.code-wrapper' ) ; // .markup .code-block code
12
- if ( ! el || ! el . textContent ) return ;
11
+ const els = elMarkup . querySelectorAll ( '.code-wrapper' ) ; // .markup .code-block code
13
12
14
- const btn = makeCodeCopyButton ( ) ;
15
- // remove final trailing newline introduced during HTML rendering
16
- btn . setAttribute ( 'data-clipboard-text' , el . textContent . replace ( / \r ? \n $ / , '' ) ) ;
17
- el . append ( btn ) ;
13
+ for ( const el of els ) {
14
+ if ( ! el || ! el . textContent ) return ;
15
+ const btn = makeCodeCopyButton ( ) ;
16
+ // remove final trailing newline introduced during HTML rendering
17
+ btn . setAttribute ( 'data-clipboard-text' , el . textContent . replace ( / \r ? \n $ / , '' ) ) ;
18
+ el . append ( btn ) ;
19
+ }
18
20
}
You can’t perform that action at this time.
0 commit comments