Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions libs/mobile/shared/features/markdown-view/src/lib/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import markdownItMath from 'markdown-it-math/no-default-renderer';
import { colorScheme } from 'nativewind';
import React, { PropsWithChildren, ReactElement, ReactNode, useCallback, useMemo } from 'react';
import { Linking } from 'react-native';
import FitImage from 'react-native-fit-image';
import Markdown, { ASTNode, MarkdownProps, RenderRules } from 'react-native-markdown-display';
import { CitationPrefix } from '@open-webui-react-native/mobile/chat/features/use-citations';
import { CodeBlock } from '@open-webui-react-native/mobile/shared/ui/code-block';
Expand Down Expand Up @@ -39,7 +40,7 @@ export function AppMarkdownView({
onCitationPress,
isContentReady,
textColor: elementTextColor,
...restProps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to break the chat UI:
Screenshot 2026-01-19 at 08 39 42

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

children,
}: AppMarkdownViewProps): ReactElement {
const { isDarkColorScheme } = useColorScheme();
const textColor = elementTextColor || (isDarkColorScheme ? colors.darkTextPrimary : colors.textPrimary);
Expand All @@ -53,7 +54,7 @@ export function AppMarkdownView({
) => {
return (
<CodeBlock
fenceStyle={[inheritedStyles, styles.fence]}
fenceStyle={[inheritedStyles, markdownStyles.fence]}
key={`code-block-${node.key}`}
sourceInfo={node.sourceInfo}
content={node.content}
Expand Down Expand Up @@ -209,6 +210,18 @@ export function AppMarkdownView({
</AppText>
),
table: renderTable,
//NOTE: A props object containing a "key" prop is being spread into JSX error fix
image: (node: ASTNode, children, parent, styles) => {
const uri = node.attributes?.src;

if (!uri) return null;

return <FitImage
key={`image-${node.key}`}
source={{ uri }}
style={styles.image}
resizeMode='contain' />;
},
};
}, [fence, onCitationPress, isContentReady, renderTable]);

Expand All @@ -220,9 +233,9 @@ export function AppMarkdownView({
code_inline: { backgroundColor: isDarkColorScheme ? colors.gray700 : colors.gray75 },
}}
rules={markdownRules}
{...restProps}
markdownit={markdownItInstance}
/>
markdownit={markdownItInstance}>
{children}
</Markdown>
);
}

Expand Down Expand Up @@ -289,4 +302,9 @@ const markdownStyles = createStyles({
backgroundColor: colorScheme.get() === 'dark' ? colors.gray700 : colors.gray75,
textDecorationLine: 'none',
},
fence: {
backgroundColor: colorScheme.get() === 'dark' ? colors.gray700 : colors.gray75,
borderRadius: 8,
padding: 12,
},
});
Loading