Skip to content

Commit 25762cd

Browse files
duom青源duom青源
authored andcommitted
feat: ios bugfix
1 parent b02a399 commit 25762cd

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

example/src/App.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ import VariableTextInputView, {
1616
export const App = () => {
1717
const inPutRef = React.createRef<IATTextViewBase>();
1818
const onChangeText = (text: string) => {
19-
console.log('sdkljflksdjfl====>', text);
19+
const triggerRegEx = /({([^{^}]*)}\[([^[]*)]\(([^(^)]*)\))/gi;
20+
const singleGroupTriggerRegEx = /({[^{^}]*}\[[^[]*]\([^(^)]*\))/gi;
21+
const matchStr = text.match(triggerRegEx);
22+
if (matchStr !== null) {
23+
const subStrArr = text.split(triggerRegEx);
24+
subStrArr.forEach((item) => {
25+
const arr = item.match(singleGroupTriggerRegEx);
26+
console.log('====>', arr);
27+
});
28+
}
2029
};
2130
const insertEmoji = () => {
2231
const data: ImageResolvedAssetSource = Image.resolveAssetSource(
@@ -113,7 +122,7 @@ const styles = StyleSheet.create({
113122
box: {
114123
backgroundColor: 'blue',
115124
color: '#fff',
116-
fontSize: 18,
125+
fontSize: 14,
117126
width: '100%',
118127
minHeight: 100,
119128
},

ios/VariableTextInputViewManager.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ -(void)insertTextEmoji:(NSDictionary *)rnImageData{
192192
NSString *planStr = [self.textInput.textStorage getPlainString];
193193
[self.textInput setPlaceholderVisibleForText:planStr];
194194
self.textInput.typingAttributes = self.typingAttributes;
195+
if (_textInput.onChange) {
196+
_textInput.onChange(@{@"text": [_textInput.textStorage getPlainString]});
197+
}
195198
}
196199
-(void)insertTagText:(NSDictionary *)mention{
197200
NSString *tag = [RCTConvert NSString:mention[@"tag"]];
@@ -264,6 +267,9 @@ -(void)setAttributedText:(NSArray *)arr{
264267
}];
265268
[attStr addAttributes:_textInput.defultTypingAttributes range:NSMakeRange(0, attStr.length)];
266269
_textInput.attributedText = attStr;
270+
if (_textInput.onChange) {
271+
_textInput.onChange(@{@"text": [_textInput.textStorage getPlainString]});
272+
}
267273

268274
}
269275
@end

0 commit comments

Comments
 (0)