@@ -30,10 +30,10 @@ @implementation VariableTextInputViewManager
3030 [view setValue: [RCTConvert UIColor: json] forKeyPath: @" placeholderTextColor" ];
3131}
3232RCT_EXPORT_VIEW_PROPERTY (onTextInput, RCTDirectEventBlock)
33+ RCT_EXPORT_VIEW_PROPERTY(onTag, RCTDirectEventBlock)
3334
3435RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
3536RCT_EXPORT_VIEW_PROPERTY(onContentSizeChange, RCTBubblingEventBlock)
36-
3737RCT_CUSTOM_VIEW_PROPERTY(textAlign, NSTextAlignment , VariableTextInput)
3838{
3939 [view setTextAlignment: [RCTConvert NSTextAlignment: json]];
@@ -92,11 +92,20 @@ @implementation VariableTextInputViewManager
9292 [self insertTextEmoji: rnImageData];
9393 });
9494}
95+ RCT_EXPORT_METHOD (dismissTag)
96+ {
97+ dispatch_async (dispatch_get_main_queue (), ^{
98+ self.textInput .tagStr = @" " ;
99+ self.textInput .keyWord = @" " ;
100+ });
101+ }
95102- (UIView *)view
96103{
97104 _textInput = [[VariableTextInput alloc ]init];
98105 _textInput.textContainerInset = UIEdgeInsetsZero;
99106 _textInput.textContainer .lineFragmentPadding = 0 ;
107+ _textInput.tagStr = @" " ;
108+ _textInput.keyWord = @" " ;
100109 _textInput.blurOnSubmit = true ;
101110 return _textInput;
102111}
@@ -221,7 +230,14 @@ -(void)insertTagText:(NSDictionary *)mention{
221230 [dic setObject: color forKey: @" NSColor" ];
222231 CGSize textSize = [showStr sizeWithAttributes: self .textInput.typingAttributes];
223232 UIImage *image = [self drawImageWithColor: [UIColor clearColor ] size: textSize text: [NSString stringWithFormat: @" %@ " ,showStr] textAttributes: dic circular: NO ];
233+ if (_textInput.tagStr != nil && ![_textInput.tagStr isEqualToString: @" " ]){
234+ _textInput.text = [_textInput.text stringByReplacingOccurrencesOfString: [NSString stringWithFormat: @" %@%@ " ,_textInput.tagStr,_textInput.keyWord] withString: @" " ];
235+ NSAttributedString *attString = _textInput.attributedText ;
236+ _textInput.tagStr = @" " ;
237+ _textInput.keyWord = @" " ;
238+ }
224239 [self setTextAttachment: image tag: emojiTag size: textSize copyStr: copyStr];
240+
225241}
226242-(void )setAttributedText : (NSArray *)arr {
227243 NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc ]init];
0 commit comments