diff --git a/src/interface/web/app/components/chatMessage/chatMessage.tsx b/src/interface/web/app/components/chatMessage/chatMessage.tsx index 5d87f7ea2..8882ef233 100644 --- a/src/interface/web/app/components/chatMessage/chatMessage.tsx +++ b/src/interface/web/app/components/chatMessage/chatMessage.tsx @@ -31,11 +31,12 @@ import { Shapes, Trash, Toolbox, + Clipboard, } from "@phosphor-icons/react"; import DOMPurify from "dompurify"; import { InlineLoading } from "../loading/loading"; -import { convertColorToTextClass } from "@/app/common/colorUtils"; +import { convertColorToTextClass } from "@/app.common/colorUtils"; import { AgentData } from "@/app/components/agentCard/agentCard"; import renderMathInElement from "katex/contrib/auto-render"; @@ -678,6 +679,22 @@ const ChatMessage = forwardRef((props, ref) => props.chatMessage.codeContext, ); + const copyReferencesToClipboard = () => { + const allReferencesMarkdown = [ + ...allReferences.notesReferenceCardData.map( + (note) => `- [${note.title}](#)`, + ), + ...allReferences.onlineReferenceCardData.map( + (online) => `- [${online.title}](${online.link})`, + ), + ...allReferences.codeReferenceCardData.map( + (code) => `- [Code Reference](#)`, + ), + ].join("\n"); + + navigator.clipboard.writeText(allReferencesMarkdown); + }; + return (
((props, ref) => /> )} + {props.chatMessage.by === "khoj" && (props.chatMessage.intent ? ( { + const allReferences = [ + ...props.notesReferenceCardData.map( + (note) => `- [${note.title}](#)`, + ), + ...props.onlineReferenceCardData.map( + (online) => `- [${online.title}](${online.link})`, + ), + ...props.codeReferenceCardData.map( + (code) => `- [Code Reference](#)`, + ), + ].join("\n"); + + navigator.clipboard.writeText(allReferences); + }; + return ( @@ -642,6 +659,14 @@ export default function ReferencePanel(props: ReferencePanelDataProps) { References View all references for this response +
{props.codeReferenceCardData.map((code, index) => {