@bsky.app/react-native-uitextview 2.6.0 → 2.7.1

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.
@@ -141,7 +141,8 @@ RNUITextViewProps::RNUITextViewProps(
141
141
  numberOfLines(convertRawProp(context, rawProps, "numberOfLines", sourceProps.numberOfLines, {0})),
142
142
  allowFontScaling(convertRawProp(context, rawProps, "allowFontScaling", sourceProps.allowFontScaling, {true})),
143
143
  ellipsizeMode(convertRawProp(context, rawProps, "ellipsizeMode", sourceProps.ellipsizeMode, {RNUITextViewEllipsizeMode::Tail})),
144
- selectable(convertRawProp(context, rawProps, "selectable", sourceProps.selectable, {false})) {}
144
+ selectable(convertRawProp(context, rawProps, "selectable", sourceProps.selectable, {false})),
145
+ selectionColor(convertRawProp(context, rawProps, "selectionColor", sourceProps.selectionColor, {})) {}
145
146
 
146
147
  #ifdef RN_SERIALIZABLE_STATE
147
148
  ComponentName RNUITextViewProps::getDiffPropsImplementationTarget() const {
@@ -174,6 +175,10 @@ folly::dynamic RNUITextViewProps::getDiffProps(
174
175
  if (selectable != oldProps->selectable) {
175
176
  result["selectable"] = selectable;
176
177
  }
178
+
179
+ if (selectionColor != oldProps->selectionColor) {
180
+ result["selectionColor"] = *selectionColor;
181
+ }
177
182
  return result;
178
183
  }
179
184
  #endif
@@ -229,6 +229,7 @@ class RNUITextViewProps final : public ViewProps {
229
229
  bool allowFontScaling{true};
230
230
  RNUITextViewEllipsizeMode ellipsizeMode{RNUITextViewEllipsizeMode::Tail};
231
231
  bool selectable{false};
232
+ SharedColor selectionColor{};
232
233
 
233
234
  #ifdef RN_SERIALIZABLE_STATE
234
235
  ComponentName getDiffPropsImplementationTarget() const override;
@@ -135,6 +135,7 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(RNUITextViewEllipsize
135
135
  CFTimeInterval _highlightActivationTime;
136
136
  NSUInteger _highlightGeneration;
137
137
  BOOL _suppressSelectionChange;
138
+ BOOL _textLayoutNeedsUpdate;
138
139
  }
139
140
 
140
141
  + (ComponentDescriptorProvider)componentDescriptorProvider
@@ -150,7 +151,9 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(RNUITextViewEllipsize
150
151
 
151
152
  _view = [[UIView alloc] init];
152
153
  self.contentView = _view;
153
- self.clipsToBounds = true;
154
+ // Match React Native's Paragraph component and allow transformed inline
155
+ // attachments to paint outside the measured text bounds. Explicit
156
+ // `overflow: hidden` styles are still handled by RCTViewComponentView.
154
157
 
155
158
  if (@available(iOS 16.0, *)) {
156
159
  // This component relies on NSLayoutManager for measurement, hit-testing,
@@ -222,11 +225,20 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(RNUITextViewEllipsize
222
225
  - (void)layoutSubviews
223
226
  {
224
227
  [super layoutSubviews];
225
- // _textView's frame is assigned inside drawRect, which only fires when
226
- // state changes. Trigger a redraw whenever the host frame moves out from
227
- // under it (rotation, parent relayout) so the text view resizes and
228
- // onTextLayout re-fires with the new line wrapping.
228
+ // Keep the inner view in sync synchronously, like RCTParagraphComponentView.
229
+ // Deferring this to drawRect can leave UITextView at an intermediate width
230
+ // after a rotation because display invalidations may be coalesced.
229
231
  if (!CGRectEqualToRect(_textView.frame, _view.frame)) {
232
+ const NSRange savedRange = _textView.selectedRange;
233
+ _suppressSelectionChange = YES;
234
+ _textView.frame = _view.frame;
235
+ if (savedRange.location != NSNotFound &&
236
+ NSMaxRange(savedRange) <= _textView.attributedText.length) {
237
+ _textView.selectedRange = savedRange;
238
+ }
239
+ _suppressSelectionChange = NO;
240
+
241
+ _textLayoutNeedsUpdate = YES;
230
242
  [self setNeedsDisplay];
231
243
  }
232
244
  }
@@ -242,13 +254,11 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(RNUITextViewEllipsize
242
254
  const auto attrString = _state->getData().attributedString;
243
255
  const auto convertedAttrString = RCTNSAttributedStringFromAttributedString(attrString);
244
256
 
245
- // Setting attributedText clears any active text selection, and re-assigning
246
- // the frame triggers a layout flush that has the same effect. Bail out
247
- // entirely when nothing actually changed so a JS-side state update made in
248
- // response to onSelectionChange doesn't deselect what the user is selecting.
257
+ // Setting attributedText clears any active text selection. Bail out entirely
258
+ // when neither the text nor its layout changed so a JS-side state update made
259
+ // in response to onSelectionChange doesn't deselect what the user is selecting.
249
260
  const BOOL textChanged = ![_textView.attributedText isEqualToAttributedString:convertedAttrString];
250
- const BOOL frameChanged = !CGRectEqualToRect(_textView.frame, _view.frame);
251
- if (!textChanged && !frameChanged) {
261
+ if (!textChanged && !_textLayoutNeedsUpdate) {
252
262
  return;
253
263
  }
254
264
  if (textChanged) {
@@ -264,9 +274,7 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(RNUITextViewEllipsize
264
274
  }
265
275
  _suppressSelectionChange = NO;
266
276
  }
267
- if (frameChanged) {
268
- _textView.frame = _view.frame;
269
- }
277
+ _textLayoutNeedsUpdate = NO;
270
278
 
271
279
  if (_activeHighlightGroup != nil) {
272
280
  [self updatePressHighlight];
@@ -308,6 +316,10 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(RNUITextViewEllipsize
308
316
  _textView.selectable = newViewProps.selectable;
309
317
  }
310
318
 
319
+ if (oldViewProps.selectionColor != newViewProps.selectionColor) {
320
+ _textView.tintColor = RCTUIColorFromSharedColor(newViewProps.selectionColor);
321
+ }
322
+
311
323
  if (oldViewProps.allowFontScaling != newViewProps.allowFontScaling) {
312
324
  if (@available(iOS 11.0, *)) {
313
325
  _textView.adjustsFontForContentSizeCategory = newViewProps.allowFontScaling;
@@ -141,7 +141,8 @@ RNUITextViewProps::RNUITextViewProps(
141
141
  numberOfLines(convertRawProp(context, rawProps, "numberOfLines", sourceProps.numberOfLines, {0})),
142
142
  allowFontScaling(convertRawProp(context, rawProps, "allowFontScaling", sourceProps.allowFontScaling, {true})),
143
143
  ellipsizeMode(convertRawProp(context, rawProps, "ellipsizeMode", sourceProps.ellipsizeMode, {RNUITextViewEllipsizeMode::Tail})),
144
- selectable(convertRawProp(context, rawProps, "selectable", sourceProps.selectable, {false})) {}
144
+ selectable(convertRawProp(context, rawProps, "selectable", sourceProps.selectable, {false})),
145
+ selectionColor(convertRawProp(context, rawProps, "selectionColor", sourceProps.selectionColor, {})) {}
145
146
 
146
147
  #ifdef RN_SERIALIZABLE_STATE
147
148
  ComponentName RNUITextViewProps::getDiffPropsImplementationTarget() const {
@@ -174,6 +175,10 @@ folly::dynamic RNUITextViewProps::getDiffProps(
174
175
  if (selectable != oldProps->selectable) {
175
176
  result["selectable"] = selectable;
176
177
  }
178
+
179
+ if (selectionColor != oldProps->selectionColor) {
180
+ result["selectionColor"] = *selectionColor;
181
+ }
177
182
  return result;
178
183
  }
179
184
  #endif
@@ -229,6 +229,7 @@ class RNUITextViewProps final : public ViewProps {
229
229
  bool allowFontScaling{true};
230
230
  RNUITextViewEllipsizeMode ellipsizeMode{RNUITextViewEllipsizeMode::Tail};
231
231
  bool selectable{false};
232
+ SharedColor selectionColor{};
232
233
 
233
234
  #ifdef RN_SERIALIZABLE_STATE
234
235
  ComponentName getDiffPropsImplementationTarget() const override;
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  type CodegenTypes,
3
+ type ColorValue,
3
4
  type ViewProps,
4
5
  codegenNativeComponent,
5
6
  } from 'react-native'
@@ -30,6 +31,7 @@ interface NativeProps extends ViewProps {
30
31
  allowFontScaling?: CodegenTypes.WithDefault<boolean, true>
31
32
  ellipsizeMode?: CodegenTypes.WithDefault<EllipsizeMode, 'tail'>
32
33
  selectable?: boolean
34
+ selectionColor?: ColorValue
33
35
  onTextLayout?: CodegenTypes.BubblingEventHandler<TextLayoutEvent>
34
36
  /**
35
37
  * Callback fired when the text selection changes.
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  type CodegenTypes,
3
+ type ColorValue,
3
4
  type ViewProps,
4
5
  codegenNativeComponent,
5
6
  } from 'react-native'
@@ -30,6 +31,7 @@ interface NativeProps extends ViewProps {
30
31
  allowFontScaling?: CodegenTypes.WithDefault<boolean, true>
31
32
  ellipsizeMode?: CodegenTypes.WithDefault<EllipsizeMode, 'tail'>
32
33
  selectable?: boolean
34
+ selectionColor?: ColorValue
33
35
  onTextLayout?: CodegenTypes.BubblingEventHandler<TextLayoutEvent>
34
36
  /**
35
37
  * Callback fired when the text selection changes.
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../../example/src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AA8E9B,MAAM,CAAC,OAAO,UAAU,GAAG,sBAuxB1B"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../../example/src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AA8E9B,MAAM,CAAC,OAAO,UAAU,GAAG,sBAiyB1B"}
@@ -1,4 +1,4 @@
1
- import { type CodegenTypes, type ViewProps } from 'react-native';
1
+ import { type CodegenTypes, type ColorValue, type ViewProps } from 'react-native';
2
2
  interface TargetedEvent {
3
3
  target: CodegenTypes.Int32;
4
4
  }
@@ -21,6 +21,7 @@ interface NativeProps extends ViewProps {
21
21
  allowFontScaling?: CodegenTypes.WithDefault<boolean, true>;
22
22
  ellipsizeMode?: CodegenTypes.WithDefault<EllipsizeMode, 'tail'>;
23
23
  selectable?: boolean;
24
+ selectionColor?: ColorValue;
24
25
  onTextLayout?: CodegenTypes.BubblingEventHandler<TextLayoutEvent>;
25
26
  /**
26
27
  * Callback fired when the text selection changes.
@@ -1 +1 @@
1
- {"version":3,"file":"RNUITextViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/RNUITextViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EAEf,MAAM,cAAc,CAAA;AAErB,UAAU,aAAa;IACrB,MAAM,EAAE,YAAY,CAAC,KAAK,CAAA;CAC3B;A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,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;AAExD,UAAU,WAAY,SAAQ,SAAS;IACrC,aAAa,CAAC,EAAE,YAAY,CAAC,KAAK,CAAA;IAClC,gBAAgB,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAC1D,aAAa,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;IAC/D,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,cAAc,CAAC,EAAE,UAAU,CAAA;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAA;IACjE;;;;;;;;;;;;;OAaG;IACH,iBAAiB,CAAC,EAAE,YAAY,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAA;CAC5E;;AAED,wBAEE"}
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../../example/src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AA8E9B,MAAM,CAAC,OAAO,UAAU,GAAG,sBAuxB1B"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../../example/src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AA8E9B,MAAM,CAAC,OAAO,UAAU,GAAG,sBAiyB1B"}
@@ -1,4 +1,4 @@
1
- import { type CodegenTypes, type ViewProps } from 'react-native';
1
+ import { type CodegenTypes, type ColorValue, type ViewProps } from 'react-native';
2
2
  interface TargetedEvent {
3
3
  target: CodegenTypes.Int32;
4
4
  }
@@ -21,6 +21,7 @@ interface NativeProps extends ViewProps {
21
21
  allowFontScaling?: CodegenTypes.WithDefault<boolean, true>;
22
22
  ellipsizeMode?: CodegenTypes.WithDefault<EllipsizeMode, 'tail'>;
23
23
  selectable?: boolean;
24
+ selectionColor?: ColorValue;
24
25
  onTextLayout?: CodegenTypes.BubblingEventHandler<TextLayoutEvent>;
25
26
  /**
26
27
  * Callback fired when the text selection changes.
@@ -1 +1 @@
1
- {"version":3,"file":"RNUITextViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/RNUITextViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EAEf,MAAM,cAAc,CAAA;AAErB,UAAU,aAAa;IACrB,MAAM,EAAE,YAAY,CAAC,KAAK,CAAA;CAC3B;AAED,UAAU,eAAgB,SAAQ,aAAa;IAC7C,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB;AAED;;;;;GAKG;AACH,UAAU,oBAAqB,SAAQ,aAAa;IAClD,KAAK,EAAE,YAAY,CAAC,KAAK,CAAA;IACzB,GAAG,EAAE,YAAY,CAAC,KAAK,CAAA;CACxB;AAED,KAAK,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;AAExD,UAAU,WAAY,SAAQ,SAAS;IACrC,aAAa,CAAC,EAAE,YAAY,CAAC,KAAK,CAAA;IAClC,gBAAgB,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAC1D,aAAa,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;IAC/D,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAA;IACjE;;;;;;;;;;;;;OAaG;IACH,iBAAiB,CAAC,EAAE,YAAY,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAA;CAC5E;;AAED,wBAEE"}
1
+ {"version":3,"file":"RNUITextViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/RNUITextViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,EAEf,MAAM,cAAc,CAAA;AAErB,UAAU,aAAa;IACrB,MAAM,EAAE,YAAY,CAAC,KAAK,CAAA;CAC3B;AAED,UAAU,eAAgB,SAAQ,aAAa;IAC7C,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB;AAED;;;;;GAKG;AACH,UAAU,oBAAqB,SAAQ,aAAa;IAClD,KAAK,EAAE,YAAY,CAAC,KAAK,CAAA;IACzB,GAAG,EAAE,YAAY,CAAC,KAAK,CAAA;CACxB;AAED,KAAK,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;AAExD,UAAU,WAAY,SAAQ,SAAS;IACrC,aAAa,CAAC,EAAE,YAAY,CAAC,KAAK,CAAA;IAClC,gBAAgB,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAC1D,aAAa,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;IAC/D,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,cAAc,CAAC,EAAE,UAAU,CAAA;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAA;IACjE;;;;;;;;;;;;;OAaG;IACH,iBAAiB,CAAC,EAAE,YAAY,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAA;CAC5E;;AAED,wBAEE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsky.app/react-native-uitextview",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "description": "UITextView for React Native",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  type CodegenTypes,
3
+ type ColorValue,
3
4
  type ViewProps,
4
5
  codegenNativeComponent,
5
6
  } from 'react-native'
@@ -30,6 +31,7 @@ interface NativeProps extends ViewProps {
30
31
  allowFontScaling?: CodegenTypes.WithDefault<boolean, true>
31
32
  ellipsizeMode?: CodegenTypes.WithDefault<EllipsizeMode, 'tail'>
32
33
  selectable?: boolean
34
+ selectionColor?: ColorValue
33
35
  onTextLayout?: CodegenTypes.BubblingEventHandler<TextLayoutEvent>
34
36
  /**
35
37
  * Callback fired when the text selection changes.