Skip to content

Commit

Permalink
Pass grammarCheck to text input views for Mac (microsoft#1293)
Browse files Browse the repository at this point in the history
# Conflicts:
#	Libraries/Components/TextInput/TextInput.js
  • Loading branch information
Alex Chiu authored and christophpurrer committed Aug 10, 2022
1 parent cd08c12 commit 202402f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Libraries/Text/TextInput/RCTBaseTextInputView.m
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,27 @@ - (void)submitOnKeyDownIfNeeded:(NSEvent *)event
}
}

- (void)automaticSpellingCorrectionDidChange:(BOOL)enabled
{
if (_onAutoCorrectToggle) {
_onAutoCorrectToggle(@{@"enabled": [NSNumber numberWithBool:enabled]});
}
}

- (void)continuousSpellCheckingDidChange:(BOOL)enabled
{
if (_onSpellCheckToggle) {
_onSpellCheckToggle(@{@"enabled": [NSNumber numberWithBool:enabled]});
}
}

- (void)grammarCheckingDidChange:(BOOL)enabled
{
if (_onGrammarCheckToggle) {
_onGrammarCheckToggle(@{@"enabled": [NSNumber numberWithBool:enabled]});
}
}

- (BOOL)textInputShouldReturn
{
// We send `submit` event here, in `textInputShouldReturn`
Expand Down
6 changes: 6 additions & 0 deletions Libraries/Text/TextInput/RCTBaseTextInputViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ @implementation RCTBaseTextInputViewManager
RCT_EXPORT_VIEW_PROPERTY(onSubmitEditing, RCTBubblingEventBlock);
RCT_EXPORT_VIEW_PROPERTY(submitKeyEvents, NSArray<NSDictionary *>);

#if TARGET_OS_OSX // TODO(macOS ISS#2323203)
RCT_EXPORT_VIEW_PROPERTY(onAutoCorrectToggle, RCTBubblingEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onSpellCheckToggle, RCTBubblingEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onGrammarCheckToggle, RCTBubblingEventBlock);
#endif // TODO(macOS ISS#2323203)

RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onKeyPressSync, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onChangeSync, RCTDirectEventBlock)
Expand Down

0 comments on commit 202402f

Please sign in to comment.