Improve text selection handling of links

This commit is contained in:
Paul Frazee
2023-04-11 15:15:03 -07:00
parent d59d701e79
commit dc071bc659
2 changed files with 12 additions and 6 deletions
+7 -2
View File
@@ -1,5 +1,5 @@
import React from 'react'
import {TextStyle, StyleProp} from 'react-native'
import {TextStyle, StyleProp, Text as RNText} from 'react-native'
import {RichText as RichTextObj, AppBskyRichtextFacet} from '@atproto/api'
import {TextLink} from '../Link'
import {Text} from './Text'
@@ -96,7 +96,11 @@ export function RichText({
/>,
)
} else {
els.push(segment.text)
els.push(
<RNText key={key} style={[style, pal.text, lineHeightStyle]}>
{segment.text}
</RNText>,
)
}
key++
}
@@ -106,6 +110,7 @@ export function RichText({
type={type}
style={[style, pal.text, lineHeightStyle]}
numberOfLines={numberOfLines}
selectable={selectable}
// @ts-ignore web only -prf
dataSet={WORD_WRAP}>
{els}
+5 -4
View File
@@ -2,6 +2,7 @@ import React from 'react'
import {Text as RNText, TextInput, TextProps} from 'react-native'
import {s, lh} from 'lib/styles'
import {useTheme, TypographyVariant} from 'lib/ThemeContext'
import {isNative} from 'platform/detection'
export type CustomTextProps = TextProps & {
type?: TypographyVariant
@@ -19,15 +20,15 @@ export function Text({
const theme = useTheme()
const typography = theme.typography[type]
const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined
if (selectable) {
if (selectable && isNative) {
return (
<TextInput
value={children as string}
scrollEnabled={false}
style={[s.black, typography, lineHeightStyle, style]}
editable={false}
multiline={true}
/>
multiline={true}>
{children}
</TextInput>
)
}
return (