@dongsuo/react-native-uitextview 1.0.1 → 1.0.3

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 (71) hide show
  1. package/README.md +1 -1
  2. package/{ios/generated → android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components}/RNUITextViewSpec/ComponentDescriptors.cpp +1 -1
  3. package/android/generated/{jni → android/app/build/generated/source/codegen/jni}/react/renderer/components/RNUITextViewSpec/ComponentDescriptors.h +1 -1
  4. package/android/generated/{jni → android/app/build/generated/source/codegen/jni}/react/renderer/components/RNUITextViewSpec/EventEmitters.cpp +1 -1
  5. package/android/generated/{jni → android/app/build/generated/source/codegen/jni}/react/renderer/components/RNUITextViewSpec/Props.cpp +3 -2
  6. package/android/generated/{jni → android/app/build/generated/source/codegen/jni}/react/renderer/components/RNUITextViewSpec/Props.h +23 -1
  7. package/{ios/generated → android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components}/RNUITextViewSpec/ShadowNodes.cpp +1 -1
  8. package/android/generated/{jni → android/app/build/generated/source/codegen/jni}/react/renderer/components/RNUITextViewSpec/ShadowNodes.h +3 -3
  9. package/android/generated/{jni → android/app/build/generated/source/codegen/jni}/react/renderer/components/RNUITextViewSpec/States.cpp +1 -1
  10. package/ios/RNUITextView.mm +47 -14
  11. package/ios/RNUITextViewChild.mm +5 -9
  12. package/ios/RNUITextViewChildShadowNode.h +3 -3
  13. package/ios/RNUITextViewShadowNode.cpp +21 -4
  14. package/ios/RNUITextViewShadowNode.h +5 -5
  15. package/{android/generated/jni → ios/generated/build/generated/ios}/react/renderer/components/RNUITextViewSpec/ComponentDescriptors.cpp +1 -1
  16. package/ios/generated/{RNUITextViewSpec → build/generated/ios/react/renderer/components/RNUITextViewSpec}/ComponentDescriptors.h +1 -1
  17. package/ios/generated/{RNUITextViewSpec → build/generated/ios/react/renderer/components/RNUITextViewSpec}/EventEmitters.cpp +1 -1
  18. package/ios/generated/{RNUITextViewSpec → build/generated/ios/react/renderer/components/RNUITextViewSpec}/Props.cpp +3 -2
  19. package/ios/generated/{RNUITextViewSpec → build/generated/ios/react/renderer/components/RNUITextViewSpec}/Props.h +23 -1
  20. package/{android/generated/jni → ios/generated/build/generated/ios}/react/renderer/components/RNUITextViewSpec/ShadowNodes.cpp +1 -1
  21. package/ios/generated/{RNUITextViewSpec → build/generated/ios/react/renderer/components/RNUITextViewSpec}/ShadowNodes.h +3 -3
  22. package/ios/generated/{RNUITextViewSpec → build/generated/ios/react/renderer/components/RNUITextViewSpec}/States.cpp +1 -1
  23. package/lib/commonjs/RNUITextViewChildNativeComponent.ts +4 -1
  24. package/lib/commonjs/RNUITextViewNativeComponent.ts +20 -20
  25. package/lib/module/RNUITextViewChildNativeComponent.ts +4 -1
  26. package/lib/module/RNUITextViewNativeComponent.ts +20 -20
  27. package/lib/typescript/commonjs/example/src/App.d.ts.map +1 -1
  28. package/lib/typescript/commonjs/lib/commonjs/RNUITextViewChildNativeComponent.d.ts +30 -0
  29. package/lib/typescript/commonjs/lib/commonjs/RNUITextViewChildNativeComponent.d.ts.map +1 -0
  30. package/lib/typescript/commonjs/lib/commonjs/RNUITextViewNativeComponent.d.ts +29 -0
  31. package/lib/typescript/commonjs/lib/commonjs/RNUITextViewNativeComponent.d.ts.map +1 -0
  32. package/lib/typescript/commonjs/lib/module/RNUITextViewChildNativeComponent.d.ts +30 -0
  33. package/lib/typescript/commonjs/lib/module/RNUITextViewChildNativeComponent.d.ts.map +1 -0
  34. package/lib/typescript/commonjs/lib/module/RNUITextViewNativeComponent.d.ts +29 -0
  35. package/lib/typescript/commonjs/lib/module/RNUITextViewNativeComponent.d.ts.map +1 -0
  36. package/lib/typescript/commonjs/src/RNUITextViewChildNativeComponent.d.ts +2 -0
  37. package/lib/typescript/commonjs/src/RNUITextViewChildNativeComponent.d.ts.map +1 -1
  38. package/lib/typescript/commonjs/src/RNUITextViewNativeComponent.d.ts +5 -5
  39. package/lib/typescript/commonjs/src/RNUITextViewNativeComponent.d.ts.map +1 -1
  40. package/lib/typescript/module/example/src/App.d.ts.map +1 -1
  41. package/lib/typescript/module/lib/commonjs/RNUITextViewChildNativeComponent.d.ts +30 -0
  42. package/lib/typescript/module/lib/commonjs/RNUITextViewChildNativeComponent.d.ts.map +1 -0
  43. package/lib/typescript/module/lib/commonjs/RNUITextViewNativeComponent.d.ts +29 -0
  44. package/lib/typescript/module/lib/commonjs/RNUITextViewNativeComponent.d.ts.map +1 -0
  45. package/lib/typescript/module/lib/module/RNUITextViewChildNativeComponent.d.ts +30 -0
  46. package/lib/typescript/module/lib/module/RNUITextViewChildNativeComponent.d.ts.map +1 -0
  47. package/lib/typescript/module/lib/module/RNUITextViewNativeComponent.d.ts +29 -0
  48. package/lib/typescript/module/lib/module/RNUITextViewNativeComponent.d.ts.map +1 -0
  49. package/lib/typescript/module/src/RNUITextViewChildNativeComponent.d.ts +2 -0
  50. package/lib/typescript/module/src/RNUITextViewChildNativeComponent.d.ts.map +1 -1
  51. package/lib/typescript/module/src/RNUITextViewNativeComponent.d.ts +5 -5
  52. package/lib/typescript/module/src/RNUITextViewNativeComponent.d.ts.map +1 -1
  53. package/package.json +3 -4
  54. package/react-native-uitextview.podspec +16 -3
  55. package/react-native.config.js +1 -1
  56. package/src/RNUITextViewChildNativeComponent.ts +4 -1
  57. package/src/RNUITextViewNativeComponent.ts +20 -20
  58. /package/android/generated/{jni → android/app/build/generated/source/codegen/jni}/CMakeLists.txt +0 -0
  59. /package/android/generated/{jni → android/app/build/generated/source/codegen/jni}/RNUITextViewSpec-generated.cpp +0 -0
  60. /package/android/generated/{jni → android/app/build/generated/source/codegen/jni}/RNUITextViewSpec.h +0 -0
  61. /package/android/generated/{jni → android/app/build/generated/source/codegen/jni}/react/renderer/components/RNUITextViewSpec/EventEmitters.h +0 -0
  62. /package/android/generated/{jni → android/app/build/generated/source/codegen/jni}/react/renderer/components/RNUITextViewSpec/RNUITextViewSpecJSI-generated.cpp +0 -0
  63. /package/android/generated/{jni → android/app/build/generated/source/codegen/jni}/react/renderer/components/RNUITextViewSpec/RNUITextViewSpecJSI.h +0 -0
  64. /package/android/generated/{jni → android/app/build/generated/source/codegen/jni}/react/renderer/components/RNUITextViewSpec/States.h +0 -0
  65. /package/ios/generated/{RNUITextViewSpec → build/generated/ios/RNUITextViewSpec}/RNUITextViewSpec-generated.mm +0 -0
  66. /package/ios/generated/{RNUITextViewSpec → build/generated/ios/RNUITextViewSpec}/RNUITextViewSpec.h +0 -0
  67. /package/ios/generated/{RNUITextViewSpecJSI-generated.cpp → build/generated/ios/RNUITextViewSpecJSI-generated.cpp} +0 -0
  68. /package/ios/generated/{RNUITextViewSpecJSI.h → build/generated/ios/RNUITextViewSpecJSI.h} +0 -0
  69. /package/ios/generated/{RNUITextViewSpec → build/generated/ios/react/renderer/components/RNUITextViewSpec}/EventEmitters.h +0 -0
  70. /package/ios/generated/{RNUITextViewSpec → build/generated/ios/react/renderer/components/RNUITextViewSpec}/RCTComponentViewHelpers.h +0 -0
  71. /package/ios/generated/{RNUITextViewSpec → build/generated/ios/react/renderer/components/RNUITextViewSpec}/States.h +0 -0
package/README.md CHANGED
@@ -218,7 +218,7 @@ Some ideas for great contributions that we do not have time to properly implemen
218
218
 
219
219
  ## License
220
220
 
221
- MIT
221
+ Bluesky Social PBC has committed to a software patent non-aggression pledge. For details see [the original announcement](https://bsky.social/about/blog/10-01-2025-patent-pledge).
222
222
 
223
223
  ---
224
224
 
@@ -8,7 +8,7 @@
8
8
  * @generated by codegen project: GenerateComponentDescriptorCpp.js
9
9
  */
10
10
 
11
- #include "ComponentDescriptors.h"
11
+ #include <react/renderer/components/RNUITextViewSpec/ComponentDescriptors.h>
12
12
  #include <react/renderer/core/ConcreteComponentDescriptor.h>
13
13
  #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
14
14
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  #pragma once
12
12
 
13
- #include "ShadowNodes.h"
13
+ #include <react/renderer/components/RNUITextViewSpec/ShadowNodes.h>
14
14
  #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
15
  #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
16
16
 
@@ -8,7 +8,7 @@
8
8
  * @generated by codegen project: GenerateEventEmitterCpp.js
9
9
  */
10
10
 
11
- #include "EventEmitters.h"
11
+ #include <react/renderer/components/RNUITextViewSpec/EventEmitters.h>
12
12
 
13
13
 
14
14
  namespace facebook::react {
@@ -8,7 +8,7 @@
8
8
  * @generated by codegen project: GeneratePropsCpp.js
9
9
  */
10
10
 
11
- #include "Props.h"
11
+ #include <react/renderer/components/RNUITextViewSpec/Props.h>
12
12
  #include <react/renderer/core/PropsParserContext.h>
13
13
  #include <react/renderer/core/propsConversions.h>
14
14
 
@@ -30,6 +30,7 @@ RNUITextViewChildProps::RNUITextViewChildProps(
30
30
  textDecorationLine(convertRawProp(context, rawProps, "textDecorationLine", sourceProps.textDecorationLine, {RNUITextViewChildTextDecorationLine::None})),
31
31
  textDecorationStyle(convertRawProp(context, rawProps, "textDecorationStyle", sourceProps.textDecorationStyle, {RNUITextViewChildTextDecorationStyle::Solid})),
32
32
  textDecorationColor(convertRawProp(context, rawProps, "textDecorationColor", sourceProps.textDecorationColor, {})),
33
+ textAlign(convertRawProp(context, rawProps, "textAlign", sourceProps.textAlign, {RNUITextViewChildTextAlign::Auto})),
33
34
  shadowRadius(convertRawProp(context, rawProps, "shadowRadius", sourceProps.shadowRadius, {0.0}))
34
35
  {}
35
36
  RNUITextViewProps::RNUITextViewProps(
@@ -38,7 +39,7 @@ RNUITextViewProps::RNUITextViewProps(
38
39
  const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
39
40
 
40
41
  numberOfLines(convertRawProp(context, rawProps, "numberOfLines", sourceProps.numberOfLines, {0})),
41
- allowsFontScaling(convertRawProp(context, rawProps, "allowsFontScaling", sourceProps.allowsFontScaling, {false})),
42
+ allowFontScaling(convertRawProp(context, rawProps, "allowFontScaling", sourceProps.allowFontScaling, {true})),
42
43
  ellipsizeMode(convertRawProp(context, rawProps, "ellipsizeMode", sourceProps.ellipsizeMode, {RNUITextViewEllipsizeMode::Tail})),
43
44
  selectable(convertRawProp(context, rawProps, "selectable", sourceProps.selectable, {false})),
44
45
  customMenuItems(convertRawProp(context, rawProps, "customMenuItems", sourceProps.customMenuItems, {}))
@@ -93,6 +93,27 @@ static inline std::string toString(const RNUITextViewChildTextDecorationStyle &v
93
93
  case RNUITextViewChildTextDecorationStyle::Dashed: return "dashed";
94
94
  }
95
95
  }
96
+ enum class RNUITextViewChildTextAlign { Auto, Left, Right, Center, Justify };
97
+
98
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNUITextViewChildTextAlign &result) {
99
+ auto string = (std::string)value;
100
+ if (string == "auto") { result = RNUITextViewChildTextAlign::Auto; return; }
101
+ if (string == "left") { result = RNUITextViewChildTextAlign::Left; return; }
102
+ if (string == "right") { result = RNUITextViewChildTextAlign::Right; return; }
103
+ if (string == "center") { result = RNUITextViewChildTextAlign::Center; return; }
104
+ if (string == "justify") { result = RNUITextViewChildTextAlign::Justify; return; }
105
+ abort();
106
+ }
107
+
108
+ static inline std::string toString(const RNUITextViewChildTextAlign &value) {
109
+ switch (value) {
110
+ case RNUITextViewChildTextAlign::Auto: return "auto";
111
+ case RNUITextViewChildTextAlign::Left: return "left";
112
+ case RNUITextViewChildTextAlign::Right: return "right";
113
+ case RNUITextViewChildTextAlign::Center: return "center";
114
+ case RNUITextViewChildTextAlign::Justify: return "justify";
115
+ }
116
+ }
96
117
 
97
118
  class RNUITextViewChildProps final : public ViewProps {
98
119
  public:
@@ -112,6 +133,7 @@ class RNUITextViewChildProps final : public ViewProps {
112
133
  RNUITextViewChildTextDecorationLine textDecorationLine{RNUITextViewChildTextDecorationLine::None};
113
134
  RNUITextViewChildTextDecorationStyle textDecorationStyle{RNUITextViewChildTextDecorationStyle::Solid};
114
135
  SharedColor textDecorationColor{};
136
+ RNUITextViewChildTextAlign textAlign{RNUITextViewChildTextAlign::Auto};
115
137
  Float shadowRadius{0.0};
116
138
  };
117
139
 
@@ -173,7 +195,7 @@ class RNUITextViewProps final : public ViewProps {
173
195
  #pragma mark - Props
174
196
 
175
197
  int numberOfLines{0};
176
- bool allowsFontScaling{false};
198
+ bool allowFontScaling{true};
177
199
  RNUITextViewEllipsizeMode ellipsizeMode{RNUITextViewEllipsizeMode::Tail};
178
200
  bool selectable{false};
179
201
  std::vector<RNUITextViewCustomMenuItemsStruct> customMenuItems{};
@@ -8,7 +8,7 @@
8
8
  * @generated by codegen project: GenerateShadowNodeCpp.js
9
9
  */
10
10
 
11
- #include "ShadowNodes.h"
11
+ #include <react/renderer/components/RNUITextViewSpec/ShadowNodes.h>
12
12
 
13
13
  namespace facebook::react {
14
14
 
@@ -10,9 +10,9 @@
10
10
 
11
11
  #pragma once
12
12
 
13
- #include "EventEmitters.h"
14
- #include "Props.h"
15
- #include "States.h"
13
+ #include <react/renderer/components/RNUITextViewSpec/EventEmitters.h>
14
+ #include <react/renderer/components/RNUITextViewSpec/Props.h>
15
+ #include <react/renderer/components/RNUITextViewSpec/States.h>
16
16
  #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
17
  #include <jsi/jsi.h>
18
18
 
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @generated by codegen project: GenerateStateCpp.js
9
9
  */
10
- #include "States.h"
10
+ #include <react/renderer/components/RNUITextViewSpec/States.h>
11
11
 
12
12
  namespace facebook::react {
13
13
 
@@ -1,18 +1,35 @@
1
1
  #import "RNUITextView.h"
2
- #import "RNUITextViewChild.h"
2
+ #import "RNUITextViewShadowNode.h"
3
3
  #import "RNUITextViewComponentDescriptor.h"
4
-
4
+ #import "RNUITextViewChild.h"
5
5
  #import <React/RCTConversions.h>
6
6
 
7
- #import <react-native-uitextview/EventEmitters.h>
8
- #import <react-native-uitextview/Props.h>
9
- #import <react-native-uitextview/RCTComponentViewHelpers.h>
10
7
  #import <react/renderer/textlayoutmanager/RCTAttributedTextUtils.h>
11
8
  #import <objc/runtime.h>
9
+ #import <react/renderer/components/RNUITextViewSpec/EventEmitters.h>
10
+ #import <react/renderer/components/RNUITextViewSpec/Props.h>
11
+ #import <react/renderer/components/RNUITextViewSpec/RCTComponentViewHelpers.h>
12
+ #import <objc/runtime.h>
12
13
  #import "RCTFabricComponentsPlugins.h"
13
14
 
14
15
  using namespace facebook::react;
15
16
 
17
+ static inline NSString *_Nullable RNStringFromStdString(const std::string &value)
18
+ {
19
+ if (value.empty()) {
20
+ return nil;
21
+ }
22
+
23
+ NSString *convertedString = [[NSString alloc] initWithBytes:value.data()
24
+ length:value.size()
25
+ encoding:NSUTF8StringEncoding];
26
+ if (!convertedString) {
27
+ NSLog(@"[RNUITextView] Failed to convert std::string (length: %lu) to NSString", (unsigned long)value.size());
28
+ }
29
+
30
+ return convertedString;
31
+ }
32
+
16
33
  @interface RNUITextView () <RCTRNUITextViewViewProtocol, UIGestureRecognizerDelegate, UITextViewDelegate>
17
34
 
18
35
  // 用于跟踪自定义菜单项
@@ -90,7 +107,7 @@ using namespace facebook::react;
90
107
  {
91
108
  [super prepareForRecycle];
92
109
  _state.reset();
93
-
110
+
94
111
  // Reset the frame to zero so that when it properly lays out on the next use
95
112
  _textView.frame = CGRectZero;
96
113
  _textView.attributedText = nil;
@@ -110,6 +127,7 @@ using namespace facebook::react;
110
127
 
111
128
  const auto attrString = _state->getData().attributedString;
112
129
  const auto convertedAttrString = RCTNSAttributedStringFromAttributedString(attrString);
130
+
113
131
  _textView.attributedText = convertedAttrString;
114
132
  _textView.frame = _view.frame;
115
133
 
@@ -146,6 +164,12 @@ using namespace facebook::react;
146
164
  _textView.selectable = newViewProps.selectable;
147
165
  }
148
166
 
167
+ if (oldViewProps.allowFontScaling != newViewProps.allowFontScaling) {
168
+ if (@available(iOS 11.0, *)) {
169
+ _textView.adjustsFontForContentSizeCategory = newViewProps.allowFontScaling;
170
+ }
171
+ }
172
+
149
173
  if (oldViewProps.ellipsizeMode != newViewProps.ellipsizeMode) {
150
174
  if (newViewProps.ellipsizeMode == RNUITextViewEllipsizeMode::Head) {
151
175
  _textView.textContainer.lineBreakMode = NSLineBreakMode::NSLineBreakByTruncatingHead;
@@ -157,6 +181,7 @@ using namespace facebook::react;
157
181
  _textView.textContainer.lineBreakMode = NSLineBreakMode::NSLineBreakByClipping;
158
182
  }
159
183
  }
184
+
160
185
 
161
186
  // I'm not sure if this is really the right way to handle this style. This means that the entire _view_ the text
162
187
  // is in will have this background color applied. To apply it just to a particular part of a string, you'd need
@@ -166,15 +191,23 @@ using namespace facebook::react;
166
191
  _textView.backgroundColor = RCTUIColorFromSharedColor(newViewProps.backgroundColor);
167
192
  }
168
193
  if (newViewProps.customMenuItems.size() > 0) {
169
- NSMutableArray *items = [NSMutableArray array];
170
- for (const auto &item : newViewProps.customMenuItems) {
171
- [items addObject:@{
172
- @"title": [NSString stringWithUTF8String:item.title.c_str()],
173
- @"actionId": [NSString stringWithUTF8String:item.actionId.c_str()]
174
- }];
194
+ NSMutableArray<NSDictionary *> *items = [NSMutableArray array];
195
+ for (const auto &item : newViewProps.customMenuItems) {
196
+ NSString *title = RNStringFromStdString(item.title);
197
+ NSString *actionId = RNStringFromStdString(item.actionId);
198
+
199
+ if (title.length == 0 || actionId.length == 0) {
200
+ NSLog(@"[RNUITextView] Skipping invalid custom menu item (title length: %lu, actionId length: %lu)", (unsigned long)title.length, (unsigned long)actionId.length);
201
+ continue;
202
+ }
203
+
204
+ [items addObject:@{ @"title": title, @"actionId": actionId }];
205
+ }
206
+
207
+ self.customMenuItems = items.count > 0 ? items : nil;
208
+ } else {
209
+ self.customMenuItems = nil;
175
210
  }
176
- self.customMenuItems = items;
177
- }
178
211
  // 自定义菜单项属性会在 JS 层设置,这里不需要从 props 中提取
179
212
 
180
213
  [super updateProps:props oldProps:oldProps];
@@ -1,12 +1,9 @@
1
- #ifdef RCT_NEW_ARCH_ENABLED
2
1
  #import "RNUITextViewChild.h"
3
2
  #import "RNUITextView.h"
4
3
  #import "RNUITextViewChildComponentDescriptor.h"
5
-
6
- #import <react-native-uitextview/EventEmitters.h>
7
- #import <react-native-uitextview/Props.h>
8
- #import <react-native-uitextview/RCTComponentViewHelpers.h>
9
-
4
+ #import <react/renderer/components/RNUITextViewSpec/EventEmitters.h>
5
+ #import <react/renderer/components/RNUITextViewSpec/Props.h>
6
+ #import <react/renderer/components/RNUITextViewSpec/RCTComponentViewHelpers.h>
10
7
  #import "RCTFabricComponentsPlugins.h"
11
8
  #import "Utils.h"
12
9
 
@@ -45,7 +42,7 @@ using namespace facebook::react;
45
42
  NSString *text = [NSString stringWithUTF8String:newViewProps.text.c_str()];
46
43
  _text = text;
47
44
  }
48
-
45
+
49
46
  [super updateProps:props oldProps:oldProps];
50
47
  }
51
48
 
@@ -55,7 +52,7 @@ using namespace facebook::react;
55
52
  ->onPress(facebook::react::RNUITextViewChildEventEmitter::OnPress{});
56
53
  }
57
54
  }
58
-
55
+
59
56
  - (void)onLongPress {
60
57
  if (_eventEmitter != nullptr) {
61
58
  std::dynamic_pointer_cast<const facebook::react::RNUITextViewChildEventEmitter>(_eventEmitter)
@@ -73,4 +70,3 @@ Class<RCTComponentViewProtocol> RNUITextViewChildCls(void)
73
70
  }
74
71
 
75
72
  @end
76
- #endif
@@ -1,8 +1,8 @@
1
1
  #pragma once
2
2
 
3
- #include <react-native-uitextview/EventEmitters.h>
4
- #include <react-native-uitextview/Props.h>
5
- #include <react-native-uitextview/States.h>
3
+ #include <react/renderer/components/RNUITextViewSpec/EventEmitters.h>
4
+ #include <react/renderer/components/RNUITextViewSpec/Props.h>
5
+ #include <react/renderer/components/RNUITextViewSpec/States.h>
6
6
  #include <react/renderer/components/view/ConcreteViewShadowNode.h>
7
7
 
8
8
  namespace facebook::react {
@@ -6,8 +6,6 @@
6
6
 
7
7
  namespace facebook::react {
8
8
 
9
- extern const char RNUITextViewComponentName[] = "RNUITextView";
10
-
11
9
  RNUITextViewShadowNode::RNUITextViewShadowNode(
12
10
  const ShadowNode& sourceShadowNode,
13
11
  const ShadowNodeFragment& fragment
@@ -34,6 +32,12 @@ Size RNUITextViewShadowNode::measureContent(
34
32
 
35
33
  auto baseTextAttributes = TextAttributes::defaultTextAttributes();
36
34
  baseTextAttributes.backgroundColor = baseProps.backgroundColor;
35
+ baseTextAttributes.allowFontScaling = baseProps.allowFontScaling;
36
+
37
+ Float fontSizeMultiplier = 1.0;
38
+ if (baseTextAttributes.allowFontScaling) {
39
+ fontSizeMultiplier = layoutContext.fontSizeMultiplier;
40
+ }
37
41
 
38
42
  auto baseAttributedString = AttributedString{};
39
43
  const auto &children = getChildren();
@@ -44,9 +48,10 @@ Size RNUITextViewShadowNode::measureContent(
44
48
  auto fragment = AttributedString::Fragment{};
45
49
  auto textAttributes = TextAttributes::defaultTextAttributes();
46
50
 
51
+ textAttributes.allowFontScaling = baseProps.allowFontScaling;
47
52
  textAttributes.backgroundColor = props.backgroundColor;
48
- textAttributes.fontSize = props.fontSize;
49
- textAttributes.lineHeight = props.lineHeight;
53
+ textAttributes.fontSize = props.fontSize * fontSizeMultiplier;
54
+ textAttributes.lineHeight = props.lineHeight * fontSizeMultiplier;
50
55
  textAttributes.foregroundColor = props.color;
51
56
  textAttributes.textShadowColor = props.shadowColor;
52
57
  textAttributes.textShadowOffset = props.shadowOffset;
@@ -95,6 +100,18 @@ Size RNUITextViewShadowNode::measureContent(
95
100
  textAttributes.textDecorationStyle = TextDecorationStyle::Double;
96
101
  }
97
102
 
103
+ if (props.textAlign == RNUITextViewChildTextAlign::Left) {
104
+ textAttributes.alignment = TextAlignment::Left;
105
+ } else if (props.textAlign == RNUITextViewChildTextAlign::Right) {
106
+ textAttributes.alignment = TextAlignment::Right;
107
+ } else if (props.textAlign == RNUITextViewChildTextAlign::Center) {
108
+ textAttributes.alignment = TextAlignment::Center;
109
+ } else if (props.textAlign == RNUITextViewChildTextAlign::Justify) {
110
+ textAttributes.alignment = TextAlignment::Justified;
111
+ } else if (props.textAlign == RNUITextViewChildTextAlign::Auto) {
112
+ textAttributes.alignment = TextAlignment::Natural;
113
+ }
114
+
98
115
  textAttributes.backgroundColor = props.backgroundColor;
99
116
 
100
117
  fragment.string = props.text;
@@ -1,7 +1,7 @@
1
1
  #pragma once
2
2
 
3
- #include <react-native-uitextview/EventEmitters.h>
4
- #include <react-native-uitextview/Props.h>
3
+ #include <react/renderer/components/RNUITextViewSpec/EventEmitters.h>
4
+ #include <react/renderer/components/RNUITextViewSpec/Props.h>
5
5
  #include <react/renderer/components/view/ConcreteViewShadowNode.h>
6
6
  #include <react/renderer/textlayoutmanager/TextLayoutManager.h>
7
7
  #include <react/renderer/core/LayoutContext.h>
@@ -23,7 +23,7 @@ RNUITextViewEventEmitter,
23
23
  RNUITextViewStateReal> {
24
24
  public:
25
25
  using ConcreteViewShadowNode::ConcreteViewShadowNode;
26
-
26
+
27
27
  RNUITextViewShadowNode(
28
28
  const ShadowNode& sourceShadowNode,
29
29
  const ShadowNodeFragment& fragment
@@ -41,8 +41,8 @@ public:
41
41
  Size measureContent(
42
42
  const LayoutContext& layoutContext,
43
43
  const LayoutConstraints& layoutConstraints) const override;
44
-
44
+
45
45
  private:
46
- mutable AttributedString _attributedString;
46
+ mutable AttributedString _attributedString;
47
47
  };
48
48
  } // namespace facebook::React
@@ -8,7 +8,7 @@
8
8
  * @generated by codegen project: GenerateComponentDescriptorCpp.js
9
9
  */
10
10
 
11
- #include "ComponentDescriptors.h"
11
+ #include <react/renderer/components/RNUITextViewSpec/ComponentDescriptors.h>
12
12
  #include <react/renderer/core/ConcreteComponentDescriptor.h>
13
13
  #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
14
14
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  #pragma once
12
12
 
13
- #include "ShadowNodes.h"
13
+ #include <react/renderer/components/RNUITextViewSpec/ShadowNodes.h>
14
14
  #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
15
  #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
16
16
 
@@ -8,7 +8,7 @@
8
8
  * @generated by codegen project: GenerateEventEmitterCpp.js
9
9
  */
10
10
 
11
- #include "EventEmitters.h"
11
+ #include <react/renderer/components/RNUITextViewSpec/EventEmitters.h>
12
12
 
13
13
 
14
14
  namespace facebook::react {
@@ -8,7 +8,7 @@
8
8
  * @generated by codegen project: GeneratePropsCpp.js
9
9
  */
10
10
 
11
- #include "Props.h"
11
+ #include <react/renderer/components/RNUITextViewSpec/Props.h>
12
12
  #include <react/renderer/core/PropsParserContext.h>
13
13
  #include <react/renderer/core/propsConversions.h>
14
14
 
@@ -30,6 +30,7 @@ RNUITextViewChildProps::RNUITextViewChildProps(
30
30
  textDecorationLine(convertRawProp(context, rawProps, "textDecorationLine", sourceProps.textDecorationLine, {RNUITextViewChildTextDecorationLine::None})),
31
31
  textDecorationStyle(convertRawProp(context, rawProps, "textDecorationStyle", sourceProps.textDecorationStyle, {RNUITextViewChildTextDecorationStyle::Solid})),
32
32
  textDecorationColor(convertRawProp(context, rawProps, "textDecorationColor", sourceProps.textDecorationColor, {})),
33
+ textAlign(convertRawProp(context, rawProps, "textAlign", sourceProps.textAlign, {RNUITextViewChildTextAlign::Auto})),
33
34
  shadowRadius(convertRawProp(context, rawProps, "shadowRadius", sourceProps.shadowRadius, {0.0}))
34
35
  {}
35
36
  RNUITextViewProps::RNUITextViewProps(
@@ -38,7 +39,7 @@ RNUITextViewProps::RNUITextViewProps(
38
39
  const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
39
40
 
40
41
  numberOfLines(convertRawProp(context, rawProps, "numberOfLines", sourceProps.numberOfLines, {0})),
41
- allowsFontScaling(convertRawProp(context, rawProps, "allowsFontScaling", sourceProps.allowsFontScaling, {false})),
42
+ allowFontScaling(convertRawProp(context, rawProps, "allowFontScaling", sourceProps.allowFontScaling, {true})),
42
43
  ellipsizeMode(convertRawProp(context, rawProps, "ellipsizeMode", sourceProps.ellipsizeMode, {RNUITextViewEllipsizeMode::Tail})),
43
44
  selectable(convertRawProp(context, rawProps, "selectable", sourceProps.selectable, {false})),
44
45
  customMenuItems(convertRawProp(context, rawProps, "customMenuItems", sourceProps.customMenuItems, {}))
@@ -93,6 +93,27 @@ static inline std::string toString(const RNUITextViewChildTextDecorationStyle &v
93
93
  case RNUITextViewChildTextDecorationStyle::Dashed: return "dashed";
94
94
  }
95
95
  }
96
+ enum class RNUITextViewChildTextAlign { Auto, Left, Right, Center, Justify };
97
+
98
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNUITextViewChildTextAlign &result) {
99
+ auto string = (std::string)value;
100
+ if (string == "auto") { result = RNUITextViewChildTextAlign::Auto; return; }
101
+ if (string == "left") { result = RNUITextViewChildTextAlign::Left; return; }
102
+ if (string == "right") { result = RNUITextViewChildTextAlign::Right; return; }
103
+ if (string == "center") { result = RNUITextViewChildTextAlign::Center; return; }
104
+ if (string == "justify") { result = RNUITextViewChildTextAlign::Justify; return; }
105
+ abort();
106
+ }
107
+
108
+ static inline std::string toString(const RNUITextViewChildTextAlign &value) {
109
+ switch (value) {
110
+ case RNUITextViewChildTextAlign::Auto: return "auto";
111
+ case RNUITextViewChildTextAlign::Left: return "left";
112
+ case RNUITextViewChildTextAlign::Right: return "right";
113
+ case RNUITextViewChildTextAlign::Center: return "center";
114
+ case RNUITextViewChildTextAlign::Justify: return "justify";
115
+ }
116
+ }
96
117
 
97
118
  class RNUITextViewChildProps final : public ViewProps {
98
119
  public:
@@ -112,6 +133,7 @@ class RNUITextViewChildProps final : public ViewProps {
112
133
  RNUITextViewChildTextDecorationLine textDecorationLine{RNUITextViewChildTextDecorationLine::None};
113
134
  RNUITextViewChildTextDecorationStyle textDecorationStyle{RNUITextViewChildTextDecorationStyle::Solid};
114
135
  SharedColor textDecorationColor{};
136
+ RNUITextViewChildTextAlign textAlign{RNUITextViewChildTextAlign::Auto};
115
137
  Float shadowRadius{0.0};
116
138
  };
117
139
 
@@ -173,7 +195,7 @@ class RNUITextViewProps final : public ViewProps {
173
195
  #pragma mark - Props
174
196
 
175
197
  int numberOfLines{0};
176
- bool allowsFontScaling{false};
198
+ bool allowFontScaling{true};
177
199
  RNUITextViewEllipsizeMode ellipsizeMode{RNUITextViewEllipsizeMode::Tail};
178
200
  bool selectable{false};
179
201
  std::vector<RNUITextViewCustomMenuItemsStruct> customMenuItems{};
@@ -8,7 +8,7 @@
8
8
  * @generated by codegen project: GenerateShadowNodeCpp.js
9
9
  */
10
10
 
11
- #include "ShadowNodes.h"
11
+ #include <react/renderer/components/RNUITextViewSpec/ShadowNodes.h>
12
12
 
13
13
  namespace facebook::react {
14
14
 
@@ -10,9 +10,9 @@
10
10
 
11
11
  #pragma once
12
12
 
13
- #include "EventEmitters.h"
14
- #include "Props.h"
15
- #include "States.h"
13
+ #include <react/renderer/components/RNUITextViewSpec/EventEmitters.h>
14
+ #include <react/renderer/components/RNUITextViewSpec/Props.h>
15
+ #include <react/renderer/components/RNUITextViewSpec/States.h>
16
16
  #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
17
  #include <jsi/jsi.h>
18
18
 
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @generated by codegen project: GenerateStateCpp.js
9
9
  */
10
- #include "States.h"
10
+ #include <react/renderer/components/RNUITextViewSpec/States.h>
11
11
 
12
12
  namespace facebook::react {
13
13
 
@@ -1,4 +1,3 @@
1
- import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'
2
1
  import type {ColorValue, ViewProps} from 'react-native'
3
2
  import type {
4
3
  BubblingEventHandler,
@@ -6,6 +5,7 @@ import type {
6
5
  Int32,
7
6
  WithDefault,
8
7
  } from 'react-native/Libraries/Types/CodegenTypes'
8
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'
9
9
 
10
10
  interface TargetedEvent {
11
11
  target: Int32
@@ -26,6 +26,8 @@ export type NativeFontWeight =
26
26
 
27
27
  type FontStyle = 'normal' | 'italic'
28
28
 
29
+ type TextAlign = 'auto' | 'left' | 'right' | 'center' | 'justify'
30
+
29
31
  interface NativeProps extends ViewProps {
30
32
  text: string
31
33
  color?: ColorValue
@@ -38,6 +40,7 @@ interface NativeProps extends ViewProps {
38
40
  textDecorationLine?: WithDefault<TextDecorationLine, 'none'>
39
41
  textDecorationStyle?: WithDefault<TextDecorationStyle, 'solid'>
40
42
  textDecorationColor?: ColorValue
43
+ textAlign?: WithDefault<TextAlign, 'auto'>
41
44
  shadowRadius?: WithDefault<Float, 0>
42
45
  onPress?: BubblingEventHandler<TargetedEvent>
43
46
  onLongPress?: BubblingEventHandler<TargetedEvent>
@@ -1,47 +1,47 @@
1
- import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'
2
- import type {ViewProps} from 'react-native'
1
+ import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
2
+ import type { ViewProps } from "react-native";
3
3
  import type {
4
4
  BubblingEventHandler,
5
5
  Int32,
6
6
  WithDefault,
7
7
  DirectEventHandler,
8
- } from 'react-native/Libraries/Types/CodegenTypes'
8
+ } from "react-native/Libraries/Types/CodegenTypes";
9
9
 
10
10
  interface TargetedEvent {
11
- target: Int32
11
+ target: Int32;
12
12
  }
13
13
 
14
14
  interface TextLayoutEvent extends TargetedEvent {
15
- lines: string[]
15
+ lines: string[];
16
16
  }
17
17
 
18
18
  // 自定义菜单项接口
19
19
  interface CustomMenuItem {
20
- title: string
21
- actionId: string
20
+ title: string;
21
+ actionId: string;
22
22
  }
23
23
 
24
24
  // 自定义菜单操作事件
25
25
  interface CustomMenuActionEvent extends TargetedEvent {
26
- actionId: string
27
- selectedText: string
26
+ actionId: string;
27
+ selectedText: string;
28
28
  }
29
29
 
30
- type EllipsizeMode = 'head' | 'middle' | 'tail' | 'clip'
30
+ type EllipsizeMode = "head" | "middle" | "tail" | "clip";
31
31
 
32
32
  interface NativeProps extends ViewProps {
33
33
  // 现有属性
34
- numberOfLines?: Int32
35
- allowsFontScaling?: boolean
36
- ellipsizeMode?: WithDefault<EllipsizeMode, 'tail'>
37
- selectable?: boolean
38
- onTextLayout?: BubblingEventHandler<TextLayoutEvent>
34
+ numberOfLines?: Int32;
35
+ allowFontScaling?: WithDefault<boolean, true>;
36
+ ellipsizeMode?: WithDefault<EllipsizeMode, "tail">;
37
+ selectable?: boolean;
38
+ onTextLayout?: BubblingEventHandler<TextLayoutEvent>;
39
39
 
40
40
  // 新增自定义菜单属性
41
- customMenuItems?: ReadonlyArray<CustomMenuItem>
42
- onCustomMenuAction?: DirectEventHandler<CustomMenuActionEvent>
41
+ customMenuItems?: ReadonlyArray<CustomMenuItem>;
42
+ onCustomMenuAction?: DirectEventHandler<CustomMenuActionEvent>;
43
43
  }
44
44
 
45
- export default codegenNativeComponent<NativeProps>('RNUITextView', {
46
- excludedPlatforms: ['android'],
47
- })
45
+ export default codegenNativeComponent<NativeProps>("RNUITextView", {
46
+ excludedPlatforms: ["android"],
47
+ });