1import { useMemo } from "react";
2import { Platform } from "react-native";
3import type { SelectableMarkdownTextProps } from "./SelectableMarkdownText.types";
4
5import { MobileEnrichedMarkdownText } from "./EnrichedMarkdownText";
6import { themeColorWithAlpha } from "../lib/mobileTheme";
7import { useUniwindTheme } from "../lib/useUniwindTheme";
8
9export type {
10 MarkdownFileContextMenu,
11 MarkdownFileContextMenuAction,
12 MarkdownImageRenderer,
13 MarkdownImageRequest,
14 MarkdownImageSourceResolver,
15 MarkdownLinkCustomization,
16 NativeMarkdownTextStyle,
17 SelectableMarkdownSkill,
18} from "./SelectableMarkdownText.types";
19
20export 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}