react-mentions 4.3.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  value: !0
9
9
  });
10
10
 
11
- var _toConsumableArray = _interopDefault(require("@babel/runtime/helpers/toConsumableArray")), _extends = _interopDefault(require("@babel/runtime/helpers/extends")), _classCallCheck = _interopDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass = _interopDefault(require("@babel/runtime/helpers/createClass")), _possibleConstructorReturn = _interopDefault(require("@babel/runtime/helpers/possibleConstructorReturn")), _getPrototypeOf = _interopDefault(require("@babel/runtime/helpers/getPrototypeOf")), _assertThisInitialized = _interopDefault(require("@babel/runtime/helpers/assertThisInitialized")), _inherits = _interopDefault(require("@babel/runtime/helpers/inherits")), _defineProperty = _interopDefault(require("@babel/runtime/helpers/defineProperty")), React = require("react"), React__default = _interopDefault(React), invariant = _interopDefault(require("invariant")), _slicedToArray = _interopDefault(require("@babel/runtime/helpers/slicedToArray")), _objectWithoutProperties = _interopDefault(require("@babel/runtime/helpers/objectWithoutProperties")), useStyles = require("substyle"), useStyles__default = _interopDefault(useStyles), PropTypes = _interopDefault(require("prop-types")), ReactDOM = _interopDefault(require("react-dom")), escapeRegex = function(str) {
11
+ var _toConsumableArray = _interopDefault(require("@babel/runtime/helpers/toConsumableArray")), _extends = _interopDefault(require("@babel/runtime/helpers/extends")), _classCallCheck = _interopDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass = _interopDefault(require("@babel/runtime/helpers/createClass")), _assertThisInitialized = _interopDefault(require("@babel/runtime/helpers/assertThisInitialized")), _inherits = _interopDefault(require("@babel/runtime/helpers/inherits")), _possibleConstructorReturn = _interopDefault(require("@babel/runtime/helpers/possibleConstructorReturn")), _getPrototypeOf = _interopDefault(require("@babel/runtime/helpers/getPrototypeOf")), _defineProperty = _interopDefault(require("@babel/runtime/helpers/defineProperty")), React = require("react"), React__default = _interopDefault(React), invariant = _interopDefault(require("invariant")), _slicedToArray = _interopDefault(require("@babel/runtime/helpers/slicedToArray")), _objectWithoutProperties = _interopDefault(require("@babel/runtime/helpers/objectWithoutProperties")), useStyles = require("substyle"), useStyles__default = _interopDefault(useStyles), PropTypes = _interopDefault(require("prop-types")), ReactDOM = _interopDefault(require("react-dom")), escapeRegex = function(str) {
12
12
  return str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
13
13
  }, PLACEHOLDERS = {
14
14
  id: "__id__",
@@ -405,6 +405,8 @@ var _toConsumableArray = _interopDefault(require("@babel/runtime/helpers/toConsu
405
405
  return removeAccents(str).toLowerCase();
406
406
  }, getSubstringIndex = function(str, substr, ignoreAccents) {
407
407
  return ignoreAccents ? normalizeString(str).indexOf(normalizeString(substr)) : str.toLowerCase().indexOf(substr.toLowerCase());
408
+ }, isIE = function() {
409
+ return !!document.documentMode;
408
410
  }, isNumber = function(val) {
409
411
  return "number" == typeof val;
410
412
  }, keys = function(obj) {
@@ -416,12 +418,12 @@ var _toConsumableArray = _interopDefault(require("@babel/runtime/helpers/toConsu
416
418
  return obj.hasOwnProperty(k) && !keys.includes(k) && void 0 !== obj[k] && (acc[k] = obj[k]),
417
419
  acc;
418
420
  }, {});
419
- };
421
+ }, _excluded = [ "style", "className", "classNames" ];
420
422
 
421
423
  function createDefaultStyle(defaultStyle, getModifiers) {
422
424
  return function(ComponentToWrap) {
423
425
  var DefaultStyleEnhancer = function(_ref) {
424
- var style = _ref.style, className = _ref.className, classNames = _ref.classNames, rest = _objectWithoutProperties(_ref, [ "style", "className", "classNames" ]), modifiers = getModifiers ? getModifiers(rest) : void 0, styles = useStyles__default(defaultStyle, {
426
+ var style = _ref.style, className = _ref.className, classNames = _ref.classNames, rest = _objectWithoutProperties(_ref, _excluded), modifiers = getModifiers ? getModifiers(rest) : void 0, styles = useStyles__default(defaultStyle, {
425
427
  style: style,
426
428
  className: className,
427
429
  classNames: classNames
@@ -435,12 +437,38 @@ function createDefaultStyle(defaultStyle, getModifiers) {
435
437
  };
436
438
  }
437
439
 
440
+ function _createSuper(Derived) {
441
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
442
+ return function() {
443
+ var result, Super = _getPrototypeOf(Derived);
444
+ if (hasNativeReflectConstruct) {
445
+ var NewTarget = _getPrototypeOf(this).constructor;
446
+ result = Reflect.construct(Super, arguments, NewTarget);
447
+ } else result = Super.apply(this, arguments);
448
+ return _possibleConstructorReturn(this, result);
449
+ };
450
+ }
451
+
452
+ function _isNativeReflectConstruct() {
453
+ if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
454
+ if (Reflect.construct.sham) return !1;
455
+ if ("function" == typeof Proxy) return !0;
456
+ try {
457
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
458
+ !0;
459
+ } catch (e) {
460
+ return !1;
461
+ }
462
+ }
463
+
438
464
  var _generateComponentKey = function(usedKeys, id) {
439
465
  return usedKeys.hasOwnProperty(id) ? usedKeys[id]++ : usedKeys[id] = 0, id + "_" + usedKeys[id];
440
466
  }, Highlighter = function(_Component) {
467
+ _inherits(Highlighter, _Component);
468
+ var _super = _createSuper(Highlighter);
441
469
  function Highlighter() {
442
470
  var _this;
443
- return _classCallCheck(this, Highlighter), _this = _possibleConstructorReturn(this, _getPrototypeOf(Highlighter).apply(this, arguments)),
471
+ return _classCallCheck(this, Highlighter), _this = _super.apply(this, arguments),
444
472
  _defineProperty(_assertThisInitialized(_this), "setCaretElement", function(el) {
445
473
  _this.caretElement = el;
446
474
  }), _this.state = {
@@ -448,7 +476,7 @@ var _generateComponentKey = function(usedKeys, id) {
448
476
  top: void 0
449
477
  }, _this;
450
478
  }
451
- return _inherits(Highlighter, _Component), _createClass(Highlighter, [ {
479
+ return _createClass(Highlighter, [ {
452
480
  key: "componentDidMount",
453
481
  value: function() {
454
482
  this.notifyCaretPosition();
@@ -555,11 +583,39 @@ var styled = createDefaultStyle({
555
583
  return {
556
584
  "&singleLine": props.singleLine
557
585
  };
558
- }), Highlighter$1 = styled(Highlighter), Suggestion = function(_Component) {
586
+ }), Highlighter$1 = styled(Highlighter);
587
+
588
+ function _createSuper$1(Derived) {
589
+ var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
590
+ return function() {
591
+ var result, Super = _getPrototypeOf(Derived);
592
+ if (hasNativeReflectConstruct) {
593
+ var NewTarget = _getPrototypeOf(this).constructor;
594
+ result = Reflect.construct(Super, arguments, NewTarget);
595
+ } else result = Super.apply(this, arguments);
596
+ return _possibleConstructorReturn(this, result);
597
+ };
598
+ }
599
+
600
+ function _isNativeReflectConstruct$1() {
601
+ if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
602
+ if (Reflect.construct.sham) return !1;
603
+ if ("function" == typeof Proxy) return !0;
604
+ try {
605
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
606
+ !0;
607
+ } catch (e) {
608
+ return !1;
609
+ }
610
+ }
611
+
612
+ var Suggestion = function(_Component) {
613
+ _inherits(Suggestion, _Component);
614
+ var _super = _createSuper$1(Suggestion);
559
615
  function Suggestion() {
560
- return _classCallCheck(this, Suggestion), _possibleConstructorReturn(this, _getPrototypeOf(Suggestion).apply(this, arguments));
616
+ return _classCallCheck(this, Suggestion), _super.apply(this, arguments);
561
617
  }
562
- return _inherits(Suggestion, _Component), _createClass(Suggestion, [ {
618
+ return _createClass(Suggestion, [ {
563
619
  key: "render",
564
620
  value: function() {
565
621
  var rest = omit(this.props, [ "style", "classNames", "className" ], keys(Suggestion.propTypes));
@@ -618,13 +674,38 @@ function LoadingIndicator() {
618
674
  return React__default.createElement("div", styles, React__default.createElement("div", spinnerStyles, React__default.createElement("div", spinnerStyles([ "element", "element1" ])), React__default.createElement("div", spinnerStyles([ "element", "element2" ])), React__default.createElement("div", spinnerStyles([ "element", "element3" ])), React__default.createElement("div", spinnerStyles([ "element", "element4" ])), React__default.createElement("div", spinnerStyles([ "element", "element5" ]))));
619
675
  }
620
676
 
677
+ function _createSuper$2(Derived) {
678
+ var hasNativeReflectConstruct = _isNativeReflectConstruct$2();
679
+ return function() {
680
+ var result, Super = _getPrototypeOf(Derived);
681
+ if (hasNativeReflectConstruct) {
682
+ var NewTarget = _getPrototypeOf(this).constructor;
683
+ result = Reflect.construct(Super, arguments, NewTarget);
684
+ } else result = Super.apply(this, arguments);
685
+ return _possibleConstructorReturn(this, result);
686
+ };
687
+ }
688
+
689
+ function _isNativeReflectConstruct$2() {
690
+ if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
691
+ if (Reflect.construct.sham) return !1;
692
+ if ("function" == typeof Proxy) return !0;
693
+ try {
694
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
695
+ !0;
696
+ } catch (e) {
697
+ return !1;
698
+ }
699
+ }
700
+
621
701
  var SuggestionsOverlay = function(_Component) {
702
+ _inherits(SuggestionsOverlay, _Component);
703
+ var _super = _createSuper$2(SuggestionsOverlay);
622
704
  function SuggestionsOverlay() {
623
- var _getPrototypeOf2, _this;
705
+ var _this;
624
706
  _classCallCheck(this, SuggestionsOverlay);
625
707
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
626
- return _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(SuggestionsOverlay)).call.apply(_getPrototypeOf2, [ this ].concat(args))),
627
- _defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function(index, ev) {
708
+ return _this = _super.call.apply(_super, [ this ].concat(args)), _defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function(index, ev) {
628
709
  _this.props.onMouseEnter && _this.props.onMouseEnter(index);
629
710
  }), _defineProperty(_assertThisInitialized(_this), "select", function(suggestion, queryInfo) {
630
711
  _this.props.onSelect(suggestion, queryInfo);
@@ -632,7 +713,7 @@ var SuggestionsOverlay = function(_Component) {
632
713
  _this.ulElement = el;
633
714
  }), _this;
634
715
  }
635
- return _inherits(SuggestionsOverlay, _Component), _createClass(SuggestionsOverlay, [ {
716
+ return _createClass(SuggestionsOverlay, [ {
636
717
  key: "componentDidUpdate",
637
718
  value: function() {
638
719
  if (this.ulElement && !(this.ulElement.offsetHeight >= this.ulElement.scrollHeight) && this.props.scrollFocusedIntoView) {
@@ -643,10 +724,11 @@ var SuggestionsOverlay = function(_Component) {
643
724
  }, {
644
725
  key: "render",
645
726
  value: function() {
646
- var _this$props = this.props, id = _this$props.id, a11ySuggestionsListLabel = _this$props.a11ySuggestionsListLabel, isOpened = _this$props.isOpened, style = _this$props.style, onMouseDown = _this$props.onMouseDown, containerRef = _this$props.containerRef, position = _this$props.position, left = _this$props.left, top = _this$props.top;
727
+ var _this$props = this.props, id = _this$props.id, a11ySuggestionsListLabel = _this$props.a11ySuggestionsListLabel, isOpened = _this$props.isOpened, style = _this$props.style, onMouseDown = _this$props.onMouseDown, containerRef = _this$props.containerRef, position = _this$props.position, left = _this$props.left, right = _this$props.right, top = _this$props.top;
647
728
  return isOpened ? React__default.createElement("div", _extends({}, useStyles.inline({
648
729
  position: position || "absolute",
649
730
  left: left,
731
+ right: right,
650
732
  top: top
651
733
  }, style), {
652
734
  onMouseDown: onMouseDown,
@@ -661,13 +743,13 @@ var SuggestionsOverlay = function(_Component) {
661
743
  }, {
662
744
  key: "renderSuggestions",
663
745
  value: function() {
664
- var _this2 = this;
665
- return Object.values(this.props.suggestions).reduce(function(accResults, _ref) {
746
+ var _this2 = this, customSuggestionsContainer = this.props.customSuggestionsContainer, suggestions = Object.values(this.props.suggestions).reduce(function(accResults, _ref) {
666
747
  var results = _ref.results, queryInfo = _ref.queryInfo;
667
748
  return [].concat(_toConsumableArray(accResults), _toConsumableArray(results.map(function(result, index) {
668
749
  return _this2.renderSuggestion(result, queryInfo, accResults.length + index);
669
750
  })));
670
751
  }, []);
752
+ return customSuggestionsContainer ? customSuggestionsContainer(suggestions) : suggestions;
671
753
  }
672
754
  }, {
673
755
  key: "renderSuggestion",
@@ -708,6 +790,7 @@ _defineProperty(SuggestionsOverlay, "propTypes", {
708
790
  focusIndex: PropTypes.number,
709
791
  position: PropTypes.string,
710
792
  left: PropTypes.number,
793
+ right: PropTypes.number,
711
794
  top: PropTypes.number,
712
795
  scrollFocusedIntoView: PropTypes.bool,
713
796
  isLoading: PropTypes.bool,
@@ -753,15 +836,39 @@ function ownKeys(object, enumerableOnly) {
753
836
  function _objectSpread(target) {
754
837
  for (var i = 1; i < arguments.length; i++) {
755
838
  var source = null != arguments[i] ? arguments[i] : {};
756
- i % 2 ? ownKeys(source, !0).forEach(function(key) {
839
+ i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
757
840
  _defineProperty(target, key, source[key]);
758
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(source).forEach(function(key) {
841
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
759
842
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
760
843
  });
761
844
  }
762
845
  return target;
763
846
  }
764
847
 
848
+ function _createSuper$3(Derived) {
849
+ var hasNativeReflectConstruct = _isNativeReflectConstruct$3();
850
+ return function() {
851
+ var result, Super = _getPrototypeOf(Derived);
852
+ if (hasNativeReflectConstruct) {
853
+ var NewTarget = _getPrototypeOf(this).constructor;
854
+ result = Reflect.construct(Super, arguments, NewTarget);
855
+ } else result = Super.apply(this, arguments);
856
+ return _possibleConstructorReturn(this, result);
857
+ };
858
+ }
859
+
860
+ function _isNativeReflectConstruct$3() {
861
+ if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
862
+ if (Reflect.construct.sham) return !1;
863
+ if ("function" == typeof Proxy) return !0;
864
+ try {
865
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
866
+ !0;
867
+ } catch (e) {
868
+ return !1;
869
+ }
870
+ }
871
+
765
872
  var makeTriggerRegex = function(trigger) {
766
873
  var options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
767
874
  if (trigger instanceof RegExp) return trigger;
@@ -790,6 +897,7 @@ var makeTriggerRegex = function(trigger) {
790
897
  a11ySuggestionsListLabel: PropTypes.string,
791
898
  value: PropTypes.string,
792
899
  onKeyDown: PropTypes.func,
900
+ customSuggestionsContainer: PropTypes.func,
793
901
  onSelect: PropTypes.func,
794
902
  onBlur: PropTypes.func,
795
903
  onChange: PropTypes.func,
@@ -799,14 +907,16 @@ var makeTriggerRegex = function(trigger) {
799
907
  }) ]),
800
908
  children: PropTypes.oneOfType([ PropTypes.element, PropTypes.arrayOf(PropTypes.element) ]).isRequired
801
909
  }, MentionsInput = function(_React$Component) {
910
+ _inherits(MentionsInput, _React$Component);
911
+ var _super = _createSuper$3(MentionsInput);
802
912
  function MentionsInput(_props) {
803
913
  var _this;
804
- return _classCallCheck(this, MentionsInput), _this = _possibleConstructorReturn(this, _getPrototypeOf(MentionsInput).call(this, _props)),
914
+ return _classCallCheck(this, MentionsInput), _this = _super.call(this, _props),
805
915
  _defineProperty(_assertThisInitialized(_this), "setContainerElement", function(el) {
806
916
  _this.containerElement = el;
807
917
  }), _defineProperty(_assertThisInitialized(_this), "getInputProps", function() {
808
918
  var _this$props = _this.props, readOnly = _this$props.readOnly, disabled = _this$props.disabled, style = _this$props.style;
809
- return _objectSpread({}, omit(_this.props, [ "style", "classNames", "className" ], keys(propTypes)), {}, style("input"), {
919
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, omit(_this.props, [ "style", "classNames", "className" ], keys(propTypes))), style("input")), {}, {
810
920
  value: _this.getPlainText()
811
921
  }, !readOnly && !disabled && {
812
922
  onChange: _this.handleChange,
@@ -816,7 +926,7 @@ var makeTriggerRegex = function(trigger) {
816
926
  onCompositionStart: _this.handleCompositionStart,
817
927
  onCompositionEnd: _this.handleCompositionEnd,
818
928
  onScroll: _this.updateHighlighterScroll
819
- }, {}, _this.isOpened() && {
929
+ }), _this.isOpened() && {
820
930
  role: "combobox",
821
931
  "aria-controls": _this.uuidSuggestionsOverlay,
822
932
  "aria-expanded": !0,
@@ -844,16 +954,18 @@ var makeTriggerRegex = function(trigger) {
844
954
  _this.suggestionsElement = el;
845
955
  }), _defineProperty(_assertThisInitialized(_this), "renderSuggestionsOverlay", function() {
846
956
  if (!isNumber(_this.state.selectionStart)) return null;
847
- var _this$state$suggestio = _this.state.suggestionsPosition, position = _this$state$suggestio.position, left = _this$state$suggestio.left, top = _this$state$suggestio.top, suggestionsNode = React__default.createElement(SuggestionsOverlay$1, {
957
+ var _this$state$suggestio = _this.state.suggestionsPosition, position = _this$state$suggestio.position, left = _this$state$suggestio.left, top = _this$state$suggestio.top, right = _this$state$suggestio.right, suggestionsNode = React__default.createElement(SuggestionsOverlay$1, {
848
958
  id: _this.uuidSuggestionsOverlay,
849
959
  style: _this.props.style("suggestions"),
850
960
  position: position,
851
961
  left: left,
852
962
  top: top,
963
+ right: right,
853
964
  focusIndex: _this.state.focusIndex,
854
965
  scrollFocusedIntoView: _this.state.scrollFocusedIntoView,
855
966
  containerRef: _this.setSuggestionsElement,
856
967
  suggestions: _this.state.suggestions,
968
+ customSuggestionsContainer: _this.props.customSuggestionsContainer,
857
969
  onSelect: _this.addMention,
858
970
  onMouseDown: _this.handleSuggestionsMouseDown,
859
971
  onMouseEnter: _this.handleSuggestionsMouseEnter,
@@ -887,27 +999,26 @@ var makeTriggerRegex = function(trigger) {
887
999
  var _this$props4, _this$props$valueLink;
888
1000
  return _this.props.onChange ? (_this$props4 = _this.props).onChange.apply(_this$props4, [ event ].concat(args)) : _this.props.valueLink ? (_this$props$valueLink = _this.props.valueLink).requestChange.apply(_this$props$valueLink, [ event.target.value ].concat(args)) : void 0;
889
1001
  }), _defineProperty(_assertThisInitialized(_this), "handleChange", function(ev) {
890
- if (isComposing = !1, (document.activeElement && document.activeElement.contentDocument || document).activeElement === ev.target) {
891
- var value = _this.props.value || "", config = readConfigFromChildren(_this.props.children), newPlainTextValue = ev.target.value, newValue = applyChangeToValue(value, newPlainTextValue, {
892
- selectionStartBefore: _this.state.selectionStart,
893
- selectionEndBefore: _this.state.selectionEnd,
894
- selectionEndAfter: ev.target.selectionEnd
895
- }, config);
896
- newPlainTextValue = getPlainText(newValue, config);
897
- var selectionStart = ev.target.selectionStart, selectionEnd = ev.target.selectionEnd, setSelectionAfterMentionChange = !1, startOfMention = findStartOfMentionInPlainText(value, config, selectionStart);
898
- void 0 !== startOfMention && _this.state.selectionEnd > startOfMention && (selectionEnd = selectionStart = startOfMention,
899
- setSelectionAfterMentionChange = !0), _this.setState({
900
- selectionStart: selectionStart,
901
- selectionEnd: selectionEnd,
902
- setSelectionAfterMentionChange: setSelectionAfterMentionChange
903
- });
904
- var mentions = getMentions(newValue, config), eventMock = {
905
- target: {
906
- value: newValue
907
- }
908
- };
909
- _this.executeOnChange(eventMock, newValue, newPlainTextValue, mentions);
910
- }
1002
+ if ((isComposing = !1, isIE()) && (document.activeElement && document.activeElement.contentDocument || document).activeElement !== ev.target) return;
1003
+ var value = _this.props.value || "", config = readConfigFromChildren(_this.props.children), newPlainTextValue = ev.target.value, newValue = applyChangeToValue(value, newPlainTextValue, {
1004
+ selectionStartBefore: _this.state.selectionStart,
1005
+ selectionEndBefore: _this.state.selectionEnd,
1006
+ selectionEndAfter: ev.target.selectionEnd
1007
+ }, config);
1008
+ newPlainTextValue = getPlainText(newValue, config);
1009
+ var selectionStart = ev.target.selectionStart, selectionEnd = ev.target.selectionEnd, setSelectionAfterMentionChange = !1, startOfMention = findStartOfMentionInPlainText(value, config, selectionStart);
1010
+ void 0 !== startOfMention && _this.state.selectionEnd > startOfMention && (selectionEnd = selectionStart = startOfMention + (ev.nativeEvent.data ? ev.nativeEvent.data.length : 0),
1011
+ setSelectionAfterMentionChange = !0), _this.setState({
1012
+ selectionStart: selectionStart,
1013
+ selectionEnd: selectionEnd,
1014
+ setSelectionAfterMentionChange: setSelectionAfterMentionChange
1015
+ });
1016
+ var mentions = getMentions(newValue, config), eventMock = {
1017
+ target: {
1018
+ value: newValue
1019
+ }
1020
+ };
1021
+ _this.executeOnChange(eventMock, newValue, newPlainTextValue, mentions);
911
1022
  }), _defineProperty(_assertThisInitialized(_this), "handleSelect", function(ev) {
912
1023
  if (_this.setState({
913
1024
  selectionStart: ev.target.selectionStart,
@@ -1041,7 +1152,7 @@ var makeTriggerRegex = function(trigger) {
1041
1152
  syncResult instanceof Array && _this.updateSuggestions(_this._queryId, childIndex, query, querySequenceStart, querySequenceEnd, plainTextValue, syncResult);
1042
1153
  }), _defineProperty(_assertThisInitialized(_this), "updateSuggestions", function(queryId, childIndex, query, querySequenceStart, querySequenceEnd, plainTextValue, results) {
1043
1154
  if (queryId === _this._queryId) {
1044
- _this.suggestions = _objectSpread({}, _this.suggestions, _defineProperty({}, childIndex, {
1155
+ _this.suggestions = _objectSpread(_objectSpread({}, _this.suggestions), {}, _defineProperty({}, childIndex, {
1045
1156
  queryInfo: {
1046
1157
  childIndex: childIndex,
1047
1158
  query: query,
@@ -1096,7 +1207,7 @@ var makeTriggerRegex = function(trigger) {
1096
1207
  suggestionsPosition: {}
1097
1208
  }, _this;
1098
1209
  }
1099
- return _inherits(MentionsInput, _React$Component), _createClass(MentionsInput, [ {
1210
+ return _createClass(MentionsInput, [ {
1100
1211
  key: "componentDidMount",
1101
1212
  value: function() {
1102
1213
  document.addEventListener("copy", this.handleCopy), document.addEventListener("cut", this.handleCut),
@@ -1129,17 +1240,19 @@ var makeTriggerRegex = function(trigger) {
1129
1240
  if (event.target === this.inputElement && this.supportsClipboardActions(event)) {
1130
1241
  event.preventDefault();
1131
1242
  var _this$state3 = this.state, selectionStart = _this$state3.selectionStart, selectionEnd = _this$state3.selectionEnd, _this$props7 = this.props, value = _this$props7.value, children = _this$props7.children, config = readConfigFromChildren(children), markupStartIndex = mapPlainTextIndex(value, config, selectionStart, "START"), markupEndIndex = mapPlainTextIndex(value, config, selectionEnd, "END"), pastedMentions = event.clipboardData.getData("text/react-mentions"), pastedData = event.clipboardData.getData("text/plain"), newValue = spliceString(value, markupStartIndex, markupEndIndex, pastedMentions || pastedData).replace(/\r/g, ""), newPlainTextValue = getPlainText(newValue, config), eventMock = {
1132
- target: _objectSpread({}, event.target, {
1243
+ target: _objectSpread(_objectSpread({}, event.target), {}, {
1133
1244
  value: newValue
1134
1245
  })
1135
1246
  };
1136
1247
  this.executeOnChange(eventMock, newValue, newPlainTextValue, getMentions(newValue, config));
1248
+ var nextPos = (findStartOfMentionInPlainText(value, config, selectionStart) || selectionStart) + getPlainText(pastedMentions || pastedData, config).length;
1249
+ this.setSelection(nextPos, nextPos);
1137
1250
  }
1138
1251
  }
1139
1252
  }, {
1140
1253
  key: "saveSelectionToClipboard",
1141
1254
  value: function(event) {
1142
- var _this$state4 = this.state, selectionStart = _this$state4.selectionStart, selectionEnd = _this$state4.selectionEnd, _this$props8 = this.props, children = _this$props8.children, value = _this$props8.value, config = readConfigFromChildren(children), markupStartIndex = mapPlainTextIndex(value, config, selectionStart, "START"), markupEndIndex = mapPlainTextIndex(value, config, selectionEnd, "END");
1255
+ var selectionStart = this.inputElement.selectionStart, selectionEnd = this.inputElement.selectionEnd, _this$props8 = this.props, children = _this$props8.children, value = _this$props8.value, config = readConfigFromChildren(children), markupStartIndex = mapPlainTextIndex(value, config, selectionStart, "START"), markupEndIndex = mapPlainTextIndex(value, config, selectionEnd, "END");
1143
1256
  event.clipboardData.setData("text/plain", event.target.value.slice(selectionStart, selectionEnd)),
1144
1257
  event.clipboardData.setData("text/react-mentions", value.slice(markupStartIndex, markupEndIndex));
1145
1258
  }
@@ -1159,8 +1272,8 @@ var makeTriggerRegex = function(trigger) {
1159
1272
  value: function(event) {
1160
1273
  if (event.target === this.inputElement && this.supportsClipboardActions(event)) {
1161
1274
  event.preventDefault(), this.saveSelectionToClipboard(event);
1162
- var _this$state5 = this.state, selectionStart = _this$state5.selectionStart, selectionEnd = _this$state5.selectionEnd, _this$props9 = this.props, children = _this$props9.children, value = _this$props9.value, config = readConfigFromChildren(children), markupStartIndex = mapPlainTextIndex(value, config, selectionStart, "START"), markupEndIndex = mapPlainTextIndex(value, config, selectionEnd, "END"), newValue = [ value.slice(0, markupStartIndex), value.slice(markupEndIndex) ].join(""), newPlainTextValue = getPlainText(newValue, config), eventMock = {
1163
- target: _objectSpread({}, event.target, {
1275
+ var _this$state4 = this.state, selectionStart = _this$state4.selectionStart, selectionEnd = _this$state4.selectionEnd, _this$props9 = this.props, children = _this$props9.children, value = _this$props9.value, config = readConfigFromChildren(children), markupStartIndex = mapPlainTextIndex(value, config, selectionStart, "START"), markupEndIndex = mapPlainTextIndex(value, config, selectionEnd, "END"), newValue = [ value.slice(0, markupStartIndex), value.slice(markupEndIndex) ].join(""), newPlainTextValue = getPlainText(newValue, config), eventMock = {
1276
+ target: _objectSpread(_objectSpread({}, event.target), {}, {
1164
1277
  value: newPlainTextValue
1165
1278
  })
1166
1279
  };