Skip to content

Commit 5450c25

Browse files
authored
feat: add missing setValue ref method (#115)
1 parent 388e3b0 commit 5450c25

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

ios/ReactNativeRichTextEditorView.mm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,9 @@ - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
680680
[self focus];
681681
} else if([commandName isEqualToString:@"blur"]) {
682682
[self blur];
683+
} else if([commandName isEqualToString:@"setValue"]) {
684+
NSString *value = (NSString *)args[0];
685+
[self setValue:value];
683686
} else if([commandName isEqualToString:@"toggleBold"]) {
684687
[self toggleRegularStyle: [BoldStyle getStyleType]];
685688
} else if([commandName isEqualToString:@"toggleItalic"]) {
@@ -736,6 +739,17 @@ - (void)focus {
736739
[textView reactFocus];
737740
}
738741

742+
- (void)setValue:(NSString *)value {
743+
NSString *initiallyProcessedHtml = [parser initiallyProcessHtml:value];
744+
if(initiallyProcessedHtml == nullptr) {
745+
// just plain text
746+
textView.text = value;
747+
} else {
748+
// we've got some seemingly proper html
749+
[parser replaceWholeFromHtml:initiallyProcessedHtml];
750+
}
751+
}
752+
739753
- (void)emitOnLinkDetectedEvent:(NSString *)text url:(NSString *)url {
740754
auto emitter = [self getEventEmitter];
741755
if(emitter != nullptr) {

0 commit comments

Comments
 (0)