react-native-macos 0.73.23 → 0.73.25

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.
@@ -12,6 +12,6 @@
12
12
  exports.version = {
13
13
  major: 0,
14
14
  minor: 73,
15
- patch: 23,
15
+ patch: 25,
16
16
  prerelease: null,
17
17
  };
@@ -211,10 +211,16 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
211
211
  NSAttributedString *oldAttributedText = [self.backedTextInputView.attributedText copy];
212
212
  NSInteger oldTextLength = oldAttributedText.string.length;
213
213
 
214
- [self.backedTextInputView.undoManager registerUndoWithTarget:self handler:^(RCTBaseTextInputView *strongSelf) {
215
- strongSelf.attributedText = oldAttributedText;
216
- [strongSelf textInputDidChange];
217
- }];
214
+ // Ghost text changes should not be part of the undo stack
215
+ if (!self.backedTextInputView.ghostTextChanging) {
216
+ // If there was ghost text previously, we don't want it showing up if we undo.
217
+ // If something goes wrong when trying to remove it, just stick with oldAttributedText.
218
+ NSAttributedString *oldAttributedTextWithoutGhostText = [self removingGhostTextFromString:oldAttributedText strict:YES] ?: oldAttributedText;
219
+ [self.backedTextInputView.undoManager registerUndoWithTarget:self handler:^(RCTBaseTextInputView *strongSelf) {
220
+ strongSelf.attributedText = oldAttributedTextWithoutGhostText;
221
+ [strongSelf textInputDidChange];
222
+ }];
223
+ }
218
224
 
219
225
  self.backedTextInputView.attributedText = attributedText;
220
226
 
@@ -975,27 +981,12 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
975
981
  self.backedTextInputView.ghostTextChanging = YES;
976
982
 
977
983
  if (_ghostText != nil) {
978
- BOOL shouldDeleteGhostText = YES;
979
- NSRange ghostTextRange = NSMakeRange(_ghostTextPosition, _ghostText.length);
980
- NSMutableAttributedString *attributedString = [self.attributedText mutableCopy];
981
-
982
- if ([attributedString length] < NSMaxRange(ghostTextRange)) {
983
- RCTAssert(false, @"Ghost text not fully present in text view text");
984
- shouldDeleteGhostText = NO;
985
- }
986
-
987
- NSString *actualGhostText = shouldDeleteGhostText
988
- ? [[attributedString attributedSubstringFromRange:ghostTextRange] string]
989
- : nil;
984
+ // When setGhostText: is called after making a standard edit, the ghost text may already be gone
985
+ BOOL ghostTextMayAlreadyBeGone = newGhostText == nil;
986
+ NSAttributedString *attributedStringWithoutGhostText = [self removingGhostTextFromString:self.attributedText strict:!ghostTextMayAlreadyBeGone];
990
987
 
991
- if (![actualGhostText isEqual:_ghostText]) {
992
- RCTAssert(false, @"Ghost text does not match text view text");
993
- shouldDeleteGhostText = NO;
994
- }
995
-
996
- if (shouldDeleteGhostText) {
997
- [attributedString deleteCharactersInRange:ghostTextRange];
998
- self.attributedText = attributedString;
988
+ if (attributedStringWithoutGhostText != nil) {
989
+ self.attributedText = attributedStringWithoutGhostText;
999
990
  [self setSelectionStart:selection.start selectionEnd:selection.end];
1000
991
  }
1001
992
  }
@@ -1016,6 +1007,48 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
1016
1007
  self.backedTextInputView.ghostTextChanging = NO;
1017
1008
  }
1018
1009
 
1010
+ /**
1011
+ * Attempts to remove the ghost text from a provided string given our current state.
1012
+ *
1013
+ * If `strict` mode is enabled, this method assumes the ghost text exists exactly
1014
+ * where we expect it to be. We assert and return `nil` if we don't find the expected ghost text.
1015
+ * It's the responsibility of the caller to make sure the result isn't `nil`.
1016
+ *
1017
+ * If disabled, we allow for the possibility that the ghost text has already been removed,
1018
+ * which can happen if a delegate callback is trying to remove ghost text after invoking `setAttributedText:`.
1019
+ */
1020
+ - (NSAttributedString *)removingGhostTextFromString:(NSAttributedString *)string strict:(BOOL)strict {
1021
+ if (_ghostText == nil) {
1022
+ return string;
1023
+ }
1024
+
1025
+ NSRange ghostTextRange = NSMakeRange(_ghostTextPosition, _ghostText.length);
1026
+ NSMutableAttributedString *attributedString = [string mutableCopy];
1027
+
1028
+ if ([attributedString length] < NSMaxRange(ghostTextRange)) {
1029
+ if (strict) {
1030
+ RCTAssert(false, @"Ghost text not fully present in text view text");
1031
+ return nil;
1032
+ } else {
1033
+ return string;
1034
+ }
1035
+ }
1036
+
1037
+ NSString *actualGhostText = [[attributedString attributedSubstringFromRange:ghostTextRange] string];
1038
+
1039
+ if (![actualGhostText isEqual:_ghostText]) {
1040
+ if (strict) {
1041
+ RCTAssert(false, @"Ghost text does not match text view text");
1042
+ return nil;
1043
+ } else {
1044
+ return string;
1045
+ }
1046
+ }
1047
+
1048
+ [attributedString deleteCharactersInRange:ghostTextRange];
1049
+ return attributedString;
1050
+ }
1051
+
1019
1052
  // macOS]
1020
1053
 
1021
1054
  #pragma mark - Helpers
@@ -137,6 +137,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)coder)
137
137
  // Pair the mouse down events with mouse up events so our _nativeTouches cache doesn't get stale
138
138
  if ([targetView isKindOfClass:[NSControl class]]) {
139
139
  _shouldSendMouseUpOnSystemBehalf = [(NSControl*)targetView isEnabled];
140
+ } else if ([targetView isKindOfClass:[NSTabView class]]) {
141
+ // NSTabView sends click events for tab buttons but doesn't inherit from NSControl
142
+ _shouldSendMouseUpOnSystemBehalf = YES;
140
143
  } else if ([targetView isKindOfClass:[NSText class]]) {
141
144
  _shouldSendMouseUpOnSystemBehalf = [(NSText*)targetView isSelectable];
142
145
  }
@@ -23,7 +23,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
23
23
  __rnVersion = @{
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(73),
26
- RCTVersionPatch: @(23),
26
+ RCTVersionPatch: @(25),
27
27
  RCTVersionPrerelease: [NSNull null],
28
28
  };
29
29
  });
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.73.23
1
+ VERSION_NAME=0.73.25
2
2
  react.internal.publishingGroup=com.facebook.react
3
3
 
4
4
  android.useAndroidX=true
@@ -17,6 +17,6 @@ public class ReactNativeVersion {
17
17
  public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
18
18
  "major", 0,
19
19
  "minor", 73,
20
- "patch", 23,
20
+ "patch", 25,
21
21
  "prerelease", null);
22
22
  }
@@ -17,7 +17,7 @@ namespace facebook::react {
17
17
  constexpr struct {
18
18
  int32_t Major = 0;
19
19
  int32_t Minor = 73;
20
- int32_t Patch = 23;
20
+ int32_t Patch = 25;
21
21
  std::string_view Prerelease = "";
22
22
  } ReactNativeVersion;
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.73.23",
3
+ "version": "0.73.25",
4
4
  "description": "React Native for macOS",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,23 +0,0 @@
1
- /*
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- package com.facebook.react.common.build;
9
-
10
- import com.facebook.react.BuildConfig;
11
-
12
- /**
13
- * Convenience class for accessing auto-generated BuildConfig so that a) other modules can just
14
- * depend on this module instead of having to manually depend on generating their own build config
15
- * and b) we don't have to deal with IntelliJ getting confused about the autogenerated BuildConfig
16
- * class all over the place.
17
- */
18
- public class ReactBuildConfig {
19
-
20
- public static final boolean DEBUG = BuildConfig.DEBUG;
21
- public static final boolean IS_INTERNAL_BUILD = BuildConfig.IS_INTERNAL_BUILD;
22
- public static final int EXOPACKAGE_FLAGS = BuildConfig.EXOPACKAGE_FLAGS;
23
- }