Преглед изворни кода

fix: fix render undefined when text children is empty (#19135)

tags/1.4.0
Good Wood пре 6 месеци
родитељ
комит
d5ee465bf9
No account linked to committer's email address
1 измењених фајлова са 2 додато и 2 уклоњено
  1. 2
    2
      web/app/components/base/markdown.tsx

+ 2
- 2
web/app/components/base/markdown.tsx Прегледај датотеку

// visit https://reactjs.org/docs/error-decoder.html?invariant=185 for the full message // visit https://reactjs.org/docs/error-decoder.html?invariant=185 for the full message
// or use the non-minified dev environment for full errors and additional helpful warnings. // or use the non-minified dev environment for full errors and additional helpful warnings.


const CodeBlock: any = memo(({ inline, className, children, ...props }: any) => {
const CodeBlock: any = memo(({ inline, className, children = '', ...props }: any) => {
const { theme } = useTheme() const { theme } = useTheme()
const [isSVG, setIsSVG] = useState(true) const [isSVG, setIsSVG] = useState(true)
const match = /language-(\w+)/.exec(className || '') const match = /language-(\w+)/.exec(className || '')
const { onSend } = useChatContext() const { onSend } = useChatContext()
const hidden_text = decodeURIComponent(node.properties.href.toString().split('abbr:')[1]) const hidden_text = decodeURIComponent(node.properties.href.toString().split('abbr:')[1])


return <abbr className="cursor-pointer underline !decoration-primary-700 decoration-dashed" onClick={() => onSend?.(hidden_text)} title={node.children[0]?.value}>{node.children[0]?.value}</abbr>
return <abbr className="cursor-pointer underline !decoration-primary-700 decoration-dashed" onClick={() => onSend?.(hidden_text)} title={node.children[0]?.value || ''}>{node.children[0]?.value || ''}</abbr>
} }
else { else {
return <a {...props} target="_blank" className="cursor-pointer underline !decoration-primary-700 decoration-dashed">{children || 'Download'}</a> return <a {...props} target="_blank" className="cursor-pointer underline !decoration-primary-700 decoration-dashed">{children || 'Download'}</a>

Loading…
Откажи
Сачувај