mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 13:22:12 +00:00
Add button to copy chat messages on Desktop client
This commit is contained in:
@@ -325,6 +325,17 @@
|
|||||||
element.innerHTML = newHTML;
|
element.innerHTML = newHTML;
|
||||||
element.className = "chat-message-text-response";
|
element.className = "chat-message-text-response";
|
||||||
|
|
||||||
|
// Add a copy button to each chat message
|
||||||
|
let copyButton = document.createElement('button');
|
||||||
|
copyButton.classList.add("copy-button");
|
||||||
|
copyButton.title = "Copy Message";
|
||||||
|
let copyIcon = document.createElement("img");
|
||||||
|
copyIcon.src = "./assets/icons/copy-button.svg";
|
||||||
|
copyIcon.classList.add("copy-icon");
|
||||||
|
copyButton.appendChild(copyIcon);
|
||||||
|
copyButton.addEventListener('click', copyParentText);
|
||||||
|
element.append(copyButton);
|
||||||
|
|
||||||
// Get any elements with a class that starts with "language"
|
// Get any elements with a class that starts with "language"
|
||||||
let codeBlockElements = element.querySelectorAll('[class^="language-"]');
|
let codeBlockElements = element.querySelectorAll('[class^="language-"]');
|
||||||
// For each element, add a parent div with the class "programmatic-output"
|
// For each element, add a parent div with the class "programmatic-output"
|
||||||
|
|||||||
Reference in New Issue
Block a user