1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-10 15:44:51 +02:00

Update code-examples.js (#38675)

This commit is contained in:
XhmikosR
2023-05-31 07:36:19 +03:00
committed by GitHub
parent 60098ac499
commit c5f46b020c

View File

@@ -20,18 +20,19 @@
const btnHtml = [ const btnHtml = [
'<div class="bd-code-snippet">', '<div class="bd-code-snippet">',
' <div class="bd-clipboard">', ' <div class="bd-clipboard">',
' <button type="button" class="btn-clipboard">', ' <button type="button" class="btn-clipboard">',
' <svg class="bi" role="img" aria-label="Copy"><use xlink:href="#clipboard"/></svg>', ' <svg class="bi" role="img" aria-label="Copy"><use xlink:href="#clipboard"/></svg>',
' </button>', ' </button>',
' </div>', ' </div>',
'</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 // Ignore examples made by shortcode
if (!element.closest('.bd-example-snippet')) {
element.insertAdjacentHTML('beforebegin', btnHtml) element.insertAdjacentHTML('beforebegin', btnHtml)
element.previousElementSibling.append(element) element.previousElementSibling.append(element)
} }