Commit 9b3c8a69 by Liu

fix:工单等提交问题

parent 06679be6
......@@ -10,6 +10,8 @@ interface MarkdownDetailProps {
children: ReactNode
/** Disable mermaid/pie rendering (fallback to normal code block). */
disableMermaid?: boolean
/** Disable only pie rendering (fallback to normal code block). */
disablePie?: boolean
}
const sanitizeSchema = {
......@@ -140,7 +142,7 @@ function MermaidBlock({ chart }: { chart: string }) {
)
}
export const MarkdownDetail: React.FC<MarkdownDetailProps> = memo(({ children, disableMermaid }) => {
export const MarkdownDetail: React.FC<MarkdownDetailProps> = memo(({ children, disableMermaid, disablePie }) => {
return (
<ReactMarkdown
rehypePlugins={[rehypeRaw, [rehypeSanitize, sanitizeSchema as any]]}
......@@ -168,7 +170,13 @@ export const MarkdownDetail: React.FC<MarkdownDetailProps> = memo(({ children, d
if (isValidElement(first)) {
const className = String((first.props as any)?.className || '')
const lang = className.match(/language-(\S+)/)?.[1]?.toLowerCase()
if (!disableMermaid && (lang?.startsWith('mermaid') || lang === 'pie')) {
const isMermaid = !!lang?.startsWith('mermaid')
const isPie = lang === 'pie'
// Keep behavior explicit: only mermaid is guarded by disableMermaid, only pie is guarded by disablePie.
if (
(isMermaid && !disableMermaid)
|| (isPie && !disablePie)
) {
const chart = toText((first.props as any)?.children)
return <MermaidBlock chart={chart} />
}
......
......@@ -186,17 +186,9 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
{!!displayedText.length && (
<div style={{ background: '#F7FAFD' }} className={answer.cardList?.length ? 'mb-[20px]' : ''}>
{answer.endAnswerFlag
? (
<MarkdownDetail>
<MarkdownDetail disablePie={!answer.endAnswerFlag}>
{displayedText}
</MarkdownDetail>
)
: (
<pre className="whitespace-pre-wrap break-words">
{displayedText}
</pre>
)}
</div>
)}
{!isTyping
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment