diff --git a/ios/ReactNativeRichTextEditorView.mm b/ios/ReactNativeRichTextEditorView.mm index 4e7ee0abd..3c9487d0f 100644 --- a/ios/ReactNativeRichTextEditorView.mm +++ b/ios/ReactNativeRichTextEditorView.mm @@ -680,6 +680,9 @@ - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args { [self focus]; } else if([commandName isEqualToString:@"blur"]) { [self blur]; + } else if([commandName isEqualToString:@"setValue"]) { + NSString *value = (NSString *)args[0]; + [self setValue:value]; } else if([commandName isEqualToString:@"toggleBold"]) { [self toggleRegularStyle: [BoldStyle getStyleType]]; } else if([commandName isEqualToString:@"toggleItalic"]) { @@ -736,6 +739,17 @@ - (void)focus { [textView reactFocus]; } +- (void)setValue:(NSString *)value { + NSString *initiallyProcessedHtml = [parser initiallyProcessHtml:value]; + if(initiallyProcessedHtml == nullptr) { + // just plain text + textView.text = value; + } else { + // we've got some seemingly proper html + [parser replaceWholeFromHtml:initiallyProcessedHtml]; + } +} + - (void)emitOnLinkDetectedEvent:(NSString *)text url:(NSString *)url { auto emitter = [self getEventEmitter]; if(emitter != nullptr) {