mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 10:40:07 +08:00
fix: update citation rendering logic in MainTextBlock component
- Added a check to determine if the citation URL is a valid link. - Updated citation tag formatting to conditionally include the link based on the URL validity.
This commit is contained in:
parent
28f1e486e6
commit
5b95d20294
@ -57,8 +57,10 @@ const MainTextBlock: React.FC<Props> = ({ block, citationBlockId, role, mentions
|
||||
title: citation.title || citation.hostname || '',
|
||||
content: citation.content?.substring(0, 200)
|
||||
}
|
||||
const isLink = citation.url.startsWith('http')
|
||||
const citationJson = encodeHTML(JSON.stringify(supData))
|
||||
const citationTag = `[<sup data-citation='${citationJson}'>${citationNum}</sup>](${citation.url})`
|
||||
const supTag = `<sup data-citation='${citationJson}'>${citationNum}</sup>`
|
||||
const citationTag = isLink ? `[${supTag}](${citation.url})` : supTag
|
||||
|
||||
// Replace all occurrences of [citationNum] with the formatted citation
|
||||
const regex = new RegExp(`\\[${citationNum}\\]`, 'g')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user