@@ -12,6 +12,8 @@ import {
1212
1313import { MarkdownTextPrimitive } from "./MarkdownTextPrimitive" ;
1414import { markdownFileIconSource } from "./markdownFileIcons" ;
15+ import { markdownLinkIconSource } from "./markdownLinkIcons" ;
16+ import { resolveMarkdownLinkIcon } from "./markdownLinks" ;
1517import type { NativeMarkdownTextRun } from "./nativeMarkdownText" ;
1618import type {
1719 MarkdownFileContextMenu ,
@@ -177,18 +179,22 @@ export function NativeMarkdownSelectableText(props: {
177179} ) {
178180 const colorScheme = useColorScheme ( ) ;
179181 const menu = useContext ( MarkdownFileContextMenuContext ) ;
180- const containsInlineFileIcon = props . runs . some ( ( run ) => run . fileIcon != null ) ;
182+ const containsInlineIcon = props . runs . some (
183+ ( run ) =>
184+ run . fileIcon != null ||
185+ ( run . externalHost != null && resolveMarkdownLinkIcon ( run . externalHost ) !== null ) ,
186+ ) ;
181187 const attachAndroidText = useCallback (
182188 ( textView : RNText | null ) => {
183- if ( Platform . OS !== "android" || ! containsInlineFileIcon || textView === null ) {
189+ if ( Platform . OS !== "android" || ! containsInlineIcon || textView === null ) {
184190 return ;
185191 }
186192 const reactTag = findNodeHandle ( textView ) ;
187193 if ( reactTag !== null ) {
188194 installMarkdownCopySanitizer ( reactTag ) ;
189195 }
190196 } ,
191- [ containsInlineFileIcon ] ,
197+ [ containsInlineIcon ] ,
192198 ) ;
193199 const occurrences = new Map < string , number > ( ) ;
194200 const prefixedExternalLinks = new Set < string > ( ) ;
@@ -198,6 +204,7 @@ export function NativeMarkdownSelectableText(props: {
198204 occurrences . set ( signature , occurrence + 1 ) ;
199205
200206 let text = run . text ;
207+ let linkIcon = null ;
201208 if ( run . fileIcon && Platform . OS === "ios" ) {
202209 text = `${ INLINE_ATTACHMENT_PREFIX } ${ text } ` ;
203210 } else if ( run . skillName && run . skillLabel ) {
@@ -207,10 +214,15 @@ export function NativeMarkdownSelectableText(props: {
207214 : `$${ run . skillName } ` ;
208215 } else if ( run . externalHost && run . href && ! prefixedExternalLinks . has ( run . href ) ) {
209216 prefixedExternalLinks . add ( run . href ) ;
210- text = `${ EXTERNAL_LINK_PREFIX } ${ text } ` ;
217+ linkIcon = resolveMarkdownLinkIcon ( run . externalHost ) ;
218+ if ( linkIcon === null ) {
219+ text = `${ EXTERNAL_LINK_PREFIX } ${ text } ` ;
220+ } else if ( Platform . OS === "ios" ) {
221+ text = `${ INLINE_ATTACHMENT_PREFIX } ${ text } ` ;
222+ }
211223 }
212224
213- return { key : `${ signature } :${ occurrence } ` , run, text } ;
225+ return { key : `${ signature } :${ occurrence } ` , run, text, linkIcon } ;
214226 } ) ;
215227 // T3MarkdownText only rebuilds its attributed string during native layout. A
216228 // color-only child update can otherwise leave the previous appearance cached.
@@ -248,7 +260,7 @@ export function NativeMarkdownSelectableText(props: {
248260 lineHeight : props . textStyle . lineHeight ,
249261 } }
250262 >
251- { keyedRuns . map ( ( { key, run, text } ) => {
263+ { keyedRuns . map ( ( { key, run, text, linkIcon } ) => {
252264 const href = run . href ;
253265 const contextMenu = run . fileIcon && href ? menu ?. fileContextMenu ( href ) : undefined ;
254266 return (
@@ -260,7 +272,9 @@ export function NativeMarkdownSelectableText(props: {
260272 ? `t3-file:${ Image . resolveAssetSource ( markdownFileIconSource ( run . fileIcon ) ) . uri } `
261273 : run . skillName
262274 ? "t3-skill:sf:cube"
263- : undefined
275+ : linkIcon
276+ ? `t3-link:${ Image . resolveAssetSource ( markdownLinkIconSource ( linkIcon ) ) . uri } `
277+ : undefined
264278 : undefined
265279 }
266280 contextMenuConfig = { contextMenu ? JSON . stringify ( contextMenu ) : undefined }
@@ -284,6 +298,12 @@ export function NativeMarkdownSelectableText(props: {
284298 >
285299 { Platform . OS === "android" && run . fileIcon ? (
286300 < Image source = { markdownFileIconSource ( run . fileIcon ) } style = { styles . inlineIcon } />
301+ ) : Platform . OS === "android" && linkIcon ? (
302+ < Image
303+ source = { markdownLinkIconSource ( linkIcon ) }
304+ style = { styles . inlineIcon }
305+ tintColor = { props . textStyle . linkColor }
306+ />
287307 ) : null }
288308 { text }
289309 </ MarkdownTextPrimitive >
0 commit comments