diff --git a/resources/js/components/code-block.tsx b/resources/js/components/code-block.tsx
index cf04563d3..ddcb41c13 100644
--- a/resources/js/components/code-block.tsx
+++ b/resources/js/components/code-block.tsx
@@ -7,10 +7,12 @@ import { cn } from '@/lib/utils';
export function CodeBlock({
html,
+ wholeHtml,
language,
isCopyable = true,
}: {
html: string;
+ wholeHtml?: string;
language: string | null;
isCopyable?: boolean;
}) {
@@ -34,7 +36,15 @@ export function CodeBlock({
return;
}
- if (await copy(codeRef.current.textContent ?? '')) {
+ // A template's content is inert: nothing in it loads or runs.
+ const whole = document.createElement('template');
+ whole.innerHTML = wholeHtml ?? '';
+ const code =
+ wholeHtml === undefined
+ ? codeRef.current.textContent
+ : whole.content.textContent;
+
+ if (await copy(code ?? '')) {
setIsCopied(true);
return;
diff --git a/resources/js/components/commit-body.tsx b/resources/js/components/commit-body.tsx
index fac23d0a0..13745fe46 100644
--- a/resources/js/components/commit-body.tsx
+++ b/resources/js/components/commit-body.tsx
@@ -91,6 +91,7 @@ export function BodySegments({