From 184873213ce9d6c67b5c298534fee6302acf19ad Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Tue, 9 Apr 2024 23:06:27 +0530 Subject: [PATCH] Add button to copy chat messages on Web client --- src/khoj/interface/web/chat.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/khoj/interface/web/chat.html b/src/khoj/interface/web/chat.html index f4f14d8b..cbc65a9f 100644 --- a/src/khoj/interface/web/chat.html +++ b/src/khoj/interface/web/chat.html @@ -352,6 +352,17 @@ To get started, just start typing below. You can also type / to see a list of co element.innerHTML = newHTML; 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 = "/static/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" let codeBlockElements = element.querySelectorAll('[class^="language-"]'); // For each element, add a parent div with the class "programmatic-output"