import React from 'react' import { StyleSheet } from 'react-native' import { Linking } from '../../utils/native_adapters' import { parseSimpleMarkdown } from '../../utils/parse_simple_markdown' import { Text, TextInlineButton } from '../display' interface Props { text: string } export function MessageMarkdown({ text }: Props) { if (!text) return null // Skip markdown for excessively long messages for performance reasons if (text.length > 5000) return {text} const parsed = parseSimpleMarkdown(text) return ( {parsed.map((part, i) => { switch (part.type) { case 'bold': return ( {part.content} ) case 'italic': return ( {part.content} ) case 'link': return ( Linking.openURL(part.content)} accessibilityRole="link" accessibilityHint="Opens browser" > {part.content} ) default: return {part.content} } })} ) } const styles = StyleSheet.create({ bold: { fontWeight: 'bold' }, italic: { fontStyle: 'italic' }, })