Skip to content

Commit 1729bcc

Browse files
authored
docs: remove trailing newline when copying snippets (#38321)
1 parent 2bbf670 commit 1729bcc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

site/assets/js/code-examples.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
(() => {
1515
'use strict'
16+
1617
// Insert copy to clipboard button before .highlight
1718
const btnTitle = 'Copy to clipboard'
1819
const btnEdit = 'Edit on StackBlitz'
@@ -27,7 +28,7 @@
2728
'</div>'
2829
].join('')
2930

30-
// wrap programmatically code blocks and add copy btn.
31+
// Wrap programmatically code blocks and add copy btn.
3132
document.querySelectorAll('.highlight')
3233
.forEach(element => {
3334
if (!element.closest('.bd-example-snippet')) { // Ignore examples made be shortcode
@@ -51,7 +52,8 @@
5152
snippetButtonTooltip('.btn-edit', btnEdit)
5253

5354
const clipboard = new ClipboardJS('.btn-clipboard', {
54-
target: trigger => trigger.closest('.bd-code-snippet').querySelector('.highlight')
55+
target: trigger => trigger.closest('.bd-code-snippet').querySelector('.highlight'),
56+
text: trigger => trigger.parentNode.nextElementSibling.textContent.trimEnd()
5557
})
5658

5759
clipboard.on('success', event => {

0 commit comments

Comments
 (0)