From 28ea56c95afb8bafe48386c3421957a716037a70 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 24 Oct 2023 17:57:09 -0700 Subject: [PATCH] feat: copy code block added --- src/routes/+page.svelte | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 0534cb12e..513a10d4e 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -123,7 +123,8 @@ blocks.forEach((block) => { // only add button if browser supports Clipboard API - if (navigator.clipboard) { + + if (navigator.clipboard && block.childNodes.length < 2) { let button = document.createElement('button'); button.innerText = 'Copy Code'; @@ -380,6 +381,7 @@ responseMessage.context = data.context; messages = messages; hljs.highlightAll(); + createCopyCodeBlockButton(); } } } @@ -477,6 +479,7 @@ responseMessage.context = data.context; messages = messages; hljs.highlightAll(); + createCopyCodeBlockButton(); } } } @@ -661,7 +664,7 @@ {:else}
{@html marked.parse(message.content)}