Open History to see the last commit
1import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
2import type { ViewProps } from "react-native";
3import type {
4 BubblingEventHandler,
5 Int32,
6 WithDefault,
7} from "react-native/Libraries/Types/CodegenTypes";
8
9interface TargetedEvent {
10 target: Int32;
11}
12
13interface TextLayoutEvent extends TargetedEvent {
14 lines: string[];
15}
16
17/**
18 * Event fired when text selection changes in the MarkdownTextPrimitive.
19 * @property target - The view tag identifier
20 * @property start - The start index of the selected range (0-based)
21 * @property end - The end index of the selected range (0-based, exclusive)
22 */
23interface SelectionChangeEvent extends TargetedEvent {
24 start: Int32;
25 end: Int32;
26}
27
28type EllipsizeMode = "head" | "middle" | "tail" | "clip";
29
30interface NativeProps extends ViewProps {
31 contextClipboardConfig?: string;
32 numberOfLines?: Int32;
33 allowFontScaling?: WithDefault<boolean, true>;
34 ellipsizeMode?: WithDefault<EllipsizeMode, "tail">;
35 selectable?: boolean;
36 onTextLayout?: BubblingEventHandler<TextLayoutEvent>;
37 /**
38 * Callback fired when the text selection changes.
39 *
40 * @example
41 * ```tsx
42 * <MarkdownTextPrimitive
43 * onSelectionChange={(event) => {
44 * console.log('Selection:', event.nativeEvent.start, event.nativeEvent.end);
45 * }}
46 * >
47 * Selectable text
48 * </MarkdownTextPrimitive>
49 * ```
50 */
51 onSelectionChange?: BubblingEventHandler<SelectionChangeEvent>;
52}
53
54export default codegenNativeComponent<NativeProps>("T3MarkdownText", {
55 excludedPlatforms: ["android"],
56});