Skip to content

Commit f9582d3

Browse files
committed
Fixed #32
Inserting an image loses the attributed and won't apply to text being typed after the image
1 parent e7c27f1 commit f9582d3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

RichTextEditor/Source/RichTextEditor.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,11 @@ - (void)richTextEditorToolbarDidSelectTextAttachment:(UIImage *)textAttachment
437437
[attachment setImage:textAttachment];
438438
NSAttributedString *attributedStringAttachment = [NSAttributedString attributedStringWithAttachment:attachment];
439439

440+
NSDictionary *previousAttributes = [self dictionaryAtIndex:self.selectedRange.location];
441+
440442
NSMutableAttributedString *attributedString = [self.attributedText mutableCopy];
441443
[attributedString insertAttributedString:attributedStringAttachment atIndex:self.selectedRange.location];
444+
[attributedString addAttributes:previousAttributes range:NSMakeRange(self.selectedRange.location, 1)];
442445
self.attributedText = attributedString;
443446
}
444447

0 commit comments

Comments
 (0)