react-native-macos 0.73.23 → 0.73.24
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/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Text/TextInput/RCTBaseTextInputView.mm +57 -24
- package/React/Base/RCTVersion.m +1 -1
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
979
|
-
|
|
980
|
-
|
|
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 (
|
|
992
|
-
|
|
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
|
package/React/Base/RCTVersion.m
CHANGED