@@ -1083,6 +1083,7 @@ function UncachedShikiCodeBlock({
10831083}
10841084
10851085interface MarkdownFileLinkProps {
1086+ children ?: ReactNode ;
10861087 href : string ;
10871088 targetPath : string ;
10881089 iconPath : string ;
@@ -1782,6 +1783,7 @@ function MarkdownExternalLinkContent({
17821783}
17831784
17841785const MarkdownFileLink = memo ( function MarkdownFileLink ( {
1786+ children,
17851787 href,
17861788 targetPath,
17871789 iconPath,
@@ -2064,6 +2066,15 @@ const MarkdownFileLink = memo(function MarkdownFileLink({
20642066 canOpenInPanel,
20652067 } ) ;
20662068
2069+ const chip = < FileTagChipContent path = { iconPath } label = { label } theme = { theme } selectable /> ;
2070+ const content = children ? (
2071+ < >
2072+ { children } (< span className = { CHAT_FILE_TAG_CHIP_CLASS_NAME } > { chip } </ span > )
2073+ </ >
2074+ ) : (
2075+ chip
2076+ ) ;
2077+
20672078 return (
20682079 < Tooltip >
20692080 < TooltipTrigger
@@ -2072,7 +2083,7 @@ const MarkdownFileLink = memo(function MarkdownFileLink({
20722083 < a
20732084 href = { href }
20742085 className = { cn (
2075- CHAT_FILE_TAG_CHIP_CLASS_NAME ,
2086+ children ? "text-left" : CHAT_FILE_TAG_CHIP_CLASS_NAME ,
20762087 MARKDOWN_FILE_LINK_CLASS_NAME ,
20772088 className ,
20782089 ) }
@@ -2092,15 +2103,15 @@ const MarkdownFileLink = memo(function MarkdownFileLink({
20922103 } }
20932104 onContextMenu = { handleContextMenu }
20942105 >
2095- < FileTagChipContent path = { iconPath } label = { label } theme = { theme } selectable />
2106+ { content }
20962107 </ a >
20972108 ) : (
20982109 < button
20992110 type = "button"
2100- aria-label = { `File options for ${ label } ` }
2111+ aria-label = { children ? undefined : `File options for ${ label } ` }
21012112 aria-haspopup = "menu"
21022113 className = { cn (
2103- CHAT_FILE_TAG_CHIP_CLASS_NAME ,
2114+ children ? "text-left" : CHAT_FILE_TAG_CHIP_CLASS_NAME ,
21042115 MARKDOWN_FILE_LINK_CLASS_NAME ,
21052116 "select-text" ,
21062117 className ,
@@ -2109,7 +2120,7 @@ const MarkdownFileLink = memo(function MarkdownFileLink({
21092120 onClick = { handleContextMenu }
21102121 onContextMenu = { handleContextMenu }
21112122 >
2112- < FileTagChipContent path = { iconPath } label = { label } theme = { theme } selectable />
2123+ { content }
21132124 </ button >
21142125 )
21152126 }
@@ -2133,6 +2144,7 @@ function areMarkdownFileLinkPropsEqual(
21332144 next : Readonly < MarkdownFileLinkProps > ,
21342145) : boolean {
21352146 return (
2147+ previous . children === next . children &&
21362148 previous . href === next . href &&
21372149 previous . targetPath === next . targetPath &&
21382150 previous . iconPath === next . iconPath &&
@@ -2496,6 +2508,7 @@ function useChatMarkdownState({
24962508 copyMarkdown : string ,
24972509 className ?: string ,
24982510 mediaSource ?: string ,
2511+ children ?: ReactNode ,
24992512 ) => {
25002513 const parentSuffix = fileLinkParentSuffixByPath . get (
25012514 fileLinkMeta . filePath . replaceAll ( "\\" , "/" ) ,
@@ -2554,7 +2567,9 @@ function useChatMarkdownState({
25542567 : undefined
25552568 }
25562569 className = { className }
2557- />
2570+ >
2571+ { children }
2572+ </ MarkdownFileLink >
25582573 ) ;
25592574 } ,
25602575 [
@@ -2967,18 +2982,17 @@ const CHAT_MARKDOWN_COMPONENTS = {
29672982 }
29682983
29692984 const label = nodeToPlainText ( children ) ;
2970- const escapedLabel = ( label || fileLinkMeta . basename )
2985+ const escapedLabel = ( label . trim ( ) ? label : fileLinkMeta . basename )
29712986 . replaceAll ( "\\" , "\\\\" )
29722987 . replaceAll ( "[" , "\\[" )
29732988 . replaceAll ( "]" , "\\]" ) ;
29742989 const copyMarkdown = `[${ escapedLabel } ](${ normalizedHref } )` ;
2975- const chip = fileLinkChip ( fileLinkMeta , copyMarkdown , props . className , normalizedHref ) ;
2976- return isMarkdownFileLinkLabel ( label , normalizedHref ) ? (
2977- chip
2978- ) : (
2979- < span data-markdown-copy = { copyMarkdown } >
2980- { children } ({ chip } )
2981- </ span >
2990+ return fileLinkChip (
2991+ fileLinkMeta ,
2992+ copyMarkdown ,
2993+ props . className ,
2994+ normalizedHref ,
2995+ isMarkdownFileLinkLabel ( label , normalizedHref ) ? undefined : children ,
29822996 ) ;
29832997 } ,
29842998 code : function MarkdownCode ( { node, children, className, ...props } ) {
0 commit comments