Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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