Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ios/EnrichedTextInputView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2000,6 +2000,14 @@ - (bool)textView:(UITextView *)textView
return NO;
}

// to be sure, we re-run typingAttributes management right before the
// character actually lands. Some times between selection change and the next
// keystroke typing attributes might get removed - seems like a native TextKit
// issue
Comment thread
Copilot marked this conversation as resolved.
Outdated
if (range.length == 0 && text.length > 0) {
Comment thread
hejsztynx marked this conversation as resolved.
Outdated
[attributesManager repeatRecentTypingAttributesManagement];
}

return YES;
}

Expand Down
1 change: 1 addition & 0 deletions ios/inputAttributesManager/InputAttributesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- (void)didRemoveTypingAttribute:(NSString *)key;
- (void)clearRemovedTypingAttributes;
- (void)manageTypingAttributesWithOnlySelection:(BOOL)onlySelectionChanged;
- (void)repeatRecentTypingAttributesManagement;
- (void)handleDirtyRangesStyling;
- (NSSet<NSString *> *)customAttributesKeys;
@end
8 changes: 8 additions & 0 deletions ios/inputAttributesManager/InputAttributesManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ @implementation InputAttributesManager {
NSMutableArray<NSValue *> *_dirtyRanges;
NSSet *_customAttributesKeys;
NSMutableSet *_removedTypingAttributes;
BOOL _recentManagedTypingAttributesOnlySelection;
}

- (instancetype)initWithInput:(EnrichedTextInputView *)input {
self = [super init];
_input = input;
_dirtyRanges = [[NSMutableArray alloc] init];
_removedTypingAttributes = [[NSMutableSet alloc] init];
_recentManagedTypingAttributesOnlySelection = NO;

// setup customAttributes
NSMutableSet *_customAttrsSet = [[NSMutableSet alloc] init];
Expand Down Expand Up @@ -129,6 +131,7 @@ - (void)handleDirtyRangesStyling {
}

- (void)manageTypingAttributesWithOnlySelection:(BOOL)onlySelectionChanged {
_recentManagedTypingAttributesOnlySelection = onlySelectionChanged;
EnrichedInputTextView *textView = _input->textView;
NSRange selectedRange = textView.selectedRange;

Expand Down Expand Up @@ -219,4 +222,9 @@ - (void)manageTypingAttributesWithOnlySelection:(BOOL)onlySelectionChanged {
textView.typingAttributes = newAttrs;
}

- (void)repeatRecentTypingAttributesManagement {
[self manageTypingAttributesWithOnlySelection:
_recentManagedTypingAttributesOnlySelection];
}

@end
Loading