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.
- package/README.md +2 -1
- package/dist/react-mentions.cjs.dev.js +101 -64
- package/dist/react-mentions.cjs.prod.js +161 -48
- package/dist/react-mentions.esm.js +101 -64
- package/package.json +4 -7
package/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
A React component that let's you mention people in a textarea like you are used to on Facebook or Twitter.
|
9
9
|
|
10
|
-
Used in production at [Signavio](https://signavio.com), [State](https://state.com), [Snips](https://snips.ai), [Swat.io](https://swat.io), [GotDone](https://www.gotdone.me), [Volinspire](https://volinspire.com), [Marvin](https://amazingmarvin.com), [Timely](https://timelyapp.com), [GuideFitter](https://www.guidefitter.com/), [Evite](https://www.evite.com/), [Publer](https://publer.me/), [Kontentino](https://www.kontentino.com/), and [you?](https://github.com/signavio/react-mentions/edit/master/README.md)
|
10
|
+
Used in production at [Signavio](https://signavio.com), [State](https://state.com), [Snips](https://snips.ai), [Swat.io](https://swat.io), [GotDone](https://www.gotdone.me), [Volinspire](https://volinspire.com), [Marvin](https://amazingmarvin.com), [Timely](https://timelyapp.com), [GuideFitter](https://www.guidefitter.com/), [Evite](https://www.evite.com/), [Publer](https://publer.me/), [Kontentino](https://www.kontentino.com/), [Wix.com](https://wix.com), [Highlight](https://highlight.run/) and [you?](https://github.com/signavio/react-mentions/edit/master/README.md)
|
11
11
|
|
12
12
|
## Getting started
|
13
13
|
|
@@ -65,6 +65,7 @@ The `MentionsInput` supports the following props for configuring the widget:
|
|
65
65
|
| inputRef | React ref | undefined | Accepts a React ref to forward to the underlying input element |
|
66
66
|
| allowSuggestionsAboveCursor | boolean | false | Renders the SuggestionList above the cursor if there is not enough space below |
|
67
67
|
| a11ySuggestionsListLabel | string | `''` | This label would be exposed to screen readers when suggestion popup appears |
|
68
|
+
| customSuggestionsContainer | function(children) | empty function | Allows customizing the container of the suggestions |
|
68
69
|
|
69
70
|
Each data source is configured using a `Mention` component, which has the following props:
|
70
71
|
|
@@ -8,10 +8,10 @@ var _toConsumableArray = _interopDefault(require('@babel/runtime/helpers/toConsu
|
|
8
8
|
var _extends = _interopDefault(require('@babel/runtime/helpers/extends'));
|
9
9
|
var _classCallCheck = _interopDefault(require('@babel/runtime/helpers/classCallCheck'));
|
10
10
|
var _createClass = _interopDefault(require('@babel/runtime/helpers/createClass'));
|
11
|
-
var _possibleConstructorReturn = _interopDefault(require('@babel/runtime/helpers/possibleConstructorReturn'));
|
12
|
-
var _getPrototypeOf = _interopDefault(require('@babel/runtime/helpers/getPrototypeOf'));
|
13
11
|
var _assertThisInitialized = _interopDefault(require('@babel/runtime/helpers/assertThisInitialized'));
|
14
12
|
var _inherits = _interopDefault(require('@babel/runtime/helpers/inherits'));
|
13
|
+
var _possibleConstructorReturn = _interopDefault(require('@babel/runtime/helpers/possibleConstructorReturn'));
|
14
|
+
var _getPrototypeOf = _interopDefault(require('@babel/runtime/helpers/getPrototypeOf'));
|
15
15
|
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
|
16
16
|
var React = require('react');
|
17
17
|
var React__default = _interopDefault(React);
|
@@ -629,6 +629,10 @@ var getSubstringIndex = function getSubstringIndex(str, substr, ignoreAccents) {
|
|
629
629
|
return normalizeString(str).indexOf(normalizeString(substr));
|
630
630
|
};
|
631
631
|
|
632
|
+
var isIE = function isIE() {
|
633
|
+
return !!document.documentMode;
|
634
|
+
};
|
635
|
+
|
632
636
|
var isNumber = function isNumber(val) {
|
633
637
|
return typeof val === 'number';
|
634
638
|
};
|
@@ -655,13 +659,15 @@ var omit = function omit(obj) {
|
|
655
659
|
}, {});
|
656
660
|
};
|
657
661
|
|
662
|
+
var _excluded = ["style", "className", "classNames"];
|
663
|
+
|
658
664
|
function createDefaultStyle(defaultStyle, getModifiers) {
|
659
665
|
var enhance = function enhance(ComponentToWrap) {
|
660
666
|
var DefaultStyleEnhancer = function DefaultStyleEnhancer(_ref) {
|
661
667
|
var style = _ref.style,
|
662
668
|
className = _ref.className,
|
663
669
|
classNames = _ref.classNames,
|
664
|
-
rest = _objectWithoutProperties(_ref,
|
670
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
665
671
|
|
666
672
|
var modifiers = getModifiers ? getModifiers(rest) : undefined;
|
667
673
|
var styles = useStyles__default(defaultStyle, {
|
@@ -669,7 +675,7 @@ function createDefaultStyle(defaultStyle, getModifiers) {
|
|
669
675
|
className: className,
|
670
676
|
classNames: classNames
|
671
677
|
}, modifiers);
|
672
|
-
return React__default.createElement(ComponentToWrap, _extends({}, rest, {
|
678
|
+
return /*#__PURE__*/React__default.createElement(ComponentToWrap, _extends({}, rest, {
|
673
679
|
style: styles
|
674
680
|
}));
|
675
681
|
};
|
@@ -682,6 +688,10 @@ function createDefaultStyle(defaultStyle, getModifiers) {
|
|
682
688
|
return enhance;
|
683
689
|
}
|
684
690
|
|
691
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
692
|
+
|
693
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
694
|
+
|
685
695
|
var _generateComponentKey = function _generateComponentKey(usedKeys, id) {
|
686
696
|
if (!usedKeys.hasOwnProperty(id)) {
|
687
697
|
usedKeys[id] = 0;
|
@@ -692,17 +702,17 @@ var _generateComponentKey = function _generateComponentKey(usedKeys, id) {
|
|
692
702
|
return id + '_' + usedKeys[id];
|
693
703
|
};
|
694
704
|
|
695
|
-
var Highlighter =
|
696
|
-
/*#__PURE__*/
|
697
|
-
function (_Component) {
|
705
|
+
var Highlighter = /*#__PURE__*/function (_Component) {
|
698
706
|
_inherits(Highlighter, _Component);
|
699
707
|
|
708
|
+
var _super = _createSuper(Highlighter);
|
709
|
+
|
700
710
|
function Highlighter() {
|
701
711
|
var _this;
|
702
712
|
|
703
713
|
_classCallCheck(this, Highlighter);
|
704
714
|
|
705
|
-
_this =
|
715
|
+
_this = _super.apply(this, arguments);
|
706
716
|
|
707
717
|
_defineProperty(_assertThisInitialized(_this), "setCaretElement", function (el) {
|
708
718
|
_this.caretElement = el;
|
@@ -805,7 +815,7 @@ function (_Component) {
|
|
805
815
|
resultComponents.push(this.renderHighlighterCaret(components));
|
806
816
|
}
|
807
817
|
|
808
|
-
return React__default.createElement("div", _extends({}, style, {
|
818
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({}, style, {
|
809
819
|
ref: containerRef
|
810
820
|
}), resultComponents);
|
811
821
|
}
|
@@ -813,7 +823,7 @@ function (_Component) {
|
|
813
823
|
key: "renderSubstring",
|
814
824
|
value: function renderSubstring(string, key) {
|
815
825
|
// set substring span to hidden, so that Emojis are not shown double in Mobile Safari
|
816
|
-
return React__default.createElement("span", _extends({}, this.props.style('substring'), {
|
826
|
+
return /*#__PURE__*/React__default.createElement("span", _extends({}, this.props.style('substring'), {
|
817
827
|
key: key
|
818
828
|
}), string);
|
819
829
|
} // Returns a clone of the Mention child applicable for the specified type to be rendered inside the highlighter
|
@@ -827,13 +837,13 @@ function (_Component) {
|
|
827
837
|
key: key
|
828
838
|
};
|
829
839
|
var child = React.Children.toArray(this.props.children)[mentionChildIndex];
|
830
|
-
return React__default.cloneElement(child, props);
|
840
|
+
return /*#__PURE__*/React__default.cloneElement(child, props);
|
831
841
|
} // Renders an component to be inserted in the highlighter at the current caret position
|
832
842
|
|
833
843
|
}, {
|
834
844
|
key: "renderHighlighterCaret",
|
835
845
|
value: function renderHighlighterCaret(children) {
|
836
|
-
return React__default.createElement("span", _extends({}, this.props.style('caret'), {
|
846
|
+
return /*#__PURE__*/React__default.createElement("span", _extends({}, this.props.style('caret'), {
|
837
847
|
ref: this.setCaretElement,
|
838
848
|
key: "caret"
|
839
849
|
}), children);
|
@@ -882,15 +892,19 @@ var styled = createDefaultStyle({
|
|
882
892
|
});
|
883
893
|
var Highlighter$1 = styled(Highlighter);
|
884
894
|
|
885
|
-
var
|
886
|
-
|
887
|
-
function (
|
895
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
896
|
+
|
897
|
+
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
898
|
+
|
899
|
+
var Suggestion = /*#__PURE__*/function (_Component) {
|
888
900
|
_inherits(Suggestion, _Component);
|
889
901
|
|
902
|
+
var _super = _createSuper$1(Suggestion);
|
903
|
+
|
890
904
|
function Suggestion() {
|
891
905
|
_classCallCheck(this, Suggestion);
|
892
906
|
|
893
|
-
return
|
907
|
+
return _super.apply(this, arguments);
|
894
908
|
}
|
895
909
|
|
896
910
|
_createClass(Suggestion, [{
|
@@ -898,7 +912,7 @@ function (_Component) {
|
|
898
912
|
value: function render() {
|
899
913
|
var rest = omit(this.props, ['style', 'classNames', 'className'], // substyle props
|
900
914
|
keys(Suggestion.propTypes));
|
901
|
-
return React__default.createElement("li", _extends({
|
915
|
+
return /*#__PURE__*/React__default.createElement("li", _extends({
|
902
916
|
id: this.props.id,
|
903
917
|
role: "option",
|
904
918
|
"aria-selected": this.props.focused
|
@@ -950,10 +964,10 @@ function (_Component) {
|
|
950
964
|
var i = getSubstringIndex(display, query, ignoreAccents);
|
951
965
|
|
952
966
|
if (i === -1) {
|
953
|
-
return React__default.createElement("span", style('display'), display);
|
967
|
+
return /*#__PURE__*/React__default.createElement("span", style('display'), display);
|
954
968
|
}
|
955
969
|
|
956
|
-
return React__default.createElement("span", style('display'), display.substring(0, i), React__default.createElement("b", style('highlight'), display.substring(i, i + query.length)), display.substring(i + query.length));
|
970
|
+
return /*#__PURE__*/React__default.createElement("span", style('display'), display.substring(0, i), /*#__PURE__*/React__default.createElement("b", style('highlight'), display.substring(i, i + query.length)), display.substring(i + query.length));
|
957
971
|
}
|
958
972
|
}]);
|
959
973
|
|
@@ -985,17 +999,19 @@ var Suggestion$1 = styled$1(Suggestion);
|
|
985
999
|
function LoadingIndicator() {
|
986
1000
|
var styles = useStyles__default();
|
987
1001
|
var spinnerStyles = styles('spinner');
|
988
|
-
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']))));
|
1002
|
+
return /*#__PURE__*/React__default.createElement("div", styles, /*#__PURE__*/React__default.createElement("div", spinnerStyles, /*#__PURE__*/React__default.createElement("div", spinnerStyles(['element', 'element1'])), /*#__PURE__*/React__default.createElement("div", spinnerStyles(['element', 'element2'])), /*#__PURE__*/React__default.createElement("div", spinnerStyles(['element', 'element3'])), /*#__PURE__*/React__default.createElement("div", spinnerStyles(['element', 'element4'])), /*#__PURE__*/React__default.createElement("div", spinnerStyles(['element', 'element5']))));
|
989
1003
|
}
|
990
1004
|
|
991
|
-
var
|
992
|
-
|
993
|
-
function (
|
1005
|
+
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
1006
|
+
|
1007
|
+
function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
1008
|
+
|
1009
|
+
var SuggestionsOverlay = /*#__PURE__*/function (_Component) {
|
994
1010
|
_inherits(SuggestionsOverlay, _Component);
|
995
1011
|
|
996
|
-
|
997
|
-
var _getPrototypeOf2;
|
1012
|
+
var _super = _createSuper$2(SuggestionsOverlay);
|
998
1013
|
|
1014
|
+
function SuggestionsOverlay() {
|
999
1015
|
var _this;
|
1000
1016
|
|
1001
1017
|
_classCallCheck(this, SuggestionsOverlay);
|
@@ -1004,7 +1020,7 @@ function (_Component) {
|
|
1004
1020
|
args[_key] = arguments[_key];
|
1005
1021
|
}
|
1006
1022
|
|
1007
|
-
_this =
|
1023
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
1008
1024
|
|
1009
1025
|
_defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function (index, ev) {
|
1010
1026
|
if (_this.props.onMouseEnter) {
|
@@ -1060,20 +1076,22 @@ function (_Component) {
|
|
1060
1076
|
containerRef = _this$props.containerRef,
|
1061
1077
|
position = _this$props.position,
|
1062
1078
|
left = _this$props.left,
|
1079
|
+
right = _this$props.right,
|
1063
1080
|
top = _this$props.top; // do not show suggestions until there is some data
|
1064
1081
|
|
1065
1082
|
if (!isOpened) {
|
1066
1083
|
return null;
|
1067
1084
|
}
|
1068
1085
|
|
1069
|
-
return React__default.createElement("div", _extends({}, useStyles.inline({
|
1086
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({}, useStyles.inline({
|
1070
1087
|
position: position || 'absolute',
|
1071
1088
|
left: left,
|
1089
|
+
right: right,
|
1072
1090
|
top: top
|
1073
1091
|
}, style), {
|
1074
1092
|
onMouseDown: onMouseDown,
|
1075
1093
|
ref: containerRef
|
1076
|
-
}), React__default.createElement("ul", _extends({
|
1094
|
+
}), /*#__PURE__*/React__default.createElement("ul", _extends({
|
1077
1095
|
ref: this.setUlElement,
|
1078
1096
|
id: id,
|
1079
1097
|
role: "listbox",
|
@@ -1085,13 +1103,15 @@ function (_Component) {
|
|
1085
1103
|
value: function renderSuggestions() {
|
1086
1104
|
var _this2 = this;
|
1087
1105
|
|
1088
|
-
|
1106
|
+
var customSuggestionsContainer = this.props.customSuggestionsContainer;
|
1107
|
+
var suggestions = Object.values(this.props.suggestions).reduce(function (accResults, _ref) {
|
1089
1108
|
var results = _ref.results,
|
1090
1109
|
queryInfo = _ref.queryInfo;
|
1091
1110
|
return [].concat(_toConsumableArray(accResults), _toConsumableArray(results.map(function (result, index) {
|
1092
1111
|
return _this2.renderSuggestion(result, queryInfo, accResults.length + index);
|
1093
1112
|
})));
|
1094
1113
|
}, []);
|
1114
|
+
if (customSuggestionsContainer) return customSuggestionsContainer(suggestions);else return suggestions;
|
1095
1115
|
}
|
1096
1116
|
}, {
|
1097
1117
|
key: "renderSuggestion",
|
@@ -1103,7 +1123,7 @@ function (_Component) {
|
|
1103
1123
|
query = queryInfo.query;
|
1104
1124
|
var renderSuggestion = React.Children.toArray(this.props.children)[childIndex].props.renderSuggestion;
|
1105
1125
|
var ignoreAccents = this.props.ignoreAccents;
|
1106
|
-
return React__default.createElement(Suggestion$1, {
|
1126
|
+
return /*#__PURE__*/React__default.createElement(Suggestion$1, {
|
1107
1127
|
style: this.props.style('item'),
|
1108
1128
|
key: "".concat(childIndex, "-").concat(getID(result)),
|
1109
1129
|
id: getSuggestionHtmlId(this.props.id, index),
|
@@ -1128,7 +1148,7 @@ function (_Component) {
|
|
1128
1148
|
return;
|
1129
1149
|
}
|
1130
1150
|
|
1131
|
-
return React__default.createElement(LoadingIndicator, {
|
1151
|
+
return /*#__PURE__*/React__default.createElement(LoadingIndicator, {
|
1132
1152
|
style: this.props.style('loadingIndicator')
|
1133
1153
|
});
|
1134
1154
|
}
|
@@ -1144,6 +1164,7 @@ _defineProperty(SuggestionsOverlay, "propTypes", {
|
|
1144
1164
|
focusIndex: PropTypes.number,
|
1145
1165
|
position: PropTypes.string,
|
1146
1166
|
left: PropTypes.number,
|
1167
|
+
right: PropTypes.number,
|
1147
1168
|
top: PropTypes.number,
|
1148
1169
|
scrollFocusedIntoView: PropTypes.bool,
|
1149
1170
|
isLoading: PropTypes.bool,
|
@@ -1184,9 +1205,13 @@ var styled$2 = createDefaultStyle({
|
|
1184
1205
|
});
|
1185
1206
|
var SuggestionsOverlay$1 = styled$2(SuggestionsOverlay);
|
1186
1207
|
|
1187
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
1208
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
1209
|
+
|
1210
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
1188
1211
|
|
1189
|
-
function
|
1212
|
+
function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
1213
|
+
|
1214
|
+
function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
1190
1215
|
var makeTriggerRegex = function makeTriggerRegex(trigger) {
|
1191
1216
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
1192
1217
|
|
@@ -1244,6 +1269,7 @@ var propTypes = {
|
|
1244
1269
|
a11ySuggestionsListLabel: PropTypes.string,
|
1245
1270
|
value: PropTypes.string,
|
1246
1271
|
onKeyDown: PropTypes.func,
|
1272
|
+
customSuggestionsContainer: PropTypes.func,
|
1247
1273
|
onSelect: PropTypes.func,
|
1248
1274
|
onBlur: PropTypes.func,
|
1249
1275
|
onChange: PropTypes.func,
|
@@ -1254,17 +1280,17 @@ var propTypes = {
|
|
1254
1280
|
children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]).isRequired
|
1255
1281
|
};
|
1256
1282
|
|
1257
|
-
var MentionsInput =
|
1258
|
-
/*#__PURE__*/
|
1259
|
-
function (_React$Component) {
|
1283
|
+
var MentionsInput = /*#__PURE__*/function (_React$Component) {
|
1260
1284
|
_inherits(MentionsInput, _React$Component);
|
1261
1285
|
|
1286
|
+
var _super = _createSuper$3(MentionsInput);
|
1287
|
+
|
1262
1288
|
function MentionsInput(_props) {
|
1263
1289
|
var _this;
|
1264
1290
|
|
1265
1291
|
_classCallCheck(this, MentionsInput);
|
1266
1292
|
|
1267
|
-
_this =
|
1293
|
+
_this = _super.call(this, _props);
|
1268
1294
|
|
1269
1295
|
_defineProperty(_assertThisInitialized(_this), "setContainerElement", function (el) {
|
1270
1296
|
_this.containerElement = el;
|
@@ -1278,7 +1304,7 @@ function (_React$Component) {
|
|
1278
1304
|
|
1279
1305
|
var props = omit(_this.props, ['style', 'classNames', 'className'], // substyle props
|
1280
1306
|
keys(propTypes));
|
1281
|
-
return _objectSpread({}, props,
|
1307
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, props), style('input')), {}, {
|
1282
1308
|
value: _this.getPlainText()
|
1283
1309
|
}, !readOnly && !disabled && {
|
1284
1310
|
onChange: _this.handleChange,
|
@@ -1288,7 +1314,7 @@ function (_React$Component) {
|
|
1288
1314
|
onCompositionStart: _this.handleCompositionStart,
|
1289
1315
|
onCompositionEnd: _this.handleCompositionEnd,
|
1290
1316
|
onScroll: _this.updateHighlighterScroll
|
1291
|
-
},
|
1317
|
+
}), _this.isOpened() && {
|
1292
1318
|
role: 'combobox',
|
1293
1319
|
'aria-controls': _this.uuidSuggestionsOverlay,
|
1294
1320
|
'aria-expanded': true,
|
@@ -1305,18 +1331,18 @@ function (_React$Component) {
|
|
1305
1331
|
|
1306
1332
|
var inputProps = _this.getInputProps();
|
1307
1333
|
|
1308
|
-
return React__default.createElement("div", style('control'), _this.renderHighlighter(), singleLine ? _this.renderInput(inputProps) : _this.renderTextarea(inputProps));
|
1334
|
+
return /*#__PURE__*/React__default.createElement("div", style('control'), _this.renderHighlighter(), singleLine ? _this.renderInput(inputProps) : _this.renderTextarea(inputProps));
|
1309
1335
|
});
|
1310
1336
|
|
1311
1337
|
_defineProperty(_assertThisInitialized(_this), "renderInput", function (props) {
|
1312
|
-
return React__default.createElement("input", _extends({
|
1338
|
+
return /*#__PURE__*/React__default.createElement("input", _extends({
|
1313
1339
|
type: "text",
|
1314
1340
|
ref: _this.setInputRef
|
1315
1341
|
}, props));
|
1316
1342
|
});
|
1317
1343
|
|
1318
1344
|
_defineProperty(_assertThisInitialized(_this), "renderTextarea", function (props) {
|
1319
|
-
return React__default.createElement("textarea", _extends({
|
1345
|
+
return /*#__PURE__*/React__default.createElement("textarea", _extends({
|
1320
1346
|
ref: _this.setInputRef
|
1321
1347
|
}, props));
|
1322
1348
|
});
|
@@ -1345,17 +1371,20 @@ function (_React$Component) {
|
|
1345
1371
|
var _this$state$suggestio = _this.state.suggestionsPosition,
|
1346
1372
|
position = _this$state$suggestio.position,
|
1347
1373
|
left = _this$state$suggestio.left,
|
1348
|
-
top = _this$state$suggestio.top
|
1349
|
-
|
1374
|
+
top = _this$state$suggestio.top,
|
1375
|
+
right = _this$state$suggestio.right;
|
1376
|
+
var suggestionsNode = /*#__PURE__*/React__default.createElement(SuggestionsOverlay$1, {
|
1350
1377
|
id: _this.uuidSuggestionsOverlay,
|
1351
1378
|
style: _this.props.style('suggestions'),
|
1352
1379
|
position: position,
|
1353
1380
|
left: left,
|
1354
1381
|
top: top,
|
1382
|
+
right: right,
|
1355
1383
|
focusIndex: _this.state.focusIndex,
|
1356
1384
|
scrollFocusedIntoView: _this.state.scrollFocusedIntoView,
|
1357
1385
|
containerRef: _this.setSuggestionsElement,
|
1358
1386
|
suggestions: _this.state.suggestions,
|
1387
|
+
customSuggestionsContainer: _this.props.customSuggestionsContainer,
|
1359
1388
|
onSelect: _this.addMention,
|
1360
1389
|
onMouseDown: _this.handleSuggestionsMouseDown,
|
1361
1390
|
onMouseEnter: _this.handleSuggestionsMouseEnter,
|
@@ -1366,7 +1395,7 @@ function (_React$Component) {
|
|
1366
1395
|
}, _this.props.children);
|
1367
1396
|
|
1368
1397
|
if (_this.props.suggestionsPortalHost) {
|
1369
|
-
return ReactDOM.createPortal(suggestionsNode, _this.props.suggestionsPortalHost);
|
1398
|
+
return /*#__PURE__*/ReactDOM.createPortal(suggestionsNode, _this.props.suggestionsPortalHost);
|
1370
1399
|
} else {
|
1371
1400
|
return suggestionsNode;
|
1372
1401
|
}
|
@@ -1381,7 +1410,7 @@ function (_React$Component) {
|
|
1381
1410
|
children = _this$props3.children,
|
1382
1411
|
value = _this$props3.value,
|
1383
1412
|
style = _this$props3.style;
|
1384
|
-
return React__default.createElement(Highlighter$1, {
|
1413
|
+
return /*#__PURE__*/React__default.createElement(Highlighter$1, {
|
1385
1414
|
containerRef: _this.setHighlighterElement,
|
1386
1415
|
style: style('highlighter'),
|
1387
1416
|
value: value,
|
@@ -1425,13 +1454,16 @@ function (_React$Component) {
|
|
1425
1454
|
});
|
1426
1455
|
|
1427
1456
|
_defineProperty(_assertThisInitialized(_this), "handleChange", function (ev) {
|
1428
|
-
isComposing = false;
|
1457
|
+
isComposing = false;
|
1429
1458
|
|
1430
|
-
|
1459
|
+
if (isIE()) {
|
1460
|
+
// if we are inside iframe, we need to find activeElement within its contentDocument
|
1461
|
+
var currentDocument = document.activeElement && document.activeElement.contentDocument || document;
|
1431
1462
|
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1463
|
+
if (currentDocument.activeElement !== ev.target) {
|
1464
|
+
// fix an IE bug (blur from empty input element with placeholder attribute trigger "input" event)
|
1465
|
+
return;
|
1466
|
+
}
|
1435
1467
|
}
|
1436
1468
|
|
1437
1469
|
var value = _this.props.value || '';
|
@@ -1455,7 +1487,7 @@ function (_React$Component) {
|
|
1455
1487
|
|
1456
1488
|
if (startOfMention !== undefined && _this.state.selectionEnd > startOfMention) {
|
1457
1489
|
// only if a deletion has taken place
|
1458
|
-
selectionStart = startOfMention;
|
1490
|
+
selectionStart = startOfMention + (ev.nativeEvent.data ? ev.nativeEvent.data.length : 0);
|
1459
1491
|
selectionEnd = selectionStart;
|
1460
1492
|
setSelectionAfterMentionChange = true;
|
1461
1493
|
}
|
@@ -1815,7 +1847,7 @@ function (_React$Component) {
|
|
1815
1847
|
if (queryId !== _this._queryId) return; // save in property so that multiple sync state updates from different mentions sources
|
1816
1848
|
// won't overwrite each other
|
1817
1849
|
|
1818
|
-
_this.suggestions = _objectSpread({}, _this.suggestions, _defineProperty({}, childIndex, {
|
1850
|
+
_this.suggestions = _objectSpread(_objectSpread({}, _this.suggestions), {}, _defineProperty({}, childIndex, {
|
1819
1851
|
queryInfo: {
|
1820
1852
|
childIndex: childIndex,
|
1821
1853
|
query: query,
|
@@ -1961,7 +1993,7 @@ function (_React$Component) {
|
|
1961
1993
|
}, {
|
1962
1994
|
key: "render",
|
1963
1995
|
value: function render() {
|
1964
|
-
return React__default.createElement("div", _extends({
|
1996
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
1965
1997
|
ref: this.setContainerElement
|
1966
1998
|
}, this.props.style), this.renderControl(), this.renderSuggestionsOverlay());
|
1967
1999
|
}
|
@@ -1991,18 +2023,23 @@ function (_React$Component) {
|
|
1991
2023
|
var newValue = spliceString(value, markupStartIndex, markupEndIndex, pastedMentions || pastedData).replace(/\r/g, '');
|
1992
2024
|
var newPlainTextValue = getPlainText(newValue, config);
|
1993
2025
|
var eventMock = {
|
1994
|
-
target: _objectSpread({}, event.target, {
|
2026
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
1995
2027
|
value: newValue
|
1996
2028
|
})
|
1997
2029
|
};
|
1998
|
-
this.executeOnChange(eventMock, newValue, newPlainTextValue, getMentions(newValue, config));
|
2030
|
+
this.executeOnChange(eventMock, newValue, newPlainTextValue, getMentions(newValue, config)); // Move the cursor position to the end of the pasted data
|
2031
|
+
|
2032
|
+
var startOfMention = findStartOfMentionInPlainText(value, config, selectionStart);
|
2033
|
+
var nextPos = (startOfMention || selectionStart) + getPlainText(pastedMentions || pastedData, config).length;
|
2034
|
+
this.setSelection(nextPos, nextPos);
|
1999
2035
|
}
|
2000
2036
|
}, {
|
2001
2037
|
key: "saveSelectionToClipboard",
|
2002
2038
|
value: function saveSelectionToClipboard(event) {
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2039
|
+
// use the actual selectionStart & selectionEnd instead of the one stored
|
2040
|
+
// in state to ensure copy & paste also works on disabled inputs & textareas
|
2041
|
+
var selectionStart = this.inputElement.selectionStart;
|
2042
|
+
var selectionEnd = this.inputElement.selectionEnd;
|
2006
2043
|
var _this$props8 = this.props,
|
2007
2044
|
children = _this$props8.children,
|
2008
2045
|
value = _this$props8.value;
|
@@ -2044,9 +2081,9 @@ function (_React$Component) {
|
|
2044
2081
|
|
2045
2082
|
event.preventDefault();
|
2046
2083
|
this.saveSelectionToClipboard(event);
|
2047
|
-
var _this$
|
2048
|
-
selectionStart = _this$
|
2049
|
-
selectionEnd = _this$
|
2084
|
+
var _this$state4 = this.state,
|
2085
|
+
selectionStart = _this$state4.selectionStart,
|
2086
|
+
selectionEnd = _this$state4.selectionEnd;
|
2050
2087
|
var _this$props9 = this.props,
|
2051
2088
|
children = _this$props9.children,
|
2052
2089
|
value = _this$props9.value;
|
@@ -2056,7 +2093,7 @@ function (_React$Component) {
|
|
2056
2093
|
var newValue = [value.slice(0, markupStartIndex), value.slice(markupEndIndex)].join('');
|
2057
2094
|
var newPlainTextValue = getPlainText(newValue, config);
|
2058
2095
|
var eventMock = {
|
2059
|
-
target: _objectSpread({}, event.target, {
|
2096
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
2060
2097
|
value: newPlainTextValue
|
2061
2098
|
})
|
2062
2099
|
};
|
@@ -2146,7 +2183,7 @@ var Mention = function Mention(_ref) {
|
|
2146
2183
|
className: className,
|
2147
2184
|
classNames: classNames
|
2148
2185
|
});
|
2149
|
-
return React__default.createElement("strong", styles, display);
|
2186
|
+
return /*#__PURE__*/React__default.createElement("strong", styles, display);
|
2150
2187
|
};
|
2151
2188
|
|
2152
2189
|
Mention.propTypes = {
|