@@ -3,6 +3,7 @@ import markdownItMath from 'markdown-it-math/no-default-renderer';
33import { colorScheme } from 'nativewind' ;
44import React , { PropsWithChildren , ReactElement , ReactNode , useCallback , useMemo } from 'react' ;
55import { Linking } from 'react-native' ;
6+ import FitImage from 'react-native-fit-image' ;
67import Markdown , { ASTNode , MarkdownProps , RenderRules } from 'react-native-markdown-display' ;
78import { CitationPrefix } from '@open-webui-react-native/mobile/chat/features/use-citations' ;
89import { CodeBlock } from '@open-webui-react-native/mobile/shared/ui/code-block' ;
@@ -39,6 +40,7 @@ export function AppMarkdownView({
3940 onCitationPress,
4041 isContentReady,
4142 textColor : elementTextColor ,
43+ children,
4244} : AppMarkdownViewProps ) : ReactElement {
4345 const { isDarkColorScheme } = useColorScheme ( ) ;
4446 const textColor = elementTextColor || ( isDarkColorScheme ? colors . darkTextPrimary : colors . textPrimary ) ;
@@ -208,6 +210,18 @@ export function AppMarkdownView({
208210 </ AppText >
209211 ) ,
210212 table : renderTable ,
213+ //NOTE: A props object containing a "key" prop is being spread into JSX error fix
214+ image : ( node : ASTNode , children , parent , styles ) => {
215+ const uri = node . attributes ?. src ;
216+
217+ if ( ! uri ) return null ;
218+
219+ return < FitImage
220+ key = { `image-${ node . key } ` }
221+ source = { { uri } }
222+ style = { styles . image }
223+ resizeMode = 'contain' /> ;
224+ } ,
211225 } ;
212226 } , [ fence , onCitationPress , isContentReady , renderTable ] ) ;
213227
@@ -219,8 +233,9 @@ export function AppMarkdownView({
219233 code_inline : { backgroundColor : isDarkColorScheme ? colors . gray700 : colors . gray75 } ,
220234 } }
221235 rules = { markdownRules }
222- markdownit = { markdownItInstance }
223- />
236+ markdownit = { markdownItInstance } >
237+ { children }
238+ </ Markdown >
224239 ) ;
225240}
226241
0 commit comments