import type {PortableTextMarkComponent} from '@portabletext/react' import type {TypedObject} from '@portabletext/types' import {useCallback} from 'react' import {Linking, Text} from 'react-native' import {markStyles} from './styles' interface DefaultLink extends TypedObject { _type: 'link' href: string } const Link: PortableTextMarkComponent = ({children, value}) => { const href = value?.href const onPress = useCallback(() => (href ? Linking.openURL(href) : undefined), [href]) return ( {children} ) } export const defaultMarks: Record = { 'em': ({children}) => {children}, 'strong': ({children}) => {children}, 'code': ({children}) => {children}, 'underline': ({children}) => {children}, 'strike-through': ({children}) => {children}, 'link': Link, }