|
14 | 14 | #import "WordsUtils.h" |
15 | 15 | #import "LayoutManagerExtension.h" |
16 | 16 | #import "ZeroWidthSpaceUtils.h" |
| 17 | +#import "ParagraphAttributesUtils.h" |
17 | 18 |
|
18 | 19 | using namespace facebook::react; |
19 | 20 |
|
@@ -977,6 +978,22 @@ - (void)manageSelectionBasedChanges { |
977 | 978 | [mentionStyleClass manageMentionTypingAttributes]; |
978 | 979 | [mentionStyleClass manageMentionEditing]; |
979 | 980 | } |
| 981 | + |
| 982 | + // typing attributes for empty lines selection reset |
| 983 | + NSString *currentString = [[textView.textStorage.string copy] stringByReplacingOccurrencesOfString:@"\u200B" withString:@""]; |
| 984 | + if(textView.selectedRange.length == 0 && [_recentlyEmittedString isEqualToString: currentString] ) { |
| 985 | + // no string change means only a selection changed with no character changes |
| 986 | + NSRange paragraphRange = [textView.textStorage.string paragraphRangeForRange:textView.selectedRange]; |
| 987 | + if( |
| 988 | + paragraphRange.length == 0 || |
| 989 | + (paragraphRange.length == 1 && |
| 990 | + [[NSCharacterSet newlineCharacterSet] characterIsMember:[textView.textStorage.string characterAtIndex:paragraphRange.location]]) |
| 991 | + ) { |
| 992 | + // user changed selection to an empty line (or empty line with a newline) |
| 993 | + // typing attributes need to be reset |
| 994 | + textView.typingAttributes = defaultTypingAttributes; |
| 995 | + } |
| 996 | + } |
980 | 997 | } |
981 | 998 |
|
982 | 999 | - (void)handleWordModificationBasedChanges:(NSString*)word inRange:(NSRange)range { |
@@ -1135,7 +1152,8 @@ - (bool)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range r |
1135 | 1152 | [h1Style handleNewlinesInRange:range replacementText:text] || |
1136 | 1153 | [h2Style handleNewlinesInRange:range replacementText:text] || |
1137 | 1154 | [h3Style handleNewlinesInRange:range replacementText:text] || |
1138 | | - [ZeroWidthSpaceUtils handleBackspaceInRange:range replacementText:text input:self] |
| 1155 | + [ZeroWidthSpaceUtils handleBackspaceInRange:range replacementText:text input:self] || |
| 1156 | + [ParagraphAttributesUtils handleBackspaceInRange:range replacementText:text input:self] |
1139 | 1157 | ) { |
1140 | 1158 | [self anyTextMayHaveBeenModified]; |
1141 | 1159 | return NO; |
|
0 commit comments