fix: Improve null handling in code block and syntax highlighting
This commit is contained in:
parent
39fe583030
commit
31b0fbf775
@ -60,7 +60,7 @@ export const SyntaxHighlighterProvider: React.FC<PropsWithChildren> = ({ childre
|
||||
|
||||
const mappedLanguage = languageMap[language] || language
|
||||
|
||||
code = code.trimEnd()
|
||||
code = code?.trimEnd() ?? ''
|
||||
const escapedCode = code?.replace(/[<>]/g, (char) => ({ '<': '<', '>': '>' })[char]!)
|
||||
|
||||
try {
|
||||
|
||||
@ -154,6 +154,7 @@ const CopyButton: React.FC<{ text: string; style?: React.CSSProperties }> = ({ t
|
||||
const { t } = useTranslation()
|
||||
|
||||
const onCopy = () => {
|
||||
if (!text) return
|
||||
navigator.clipboard.writeText(text)
|
||||
window.message.success({ content: t('message.copied'), key: 'copy-code' })
|
||||
setCopied(true)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user