-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: unstable mention value parse with emojis
Optimize algorithm for parsing value. Use String.prototype.split instead of matchAll utility. Add emojis to some tests. BREAKING CHANGES: now it's important to use only one group in the part patterns for correct work of `getKeyword` and ``parseValue` methods. #66
- Loading branch information
1 parent
f7ab2c9
commit 81bb8f3
Showing
7 changed files
with
309 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { StyleProp, TextStyle } from 'react-native'; | ||
|
||
/** | ||
* RegEx grouped results. Example - "@[Full Name](123abc)" | ||
* We have 4 groups here: | ||
* - The whole original string - "@[Full Name](123abc)" | ||
* - Mention trigger - "@" | ||
* - Name - "Full Name" | ||
* - Id - "123abc" | ||
*/ | ||
const mentionRegEx = /((.)\[([^[]*)]\(([^(^)]*)\))/i; | ||
|
||
/** | ||
* We need this single group regex for using String.prototype.split method | ||
*/ | ||
const singleGroupMentionRegEx = /(.\[[^[]*]\([^(^)]*\))/gi; | ||
|
||
const DEFAULT_ALLOWED_SPACES_COUNT = 1; | ||
|
||
// Empty object with static reference | ||
const emptyObject: any = {}; | ||
|
||
const defaultMentionTextStyle: StyleProp<TextStyle> = { | ||
fontWeight: 'bold', | ||
color: 'blue', | ||
}; | ||
|
||
export { | ||
mentionRegEx, | ||
singleGroupMentionRegEx, | ||
DEFAULT_ALLOWED_SPACES_COUNT, | ||
emptyObject, | ||
defaultMentionTextStyle, | ||
}; |
Oops, something went wrong.