react-mentions 4.4.2 → 4.4.4
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.
- package/CHANGELOG.md +13 -0
- package/dist/react-mentions.cjs.dev.js +92 -62
- package/dist/react-mentions.cjs.prod.js +144 -31
- package/dist/react-mentions.esm.js +92 -62
- package/package.json +7 -6
|
@@ -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")),
|
|
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__",
|
|
@@ -418,12 +418,12 @@ var _toConsumableArray = _interopDefault(require("@babel/runtime/helpers/toConsu
|
|
|
418
418
|
return obj.hasOwnProperty(k) && !keys.includes(k) && void 0 !== obj[k] && (acc[k] = obj[k]),
|
|
419
419
|
acc;
|
|
420
420
|
}, {});
|
|
421
|
-
};
|
|
421
|
+
}, _excluded = [ "style", "className", "classNames" ];
|
|
422
422
|
|
|
423
423
|
function createDefaultStyle(defaultStyle, getModifiers) {
|
|
424
424
|
return function(ComponentToWrap) {
|
|
425
425
|
var DefaultStyleEnhancer = function(_ref) {
|
|
426
|
-
var style = _ref.style, className = _ref.className, classNames = _ref.classNames, rest = _objectWithoutProperties(_ref,
|
|
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, {
|
|
427
427
|
style: style,
|
|
428
428
|
className: className,
|
|
429
429
|
classNames: classNames
|
|
@@ -437,12 +437,38 @@ function createDefaultStyle(defaultStyle, getModifiers) {
|
|
|
437
437
|
};
|
|
438
438
|
}
|
|
439
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
|
+
|
|
440
464
|
var _generateComponentKey = function(usedKeys, id) {
|
|
441
465
|
return usedKeys.hasOwnProperty(id) ? usedKeys[id]++ : usedKeys[id] = 0, id + "_" + usedKeys[id];
|
|
442
466
|
}, Highlighter = function(_Component) {
|
|
467
|
+
_inherits(Highlighter, _Component);
|
|
468
|
+
var _super = _createSuper(Highlighter);
|
|
443
469
|
function Highlighter() {
|
|
444
470
|
var _this;
|
|
445
|
-
return _classCallCheck(this, Highlighter), _this =
|
|
471
|
+
return _classCallCheck(this, Highlighter), _this = _super.apply(this, arguments),
|
|
446
472
|
_defineProperty(_assertThisInitialized(_this), "setCaretElement", function(el) {
|
|
447
473
|
_this.caretElement = el;
|
|
448
474
|
}), _this.state = {
|
|
@@ -450,7 +476,7 @@ var _generateComponentKey = function(usedKeys, id) {
|
|
|
450
476
|
top: void 0
|
|
451
477
|
}, _this;
|
|
452
478
|
}
|
|
453
|
-
return
|
|
479
|
+
return _createClass(Highlighter, [ {
|
|
454
480
|
key: "componentDidMount",
|
|
455
481
|
value: function() {
|
|
456
482
|
this.notifyCaretPosition();
|
|
@@ -557,11 +583,39 @@ var styled = createDefaultStyle({
|
|
|
557
583
|
return {
|
|
558
584
|
"&singleLine": props.singleLine
|
|
559
585
|
};
|
|
560
|
-
}), Highlighter$1 = styled(Highlighter)
|
|
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);
|
|
561
615
|
function Suggestion() {
|
|
562
|
-
return _classCallCheck(this, Suggestion),
|
|
616
|
+
return _classCallCheck(this, Suggestion), _super.apply(this, arguments);
|
|
563
617
|
}
|
|
564
|
-
return
|
|
618
|
+
return _createClass(Suggestion, [ {
|
|
565
619
|
key: "render",
|
|
566
620
|
value: function() {
|
|
567
621
|
var rest = omit(this.props, [ "style", "classNames", "className" ], keys(Suggestion.propTypes));
|
|
@@ -615,18 +669,49 @@ var styled$1 = createDefaultStyle({
|
|
|
615
669
|
};
|
|
616
670
|
}), Suggestion$1 = styled$1(Suggestion);
|
|
617
671
|
|
|
618
|
-
function LoadingIndicator() {
|
|
619
|
-
var
|
|
672
|
+
function LoadingIndicator(_ref) {
|
|
673
|
+
var style = _ref.style, className = _ref.className, classNames = _ref.classNames, styles = useStyles__default(defaultstyle, {
|
|
674
|
+
style: style,
|
|
675
|
+
className: className,
|
|
676
|
+
classNames: classNames
|
|
677
|
+
}), spinnerStyles = styles("spinner");
|
|
620
678
|
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" ]))));
|
|
621
679
|
}
|
|
622
680
|
|
|
681
|
+
var defaultstyle = {};
|
|
682
|
+
|
|
683
|
+
function _createSuper$2(Derived) {
|
|
684
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$2();
|
|
685
|
+
return function() {
|
|
686
|
+
var result, Super = _getPrototypeOf(Derived);
|
|
687
|
+
if (hasNativeReflectConstruct) {
|
|
688
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
689
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
690
|
+
} else result = Super.apply(this, arguments);
|
|
691
|
+
return _possibleConstructorReturn(this, result);
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function _isNativeReflectConstruct$2() {
|
|
696
|
+
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
|
697
|
+
if (Reflect.construct.sham) return !1;
|
|
698
|
+
if ("function" == typeof Proxy) return !0;
|
|
699
|
+
try {
|
|
700
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
701
|
+
!0;
|
|
702
|
+
} catch (e) {
|
|
703
|
+
return !1;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
623
707
|
var SuggestionsOverlay = function(_Component) {
|
|
708
|
+
_inherits(SuggestionsOverlay, _Component);
|
|
709
|
+
var _super = _createSuper$2(SuggestionsOverlay);
|
|
624
710
|
function SuggestionsOverlay() {
|
|
625
|
-
var
|
|
711
|
+
var _this;
|
|
626
712
|
_classCallCheck(this, SuggestionsOverlay);
|
|
627
713
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
|
|
628
|
-
return _this =
|
|
629
|
-
_defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function(index, ev) {
|
|
714
|
+
return _this = _super.call.apply(_super, [ this ].concat(args)), _defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function(index, ev) {
|
|
630
715
|
_this.props.onMouseEnter && _this.props.onMouseEnter(index);
|
|
631
716
|
}), _defineProperty(_assertThisInitialized(_this), "select", function(suggestion, queryInfo) {
|
|
632
717
|
_this.props.onSelect(suggestion, queryInfo);
|
|
@@ -634,7 +719,7 @@ var SuggestionsOverlay = function(_Component) {
|
|
|
634
719
|
_this.ulElement = el;
|
|
635
720
|
}), _this;
|
|
636
721
|
}
|
|
637
|
-
return
|
|
722
|
+
return _createClass(SuggestionsOverlay, [ {
|
|
638
723
|
key: "componentDidUpdate",
|
|
639
724
|
value: function() {
|
|
640
725
|
if (this.ulElement && !(this.ulElement.offsetHeight >= this.ulElement.scrollHeight) && this.props.scrollFocusedIntoView) {
|
|
@@ -664,13 +749,13 @@ var SuggestionsOverlay = function(_Component) {
|
|
|
664
749
|
}, {
|
|
665
750
|
key: "renderSuggestions",
|
|
666
751
|
value: function() {
|
|
667
|
-
var _this2 = this
|
|
668
|
-
return Object.values(this.props.suggestions).reduce(function(accResults, _ref) {
|
|
752
|
+
var _this2 = this, customSuggestionsContainer = this.props.customSuggestionsContainer, suggestions = Object.values(this.props.suggestions).reduce(function(accResults, _ref) {
|
|
669
753
|
var results = _ref.results, queryInfo = _ref.queryInfo;
|
|
670
754
|
return [].concat(_toConsumableArray(accResults), _toConsumableArray(results.map(function(result, index) {
|
|
671
755
|
return _this2.renderSuggestion(result, queryInfo, accResults.length + index);
|
|
672
756
|
})));
|
|
673
757
|
}, []);
|
|
758
|
+
return customSuggestionsContainer ? customSuggestionsContainer(suggestions) : suggestions;
|
|
674
759
|
}
|
|
675
760
|
}, {
|
|
676
761
|
key: "renderSuggestion",
|
|
@@ -757,15 +842,39 @@ function ownKeys(object, enumerableOnly) {
|
|
|
757
842
|
function _objectSpread(target) {
|
|
758
843
|
for (var i = 1; i < arguments.length; i++) {
|
|
759
844
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
760
|
-
i % 2 ? ownKeys(source, !0).forEach(function(key) {
|
|
845
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
|
|
761
846
|
_defineProperty(target, key, source[key]);
|
|
762
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(source).forEach(function(key) {
|
|
847
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
763
848
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
764
849
|
});
|
|
765
850
|
}
|
|
766
851
|
return target;
|
|
767
852
|
}
|
|
768
853
|
|
|
854
|
+
function _createSuper$3(Derived) {
|
|
855
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$3();
|
|
856
|
+
return function() {
|
|
857
|
+
var result, Super = _getPrototypeOf(Derived);
|
|
858
|
+
if (hasNativeReflectConstruct) {
|
|
859
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
860
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
861
|
+
} else result = Super.apply(this, arguments);
|
|
862
|
+
return _possibleConstructorReturn(this, result);
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
function _isNativeReflectConstruct$3() {
|
|
867
|
+
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
|
868
|
+
if (Reflect.construct.sham) return !1;
|
|
869
|
+
if ("function" == typeof Proxy) return !0;
|
|
870
|
+
try {
|
|
871
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
872
|
+
!0;
|
|
873
|
+
} catch (e) {
|
|
874
|
+
return !1;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
769
878
|
var makeTriggerRegex = function(trigger) {
|
|
770
879
|
var options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
|
771
880
|
if (trigger instanceof RegExp) return trigger;
|
|
@@ -794,6 +903,7 @@ var makeTriggerRegex = function(trigger) {
|
|
|
794
903
|
a11ySuggestionsListLabel: PropTypes.string,
|
|
795
904
|
value: PropTypes.string,
|
|
796
905
|
onKeyDown: PropTypes.func,
|
|
906
|
+
customSuggestionsContainer: PropTypes.func,
|
|
797
907
|
onSelect: PropTypes.func,
|
|
798
908
|
onBlur: PropTypes.func,
|
|
799
909
|
onChange: PropTypes.func,
|
|
@@ -803,24 +913,26 @@ var makeTriggerRegex = function(trigger) {
|
|
|
803
913
|
}) ]),
|
|
804
914
|
children: PropTypes.oneOfType([ PropTypes.element, PropTypes.arrayOf(PropTypes.element) ]).isRequired
|
|
805
915
|
}, MentionsInput = function(_React$Component) {
|
|
916
|
+
_inherits(MentionsInput, _React$Component);
|
|
917
|
+
var _super = _createSuper$3(MentionsInput);
|
|
806
918
|
function MentionsInput(_props) {
|
|
807
919
|
var _this;
|
|
808
|
-
return _classCallCheck(this, MentionsInput), _this =
|
|
920
|
+
return _classCallCheck(this, MentionsInput), _this = _super.call(this, _props),
|
|
809
921
|
_defineProperty(_assertThisInitialized(_this), "setContainerElement", function(el) {
|
|
810
922
|
_this.containerElement = el;
|
|
811
923
|
}), _defineProperty(_assertThisInitialized(_this), "getInputProps", function() {
|
|
812
924
|
var _this$props = _this.props, readOnly = _this$props.readOnly, disabled = _this$props.disabled, style = _this$props.style;
|
|
813
|
-
return _objectSpread({}, omit(_this.props, [ "style", "classNames", "className" ], keys(propTypes)),
|
|
814
|
-
value: _this.getPlainText()
|
|
925
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, omit(_this.props, [ "style", "classNames", "className" ], keys(propTypes))), style("input")), {}, {
|
|
926
|
+
value: _this.getPlainText(),
|
|
927
|
+
onScroll: _this.updateHighlighterScroll
|
|
815
928
|
}, !readOnly && !disabled && {
|
|
816
929
|
onChange: _this.handleChange,
|
|
817
930
|
onSelect: _this.handleSelect,
|
|
818
931
|
onKeyDown: _this.handleKeyDown,
|
|
819
932
|
onBlur: _this.handleBlur,
|
|
820
933
|
onCompositionStart: _this.handleCompositionStart,
|
|
821
|
-
onCompositionEnd: _this.handleCompositionEnd
|
|
822
|
-
|
|
823
|
-
}, {}, _this.isOpened() && {
|
|
934
|
+
onCompositionEnd: _this.handleCompositionEnd
|
|
935
|
+
}), _this.isOpened() && {
|
|
824
936
|
role: "combobox",
|
|
825
937
|
"aria-controls": _this.uuidSuggestionsOverlay,
|
|
826
938
|
"aria-expanded": !0,
|
|
@@ -859,6 +971,7 @@ var makeTriggerRegex = function(trigger) {
|
|
|
859
971
|
scrollFocusedIntoView: _this.state.scrollFocusedIntoView,
|
|
860
972
|
containerRef: _this.setSuggestionsElement,
|
|
861
973
|
suggestions: _this.state.suggestions,
|
|
974
|
+
customSuggestionsContainer: _this.props.customSuggestionsContainer,
|
|
862
975
|
onSelect: _this.addMention,
|
|
863
976
|
onMouseDown: _this.handleSuggestionsMouseDown,
|
|
864
977
|
onMouseEnter: _this.handleSuggestionsMouseEnter,
|
|
@@ -900,7 +1013,7 @@ var makeTriggerRegex = function(trigger) {
|
|
|
900
1013
|
}, config);
|
|
901
1014
|
newPlainTextValue = getPlainText(newValue, config);
|
|
902
1015
|
var selectionStart = ev.target.selectionStart, selectionEnd = ev.target.selectionEnd, setSelectionAfterMentionChange = !1, startOfMention = findStartOfMentionInPlainText(value, config, selectionStart);
|
|
903
|
-
void 0 !== startOfMention && _this.state.selectionEnd > startOfMention && (selectionEnd = selectionStart = startOfMention,
|
|
1016
|
+
void 0 !== startOfMention && _this.state.selectionEnd > startOfMention && (selectionEnd = selectionStart = startOfMention + (ev.nativeEvent.data ? ev.nativeEvent.data.length : 0),
|
|
904
1017
|
setSelectionAfterMentionChange = !0), _this.setState({
|
|
905
1018
|
selectionStart: selectionStart,
|
|
906
1019
|
selectionEnd: selectionEnd,
|
|
@@ -1045,7 +1158,7 @@ var makeTriggerRegex = function(trigger) {
|
|
|
1045
1158
|
syncResult instanceof Array && _this.updateSuggestions(_this._queryId, childIndex, query, querySequenceStart, querySequenceEnd, plainTextValue, syncResult);
|
|
1046
1159
|
}), _defineProperty(_assertThisInitialized(_this), "updateSuggestions", function(queryId, childIndex, query, querySequenceStart, querySequenceEnd, plainTextValue, results) {
|
|
1047
1160
|
if (queryId === _this._queryId) {
|
|
1048
|
-
_this.suggestions = _objectSpread({}, _this.suggestions, _defineProperty({}, childIndex, {
|
|
1161
|
+
_this.suggestions = _objectSpread(_objectSpread({}, _this.suggestions), {}, _defineProperty({}, childIndex, {
|
|
1049
1162
|
queryInfo: {
|
|
1050
1163
|
childIndex: childIndex,
|
|
1051
1164
|
query: query,
|
|
@@ -1100,7 +1213,7 @@ var makeTriggerRegex = function(trigger) {
|
|
|
1100
1213
|
suggestionsPosition: {}
|
|
1101
1214
|
}, _this;
|
|
1102
1215
|
}
|
|
1103
|
-
return
|
|
1216
|
+
return _createClass(MentionsInput, [ {
|
|
1104
1217
|
key: "componentDidMount",
|
|
1105
1218
|
value: function() {
|
|
1106
1219
|
document.addEventListener("copy", this.handleCopy), document.addEventListener("cut", this.handleCut),
|
|
@@ -1133,7 +1246,7 @@ var makeTriggerRegex = function(trigger) {
|
|
|
1133
1246
|
if (event.target === this.inputElement && this.supportsClipboardActions(event)) {
|
|
1134
1247
|
event.preventDefault();
|
|
1135
1248
|
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 = {
|
|
1136
|
-
target: _objectSpread({}, event.target, {
|
|
1249
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
|
1137
1250
|
value: newValue
|
|
1138
1251
|
})
|
|
1139
1252
|
};
|
|
@@ -1145,7 +1258,7 @@ var makeTriggerRegex = function(trigger) {
|
|
|
1145
1258
|
}, {
|
|
1146
1259
|
key: "saveSelectionToClipboard",
|
|
1147
1260
|
value: function(event) {
|
|
1148
|
-
var
|
|
1261
|
+
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");
|
|
1149
1262
|
event.clipboardData.setData("text/plain", event.target.value.slice(selectionStart, selectionEnd)),
|
|
1150
1263
|
event.clipboardData.setData("text/react-mentions", value.slice(markupStartIndex, markupEndIndex));
|
|
1151
1264
|
}
|
|
@@ -1165,8 +1278,8 @@ var makeTriggerRegex = function(trigger) {
|
|
|
1165
1278
|
value: function(event) {
|
|
1166
1279
|
if (event.target === this.inputElement && this.supportsClipboardActions(event)) {
|
|
1167
1280
|
event.preventDefault(), this.saveSelectionToClipboard(event);
|
|
1168
|
-
var _this$
|
|
1169
|
-
target: _objectSpread({}, event.target, {
|
|
1281
|
+
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 = {
|
|
1282
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
|
1170
1283
|
value: newPlainTextValue
|
|
1171
1284
|
})
|
|
1172
1285
|
};
|