diff --git a/src/khoj/interface/web/assets/icons/copy-button-success.svg b/src/khoj/interface/web/assets/icons/copy-button-success.svg
new file mode 100644
index 00000000..7a00dcd0
--- /dev/null
+++ b/src/khoj/interface/web/assets/icons/copy-button-success.svg
@@ -0,0 +1,6 @@
+
+
diff --git a/src/khoj/interface/web/assets/icons/copy-button.svg b/src/khoj/interface/web/assets/icons/copy-button.svg
new file mode 100644
index 00000000..36fc8971
--- /dev/null
+++ b/src/khoj/interface/web/assets/icons/copy-button.svg
@@ -0,0 +1,5 @@
+
+
diff --git a/src/khoj/interface/web/assets/icons/copy_button.svg b/src/khoj/interface/web/assets/icons/copy_button.svg
deleted file mode 100644
index fadf344a..00000000
--- a/src/khoj/interface/web/assets/icons/copy_button.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/src/khoj/interface/web/chat.html b/src/khoj/interface/web/chat.html
index 1b2ccda0..f4f14d8b 100644
--- a/src/khoj/interface/web/chat.html
+++ b/src/khoj/interface/web/chat.html
@@ -30,20 +30,21 @@ To get started, just start typing below. You can also type / to see a list of co
const allowedExtensions = ['text/org', 'text/markdown', 'text/plain', 'text/html', 'application/pdf'];
const allowedFileEndings = ['org', 'md', 'txt', 'html', 'pdf'];
let chatOptions = [];
- function copyProgrammaticOutput(event) {
- // Remove the first 4 characters which are the "Copy" button
+ function copyParentText(event) {
const button = event.currentTarget;
- const programmaticOutput = button.parentNode.textContent.trim();
- navigator.clipboard.writeText(programmaticOutput).then(() => {
- button.textContent = "✅ Copied to clipboard!";
+ const textContent = button.parentNode.textContent.trim();
+ navigator.clipboard.writeText(textContent).then(() => {
+ button.firstChild.src = "/static/assets/icons/copy-button-success.svg";
setTimeout(() => {
- button.textContent = "✅";
+ button.firstChild.src = "/static/assets/icons/copy-button.svg";
}, 1000);
}).catch((error) => {
console.error("Error copying programmatic output to clipboard:", error);
- button.textContent = "⛔️ Failed to copy!";
+ const originalButtonText = button.innerHTML;
+ button.innerHTML = "⛔️";
setTimeout(() => {
- button.textContent = "⛔️";
+ button.innerHTML = originalButtonText;
+ button.firstChild.src = "/static/assets/icons/copy-button.svg";
}, 1000);
});
}
@@ -365,11 +366,12 @@ To get started, just start typing below. You can also type / to see a list of co
// Add a copy button to each element
let copyButton = document.createElement('button');
copyButton.classList.add("copy-button");
+ copyButton.title = "Copy Code";
let copyIcon = document.createElement("img");
- copyIcon.src = "/static/assets/icons/copy_button.svg";
+ copyIcon.src = "/static/assets/icons/copy-button.svg";
copyIcon.classList.add("copy-icon");
copyButton.appendChild(copyIcon);
- copyButton.addEventListener('click', copyProgrammaticOutput);
+ copyButton.addEventListener('click', copyParentText);
codeElement.prepend(copyButton);
});
@@ -2183,7 +2185,7 @@ To get started, just start typing below. You can also type / to see a list of co
}
button.copy-button:hover {
- background-color: black;
+ background-color: var(--primary-hover);
color: #f5f5f5;
}