| 1 | import { useMemo } from "react"; |
| 2 | import { Platform } from "react-native"; |
| 3 | import type { SelectableMarkdownTextProps } from "./SelectableMarkdownText.types"; |
| 4 | |
| 5 | import { MobileEnrichedMarkdownText } from "./EnrichedMarkdownText"; |
| 6 | import { themeColorWithAlpha } from "../lib/mobileTheme"; |
| 7 | import { useUniwindTheme } from "../lib/useUniwindTheme"; |
| 8 | |
| 9 | export type { |
| 10 | MarkdownFileContextMenu, |
| 11 | MarkdownFileContextMenuAction, |
| 12 | MarkdownImageRenderer, |
| 13 | MarkdownImageRequest, |
| 14 | MarkdownImageSourceResolver, |
| 15 | MarkdownLinkCustomization, |
| 16 | NativeMarkdownTextStyle, |
| 17 | SelectableMarkdownSkill, |
| 18 | } from "./SelectableMarkdownText.types"; |
| 19 | |
| 20 | export function SelectableMarkdownText(props: SelectableMarkdownTextProps) { |
| 21 | const theme = useUniwindTheme(); |
| 22 | const selectionColor = themeColorWithAlpha(theme["--color-focus"], 0.32); |
| 23 | const selectionHandleColor = theme["--color-focus"]; |
| 24 | const textStyle = useMemo( |
| 25 | () => |
| 26 | Platform.OS === "android" |
| 27 | ? { selectionColor, selectionHandleColor, ...props.textStyle } |
| 28 | : props.textStyle, |
| 29 | [props.textStyle, selectionColor, selectionHandleColor], |
| 30 | ); |
| 31 | return <MobileEnrichedMarkdownText {...props} textStyle={textStyle} />; |
| 32 | } |