diff --git a/README.md b/README.md index 6d2a7f2b..b025644e 100755 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ The `MentionsInput` supports the following props for configuring the widget: | singleLine | boolean | `false` | Renders a single line text input instead of a textarea, if set to `true` | | onBlur | function (event, clickedSuggestion) | empty function | Passes `true` as second argument if the blur was caused by a mousedown on a suggestion | | allowSpaceInQuery | boolean | false | Keep suggestions open even if the user separates keywords with spaces. | +| allowTriggerInQuery | boolean | false | Keep suggestions open even if the user separates keywords with trigger. | | suggestionsPortalHost | DOM Element | undefined | Render suggestions into the DOM in the supplied host element. | | inputRef | React ref | undefined | Accepts a React ref to forward to the underlying input element | | allowSuggestionsAboveCursor | boolean | false | Renders the SuggestionList above the cursor if there is not enough space below | diff --git a/src/Mention.js b/src/Mention.js index 36bdc687..e9955168 100644 --- a/src/Mention.js +++ b/src/Mention.js @@ -38,7 +38,7 @@ Mention.propTypes = { * If set to `true` spaces will not interrupt matching suggestions */ allowSpaceInQuery: PropTypes.bool, - + allowTriggerInQuery: PropTypes.bool, isLoading: PropTypes.bool, } diff --git a/src/MentionsInput.js b/src/MentionsInput.js index 68e6b73d..0b28f29e 100755 --- a/src/MentionsInput.js +++ b/src/MentionsInput.js @@ -29,7 +29,7 @@ export const makeTriggerRegex = function(trigger, options = {}) { if (trigger instanceof RegExp) { return trigger } else { - const { allowSpaceInQuery } = options + const { allowSpaceInQuery,allowTriggerInQuery } = options const escapedTriggerChar = escapeRegex(trigger) // first capture group is the part to be replaced on completion @@ -37,7 +37,7 @@ export const makeTriggerRegex = function(trigger, options = {}) { return new RegExp( `(?:^|\\s)(${escapedTriggerChar}([^${ allowSpaceInQuery ? '' : '\\s' - }${escapedTriggerChar}]*))$` + }${allowTriggerInQuery ? '' : escapedTriggerChar}]*))$` ) } } @@ -72,6 +72,7 @@ const propTypes = { */ singleLine: PropTypes.bool, allowSpaceInQuery: PropTypes.bool, + allowTriggerInQuery: PropTypes.bool, allowSuggestionsAboveCursor: PropTypes.bool, forceSuggestionsAboveCursor: PropTypes.bool, ignoreAccents: PropTypes.bool,