Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt iOS16+ dictation #37188

Closed
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ - (BOOL)textOf:(NSAttributedString *)newText equals:(NSAttributedString *)oldTex
// If the user added an emoji, the system adds a font attribute for the emoji and stores the original font in
// NSOriginalFont. Lastly, when entering a password, etc., there will be additional styling on the field as the native
// text view handles showing the last character for a split second.
__block BOOL isDictationRunning = false;
[oldText enumerateAttribute:NSAttachmentAttributeName
inRange:NSMakeRange(0, oldText.length)
options:kNilOptions
usingBlock:^(id _Nullable value, NSRange range, BOOL * _Nonnull stop) {
if ([value respondsToSelector:NSSelectorFromString(@"typingAttributesBeforeInsertion")]) {
isDictationRunning = true;
*stop = true;
}
}];
__block BOOL fontHasBeenUpdatedBySystem = false;
[oldText enumerateAttribute:@"NSOriginalFont"
inRange:NSMakeRange(0, oldText.length)
Expand All @@ -120,7 +130,7 @@ - (BOOL)textOf:(NSAttributedString *)newText equals:(NSAttributedString *)oldTex
}];

BOOL shouldFallbackToBareTextComparison =
[self.backedTextInputView.textInputMode.primaryLanguage isEqualToString:@"dictation"] ||
isDictationRunning ||
[self.backedTextInputView.textInputMode.primaryLanguage isEqualToString:@"ko-KR"] ||
self.backedTextInputView.markedTextRange || self.backedTextInputView.isSecureTextEntry ||
fontHasBeenUpdatedBySystem;
Expand Down