Improve text selection handling of links
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react'
|
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 {RichText as RichTextObj, AppBskyRichtextFacet} from '@atproto/api'
|
||||||
import {TextLink} from '../Link'
|
import {TextLink} from '../Link'
|
||||||
import {Text} from './Text'
|
import {Text} from './Text'
|
||||||
@@ -96,7 +96,11 @@ export function RichText({
|
|||||||
/>,
|
/>,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
els.push(segment.text)
|
els.push(
|
||||||
|
<RNText key={key} style={[style, pal.text, lineHeightStyle]}>
|
||||||
|
{segment.text}
|
||||||
|
</RNText>,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
key++
|
key++
|
||||||
}
|
}
|
||||||
@@ -106,6 +110,7 @@ export function RichText({
|
|||||||
type={type}
|
type={type}
|
||||||
style={[style, pal.text, lineHeightStyle]}
|
style={[style, pal.text, lineHeightStyle]}
|
||||||
numberOfLines={numberOfLines}
|
numberOfLines={numberOfLines}
|
||||||
|
selectable={selectable}
|
||||||
// @ts-ignore web only -prf
|
// @ts-ignore web only -prf
|
||||||
dataSet={WORD_WRAP}>
|
dataSet={WORD_WRAP}>
|
||||||
{els}
|
{els}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React from 'react'
|
|||||||
import {Text as RNText, TextInput, TextProps} from 'react-native'
|
import {Text as RNText, TextInput, TextProps} from 'react-native'
|
||||||
import {s, lh} from 'lib/styles'
|
import {s, lh} from 'lib/styles'
|
||||||
import {useTheme, TypographyVariant} from 'lib/ThemeContext'
|
import {useTheme, TypographyVariant} from 'lib/ThemeContext'
|
||||||
|
import {isNative} from 'platform/detection'
|
||||||
|
|
||||||
export type CustomTextProps = TextProps & {
|
export type CustomTextProps = TextProps & {
|
||||||
type?: TypographyVariant
|
type?: TypographyVariant
|
||||||
@@ -19,15 +20,15 @@ export function Text({
|
|||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
const typography = theme.typography[type]
|
const typography = theme.typography[type]
|
||||||
const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined
|
const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined
|
||||||
if (selectable) {
|
if (selectable && isNative) {
|
||||||
return (
|
return (
|
||||||
<TextInput
|
<TextInput
|
||||||
value={children as string}
|
|
||||||
scrollEnabled={false}
|
scrollEnabled={false}
|
||||||
style={[s.black, typography, lineHeightStyle, style]}
|
style={[s.black, typography, lineHeightStyle, style]}
|
||||||
editable={false}
|
editable={false}
|
||||||
multiline={true}
|
multiline={true}>
|
||||||
/>
|
{children}
|
||||||
|
</TextInput>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user