]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
docs: remove trailing newline when copying snippets (#38321)
authorXhmikosR <xhmikosr@gmail.com>
Mon, 27 Mar 2023 08:04:52 +0000 (11:04 +0300)
committerGitHub <noreply@github.com>
Mon, 27 Mar 2023 08:04:52 +0000 (11:04 +0300)
site/assets/js/code-examples.js

index 555bd7b6fa2a1196a13cdb2711a3e5fcf925778c..f224500f47ac9dd2804ec4389d4af95ccbb3e599 100644 (file)
@@ -13,6 +13,7 @@
 
 (() => {
   'use strict'
+
   // Insert copy to clipboard button before .highlight
   const btnTitle = 'Copy to clipboard'
   const btnEdit = 'Edit on StackBlitz'
@@ -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
@@ -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 => {