mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-01 10:40:47 +02:00
add copying for unrecognized languages (#2883)
* add copying for unrecognized languages * k
This commit is contained in:
parent
5703ea47d2
commit
143da5bc0d
@ -348,7 +348,6 @@ export function getCitedDocumentsFromMessage(message: Message) {
|
||||
}
|
||||
|
||||
export function groupSessionsByDateRange(chatSessions: ChatSession[]) {
|
||||
console.log(chatSessions);
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0); // Set to start of today for accurate comparison
|
||||
|
||||
|
@ -116,6 +116,7 @@ export const CodeBlock = memo(function CodeBlock({
|
||||
{codeText && <CopyButton />}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<CodeContent />
|
||||
</div>
|
||||
);
|
||||
|
@ -1,3 +1,5 @@
|
||||
import React from "react";
|
||||
|
||||
export function extractCodeText(
|
||||
node: any,
|
||||
content: string,
|
||||
@ -32,7 +34,27 @@ export function extractCodeText(
|
||||
codeText = formattedCodeLines.join("\n").trim();
|
||||
} else {
|
||||
// Fallback if position offsets are not available
|
||||
codeText = children?.toString() || null;
|
||||
const extractTextFromReactNode = (node: React.ReactNode): string => {
|
||||
if (typeof node === "string") return node;
|
||||
if (typeof node === "number") return String(node);
|
||||
if (!node) return "";
|
||||
|
||||
if (React.isValidElement(node)) {
|
||||
const children = node.props.children;
|
||||
if (Array.isArray(children)) {
|
||||
return children.map(extractTextFromReactNode).join("");
|
||||
}
|
||||
return extractTextFromReactNode(children);
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
return node.map(extractTextFromReactNode).join("");
|
||||
}
|
||||
|
||||
return "";
|
||||
};
|
||||
|
||||
codeText = extractTextFromReactNode(children);
|
||||
}
|
||||
|
||||
return codeText || "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user