@@ -30,10 +30,10 @@ @implementation VariableTextInputViewManager
30
30
[view setValue: [RCTConvert UIColor: json] forKeyPath: @" placeholderTextColor" ];
31
31
}
32
32
RCT_EXPORT_VIEW_PROPERTY (onTextInput, RCTDirectEventBlock)
33
+ RCT_EXPORT_VIEW_PROPERTY(onTag, RCTDirectEventBlock)
33
34
34
35
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
35
36
RCT_EXPORT_VIEW_PROPERTY(onContentSizeChange, RCTBubblingEventBlock)
36
-
37
37
RCT_CUSTOM_VIEW_PROPERTY(textAlign, NSTextAlignment , VariableTextInput)
38
38
{
39
39
[view setTextAlignment: [RCTConvert NSTextAlignment: json]];
@@ -92,11 +92,20 @@ @implementation VariableTextInputViewManager
92
92
[self insertTextEmoji: rnImageData];
93
93
});
94
94
}
95
+ RCT_EXPORT_METHOD (dismissTag)
96
+ {
97
+ dispatch_async (dispatch_get_main_queue (), ^{
98
+ self.textInput .tagStr = @" " ;
99
+ self.textInput .keyWord = @" " ;
100
+ });
101
+ }
95
102
- (UIView *)view
96
103
{
97
104
_textInput = [[VariableTextInput alloc ]init];
98
105
_textInput.textContainerInset = UIEdgeInsetsZero;
99
106
_textInput.textContainer .lineFragmentPadding = 0 ;
107
+ _textInput.tagStr = @" " ;
108
+ _textInput.keyWord = @" " ;
100
109
_textInput.blurOnSubmit = true ;
101
110
return _textInput;
102
111
}
@@ -221,7 +230,14 @@ -(void)insertTagText:(NSDictionary *)mention{
221
230
[dic setObject: color forKey: @" NSColor" ];
222
231
CGSize textSize = [showStr sizeWithAttributes: self .textInput.typingAttributes];
223
232
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
+ }
224
239
[self setTextAttachment: image tag: emojiTag size: textSize copyStr: copyStr];
240
+
225
241
}
226
242
-(void )setAttributedText : (NSArray *)arr {
227
243
NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc ]init];
0 commit comments