fix: 修复 Markdown 渲染的 typography 插件和 code block 样式
- 安装 @tailwindcss/typography 并在 index.css 添加 @plugin 指令,使 prose 样式生效 - 在 AiPanel.tsx 中为 ReactMarkdown 添加 pre 组件,并为 code 组件增加 className 参数,区分 inline code 与 code block(兼容 react-markdown v10) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
bf66b269d4
commit
5faf8aa35e
@@ -250,7 +250,14 @@ export function AiPanel() {
|
||||
ul: ({children}) => <ul className="list-disc pl-4 mb-1">{children}</ul>,
|
||||
ol: ({children}) => <ol className="list-decimal pl-4 mb-1">{children}</ol>,
|
||||
li: ({children}) => <li className="mb-0.5">{children}</li>,
|
||||
code: ({children}) => <code className="px-1 rounded text-xs" style={{background:'var(--bg-muted)'}}>{children}</code>,
|
||||
pre: ({children}) => (
|
||||
<pre className="rounded-lg p-3 my-2 overflow-x-auto text-xs" style={{background:'var(--bg-muted)'}}>
|
||||
{children}
|
||||
</pre>
|
||||
),
|
||||
code: ({className, children}) => (
|
||||
<code className={`px-1 rounded text-xs ${className ?? ''}`} style={{background:'var(--bg-muted)'}}>{children}</code>
|
||||
),
|
||||
strong: ({children}) => <strong style={{color:'var(--text)'}}>{children}</strong>,
|
||||
}}
|
||||
>{msg.content}</ReactMarkdown>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@import "tailwindcss";
|
||||
@plugin "@tailwindcss/typography";
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
|
||||
Reference in New Issue
Block a user