Skip to content

Commit 8ccbd1a

Browse files
committed
Merge pull request draft-js-plugins#181 from draft-js-plugins/improve-emoji-and-mention-regex
improve regex for emoji & mention plugins to avoid issues when combin…
2 parents 59aa361 + 6841206 commit 8ccbd1a

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

draft-js-emoji-plugin/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
88
### Changed
99

1010
- Move to a flat configuration. Instead of plugin properties (decorators & hooks) being stored within pluginProps they now moved to the root object. See the changes here [#150](https://github.com/draft-js-plugins/draft-js-plugins/pull/150/files) as well as the initial discussion here [#143](https://github.com/draft-js-plugins/draft-js-plugins/issues/143)
11+
- Improved the regex and now test for a whitespace in front of the `:` to make sure it doesn't match on normal text like a link [#104](https://github.com/draft-js-plugins/draft-js-plugins/issues/104)
1112

1213
### Fixed
1314

draft-js-emoji-plugin/src/emojiSearchStrategy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import findWithRegex from 'find-with-regex';
44

5-
const EMOJI_REGEX = /:[\w]*/g;
5+
const EMOJI_REGEX = /\s:[\w]*/g;
66

77
export default (contentBlock: Object, callback: Function) => {
88
findWithRegex(EMOJI_REGEX, contentBlock, callback);

draft-js-mention-plugin/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
88
### Changed
99

1010
- Move to a flat configuration. Instead of plugin properties (decorators & hooks) being stored within pluginProps they now moved to the root object. See the changes here [#150](https://github.com/draft-js-plugins/draft-js-plugins/pull/150/files) as well as the initial discussion here [#143](https://github.com/draft-js-plugins/draft-js-plugins/issues/143)
11+
- Improved the regex and now test for a whitespace in front of the `@` to make sure it doesn't match on normal text like an email [#104](https://github.com/draft-js-plugins/draft-js-plugins/issues/104)
1112

1213
### Fixed
1314

draft-js-mention-plugin/src/mentionSearchStrategy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import findWithRegex from 'find-with-regex';
44

5-
const MENTION_REGEX = /\@[\w]*/g;
5+
const MENTION_REGEX = /\s\@[\w]*/g;
66

77
export default (contentBlock: Object, callback: Function) => {
88
findWithRegex(MENTION_REGEX, contentBlock, callback);

0 commit comments

Comments
 (0)