mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 13:22:12 +00:00
Fix target determination in the copy programmatic output button
This commit is contained in:
@@ -29,17 +29,18 @@ To get started, just start typing below. You can also type / to see a list of co
|
|||||||
let chatOptions = [];
|
let chatOptions = [];
|
||||||
function copyProgrammaticOutput(event) {
|
function copyProgrammaticOutput(event) {
|
||||||
// Remove the first 4 characters which are the "Copy" button
|
// Remove the first 4 characters which are the "Copy" button
|
||||||
const programmaticOutput = event.target.parentNode.textContent.trim();
|
const button = event.currentTarget;
|
||||||
|
const programmaticOutput = button.parentNode.textContent.trim();
|
||||||
navigator.clipboard.writeText(programmaticOutput).then(() => {
|
navigator.clipboard.writeText(programmaticOutput).then(() => {
|
||||||
event.target.textContent = "✅ Copied to clipboard!";
|
button.textContent = "✅ Copied to clipboard!";
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
event.target.textContent = "✅";
|
button.textContent = "✅";
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.error("Error copying programmatic output to clipboard:", error);
|
console.error("Error copying programmatic output to clipboard:", error);
|
||||||
event.target.textContent = "⛔️ Failed to copy!";
|
button.textContent = "⛔️ Failed to copy!";
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
event.target.textContent = "⛔️";
|
button.textContent = "⛔️";
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user