Merge pull request #215 from boeto/v2

This commit is contained in:
jxxghp
2024-10-25 17:49:10 +08:00
committed by GitHub

View File

@@ -21,6 +21,8 @@ export async function copyToClipboard(content: string) {
const input = document.createElement('textarea')
input.value = content
document.body.appendChild(input)
// 阻止事件冒泡到其他元素,确保 focusin 事件只在 textarea 元素上处理,不会影响其他元素
input.addEventListener('focusin', e => e.stopPropagation())
input.select()
document.execCommand('copy')
document.body.removeChild(input)