Added support for removing copy-to-clipboard button

This commit is contained in:
squidfunk
2022-11-12 14:32:13 +01:00
parent 557163a482
commit 128e26742c
10 changed files with 23 additions and 17 deletions

View File

@@ -173,12 +173,16 @@ export function mountCodeBlock(
/* Render button for Clipboard.js integration */
if (ClipboardJS.isSupported()) {
const parent = el.closest("pre")!
parent.id = `__code_${++sequence}`
parent.insertBefore(
renderClipboardButton(parent.id),
el
)
if (el.closest(".copy") || (
feature("content.code.copy") && !el.closest(".no-copy")
)) {
const parent = el.closest("pre")!
parent.id = `__code_${++sequence}`
parent.insertBefore(
renderClipboardButton(parent.id),
el
)
}
}
/* Handle code annotations */