From 1c101873d780d60453df45e85eeb1d5a5304e869 Mon Sep 17 00:00:00 2001 From: Liu Yuhe <171144077+liuyuhe666@users.noreply.github.com> Date: Mon, 2 Sep 2024 20:04:11 +0800 Subject: [PATCH] fix: code copy failed (#2168) --- src/hooks/useCodeCopy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useCodeCopy.ts b/src/hooks/useCodeCopy.ts index 0941fe2c69..6f39c6322c 100644 --- a/src/hooks/useCodeCopy.ts +++ b/src/hooks/useCodeCopy.ts @@ -9,7 +9,7 @@ export const useCodeCopy = () => { e.target.closest("button.copy-button") if (button) { if (button.classList.contains("copied")) return - const pre = button.nextElementSibling + const pre = button.nextElementSibling?.children[0] if (pre?.tagName === "PRE") { clipboardCopy(pre.textContent || "") const textEl = button.querySelector("span:nth-child(2)")