-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathEnrichedTextNativeComponent.ts
More file actions
119 lines (108 loc) · 2.69 KB
/
Copy pathEnrichedTextNativeComponent.ts
File metadata and controls
119 lines (108 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import { codegenNativeComponent, type ColorValue } from 'react-native';
import type { HostComponent, ViewProps } from 'react-native';
import type {
DirectEventHandler,
Float,
Int32,
UnsafeMixed,
} from 'react-native/Libraries/Types/CodegenTypes';
type Heading = {
fontSize?: Float;
bold?: boolean;
};
export interface EnrichedTextHtmlStyleInternal {
h1?: Heading;
h2?: Heading;
h3?: Heading;
h4?: Heading;
h5?: Heading;
h6?: Heading;
blockquote?: {
borderColor?: ColorValue;
borderWidth?: Float;
gapWidth?: Float;
color?: ColorValue;
};
codeblock?: {
color?: ColorValue;
borderRadius?: Float;
backgroundColor?: ColorValue;
};
code?: {
color?: ColorValue;
backgroundColor?: ColorValue;
};
a?: {
color?: ColorValue;
textDecorationLine?: string;
pressColor?: ColorValue;
pressTextDecorationLine?: string;
};
// This is a workaround for the fact that codegen does not support Records.
// On native Android side this will become a ReadableMap, on native iOS we can work with a folly::dynamic object.
mention?: UnsafeMixed;
ol?: {
gapWidth?: Float;
marginLeft?: Float;
markerFontWeight?: string;
markerColor?: ColorValue;
};
ul?: {
bulletColor?: ColorValue;
bulletSize?: Float;
marginLeft?: Float;
gapWidth?: Float;
};
ulCheckbox?: {
gapWidth?: Float;
boxSize?: Float;
marginLeft?: Float;
boxColor?: ColorValue;
};
}
export interface OnLinkPressEvent {
url: string;
}
export interface OnMentionPressEventInternal {
text: string;
indicator: string;
attributes: UnsafeMixed;
}
export interface OnMentionPressEvent {
text: string;
indicator: string;
attributes: Record<string, string>;
}
export interface OnImagePressEvent {
image: {
uri: string;
width: Float;
height: Float;
};
}
export interface NativeProps extends ViewProps {
// Custom props
text: string;
htmlStyle?: EnrichedTextHtmlStyleInternal;
useHtmlNormalizer: boolean;
allowFontScaling?: boolean;
// ReactNative TextProps
ellipsizeMode: string;
numberOfLines: Int32;
selectable: boolean;
selectionColor?: ColorValue;
// Events
onLinkPress?: DirectEventHandler<OnLinkPressEvent>;
onMentionPress?: DirectEventHandler<OnMentionPressEventInternal>;
onImagePress?: DirectEventHandler<OnImagePressEvent>;
// Style related props - used for generating proper setters in component's manager
// These should not be passed as regular props
color?: ColorValue;
fontSize?: Float;
fontFamily?: string;
fontWeight?: string;
fontStyle?: string;
}
export default codegenNativeComponent<NativeProps>('EnrichedTextView', {
interfaceOnly: true,
}) as HostComponent<NativeProps>;