@@ -41,45 +41,14 @@ interface CopilotModalMessage {
4141
4242// Modal-specific message component
4343function ModalCopilotMessage ( { message } : CopilotModalMessage ) {
44- const renderCitations = (
45- text : string ,
46- citations ?: Array < { id : number ; title : string ; url : string } >
47- ) => {
48- if ( ! citations || citations . length === 0 ) return text
49-
44+ const renderMarkdown = ( text : string ) => {
5045 let processedText = text
5146
52- // Replace [1], [2], [3] etc. with clickable citation icons
53- processedText = processedText . replace ( / \[ ( \d + ) \] / g, ( match , num ) => {
54- const citationIndex = Number . parseInt ( num ) - 1
55- const citation = citations ?. [ citationIndex ]
56-
57- if ( citation ) {
58- return `<a href="${ citation . url } " target="_blank" rel="noopener noreferrer" class="inline-flex items-center text-primary hover:text-primary/80 text-sm" title="${ citation . title } ">↗</a>`
59- }
60-
61- return match
62- } )
63-
64- // Also replace standalone ↗ symbols with clickable citation links
65- if ( citations && citations . length > 0 ) {
66- let citationIndex = 0
67- processedText = processedText . replace ( / ↗ / g, ( ) => {
68- if ( citationIndex < citations . length ) {
69- const citation = citations [ citationIndex ]
70- citationIndex ++
71- return `<a href="${ citation . url } " target="_blank" rel="noopener noreferrer" class="inline-flex items-center text-primary hover:text-primary/80 text-sm" title="${ citation . title } ">↗</a>`
72- }
73- return '↗'
74- } )
75- }
76-
77- return processedText
78- }
79-
80- const renderMarkdown = ( text : string ) => {
81- // Handle citations first
82- let processedText = renderCitations ( text , message . citations )
47+ // Process markdown links: [text](url)
48+ processedText = processedText . replace (
49+ / \[ ( [ ^ \] ] + ) \] \( ( [ ^ ) ] + ) \) / g,
50+ '<a href="$2" target="_blank" rel="noopener noreferrer" class="text-blue-600 hover:text-blue-800 font-semibold underline transition-colors">$1</a>'
51+ )
8352
8453 // Handle code blocks
8554 processedText = processedText . replace (
0 commit comments