0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-20 17:54:23 +01:00

docs: remove trailing newline when copying snippets (#38321)

This commit is contained in:
XhmikosR 2023-03-27 11:04:52 +03:00 committed by GitHub
parent 2bbf670fc2
commit 1729bcca1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@
(() => { (() => {
'use strict' 'use strict'
// Insert copy to clipboard button before .highlight // Insert copy to clipboard button before .highlight
const btnTitle = 'Copy to clipboard' const btnTitle = 'Copy to clipboard'
const btnEdit = 'Edit on StackBlitz' const btnEdit = 'Edit on StackBlitz'
@ -27,7 +28,7 @@
'</div>' '</div>'
].join('') ].join('')
// wrap programmatically code blocks and add copy btn. // Wrap programmatically code blocks and add copy btn.
document.querySelectorAll('.highlight') document.querySelectorAll('.highlight')
.forEach(element => { .forEach(element => {
if (!element.closest('.bd-example-snippet')) { // Ignore examples made be shortcode if (!element.closest('.bd-example-snippet')) { // Ignore examples made be shortcode
@ -51,7 +52,8 @@
snippetButtonTooltip('.btn-edit', btnEdit) snippetButtonTooltip('.btn-edit', btnEdit)
const clipboard = new ClipboardJS('.btn-clipboard', { 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 => { clipboard.on('success', event => {