mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-16 19:10:53 +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[]) {
|
export function groupSessionsByDateRange(chatSessions: ChatSession[]) {
|
||||||
console.log(chatSessions);
|
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
today.setHours(0, 0, 0, 0); // Set to start of today for accurate comparison
|
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 />}
|
{codeText && <CopyButton />}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<CodeContent />
|
<CodeContent />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
export function extractCodeText(
|
export function extractCodeText(
|
||||||
node: any,
|
node: any,
|
||||||
content: string,
|
content: string,
|
||||||
@ -32,7 +34,27 @@ export function extractCodeText(
|
|||||||
codeText = formattedCodeLines.join("\n").trim();
|
codeText = formattedCodeLines.join("\n").trim();
|
||||||
} else {
|
} else {
|
||||||
// Fallback if position offsets are not available
|
// 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 || "";
|
return codeText || "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user