diff --git a/ios/MarkdownTextInputDecoratorView.mm b/ios/MarkdownTextInputDecoratorView.mm index a77d7d53..c6ae82fb 100644 --- a/ios/MarkdownTextInputDecoratorView.mm +++ b/ios/MarkdownTextInputDecoratorView.mm @@ -110,12 +110,17 @@ - (void)setMarkdownStyle:(RCTMarkdownStyle *)markdownStyle _markdownStyle = markdownStyle; [_markdownUtils setMarkdownStyle:markdownStyle]; - // apply new styles + if (_textView != nil) { + // We want to use `textStorage` for applying markdown when possible. Currently it's only available for UITextView + [_textView textDidChange]; + } else { + // apply new styles #ifdef RCT_NEW_ARCH_ENABLED - [_textInput _setAttributedString:_backedTextInputView.attributedText]; + [_textInput _setAttributedString:_backedTextInputView.attributedText]; #else - [_textInput setAttributedText:_textInput.attributedText]; + [_textInput setAttributedText:_textInput.attributedText]; #endif /* RCT_NEW_ARCH_ENABLED */ + } } @end diff --git a/ios/RCTUITextView+Markdown.h b/ios/RCTUITextView+Markdown.h index f792140e..40deedad 100644 --- a/ios/RCTUITextView+Markdown.h +++ b/ios/RCTUITextView+Markdown.h @@ -4,6 +4,10 @@ NS_ASSUME_NONNULL_BEGIN +@interface RCTUITextView (Private) +- (void)textDidChange; +@end + @interface RCTUITextView (Markdown) @property(nonatomic, nullable, getter=getMarkdownUtils) RCTMarkdownUtils *markdownUtils;