Skip to content

Commit 2bba2e1

Browse files
authored
fix: finally solve resetting attributes without edge cases (#132)
1 parent b3a7bda commit 2bba2e1

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

ios/ReactNativeRichTextEditorView.mm

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -792,11 +792,6 @@ - (void)setValue:(NSString *)value {
792792
if(initiallyProcessedHtml == nullptr) {
793793
// just plain text
794794
textView.text = value;
795-
796-
// typing attribtues need to be reset firstly if the input was emptied
797-
if(textView.text.length == 0) {
798-
textView.typingAttributes = defaultTypingAttributes;
799-
}
800795
} else {
801796
// we've got some seemingly proper html
802797
[parser replaceWholeFromHtml:initiallyProcessedHtml];
@@ -1000,6 +995,12 @@ - (void)anyTextMayHaveBeenModified {
1000995
return;
1001996
}
1002997

998+
// emptying input typing attributes management
999+
if(textView.textStorage.string.length == 0 && _recentlyEmittedString.length > 0) {
1000+
// reset typing attribtues
1001+
textView.typingAttributes = defaultTypingAttributes;
1002+
}
1003+
10031004
// zero width space removal
10041005
[ZeroWidthSpaceUtils handleZeroWidthSpacesInEditor:self];
10051006

@@ -1023,12 +1024,6 @@ - (void)anyTextMayHaveBeenModified {
10231024
}
10241025

10251026
if(![textView.textStorage.string isEqualToString:_recentlyEmittedString]) {
1026-
// emptying input typing attributes management
1027-
if(textView.textStorage.string.length == 0) {
1028-
// reset typing attribtues
1029-
textView.typingAttributes = defaultTypingAttributes;
1030-
}
1031-
10321027
// mentions removal management
10331028
MentionStyle *mentionStyleClass = (MentionStyle *)stylesDict[@([MentionStyle getStyleType])];
10341029
if(mentionStyleClass != nullptr) {

0 commit comments

Comments
 (0)