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

T3MarkdownTextNativeComponent.ts

50 lines1.5 KB

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