Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

T3MarkdownTextNativeComponent.ts

55 lines1.5 KB

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;
12​
13interface TextLayoutEvent extends TargetedEvent {
14 lines: string[];
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;
27​
28type EllipsizeMode = "head" | "middle" | "tail" | "clip";
29​
30interface NativeProps extends ViewProps {
31 numberOfLines?: Int32;
32 allowFontScaling?: WithDefault<boolean, true>;
33 ellipsizeMode?: WithDefault<EllipsizeMode, "tail">;
34 selectable?: boolean;
35 onTextLayout?: BubblingEventHandler<TextLayoutEvent>;
36 /**
37 * Callback fired when the text selection changes.
38 *
39 * @example
40 * ```tsx
41 * <MarkdownTextPrimitive
42 * onSelectionChange={(event) => {
43 * console.log('Selection:', event.nativeEvent.start, event.nativeEvent.end);
44 * }}
45 * >
46 * Selectable text
47 * </MarkdownTextPrimitive>
48 * ```
49 */
50 onSelectionChange?: BubblingEventHandler<SelectionChangeEvent>;
52​
53export default codegenNativeComponent<NativeProps>("T3MarkdownText", {
54 excludedPlatforms: ["android"],
55});