Open History to see the last commit
1import {
2 SelectableMarkdownText as T3SelectableMarkdownText,
3 type SelectableMarkdownTextProps,
4} from "@t3tools/mobile-markdown-text/renderer";
5import { useMemo } from "react";
6
7import { highlightCodeSnippet } from "../features/review/shikiReviewHighlighter";
8import { themeColorWithAlpha } from "../lib/mobileTheme";
9import { useUniwindTheme } from "../lib/useUniwindTheme";
10
11type MobileSelectableMarkdownTextProps = Omit<SelectableMarkdownTextProps, "highlightCode">;
12
13export type {
14 MarkdownImageRequest,
15 NativeMarkdownTextStyle,
16 SelectableMarkdownSkill,
17} from "@t3tools/mobile-markdown-text/types";
18
19// The renderer falls back to React Native Text outside iOS, so Android can use
20// the same Markdown chunking while retaining native text selection.
21export function hasNativeSelectableMarkdownText(): boolean {
22 return true;
23}
24
25export function SelectableMarkdownText(props: MobileSelectableMarkdownTextProps) {
26 const theme = useUniwindTheme();
27 const selectionColor = themeColorWithAlpha(theme["--color-focus"], 0.32);
28 const selectionHandleColor = theme["--color-focus"];
29 const textStyle = useMemo(
30 () => ({ selectionColor, selectionHandleColor, ...props.textStyle }),
31 [props.textStyle, selectionColor, selectionHandleColor],
32 );
33 return (
34 <T3SelectableMarkdownText
35 {...props}
36 textStyle={textStyle}
37 highlightCode={highlightCodeSnippet}
38 />
39 );
40}