Skip to content

Commit

Permalink
docs: update “Copy code” button to find <pre>
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Mar 7, 2025
1 parent 888509e commit 7be28b7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/assets/javascript/copy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ Copy.prototype.init = function () {
}

Copy.prototype.copyAction = function () {
const $pre = this.$module.querySelector('pre')

// Copy to clipboard
try {
new ClipboardJS('.js-copy-button', {
target: function (trigger) {
return trigger.nextElementSibling
target: function () {
return $pre
}
}).on('success', function (e) {
e.trigger.textContent = 'Code copied'
Expand Down

0 comments on commit 7be28b7

Please sign in to comment.