feat: 增强 Markdown 代码块高亮和表格样式

This commit is contained in:
2026-06-03 17:23:43 +08:00
parent 714da2d633
commit a896091d27
11 changed files with 499 additions and 6 deletions

View File

@@ -3,6 +3,9 @@ import Markdown from "markdown-to-jsx/react";
import type { PartProps } from "./types";
import { CodeBlock } from "./CodeBlock";
import { MarkdownTable } from "./MarkdownTable";
interface TextPartProps extends PartProps {
isStreaming: boolean;
role: string;
@@ -16,7 +19,17 @@ export function TextPart({ isStreaming, part, role }: TextPartProps) {
{role === "user" ? (
<Typography.Paragraph className="message-body-text">{text}</Typography.Paragraph>
) : (
<Markdown options={{ optimizeForStreaming: isStreaming }}>{text}</Markdown>
<Markdown
options={{
optimizeForStreaming: isStreaming,
overrides: {
pre: { component: CodeBlock, props: { isStreaming } },
table: MarkdownTable,
},
}}
>
{text}
</Markdown>
)}
</div>
);