mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-07-28 17:53:21 +08:00
feat: add message request loader
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { ReactElement } from "react";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import { useUserStore } from "@/store";
|
||||
@ -39,23 +40,20 @@ const MessageView = (props: Props) => {
|
||||
remarkPlugins={[remarkGfm]}
|
||||
components={{
|
||||
pre({ node, className, children, ...props }) {
|
||||
const child = children[0] as ReactElement;
|
||||
const match = /language-(\w+)/.exec(child.props.className || "");
|
||||
const language = match ? match[1] : "plain";
|
||||
return (
|
||||
<pre className={`${className || ""} p-0 w-full`} {...props}>
|
||||
{children}
|
||||
<CodeBlock
|
||||
key={Math.random()}
|
||||
language={language || "plain"}
|
||||
value={String(child.props.children).replace(/\n$/, "")}
|
||||
{...props}
|
||||
/>
|
||||
</pre>
|
||||
);
|
||||
},
|
||||
code({ node, inline, className, children, ...props }) {
|
||||
const match = /language-(\w+)/.exec(className || "");
|
||||
const language = match ? match[1] : "plain";
|
||||
return !inline ? (
|
||||
<CodeBlock key={Math.random()} language={language || "plain"} value={String(children).replace(/\n$/, "")} {...props} />
|
||||
) : (
|
||||
<code className={className} {...props}>
|
||||
{children}
|
||||
</code>
|
||||
);
|
||||
},
|
||||
}}
|
||||
>
|
||||
{message.content}
|
||||
|
Reference in New Issue
Block a user