[fix] copy failure (#446)

This commit is contained in:
星日语 2024-04-26 01:41:53 +08:00 committed by GitHub
parent ae9700a4ad
commit 988a88e196
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -7,7 +7,7 @@ window.codeElements.forEach((codeElement) => {
// 添加点击事件监听
codeCopyBtn.addEventListener('click', async () => {
const codeToCopy = codeElement.querySelector('code')?.textContent || '';
const codeToCopy = codeElement.querySelector('pre')?.innerText || '';
if (navigator.clipboard) {
try {
await navigator.clipboard.writeText(codeToCopy);