@dongsuo/react-native-uitextview 1.0.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.
Files changed (102) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +225 -0
  3. package/android/generated/jni/CMakeLists.txt +36 -0
  4. package/android/generated/jni/RNUITextViewSpec-generated.cpp +22 -0
  5. package/android/generated/jni/RNUITextViewSpec.h +24 -0
  6. package/android/generated/jni/react/renderer/components/RNUITextViewSpec/ComponentDescriptors.cpp +23 -0
  7. package/android/generated/jni/react/renderer/components/RNUITextViewSpec/ComponentDescriptors.h +25 -0
  8. package/android/generated/jni/react/renderer/components/RNUITextViewSpec/EventEmitters.cpp +61 -0
  9. package/android/generated/jni/react/renderer/components/RNUITextViewSpec/EventEmitters.h +49 -0
  10. package/android/generated/jni/react/renderer/components/RNUITextViewSpec/Props.cpp +47 -0
  11. package/android/generated/jni/react/renderer/components/RNUITextViewSpec/Props.h +182 -0
  12. package/android/generated/jni/react/renderer/components/RNUITextViewSpec/RNUITextViewSpecJSI-generated.cpp +17 -0
  13. package/android/generated/jni/react/renderer/components/RNUITextViewSpec/RNUITextViewSpecJSI.h +19 -0
  14. package/android/generated/jni/react/renderer/components/RNUITextViewSpec/ShadowNodes.cpp +18 -0
  15. package/android/generated/jni/react/renderer/components/RNUITextViewSpec/ShadowNodes.h +43 -0
  16. package/android/generated/jni/react/renderer/components/RNUITextViewSpec/States.cpp +16 -0
  17. package/android/generated/jni/react/renderer/components/RNUITextViewSpec/States.h +41 -0
  18. package/ios/RNUITextView.h +23 -0
  19. package/ios/RNUITextView.mm +474 -0
  20. package/ios/RNUITextViewChild.h +24 -0
  21. package/ios/RNUITextViewChild.mm +76 -0
  22. package/ios/RNUITextViewChildComponentDescriptor.h +13 -0
  23. package/ios/RNUITextViewChildShadowNode.cpp +6 -0
  24. package/ios/RNUITextViewChildShadowNode.h +16 -0
  25. package/ios/RNUITextViewComponentDescriptor.h +13 -0
  26. package/ios/RNUITextViewEventEmitter.h +26 -0
  27. package/ios/RNUITextViewManager.mm +36 -0
  28. package/ios/RNUITextViewShadowNode.cpp +127 -0
  29. package/ios/RNUITextViewShadowNode.h +48 -0
  30. package/ios/RNUITextViewSpecJSI-generated.cpp +17 -0
  31. package/ios/RNUITextViewSpecJSI.h +19 -0
  32. package/ios/generated/RNUITextViewSpec/ComponentDescriptors.cpp +23 -0
  33. package/ios/generated/RNUITextViewSpec/ComponentDescriptors.h +25 -0
  34. package/ios/generated/RNUITextViewSpec/EventEmitters.cpp +61 -0
  35. package/ios/generated/RNUITextViewSpec/EventEmitters.h +49 -0
  36. package/ios/generated/RNUITextViewSpec/Props.cpp +47 -0
  37. package/ios/generated/RNUITextViewSpec/Props.h +182 -0
  38. package/ios/generated/RNUITextViewSpec/RCTComponentViewHelpers.h +24 -0
  39. package/ios/generated/RNUITextViewSpec/RNUITextViewSpec-generated.mm +16 -0
  40. package/ios/generated/RNUITextViewSpec/RNUITextViewSpec.h +38 -0
  41. package/ios/generated/RNUITextViewSpec/ShadowNodes.cpp +18 -0
  42. package/ios/generated/RNUITextViewSpec/ShadowNodes.h +43 -0
  43. package/ios/generated/RNUITextViewSpec/States.cpp +16 -0
  44. package/ios/generated/RNUITextViewSpec/States.h +41 -0
  45. package/ios/generated/RNUITextViewSpecJSI-generated.cpp +17 -0
  46. package/ios/generated/RNUITextViewSpecJSI.h +19 -0
  47. package/lib/commonjs/RNUITextViewChildNativeComponent.ts +48 -0
  48. package/lib/commonjs/RNUITextViewNativeComponent.ts +47 -0
  49. package/lib/commonjs/Text.js +140 -0
  50. package/lib/commonjs/Text.js.map +1 -0
  51. package/lib/commonjs/index.js +17 -0
  52. package/lib/commonjs/index.js.map +1 -0
  53. package/lib/commonjs/package.json +1 -0
  54. package/lib/commonjs/util.js +64 -0
  55. package/lib/commonjs/util.js.map +1 -0
  56. package/lib/module/RNUITextViewChildNativeComponent.ts +48 -0
  57. package/lib/module/RNUITextViewNativeComponent.ts +47 -0
  58. package/lib/module/Text.js +136 -0
  59. package/lib/module/Text.js.map +1 -0
  60. package/lib/module/index.js +4 -0
  61. package/lib/module/index.js.map +1 -0
  62. package/lib/module/package.json +1 -0
  63. package/lib/module/util.js +60 -0
  64. package/lib/module/util.js.map +1 -0
  65. package/lib/typescript/commonjs/example/src/App.d.ts +2 -0
  66. package/lib/typescript/commonjs/example/src/App.d.ts.map +1 -0
  67. package/lib/typescript/commonjs/example/src/CustomMenuExample.d.ts +3 -0
  68. package/lib/typescript/commonjs/example/src/CustomMenuExample.d.ts.map +1 -0
  69. package/lib/typescript/commonjs/package.json +1 -0
  70. package/lib/typescript/commonjs/src/RNUITextViewChildNativeComponent.d.ts +28 -0
  71. package/lib/typescript/commonjs/src/RNUITextViewChildNativeComponent.d.ts.map +1 -0
  72. package/lib/typescript/commonjs/src/RNUITextViewNativeComponent.d.ts +29 -0
  73. package/lib/typescript/commonjs/src/RNUITextViewNativeComponent.d.ts.map +1 -0
  74. package/lib/typescript/commonjs/src/Text.d.ts +17 -0
  75. package/lib/typescript/commonjs/src/Text.d.ts.map +1 -0
  76. package/lib/typescript/commonjs/src/index.d.ts +2 -0
  77. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  78. package/lib/typescript/commonjs/src/util.d.ts +160 -0
  79. package/lib/typescript/commonjs/src/util.d.ts.map +1 -0
  80. package/lib/typescript/module/example/src/App.d.ts +2 -0
  81. package/lib/typescript/module/example/src/App.d.ts.map +1 -0
  82. package/lib/typescript/module/example/src/CustomMenuExample.d.ts +3 -0
  83. package/lib/typescript/module/example/src/CustomMenuExample.d.ts.map +1 -0
  84. package/lib/typescript/module/package.json +1 -0
  85. package/lib/typescript/module/src/RNUITextViewChildNativeComponent.d.ts +28 -0
  86. package/lib/typescript/module/src/RNUITextViewChildNativeComponent.d.ts.map +1 -0
  87. package/lib/typescript/module/src/RNUITextViewNativeComponent.d.ts +29 -0
  88. package/lib/typescript/module/src/RNUITextViewNativeComponent.d.ts.map +1 -0
  89. package/lib/typescript/module/src/Text.d.ts +17 -0
  90. package/lib/typescript/module/src/Text.d.ts.map +1 -0
  91. package/lib/typescript/module/src/index.d.ts +2 -0
  92. package/lib/typescript/module/src/index.d.ts.map +1 -0
  93. package/lib/typescript/module/src/util.d.ts +160 -0
  94. package/lib/typescript/module/src/util.d.ts.map +1 -0
  95. package/package.json +187 -0
  96. package/react-native-uitextview.podspec +21 -0
  97. package/react-native.config.js +28 -0
  98. package/src/RNUITextViewChildNativeComponent.ts +48 -0
  99. package/src/RNUITextViewNativeComponent.ts +47 -0
  100. package/src/Text.tsx +148 -0
  101. package/src/index.tsx +1 -0
  102. package/src/util.ts +65 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-25 Bluesky PBC
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,225 @@
1
+ # React Native UITextView with Custom Context Menu
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@dongsuo/react-native-uitextview?style=flat-square)](https://www.npmjs.com/package/@dongsuo/react-native-uitextview)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
5
+
6
+ An enhanced fork of `react-native-uitextview` with custom context menu support for React Native iOS applications.
7
+
8
+ ## Features
9
+
10
+ - Full support for UITextView on iOS
11
+ - Customizable context menu with your own actions
12
+ - Hide system default menu items
13
+ - Easy to integrate and use
14
+ - Maintains all original functionality
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ yarn add @dongsuo/react-native-uitextview
20
+ # or
21
+ npm install @dongsuo/react-native-uitextview
22
+ ```
23
+
24
+ ### iOS
25
+
26
+ Run the following command to install the native dependencies:
27
+
28
+ ```bash
29
+ cd ios && pod install && cd ..
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ### Basic Usage
35
+
36
+ ```jsx
37
+ import {UITextView} from '@dongsuo/react-native-uitextview'
38
+
39
+ // In your component
40
+ ;<UITextView
41
+ style={{height: 100, borderWidth: 1, padding: 10}}
42
+ placeholder="Type something..."
43
+ selectable={true}
44
+ uiTextView={true}
45
+ />
46
+ ```
47
+
48
+ ### Custom Context Menu
49
+
50
+ ```jsx
51
+ import {UITextView} from '@dongsuo/react-native-uitextview'
52
+
53
+ const MyComponent = () => {
54
+ const handleCustomMenuAction = event => {
55
+ const {actionId, selectedText} = event.nativeEvent
56
+ console.log(`Action: ${actionId}`, `Selected text: ${selectedText}`)
57
+
58
+ // Handle different actions
59
+ switch (actionId) {
60
+ case 'translate':
61
+ // Handle translate action
62
+ break
63
+ case 'share':
64
+ // Handle share action
65
+ break
66
+ case 'search':
67
+ // Handle search action
68
+ break
69
+ }
70
+ }
71
+
72
+ return (
73
+ <UITextView
74
+ style={{height: 100, borderWidth: 1, padding: 10}}
75
+ placeholder="Select text to see custom menu"
76
+ selectable={true}
77
+ uiTextView={true}
78
+ customMenuItems={[
79
+ {title: 'Translate', actionId: 'translate'},
80
+ {title: 'Share', actionId: 'share'},
81
+ {title: 'Search', actionId: 'search'},
82
+ ]}
83
+ onCustomMenuAction={handleCustomMenuAction}
84
+ />
85
+ )
86
+ }
87
+ ```
88
+
89
+ ## Props
90
+
91
+ | Prop | Type | Description | Default |
92
+ | -------------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------ | ------- |
93
+ | `customMenuItems` | `Array<{title: string, actionId: string}>` | Array of custom menu items to show when text is selected | `[]` |
94
+ | `onCustomMenuAction` | `(event: {nativeEvent: {actionId: string, selectedText: string}}) => void` | Callback when a custom menu item is pressed | - |
95
+ | ... | ... | All other props from React Native's `Text` component are supported | - |
96
+
97
+ ## License
98
+
99
+ MIT
100
+
101
+ ## Credits
102
+
103
+ Forked from [react-native-uitextview](https://github.com/bluesky-social/react-native-uitextview) by [Hailey](https://github.com/haileyok)
104
+
105
+ # React Native UITextView
106
+
107
+ The `Text` implementation in React Native much more closely resembles `UILabel` on iOS. Unfortunately, this prevents
108
+ the user from being able to highlight text for selection. The only copy behavior that is possible is to copy the
109
+ entire block of text.
110
+
111
+ `UITextView` however allows a user to highlight portions of the text block for copying,
112
+ translation, or other native capabilities.
113
+
114
+ React Native UITextView takes advantage of `UITextView` to allow for both types of copying
115
+ on iOS: highlight and copy or the current, `UILabel` behavior to just copy the entire
116
+ block of text.
117
+
118
+ ## Installation
119
+
120
+ > [!WARNING]
121
+ > The final version of this package that supports the old React Native architecture is `1.4.0`. All versions `2.x` and
122
+ > higher support only the new architecture. Unfortunately I do not have time to maintain support for both architectures.
123
+ > Version `1.4.0` however is stable and - aside from the still missing features from the base `<Text>` component, should
124
+ > work the same as `2.x` and higher.
125
+
126
+ > [!NOTE]
127
+ > Version 2.0.0 of `react-native-uitextview` is tested against and used in production with React Nave 0.79. No other versions
128
+ > are officially supported. As there have been a number of changes to the text layout engine in the new architecture, things
129
+ > may be broken if you are not using this version of React Native with this package. Generally, these problems are inside of
130
+ > `RNUITextViewShadowNode.cpp`.
131
+
132
+ ```sh
133
+ yarn add react-native-uitextview
134
+ cd ios
135
+ pod install
136
+ ```
137
+
138
+ ## Limitations
139
+
140
+ React Native UITextView can - for the most part - be used as a drop-in replacement
141
+ for existing blocks of `Text`. However, there are a few limitations:
142
+
143
+ - Children of `UITextView` may only be other UITextView children (base `Text` children
144
+ will be converted to `UITextView` children, so you only need to adjust the wrapper).
145
+ This means that things like in-line images are not supported as they are in the base
146
+ React Native `Text` component.
147
+ - A few styles have not yet been implemented, but all should be possible.
148
+
149
+ ## Usage
150
+
151
+ Usage of this component is the same as the base React Native `Text` component. It
152
+ can be imported as `Text` from `react-native-uitextview`, so in most cases you only
153
+ need to replace your current `Text` import with this one.
154
+
155
+ Aside from the few limitations above, all of the existing styles and props that you
156
+ are using for `Text` should work. On non-iOS platforms, the base React Native `Text`
157
+ will always be used. On iOS, the base React Native `Text` component will be used
158
+ unless the `selectable` and the `uiTextView` props are both `true`.
159
+
160
+ ```tsx
161
+ import {UITextView as Text} from 'react-native-uitextview'
162
+
163
+ function SomeView() {
164
+ return (
165
+ <View style={{flex: 1}}>
166
+ <Text
167
+ style={{color: 'green', lineHeight: 20, fontSize: 14}}
168
+ selectable
169
+ uiTextView>
170
+ This is some highlightable text! It uses UITextView
171
+ </Text>
172
+ <Text
173
+ style={{color: 'blue', lineHeight: 20, fontSize: 14}}
174
+ selectable // Note we do not add the uiTextView prop
175
+ >
176
+ This text still uses the base Text component. It can only be copied.
177
+ </Text>
178
+ <Text
179
+ style={{color: 'red', lineHeight: 20, fontSize: 14}}
180
+ uiTextView // Note we do not add the selectable prop
181
+ >
182
+ This text still uses the base Text component. It can't be highlighted or
183
+ copied at all.
184
+ </Text>
185
+ </View>
186
+ )
187
+ }
188
+ ```
189
+
190
+ Nesting of `UITextView` components is supported. For example, if you have styles
191
+ that should be applied only to a portion of the text, or an `onPress` callback to
192
+ add to a link.
193
+
194
+ ```tsx
195
+ <Text style={{fontSize: 14}} selectable uiTextView>
196
+ This is some text that's highlightable with{' '}
197
+ <Text
198
+ style={{color: 'blue', textDecorationLine: 'underline'}}
199
+ onPress={() => Linking.openURL('https://google.com')}>
200
+ a link
201
+ </Text>
202
+ .
203
+ </Text>
204
+ ```
205
+
206
+ ## Contributing
207
+
208
+ Contributions are always welcome - and encouraged. Please note however that it might take
209
+ time for PRs to be reviewed and merged, and they might not be merged at all. This library
210
+ was created to support text selection in the
211
+ [Bluesky Social App](https://github.com/bluesky-social/social-app). Contributions that may
212
+ affect the proper functioning of the component in Bluesky will not be merged.
213
+
214
+ Some ideas for great contributions that we do not have time to properly implement:
215
+
216
+ - Full support for all RN styles
217
+ - Accessibility improvements
218
+
219
+ ## License
220
+
221
+ MIT
222
+
223
+ ---
224
+
225
+ Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
@@ -0,0 +1,36 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ cmake_minimum_required(VERSION 3.13)
7
+ set(CMAKE_VERBOSE_MAKEFILE on)
8
+
9
+ file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNUITextViewSpec/*.cpp)
10
+
11
+ add_library(
12
+ react_codegen_RNUITextViewSpec
13
+ OBJECT
14
+ ${react_codegen_SRCS}
15
+ )
16
+
17
+ target_include_directories(react_codegen_RNUITextViewSpec PUBLIC . react/renderer/components/RNUITextViewSpec)
18
+
19
+ target_link_libraries(
20
+ react_codegen_RNUITextViewSpec
21
+ fbjni
22
+ jsi
23
+ # We need to link different libraries based on whether we are building rncore or not, that's necessary
24
+ # because we want to break a circular dependency between react_codegen_rncore and reactnative
25
+ reactnative
26
+ )
27
+
28
+ target_compile_options(
29
+ react_codegen_RNUITextViewSpec
30
+ PRIVATE
31
+ -DLOG_TAG=\"ReactNative\"
32
+ -fexceptions
33
+ -frtti
34
+ -std=c++20
35
+ -Wall
36
+ )
@@ -0,0 +1,22 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniCpp.js
9
+ */
10
+
11
+ #include "RNUITextViewSpec.h"
12
+
13
+ namespace facebook::react {
14
+
15
+
16
+
17
+ std::shared_ptr<TurboModule> RNUITextViewSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
18
+
19
+ return nullptr;
20
+ }
21
+
22
+ } // namespace facebook::react
@@ -0,0 +1,24 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <ReactCommon/JavaTurboModule.h>
14
+ #include <ReactCommon/TurboModule.h>
15
+ #include <jsi/jsi.h>
16
+
17
+ namespace facebook::react {
18
+
19
+
20
+
21
+ JSI_EXPORT
22
+ std::shared_ptr<TurboModule> RNUITextViewSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
23
+
24
+ } // namespace facebook::react
@@ -0,0 +1,23 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorCpp.js
9
+ */
10
+
11
+ #include "ComponentDescriptors.h"
12
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
13
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
14
+
15
+ namespace facebook::react {
16
+
17
+ void RNUITextViewSpec_registerComponentDescriptorsFromCodegen(
18
+ std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
19
+ registry->add(concreteComponentDescriptorProvider<RNUITextViewChildComponentDescriptor>());
20
+ registry->add(concreteComponentDescriptorProvider<RNUITextViewComponentDescriptor>());
21
+ }
22
+
23
+ } // namespace facebook::react
@@ -0,0 +1,25 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include "ShadowNodes.h"
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
16
+
17
+ namespace facebook::react {
18
+
19
+ using RNUITextViewChildComponentDescriptor = ConcreteComponentDescriptor<RNUITextViewChildShadowNode>;
20
+ using RNUITextViewComponentDescriptor = ConcreteComponentDescriptor<RNUITextViewShadowNode>;
21
+
22
+ void RNUITextViewSpec_registerComponentDescriptorsFromCodegen(
23
+ std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
24
+
25
+ } // namespace facebook::react
@@ -0,0 +1,61 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateEventEmitterCpp.js
9
+ */
10
+
11
+ #include "EventEmitters.h"
12
+
13
+
14
+ namespace facebook::react {
15
+
16
+ void RNUITextViewChildEventEmitter::onPress(OnPress $event) const {
17
+ dispatchEvent("press", [$event=std::move($event)](jsi::Runtime &runtime) {
18
+ auto $payload = jsi::Object(runtime);
19
+ $payload.setProperty(runtime, "target", $event.target);
20
+ return $payload;
21
+ });
22
+ }
23
+
24
+
25
+ void RNUITextViewChildEventEmitter::onLongPress(OnLongPress $event) const {
26
+ dispatchEvent("longPress", [$event=std::move($event)](jsi::Runtime &runtime) {
27
+ auto $payload = jsi::Object(runtime);
28
+ $payload.setProperty(runtime, "target", $event.target);
29
+ return $payload;
30
+ });
31
+ }
32
+
33
+
34
+ void RNUITextViewEventEmitter::onTextLayout(OnTextLayout $event) const {
35
+ dispatchEvent("textLayout", [$event=std::move($event)](jsi::Runtime &runtime) {
36
+ auto $payload = jsi::Object(runtime);
37
+ $payload.setProperty(runtime, "target", $event.target);
38
+
39
+ auto lines = jsi::Array(runtime, $event.lines.size());
40
+ size_t linesIndex = 0;
41
+ for (auto linesValue : $event.lines) {
42
+ lines.setValueAtIndex(runtime, linesIndex++, linesValue);
43
+ }
44
+ $payload.setProperty(runtime, "lines", lines);
45
+
46
+ return $payload;
47
+ });
48
+ }
49
+
50
+
51
+ void RNUITextViewEventEmitter::onCustomMenuAction(OnCustomMenuAction $event) const {
52
+ dispatchEvent("customMenuAction", [$event=std::move($event)](jsi::Runtime &runtime) {
53
+ auto $payload = jsi::Object(runtime);
54
+ $payload.setProperty(runtime, "target", $event.target);
55
+ $payload.setProperty(runtime, "actionId", $event.actionId);
56
+ $payload.setProperty(runtime, "selectedText", $event.selectedText);
57
+ return $payload;
58
+ });
59
+ }
60
+
61
+ } // namespace facebook::react
@@ -0,0 +1,49 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateEventEmitterH.js
9
+ */
10
+ #pragma once
11
+
12
+ #include <react/renderer/components/view/ViewEventEmitter.h>
13
+
14
+
15
+ namespace facebook::react {
16
+ class RNUITextViewChildEventEmitter : public ViewEventEmitter {
17
+ public:
18
+ using ViewEventEmitter::ViewEventEmitter;
19
+
20
+ struct OnPress {
21
+ int target;
22
+ };
23
+
24
+ struct OnLongPress {
25
+ int target;
26
+ };
27
+ void onPress(OnPress value) const;
28
+
29
+ void onLongPress(OnLongPress value) const;
30
+ };
31
+ class RNUITextViewEventEmitter : public ViewEventEmitter {
32
+ public:
33
+ using ViewEventEmitter::ViewEventEmitter;
34
+
35
+ struct OnTextLayout {
36
+ int target;
37
+ std::vector<std::string> lines;
38
+ };
39
+
40
+ struct OnCustomMenuAction {
41
+ int target;
42
+ std::string actionId;
43
+ std::string selectedText;
44
+ };
45
+ void onTextLayout(OnTextLayout value) const;
46
+
47
+ void onCustomMenuAction(OnCustomMenuAction value) const;
48
+ };
49
+ } // namespace facebook::react
@@ -0,0 +1,47 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GeneratePropsCpp.js
9
+ */
10
+
11
+ #include "Props.h"
12
+ #include <react/renderer/core/PropsParserContext.h>
13
+ #include <react/renderer/core/propsConversions.h>
14
+
15
+ namespace facebook::react {
16
+
17
+ RNUITextViewChildProps::RNUITextViewChildProps(
18
+ const PropsParserContext &context,
19
+ const RNUITextViewChildProps &sourceProps,
20
+ const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
21
+
22
+ text(convertRawProp(context, rawProps, "text", sourceProps.text, {})),
23
+ color(convertRawProp(context, rawProps, "color", sourceProps.color, {})),
24
+ fontSize(convertRawProp(context, rawProps, "fontSize", sourceProps.fontSize, {0.0})),
25
+ fontStyle(convertRawProp(context, rawProps, "fontStyle", sourceProps.fontStyle, {RNUITextViewChildFontStyle::Normal})),
26
+ fontWeight(convertRawProp(context, rawProps, "fontWeight", sourceProps.fontWeight, {RNUITextViewChildFontWeight::Normal})),
27
+ fontFamily(convertRawProp(context, rawProps, "fontFamily", sourceProps.fontFamily, {})),
28
+ letterSpacing(convertRawProp(context, rawProps, "letterSpacing", sourceProps.letterSpacing, {0.0})),
29
+ lineHeight(convertRawProp(context, rawProps, "lineHeight", sourceProps.lineHeight, {0.0})),
30
+ textDecorationLine(convertRawProp(context, rawProps, "textDecorationLine", sourceProps.textDecorationLine, {RNUITextViewChildTextDecorationLine::None})),
31
+ textDecorationStyle(convertRawProp(context, rawProps, "textDecorationStyle", sourceProps.textDecorationStyle, {RNUITextViewChildTextDecorationStyle::Solid})),
32
+ textDecorationColor(convertRawProp(context, rawProps, "textDecorationColor", sourceProps.textDecorationColor, {})),
33
+ shadowRadius(convertRawProp(context, rawProps, "shadowRadius", sourceProps.shadowRadius, {0.0}))
34
+ {}
35
+ RNUITextViewProps::RNUITextViewProps(
36
+ const PropsParserContext &context,
37
+ const RNUITextViewProps &sourceProps,
38
+ const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
39
+
40
+ numberOfLines(convertRawProp(context, rawProps, "numberOfLines", sourceProps.numberOfLines, {0})),
41
+ allowsFontScaling(convertRawProp(context, rawProps, "allowsFontScaling", sourceProps.allowsFontScaling, {false})),
42
+ ellipsizeMode(convertRawProp(context, rawProps, "ellipsizeMode", sourceProps.ellipsizeMode, {RNUITextViewEllipsizeMode::Tail})),
43
+ selectable(convertRawProp(context, rawProps, "selectable", sourceProps.selectable, {false})),
44
+ customMenuItems(convertRawProp(context, rawProps, "customMenuItems", sourceProps.customMenuItems, {}))
45
+ {}
46
+
47
+ } // namespace facebook::react