mirror of
https://github.com/MODSetter/SurfSense.git
synced 2025-09-09 22:04:47 +00:00
Initial formatting using biome
This commit is contained in:
parent
4c8ff48155
commit
758603b275
156 changed files with 23825 additions and 29508 deletions
|
@ -5,12 +5,9 @@ import rehypeSanitize from "rehype-sanitize";
|
|||
import remarkGfm from "remark-gfm";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Citation } from "./chat/Citation";
|
||||
import { Source } from "./chat/types";
|
||||
import type { Source } from "./chat/types";
|
||||
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
||||
import {
|
||||
oneLight,
|
||||
oneDark,
|
||||
} from "react-syntax-highlighter/dist/cjs/styles/prism";
|
||||
import { oneLight, oneDark } from "react-syntax-highlighter/dist/cjs/styles/prism";
|
||||
import { Check, Copy } from "lucide-react";
|
||||
import { useTheme } from "next-themes";
|
||||
import CopyButton from "./copy-button";
|
||||
|
@ -68,12 +65,8 @@ export function MarkdownViewer({
|
|||
: children;
|
||||
return <li {...props}>{processedChildren}</li>;
|
||||
},
|
||||
ul: ({ node, ...props }: any) => (
|
||||
<ul className="list-disc pl-5 my-2" {...props} />
|
||||
),
|
||||
ol: ({ node, ...props }: any) => (
|
||||
<ol className="list-decimal pl-5 my-2" {...props} />
|
||||
),
|
||||
ul: ({ node, ...props }: any) => <ul className="list-disc pl-5 my-2" {...props} />,
|
||||
ol: ({ node, ...props }: any) => <ol className="list-decimal pl-5 my-2" {...props} />,
|
||||
h1: ({ node, children, ...props }: any) => {
|
||||
const processedChildren = getCitationSource
|
||||
? processCitationsInReactChildren(children, getCitationSource)
|
||||
|
@ -115,14 +108,9 @@ export function MarkdownViewer({
|
|||
);
|
||||
},
|
||||
blockquote: ({ node, ...props }: any) => (
|
||||
<blockquote
|
||||
className="border-l-4 border-muted pl-4 italic my-2"
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
hr: ({ node, ...props }: any) => (
|
||||
<hr className="my-4 border-muted" {...props} />
|
||||
<blockquote className="border-l-4 border-muted pl-4 italic my-2" {...props} />
|
||||
),
|
||||
hr: ({ node, ...props }: any) => <hr className="my-4 border-muted" {...props} />,
|
||||
img: ({ node, ...props }: any) => (
|
||||
<img className="max-w-full h-auto my-4 rounded" {...props} />
|
||||
),
|
||||
|
@ -161,10 +149,7 @@ export function MarkdownViewer({
|
|||
}, [getCitationSource]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn("prose prose-sm dark:prose-invert max-w-none", className)}
|
||||
ref={ref}
|
||||
>
|
||||
<div className={cn("prose prose-sm dark:prose-invert max-w-none", className)} ref={ref}>
|
||||
<ReactMarkdown
|
||||
rehypePlugins={[rehypeRaw, rehypeSanitize]}
|
||||
remarkPlugins={[remarkGfm]}
|
||||
|
@ -178,13 +163,7 @@ export function MarkdownViewer({
|
|||
}
|
||||
|
||||
// Code block component with syntax highlighting and copy functionality
|
||||
const CodeBlock = ({
|
||||
children,
|
||||
language,
|
||||
}: {
|
||||
children: string;
|
||||
language: string;
|
||||
}) => {
|
||||
const CodeBlock = ({ children, language }: { children: string; language: string }) => {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const { resolvedTheme, theme } = useTheme();
|
||||
const [mounted, setMounted] = useState(false);
|
||||
|
@ -272,9 +251,7 @@ const CodeBlock = ({
|
|||
) : (
|
||||
<div className="bg-muted p-4 rounded-md">
|
||||
<pre className="m-0 p-0 border-0">
|
||||
<code className="text-xs font-mono border-0 leading-6">
|
||||
{children}
|
||||
</code>
|
||||
<code className="text-xs font-mono border-0 leading-6">{children}</code>
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
|
@ -285,7 +262,7 @@ const CodeBlock = ({
|
|||
// Helper function to process citations within React children
|
||||
const processCitationsInReactChildren = (
|
||||
children: React.ReactNode,
|
||||
getCitationSource: (id: number) => Source | null,
|
||||
getCitationSource: (id: number) => Source | null
|
||||
): React.ReactNode => {
|
||||
// If children is not an array or string, just return it
|
||||
if (!children || (typeof children !== "string" && !Array.isArray(children))) {
|
||||
|
@ -313,7 +290,7 @@ const processCitationsInReactChildren = (
|
|||
// Process citation references in text content
|
||||
const processCitationsInText = (
|
||||
text: string,
|
||||
getCitationSource: (id: number) => Source | null,
|
||||
getCitationSource: (id: number) => Source | null
|
||||
): React.ReactNode[] => {
|
||||
// Use improved regex to catch citation numbers more reliably
|
||||
// This will match patterns like [1], [42], etc. including when they appear at the end of a line or sentence
|
||||
|
@ -340,7 +317,7 @@ const processCitationsInText = (
|
|||
citationText={match[0]}
|
||||
position={position}
|
||||
source={source}
|
||||
/>,
|
||||
/>
|
||||
);
|
||||
|
||||
lastIndex = match.index + match[0].length;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue