react-native-typerich 1.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +251 -10
- package/ReactNativeTypeRich.podspec +41 -0
- package/android/src/main/java/com/typerich/TypeRichTextInputView.kt +37 -10
- package/android/src/main/java/com/typerich/TypeRichTextInputViewManager.kt +5 -0
- package/ios/TypeRichTextInputView.h +27 -7
- package/ios/TypeRichTextInputView.mm +809 -26
- package/ios/cpp/TypeRichTextInputViewComponentDescriptor.h +19 -0
- package/ios/cpp/TypeRichTextInputViewShadowNode.h +44 -0
- package/ios/cpp/TypeRichTextInputViewShadowNode.mm +110 -0
- package/ios/cpp/TypeRichTextInputViewState.cpp +10 -0
- package/ios/cpp/TypeRichTextInputViewState.h +22 -0
- package/ios/inputTextView/TypeRichUITextView.h +14 -0
- package/ios/inputTextView/TypeRichUITextView.mm +100 -0
- package/ios/modules/commands/TypeRichTextInputCommands.h +24 -0
- package/ios/modules/commands/TypeRichTextInputCommands.mm +392 -0
- package/ios/utils/StringUtils.h +19 -0
- package/ios/utils/StringUtils.mm +15 -0
- package/ios/utils/TextInputUtils.h +26 -0
- package/ios/utils/TextInputUtils.mm +58 -0
- package/lib/module/TypeRichTextInput.js +13 -36
- package/lib/module/TypeRichTextInput.js.map +1 -1
- package/lib/module/TypeRichTextInputNativeComponent.ts +266 -52
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/TypeRichTextInput.js +4 -0
- package/lib/module/types/TypeRichTextInput.js.map +1 -0
- package/lib/typescript/src/TypeRichTextInput.d.ts +2 -22
- package/lib/typescript/src/TypeRichTextInput.d.ts.map +1 -1
- package/lib/typescript/src/TypeRichTextInputNativeComponent.d.ts +200 -14
- package/lib/typescript/src/TypeRichTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/TypeRichTextInput.d.ts +95 -0
- package/lib/typescript/src/types/TypeRichTextInput.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/TypeRichTextInput.tsx +20 -70
- package/src/TypeRichTextInputNativeComponent.ts +266 -52
- package/src/index.tsx +1 -5
- package/src/types/TypeRichTextInput.tsx +116 -0
- package/TypeRichTextInput.podspec +0 -20
- package/ios/TypeRichTextInputViewManager.mm +0 -27
|
@@ -1,111 +1,325 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
codegenNativeComponent,
|
|
4
|
-
codegenNativeCommands,
|
|
5
|
-
type ViewProps,
|
|
6
|
-
} from 'react-native';
|
|
1
|
+
import { codegenNativeComponent, codegenNativeCommands } from 'react-native';
|
|
7
2
|
import type { HostComponent } from 'react-native';
|
|
3
|
+
import type { ColorValue, ViewProps } from 'react-native';
|
|
8
4
|
import type {
|
|
9
5
|
BubblingEventHandler,
|
|
10
|
-
Double,
|
|
11
6
|
WithDefault,
|
|
12
7
|
DirectEventHandler,
|
|
13
8
|
Float,
|
|
9
|
+
Double,
|
|
14
10
|
Int32,
|
|
15
11
|
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
16
12
|
|
|
13
|
+
type ComponentType = HostComponent<TypeRichTextInputNativeProps>;
|
|
14
|
+
|
|
15
|
+
interface NativeCommands {
|
|
16
|
+
// General commands
|
|
17
|
+
focus: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
18
|
+
blur: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
19
|
+
setText: (viewRef: React.ElementRef<ComponentType>, text: string) => void;
|
|
20
|
+
insertTextAt: (
|
|
21
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
22
|
+
start: Int32,
|
|
23
|
+
end: Int32,
|
|
24
|
+
text: string
|
|
25
|
+
) => void;
|
|
26
|
+
setSelection: (
|
|
27
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
28
|
+
start: Int32,
|
|
29
|
+
end: Int32
|
|
30
|
+
) => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
34
|
+
supportedCommands: [
|
|
35
|
+
// General commands
|
|
36
|
+
'focus',
|
|
37
|
+
'blur',
|
|
38
|
+
'setText',
|
|
39
|
+
'setSelection',
|
|
40
|
+
'insertTextAt',
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export default codegenNativeComponent<TypeRichTextInputNativeProps>(
|
|
45
|
+
'TypeRichTextInputView',
|
|
46
|
+
{
|
|
47
|
+
interfaceOnly: true,
|
|
48
|
+
}
|
|
49
|
+
) as HostComponent<TypeRichTextInputNativeProps>;
|
|
50
|
+
|
|
51
|
+
// types ---------------------------------------------------
|
|
52
|
+
/**
|
|
53
|
+
* Payload for the `onChangeText` event.
|
|
54
|
+
*
|
|
55
|
+
* Emitted whenever the text content of the input changes.
|
|
56
|
+
*/
|
|
17
57
|
export interface OnChangeTextEvent {
|
|
58
|
+
/**
|
|
59
|
+
* The current text value of the input.
|
|
60
|
+
*/
|
|
18
61
|
value: string;
|
|
19
62
|
}
|
|
20
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Payload for the `onChangeSelection` event.
|
|
66
|
+
*
|
|
67
|
+
* Emitted when the text selection or cursor position changes.
|
|
68
|
+
*/
|
|
21
69
|
export interface OnChangeSelectionEvent {
|
|
70
|
+
/**
|
|
71
|
+
* Start index of the selection (inclusive).
|
|
72
|
+
*/
|
|
22
73
|
start: Int32;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* End index of the selection (exclusive).
|
|
77
|
+
*/
|
|
23
78
|
end: Int32;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Full text content at the time of the selection change.
|
|
82
|
+
*/
|
|
24
83
|
text: string;
|
|
25
84
|
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Payload for the `onPasteImage` event.
|
|
88
|
+
*
|
|
89
|
+
* Emitted when an image is pasted into the input from the clipboard,
|
|
90
|
+
* keyboard, or context menu.
|
|
91
|
+
*/
|
|
26
92
|
export interface onPasteImageEventData {
|
|
93
|
+
/**
|
|
94
|
+
* Local URI of the pasted image.
|
|
95
|
+
*/
|
|
27
96
|
uri: string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* MIME type of the image (e.g. `image/png`, `image/jpeg`).
|
|
100
|
+
*/
|
|
28
101
|
type: string;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Original file name of the image, if available.
|
|
105
|
+
*/
|
|
29
106
|
fileName: string;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* File size of the image in bytes.
|
|
110
|
+
*/
|
|
30
111
|
fileSize: Double;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Source from which the image was pasted.
|
|
115
|
+
*
|
|
116
|
+
* - `keyboard` — Inserted via keyboard image/GIF picker
|
|
117
|
+
* - `clipboard` — Pasted directly from the system clipboard and context menu
|
|
118
|
+
* - `context_menu` — Pasted via long-press context menu
|
|
119
|
+
*
|
|
120
|
+
* ⚠️ **Deprecation notice**
|
|
121
|
+
* The `context_menu` source is **temporary** and will be
|
|
122
|
+
* removed in a future release due to platform limitations
|
|
123
|
+
*/
|
|
31
124
|
source: 'keyboard' | 'clipboard' | 'context_menu';
|
|
32
|
-
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Optional error information if the image could not be processed.
|
|
128
|
+
*/
|
|
129
|
+
error?: {
|
|
130
|
+
/**
|
|
131
|
+
* Human-readable error message.
|
|
132
|
+
*/
|
|
133
|
+
message: string;
|
|
134
|
+
};
|
|
33
135
|
}
|
|
34
136
|
|
|
35
137
|
export interface TypeRichTextInputNativeProps extends ViewProps {
|
|
36
|
-
// base props
|
|
138
|
+
// base props ---------------------------------------------------------------
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated
|
|
141
|
+
* ⚠️ Do NOT use this for controlled input.
|
|
142
|
+
*
|
|
143
|
+
* This prop is **not reactive** after mount.
|
|
144
|
+
* Use the `setText()` command instead.
|
|
145
|
+
*/
|
|
37
146
|
value?: string;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Automatically focuses the input when it mounts.
|
|
150
|
+
*/
|
|
38
151
|
autoFocus?: boolean;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Controls whether the input is editable.
|
|
155
|
+
*
|
|
156
|
+
* When set to `false`, the input becomes read-only and cannot be focused.
|
|
157
|
+
*/
|
|
39
158
|
editable?: boolean;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Initial text value applied on mount.
|
|
162
|
+
*
|
|
163
|
+
* Unlike `value`, this is safe to use and does not imply controlled behavior.
|
|
164
|
+
*/
|
|
40
165
|
defaultValue?: string;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Placeholder text displayed when the input is empty.
|
|
169
|
+
*/
|
|
41
170
|
placeholder?: string;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Color of the placeholder text.
|
|
174
|
+
*/
|
|
42
175
|
placeholderTextColor?: ColorValue;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Color of the text cursor (caret).
|
|
179
|
+
* on iOS cursor color will be same as selection color
|
|
180
|
+
*/
|
|
43
181
|
cursorColor?: ColorValue;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Color of the text selection highlight.
|
|
185
|
+
*/
|
|
44
186
|
selectionColor?: ColorValue;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Controls automatic capitalization behavior.
|
|
190
|
+
*
|
|
191
|
+
* values: `"none"`, `"sentences"`, `"words"`, `"characters"`.
|
|
192
|
+
*/
|
|
45
193
|
autoCapitalize?: string;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Enables or disables vertical scrolling.
|
|
197
|
+
*
|
|
198
|
+
* When disabled, the input will expand to fit its content.
|
|
199
|
+
*/
|
|
46
200
|
scrollEnabled?: boolean;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Enables multiline text input.
|
|
204
|
+
*
|
|
205
|
+
* When `true`, the input can span multiple lines.
|
|
206
|
+
*/
|
|
47
207
|
multiline?: boolean;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* ⚠️ **Use with caution**
|
|
211
|
+
*
|
|
212
|
+
* Limits the number of visible text lines.
|
|
213
|
+
*
|
|
214
|
+
* In complex or rich-text scenarios, `numberOfLines` may cause
|
|
215
|
+
* unexpected layout or scrolling issues—especially on iOS.
|
|
216
|
+
*
|
|
217
|
+
* **Recommended approach:**
|
|
218
|
+
* - Set `multiline={true}`
|
|
219
|
+
* - Control height using `maxHeight` instead
|
|
220
|
+
*/
|
|
48
221
|
numberOfLines?: Int32;
|
|
49
|
-
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* **Android only**
|
|
225
|
+
*
|
|
226
|
+
* Enables secure text entry (password mode).
|
|
227
|
+
* Characters are obscured as the user types.
|
|
228
|
+
*/
|
|
229
|
+
secureTextEntry?: boolean; // Android only
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* **iOS only**
|
|
233
|
+
*
|
|
234
|
+
* Controls the keyboard appearance.
|
|
235
|
+
*
|
|
236
|
+
* - `default` — System default appearance
|
|
237
|
+
* - `light` — Light keyboard
|
|
238
|
+
* - `dark` — Dark keyboard
|
|
239
|
+
*/
|
|
50
240
|
keyboardAppearance?: WithDefault<'default' | 'light' | 'dark', 'default'>; // ios only
|
|
51
241
|
|
|
52
|
-
|
|
53
|
-
|
|
242
|
+
/**
|
|
243
|
+
* Disables pasting images from the clipboard.
|
|
244
|
+
*
|
|
245
|
+
* - **iOS:** The “Paste” option is removed from the context menu
|
|
246
|
+
* when the clipboard contains only images.
|
|
247
|
+
* - **Android:** Stickers and GIF inputs are disabled, but the
|
|
248
|
+
* paste option may still appear due to platform limitations.
|
|
249
|
+
*/
|
|
250
|
+
disableImagePasting?: boolean;
|
|
54
251
|
|
|
55
|
-
// event callbacks
|
|
252
|
+
// event callbacks ---------------------------------------------------------------
|
|
253
|
+
/**
|
|
254
|
+
* Called when the input receives focus.
|
|
255
|
+
*/
|
|
56
256
|
onInputFocus?: DirectEventHandler<null>;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Called when the input loses focus.
|
|
260
|
+
*/
|
|
57
261
|
onInputBlur?: DirectEventHandler<null>;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Called whenever the text content changes.
|
|
265
|
+
*/
|
|
58
266
|
onChangeText?: DirectEventHandler<OnChangeTextEvent>;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Called when the text selection changes.
|
|
270
|
+
*/
|
|
59
271
|
onChangeSelection?: DirectEventHandler<OnChangeSelectionEvent>;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Called when an image is pasted from the clipboard.
|
|
275
|
+
* Emits {@link onPasteImageEventData}.
|
|
276
|
+
*/
|
|
60
277
|
onPasteImage?: BubblingEventHandler<onPasteImageEventData>;
|
|
61
278
|
|
|
62
279
|
// Style related props - used for generating proper setters in component's manager
|
|
63
280
|
// These should not be passed as regular props
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Text color.
|
|
284
|
+
*/
|
|
64
285
|
color?: ColorValue;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Font size of the text.
|
|
289
|
+
*/
|
|
65
290
|
fontSize?: Float;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Font family name.
|
|
294
|
+
*/
|
|
66
295
|
fontFamily?: string;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Font weight.
|
|
299
|
+
*
|
|
300
|
+
* Example values: `"normal"`, `"bold"`, `"100"`–`"900"`.
|
|
301
|
+
*/
|
|
67
302
|
fontWeight?: string;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Font style.
|
|
306
|
+
*
|
|
307
|
+
* Example values: `"normal"`, `"italic"`.
|
|
308
|
+
*/
|
|
68
309
|
fontStyle?: string;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Line height of the text.
|
|
313
|
+
*/
|
|
69
314
|
lineHeight?: Float;
|
|
70
315
|
|
|
71
|
-
|
|
316
|
+
/**
|
|
317
|
+
* ⚠️ **Use with caution**
|
|
318
|
+
* Enabling this prop fixes input flickering while auto growing.
|
|
319
|
+
* However, it's still experimental and not tested well.
|
|
320
|
+
* it's causing some strange issues.
|
|
321
|
+
* See: https://github.com/software-mansion/react-native-enriched/issues/229
|
|
322
|
+
* const ANDROID_EXPERIMENTAL_SYNCHRONOUS_EVENTS = false;
|
|
323
|
+
*/
|
|
72
324
|
androidExperimentalSynchronousEvents?: boolean;
|
|
73
325
|
}
|
|
74
|
-
|
|
75
|
-
type ComponentType = HostComponent<TypeRichTextInputNativeProps>;
|
|
76
|
-
|
|
77
|
-
interface NativeCommands {
|
|
78
|
-
// General commands
|
|
79
|
-
focus: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
80
|
-
blur: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
81
|
-
setText: (viewRef: React.ElementRef<ComponentType>, text: string) => void;
|
|
82
|
-
insertTextAt: (
|
|
83
|
-
viewRef: React.ElementRef<ComponentType>,
|
|
84
|
-
start: Int32,
|
|
85
|
-
end: Int32,
|
|
86
|
-
text: string
|
|
87
|
-
) => void;
|
|
88
|
-
setSelection: (
|
|
89
|
-
viewRef: React.ElementRef<ComponentType>,
|
|
90
|
-
start: Int32,
|
|
91
|
-
end: Int32
|
|
92
|
-
) => void;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
96
|
-
supportedCommands: [
|
|
97
|
-
// General commands
|
|
98
|
-
'focus',
|
|
99
|
-
'blur',
|
|
100
|
-
'setText',
|
|
101
|
-
'setSelection',
|
|
102
|
-
'insertTextAt',
|
|
103
|
-
],
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
export default codegenNativeComponent<TypeRichTextInputNativeProps>(
|
|
107
|
-
'TypeRichTextInputView',
|
|
108
|
-
{
|
|
109
|
-
interfaceOnly: true,
|
|
110
|
-
}
|
|
111
|
-
) as HostComponent<TypeRichTextInputNativeProps>;
|
package/lib/module/index.js
CHANGED
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","TypeRichTextInput"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,iBAAiB,QAAQ,wBAAqB;AAClE,cAAc,oCAAoC;AAClD,cAAc,wBAAqB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["default","TypeRichTextInput"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,iBAAiB,QAAQ,wBAAqB;AAClE,cAAc,oCAAoC;AAClD,cAAc,wBAAqB;AACnC,cAAc,8BAA2B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/TypeRichTextInput.tsx"],"mappings":"","ignoreList":[]}
|
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TypeRichTextInputProps, TypeRichTextInputRef } from './types/TypeRichTextInput';
|
|
2
2
|
type MaybeNativeEvent<T> = T | {
|
|
3
3
|
nativeEvent: T;
|
|
4
4
|
};
|
|
5
5
|
export declare function normalizeEvent<T>(event: MaybeNativeEvent<T>): T;
|
|
6
|
-
export interface TypeRichTextInputProps extends Omit<TypeRichTextInputNativeProps, 'onChangeText' | 'onChangeSelection' | 'onInputFocus' | 'onInputBlur' | 'onPasteImage'> {
|
|
7
|
-
onFocus?: () => void;
|
|
8
|
-
onBlur?: () => void;
|
|
9
|
-
onChangeText?: (value: string) => void;
|
|
10
|
-
onChangeSelection?: (event: {
|
|
11
|
-
start: number;
|
|
12
|
-
end: number;
|
|
13
|
-
text: string;
|
|
14
|
-
}) => void;
|
|
15
|
-
onPasteImageData?: (data: onPasteImageEventData) => void;
|
|
16
|
-
}
|
|
17
|
-
export interface TypeRichTextInputRef {
|
|
18
|
-
focus: () => void;
|
|
19
|
-
blur: () => void;
|
|
20
|
-
setText: (text: string) => void;
|
|
21
|
-
insertTextAt: (start: number, end: number, text: string) => void;
|
|
22
|
-
setSelection: (start: number, end: number) => void;
|
|
23
|
-
getNativeRef: () => any | null;
|
|
24
|
-
}
|
|
25
6
|
/**
|
|
26
7
|
* TypeRichTextInput
|
|
27
8
|
*
|
|
@@ -30,8 +11,7 @@ export interface TypeRichTextInputRef {
|
|
|
30
11
|
* - Fabric-based rendering
|
|
31
12
|
* - custom ShadowNode on Android
|
|
32
13
|
*
|
|
33
|
-
* iOS support is currently
|
|
34
|
-
* we are planning to add support for ios too soon
|
|
14
|
+
* iOS support is currently in Beta Stage
|
|
35
15
|
*/
|
|
36
16
|
declare const TypeRichTextInput: import("react").ForwardRefExoticComponent<TypeRichTextInputProps & import("react").RefAttributes<TypeRichTextInputRef>>;
|
|
37
17
|
export default TypeRichTextInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeRichTextInput.d.ts","sourceRoot":"","sources":["../../../src/TypeRichTextInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TypeRichTextInput.d.ts","sourceRoot":"","sources":["../../../src/TypeRichTextInput.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AAEnC,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,WAAW,EAAE,CAAC,CAAA;CAAE,CAAC;AAElD,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,CAK/D;AAED;;;;;;;;;GASG;AACH,QAAA,MAAM,iBAAiB,yHAuFtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,62 +1,248 @@
|
|
|
1
|
-
import type { ColorValue } from 'react-native';
|
|
2
|
-
import { type ViewProps } from 'react-native';
|
|
3
1
|
import type { HostComponent } from 'react-native';
|
|
4
|
-
import type {
|
|
2
|
+
import type { ColorValue, ViewProps } from 'react-native';
|
|
3
|
+
import type { BubblingEventHandler, WithDefault, DirectEventHandler, Float, Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
type ComponentType = HostComponent<TypeRichTextInputNativeProps>;
|
|
5
|
+
interface NativeCommands {
|
|
6
|
+
focus: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
7
|
+
blur: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
8
|
+
setText: (viewRef: React.ElementRef<ComponentType>, text: string) => void;
|
|
9
|
+
insertTextAt: (viewRef: React.ElementRef<ComponentType>, start: Int32, end: Int32, text: string) => void;
|
|
10
|
+
setSelection: (viewRef: React.ElementRef<ComponentType>, start: Int32, end: Int32) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const Commands: NativeCommands;
|
|
13
|
+
declare const _default: HostComponent<TypeRichTextInputNativeProps>;
|
|
14
|
+
export default _default;
|
|
15
|
+
/**
|
|
16
|
+
* Payload for the `onChangeText` event.
|
|
17
|
+
*
|
|
18
|
+
* Emitted whenever the text content of the input changes.
|
|
19
|
+
*/
|
|
5
20
|
export interface OnChangeTextEvent {
|
|
21
|
+
/**
|
|
22
|
+
* The current text value of the input.
|
|
23
|
+
*/
|
|
6
24
|
value: string;
|
|
7
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Payload for the `onChangeSelection` event.
|
|
28
|
+
*
|
|
29
|
+
* Emitted when the text selection or cursor position changes.
|
|
30
|
+
*/
|
|
8
31
|
export interface OnChangeSelectionEvent {
|
|
32
|
+
/**
|
|
33
|
+
* Start index of the selection (inclusive).
|
|
34
|
+
*/
|
|
9
35
|
start: Int32;
|
|
36
|
+
/**
|
|
37
|
+
* End index of the selection (exclusive).
|
|
38
|
+
*/
|
|
10
39
|
end: Int32;
|
|
40
|
+
/**
|
|
41
|
+
* Full text content at the time of the selection change.
|
|
42
|
+
*/
|
|
11
43
|
text: string;
|
|
12
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Payload for the `onPasteImage` event.
|
|
47
|
+
*
|
|
48
|
+
* Emitted when an image is pasted into the input from the clipboard,
|
|
49
|
+
* keyboard, or context menu.
|
|
50
|
+
*/
|
|
13
51
|
export interface onPasteImageEventData {
|
|
52
|
+
/**
|
|
53
|
+
* Local URI of the pasted image.
|
|
54
|
+
*/
|
|
14
55
|
uri: string;
|
|
56
|
+
/**
|
|
57
|
+
* MIME type of the image (e.g. `image/png`, `image/jpeg`).
|
|
58
|
+
*/
|
|
15
59
|
type: string;
|
|
60
|
+
/**
|
|
61
|
+
* Original file name of the image, if available.
|
|
62
|
+
*/
|
|
16
63
|
fileName: string;
|
|
64
|
+
/**
|
|
65
|
+
* File size of the image in bytes.
|
|
66
|
+
*/
|
|
17
67
|
fileSize: Double;
|
|
68
|
+
/**
|
|
69
|
+
* Source from which the image was pasted.
|
|
70
|
+
*
|
|
71
|
+
* - `keyboard` — Inserted via keyboard image/GIF picker
|
|
72
|
+
* - `clipboard` — Pasted directly from the system clipboard and context menu
|
|
73
|
+
* - `context_menu` — Pasted via long-press context menu
|
|
74
|
+
*
|
|
75
|
+
* ⚠️ **Deprecation notice**
|
|
76
|
+
* The `context_menu` source is **temporary** and will be
|
|
77
|
+
* removed in a future release due to platform limitations
|
|
78
|
+
*/
|
|
18
79
|
source: 'keyboard' | 'clipboard' | 'context_menu';
|
|
80
|
+
/**
|
|
81
|
+
* Optional error information if the image could not be processed.
|
|
82
|
+
*/
|
|
19
83
|
error?: {
|
|
84
|
+
/**
|
|
85
|
+
* Human-readable error message.
|
|
86
|
+
*/
|
|
20
87
|
message: string;
|
|
21
88
|
};
|
|
22
89
|
}
|
|
23
90
|
export interface TypeRichTextInputNativeProps extends ViewProps {
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated
|
|
93
|
+
* ⚠️ Do NOT use this for controlled input.
|
|
94
|
+
*
|
|
95
|
+
* This prop is **not reactive** after mount.
|
|
96
|
+
* Use the `setText()` command instead.
|
|
97
|
+
*/
|
|
24
98
|
value?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Automatically focuses the input when it mounts.
|
|
101
|
+
*/
|
|
25
102
|
autoFocus?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Controls whether the input is editable.
|
|
105
|
+
*
|
|
106
|
+
* When set to `false`, the input becomes read-only and cannot be focused.
|
|
107
|
+
*/
|
|
26
108
|
editable?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Initial text value applied on mount.
|
|
111
|
+
*
|
|
112
|
+
* Unlike `value`, this is safe to use and does not imply controlled behavior.
|
|
113
|
+
*/
|
|
27
114
|
defaultValue?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Placeholder text displayed when the input is empty.
|
|
117
|
+
*/
|
|
28
118
|
placeholder?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Color of the placeholder text.
|
|
121
|
+
*/
|
|
29
122
|
placeholderTextColor?: ColorValue;
|
|
123
|
+
/**
|
|
124
|
+
* Color of the text cursor (caret).
|
|
125
|
+
* on iOS cursor color will be same as selection color
|
|
126
|
+
*/
|
|
30
127
|
cursorColor?: ColorValue;
|
|
128
|
+
/**
|
|
129
|
+
* Color of the text selection highlight.
|
|
130
|
+
*/
|
|
31
131
|
selectionColor?: ColorValue;
|
|
132
|
+
/**
|
|
133
|
+
* Controls automatic capitalization behavior.
|
|
134
|
+
*
|
|
135
|
+
* values: `"none"`, `"sentences"`, `"words"`, `"characters"`.
|
|
136
|
+
*/
|
|
32
137
|
autoCapitalize?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Enables or disables vertical scrolling.
|
|
140
|
+
*
|
|
141
|
+
* When disabled, the input will expand to fit its content.
|
|
142
|
+
*/
|
|
33
143
|
scrollEnabled?: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Enables multiline text input.
|
|
146
|
+
*
|
|
147
|
+
* When `true`, the input can span multiple lines.
|
|
148
|
+
*/
|
|
34
149
|
multiline?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* ⚠️ **Use with caution**
|
|
152
|
+
*
|
|
153
|
+
* Limits the number of visible text lines.
|
|
154
|
+
*
|
|
155
|
+
* In complex or rich-text scenarios, `numberOfLines` may cause
|
|
156
|
+
* unexpected layout or scrolling issues—especially on iOS.
|
|
157
|
+
*
|
|
158
|
+
* **Recommended approach:**
|
|
159
|
+
* - Set `multiline={true}`
|
|
160
|
+
* - Control height using `maxHeight` instead
|
|
161
|
+
*/
|
|
35
162
|
numberOfLines?: Int32;
|
|
163
|
+
/**
|
|
164
|
+
* **Android only**
|
|
165
|
+
*
|
|
166
|
+
* Enables secure text entry (password mode).
|
|
167
|
+
* Characters are obscured as the user types.
|
|
168
|
+
*/
|
|
36
169
|
secureTextEntry?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* **iOS only**
|
|
172
|
+
*
|
|
173
|
+
* Controls the keyboard appearance.
|
|
174
|
+
*
|
|
175
|
+
* - `default` — System default appearance
|
|
176
|
+
* - `light` — Light keyboard
|
|
177
|
+
* - `dark` — Dark keyboard
|
|
178
|
+
*/
|
|
37
179
|
keyboardAppearance?: WithDefault<'default' | 'light' | 'dark', 'default'>;
|
|
180
|
+
/**
|
|
181
|
+
* Disables pasting images from the clipboard.
|
|
182
|
+
*
|
|
183
|
+
* - **iOS:** The “Paste” option is removed from the context menu
|
|
184
|
+
* when the clipboard contains only images.
|
|
185
|
+
* - **Android:** Stickers and GIF inputs are disabled, but the
|
|
186
|
+
* paste option may still appear due to platform limitations.
|
|
187
|
+
*/
|
|
188
|
+
disableImagePasting?: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Called when the input receives focus.
|
|
191
|
+
*/
|
|
38
192
|
onInputFocus?: DirectEventHandler<null>;
|
|
193
|
+
/**
|
|
194
|
+
* Called when the input loses focus.
|
|
195
|
+
*/
|
|
39
196
|
onInputBlur?: DirectEventHandler<null>;
|
|
197
|
+
/**
|
|
198
|
+
* Called whenever the text content changes.
|
|
199
|
+
*/
|
|
40
200
|
onChangeText?: DirectEventHandler<OnChangeTextEvent>;
|
|
201
|
+
/**
|
|
202
|
+
* Called when the text selection changes.
|
|
203
|
+
*/
|
|
41
204
|
onChangeSelection?: DirectEventHandler<OnChangeSelectionEvent>;
|
|
205
|
+
/**
|
|
206
|
+
* Called when an image is pasted from the clipboard.
|
|
207
|
+
* Emits {@link onPasteImageEventData}.
|
|
208
|
+
*/
|
|
42
209
|
onPasteImage?: BubblingEventHandler<onPasteImageEventData>;
|
|
210
|
+
/**
|
|
211
|
+
* Text color.
|
|
212
|
+
*/
|
|
43
213
|
color?: ColorValue;
|
|
214
|
+
/**
|
|
215
|
+
* Font size of the text.
|
|
216
|
+
*/
|
|
44
217
|
fontSize?: Float;
|
|
218
|
+
/**
|
|
219
|
+
* Font family name.
|
|
220
|
+
*/
|
|
45
221
|
fontFamily?: string;
|
|
222
|
+
/**
|
|
223
|
+
* Font weight.
|
|
224
|
+
*
|
|
225
|
+
* Example values: `"normal"`, `"bold"`, `"100"`–`"900"`.
|
|
226
|
+
*/
|
|
46
227
|
fontWeight?: string;
|
|
228
|
+
/**
|
|
229
|
+
* Font style.
|
|
230
|
+
*
|
|
231
|
+
* Example values: `"normal"`, `"italic"`.
|
|
232
|
+
*/
|
|
47
233
|
fontStyle?: string;
|
|
234
|
+
/**
|
|
235
|
+
* Line height of the text.
|
|
236
|
+
*/
|
|
48
237
|
lineHeight?: Float;
|
|
238
|
+
/**
|
|
239
|
+
* ⚠️ **Use with caution**
|
|
240
|
+
* Enabling this prop fixes input flickering while auto growing.
|
|
241
|
+
* However, it's still experimental and not tested well.
|
|
242
|
+
* it's causing some strange issues.
|
|
243
|
+
* See: https://github.com/software-mansion/react-native-enriched/issues/229
|
|
244
|
+
* const ANDROID_EXPERIMENTAL_SYNCHRONOUS_EVENTS = false;
|
|
245
|
+
*/
|
|
49
246
|
androidExperimentalSynchronousEvents?: boolean;
|
|
50
247
|
}
|
|
51
|
-
type ComponentType = HostComponent<TypeRichTextInputNativeProps>;
|
|
52
|
-
interface NativeCommands {
|
|
53
|
-
focus: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
54
|
-
blur: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
55
|
-
setText: (viewRef: React.ElementRef<ComponentType>, text: string) => void;
|
|
56
|
-
insertTextAt: (viewRef: React.ElementRef<ComponentType>, start: Int32, end: Int32, text: string) => void;
|
|
57
|
-
setSelection: (viewRef: React.ElementRef<ComponentType>, start: Int32, end: Int32) => void;
|
|
58
|
-
}
|
|
59
|
-
export declare const Commands: NativeCommands;
|
|
60
|
-
declare const _default: HostComponent<TypeRichTextInputNativeProps>;
|
|
61
|
-
export default _default;
|
|
62
248
|
//# sourceMappingURL=TypeRichTextInputNativeComponent.d.ts.map
|