diff --git a/Libraries/Components/TextInput/RCTTextInputViewConfig.js b/Libraries/Components/TextInput/RCTTextInputViewConfig.js index ee479389c8162e..d757e17c5b02cd 100644 --- a/Libraries/Components/TextInput/RCTTextInputViewConfig.js +++ b/Libraries/Components/TextInput/RCTTextInputViewConfig.js @@ -141,6 +141,7 @@ const RCTTextInputViewConfig = { autoCapitalize: true, keyboardAppearance: true, passwordRules: true, + grammarCheck: true, // TODO(macOS GH#774) spellCheck: true, selectTextOnFocus: true, text: true, diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 913af59001c817..bd9f8cbd11b394 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -303,6 +303,14 @@ type IOSProps = $ReadOnly<{| */ scrollEnabled?: ?boolean, + // [TODO(macOS GH#774) + /** + * If `false`, disables grammar-check. + * @platform macOS + */ + grammarCheck?: ?boolean, + // ]TODO(macOS GH#774) + /** * If `false`, disables spell-check style (i.e. red underlines). * The default value is inherited from `autoCorrect`. diff --git a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m index fb39d14f1ffa10..eceea1b08ffc4b 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m @@ -48,6 +48,7 @@ @implementation RCTBaseTextInputViewManager RCT_REMAP_NOT_OSX_VIEW_PROPERTY(returnKeyType, backedTextInputView.returnKeyType, UIReturnKeyType) // TODO(macOS GH#774) RCT_REMAP_NOT_OSX_VIEW_PROPERTY(selectionColor, backedTextInputView.tintColor, UIColor) // TODO(macOS GH#774) RCT_REMAP_OSX_VIEW_PROPERTY(selectionColor, backedTextInputView.selectionColor, UIColor) // TODO(macOS GH#774) +RCT_REMAP_OSX_VIEW_PROPERTY(grammarCheck, backedTextInputView.grammarCheckingEnabled, BOOL) // TODO(macOS GH#774) RCT_REMAP_NOT_OSX_VIEW_PROPERTY(spellCheck, backedTextInputView.spellCheckingType, UITextSpellCheckingType) // TODO(macOS GH#774) RCT_REMAP_OSX_VIEW_PROPERTY(spellCheck, backedTextInputView.continuousSpellCheckingEnabled, BOOL) // TODO(macOS GH#774) RCT_REMAP_NOT_OSX_VIEW_PROPERTY(caretHidden, backedTextInputView.caretHidden, BOOL) // TODO(macOS GH#774) diff --git a/Libraries/Text/TextInput/Singleline/RCTUITextField.h b/Libraries/Text/TextInput/Singleline/RCTUITextField.h index 6cd3c2170381bd..abbae748ea1e4c 100644 --- a/Libraries/Text/TextInput/Singleline/RCTUITextField.h +++ b/Libraries/Text/TextInput/Singleline/RCTUITextField.h @@ -55,6 +55,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, getter=isAutomaticTextReplacementEnabled) BOOL automaticTextReplacementEnabled; @property (nonatomic, getter=isAutomaticSpellingCorrectionEnabled) BOOL automaticSpellingCorrectionEnabled; @property (nonatomic, getter=isContinuousSpellCheckingEnabled) BOOL continuousSpellCheckingEnabled; +@property (nonatomic, getter=isGrammarCheckingEnabled) BOOL grammarCheckingEnabled; @property (nonatomic, assign) BOOL enableFocusRing; @property (nonatomic, strong, nullable) RCTUIColor *selectionColor; @property (weak, nullable) id delegate; diff --git a/Libraries/Text/TextInput/Singleline/RCTUITextField.m b/Libraries/Text/TextInput/Singleline/RCTUITextField.m index 7c4aaf1a874dd5..8823b62018f48f 100644 --- a/Libraries/Text/TextInput/Singleline/RCTUITextField.m +++ b/Libraries/Text/TextInput/Singleline/RCTUITextField.m @@ -27,6 +27,7 @@ @interface RCTUITextFieldCell : NSTextFieldCell @property (nonatomic, getter=isAutomaticTextReplacementEnabled) BOOL automaticTextReplacementEnabled; @property (nonatomic, getter=isAutomaticSpellingCorrectionEnabled) BOOL automaticSpellingCorrectionEnabled; @property (nonatomic, getter=isContinuousSpellCheckingEnabled) BOOL continuousSpellCheckingEnabled; +@property (nonatomic, getter=isGrammarCheckingEnabled) BOOL grammarCheckingEnabled; @property (nonatomic, strong, nullable) RCTUIColor *selectionColor; @end @@ -72,6 +73,7 @@ - (NSText *)setUpFieldEditorAttributes:(NSText *)textObj fieldEditor.automaticSpellingCorrectionEnabled = self.isAutomaticSpellingCorrectionEnabled; fieldEditor.automaticTextReplacementEnabled = self.isAutomaticTextReplacementEnabled; fieldEditor.continuousSpellCheckingEnabled = self.isContinuousSpellCheckingEnabled; + fieldEditor.grammarCheckingEnabled = self.isGrammarCheckingEnabled; NSMutableDictionary *selectTextAttributes = fieldEditor.selectedTextAttributes.mutableCopy; selectTextAttributes[NSBackgroundColorAttributeName] = self.selectionColor ?: [NSColor selectedControlColor]; fieldEditor.selectedTextAttributes = selectTextAttributes; @@ -208,6 +210,16 @@ - (BOOL)isContinuousSpellCheckingEnabled return ((RCTUITextFieldCell*)self.cell).isContinuousSpellCheckingEnabled; } +- (void)setGrammarCheckingEnabled:(BOOL)grammarCheckingEnabled +{ + ((RCTUITextFieldCell*)self.cell).grammarCheckingEnabled = grammarCheckingEnabled; +} + +- (BOOL)isGrammarCheckingEnabled +{ + return ((RCTUITextFieldCell*)self.cell).isGrammarCheckingEnabled; +} + - (void)setSelectionColor:(RCTUIColor *)selectionColor // TODO(OSS Candidate ISS#2710739) { ((RCTUITextFieldCell*)self.cell).selectionColor = selectionColor;