Skip to content

Commit

Permalink
docs: remove trailing newline when copying snippets (#38321)
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR authored Mar 27, 2023
1 parent 2bbf670 commit 1729bcc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions site/assets/js/code-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

(() => {
'use strict'

// Insert copy to clipboard button before .highlight
const btnTitle = 'Copy to clipboard'
const btnEdit = 'Edit on StackBlitz'
Expand All @@ -27,7 +28,7 @@
'</div>'
].join('')

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

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

clipboard.on('success', event => {
Expand Down

0 comments on commit 1729bcc

Please sign in to comment.