diff --git a/Source/ASEditableTextNode.h b/Source/ASEditableTextNode.h index 558ca6f1ca..e15a288515 100644 --- a/Source/ASEditableTextNode.h +++ b/Source/ASEditableTextNode.h @@ -140,8 +140,9 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic) BOOL enablesReturnKeyAutomatically; // default is NO (when YES, will automatically disable return key when text widget has zero-length contents, and will automatically enable when text widget has non-zero-length contents) @property (nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry; // default is NO -- (void)dropAutocorrection; +@property (nonatomic, strong) NSString * _Nullable initialPrimaryLanguage; +- (void)dropAutocorrection; @end diff --git a/Source/ASEditableTextNode.mm b/Source/ASEditableTextNode.mm index 1c8e3d7098..9b020c06a3 100644 --- a/Source/ASEditableTextNode.mm +++ b/Source/ASEditableTextNode.mm @@ -83,6 +83,7 @@ @interface ASPanningOverriddenUITextView : ASTextKitComponentsTextView { BOOL _shouldBlockPanGesture; + BOOL _initializedPrimaryInputLanguage; } @property (nonatomic, copy) bool (^shouldPaste)(); @@ -90,6 +91,8 @@ @property (nonatomic, copy) bool (^shouldReturn)(); @property (nonatomic, copy) void (^backspaceWhileEmpty)(); +@property (nonatomic, strong) NSString * _Nullable initialPrimaryLanguage; + @end @implementation ASPanningOverriddenUITextView @@ -190,6 +193,21 @@ } } +- (UITextInputMode *)textInputMode { + if (!_initializedPrimaryInputLanguage) { + _initializedPrimaryInputLanguage = true; + /*if (_initialPrimaryLanguage != nil) { + for (UITextInputMode *inputMode in [UITextInputMode activeInputModes]) { + NSString *primaryLanguage = inputMode.primaryLanguage; + if (primaryLanguage != nil && [primaryLanguage isEqualToString:_initialPrimaryLanguage]) { + return inputMode; + } + }*/ + } + } + return [super textInputMode]; +} + #endif - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer @@ -316,6 +334,7 @@ // Create and configure our text view. ASPanningOverriddenUITextView *textView = [[ASPanningOverriddenUITextView alloc] initWithFrame:CGRectZero textContainer:_textKitComponents.textContainer]; + textView.initialPrimaryLanguage = _initialPrimaryLanguage; __weak ASEditableTextNode *weakSelf = self; textView.shouldPaste = ^bool{ __strong ASEditableTextNode *strongSelf = weakSelf;