diff options
author | Eric Bailey <git@esb.lol> | 2024-02-19 10:08:21 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-19 08:08:21 -0800 |
commit | 943acd16aac187ed4eb5f9cea67d6c507aab1ab5 (patch) | |
tree | 8a9960f70d317e5fb564f52b3f8bcb443b4f3280 /src/components/RichText.tsx | |
parent | 7390863a1005eeadbb6dbdcbc47f9cc13298e101 (diff) | |
download | voidsky-943acd16aac187ed4eb5f9cea67d6c507aab1ab5.tar.zst |
Add `selectable` to new text components (#2899)
* Make new text selectable (broken) * Fixes * Fix bad conflict resolution * Remove console
Diffstat (limited to 'src/components/RichText.tsx')
-rw-r--r-- | src/components/RichText.tsx | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/components/RichText.tsx b/src/components/RichText.tsx index 068ee99e0..8aeef9ea1 100644 --- a/src/components/RichText.tsx +++ b/src/components/RichText.tsx @@ -3,7 +3,7 @@ import {RichText as RichTextAPI, AppBskyRichtextFacet} from '@atproto/api' import {atoms as a, TextStyleProp} from '#/alf' import {InlineLink} from '#/components/Link' -import {Text} from '#/components/Typography' +import {Text, TextProps} from '#/components/Typography' import {toShortUrl} from 'lib/strings/url-helpers' import {getAgent} from '#/state/session' @@ -16,13 +16,15 @@ export function RichText({ numberOfLines, disableLinks, resolveFacets = false, -}: TextStyleProp & { - value: RichTextAPI | string - testID?: string - numberOfLines?: number - disableLinks?: boolean - resolveFacets?: boolean -}) { + selectable, +}: TextStyleProp & + Pick<TextProps, 'selectable'> & { + value: RichTextAPI | string + testID?: string + numberOfLines?: number + disableLinks?: boolean + resolveFacets?: boolean + }) { const detected = React.useRef(false) const [richText, setRichText] = React.useState<RichTextAPI>(() => value instanceof RichTextAPI ? value : new RichTextAPI({text: value}), @@ -50,6 +52,7 @@ export function RichText({ if (text.length <= 5 && /^\p{Extended_Pictographic}+$/u.test(text)) { return ( <Text + selectable={selectable} testID={testID} style={[ { @@ -65,6 +68,7 @@ export function RichText({ } return ( <Text + selectable={selectable} testID={testID} style={styles} numberOfLines={numberOfLines} @@ -88,6 +92,7 @@ export function RichText({ ) { els.push( <InlineLink + selectable={selectable} key={key} to={`/profile/${mention.did}`} style={[...styles, {pointerEvents: 'auto'}]} @@ -102,6 +107,7 @@ export function RichText({ } else { els.push( <InlineLink + selectable={selectable} key={key} to={link.uri} style={[...styles, {pointerEvents: 'auto'}]} @@ -120,6 +126,7 @@ export function RichText({ return ( <Text + selectable={selectable} testID={testID} style={styles} numberOfLines={numberOfLines} |