react-mentions 4.3.0 → 4.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/react-mentions.cjs.dev.js +12 -5
- package/dist/react-mentions.cjs.prod.js +22 -21
- package/dist/react-mentions.esm.js +12 -5
- package/package.json +1 -1
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) and [you?](https://github.com/signavio/react-mentions/edit/master/README.md)
|
11
11
|
|
12
12
|
## Getting started
|
13
13
|
|
@@ -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
|
};
|
@@ -1425,13 +1429,16 @@ function (_React$Component) {
|
|
1425
1429
|
});
|
1426
1430
|
|
1427
1431
|
_defineProperty(_assertThisInitialized(_this), "handleChange", function (ev) {
|
1428
|
-
isComposing = false;
|
1432
|
+
isComposing = false;
|
1429
1433
|
|
1430
|
-
|
1434
|
+
if (isIE()) {
|
1435
|
+
// if we are inside iframe, we need to find activeElement within its contentDocument
|
1436
|
+
var currentDocument = document.activeElement && document.activeElement.contentDocument || document;
|
1431
1437
|
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1438
|
+
if (currentDocument.activeElement !== ev.target) {
|
1439
|
+
// fix an IE bug (blur from empty input element with placeholder attribute trigger "input" event)
|
1440
|
+
return;
|
1441
|
+
}
|
1435
1442
|
}
|
1436
1443
|
|
1437
1444
|
var value = _this.props.value || '';
|
@@ -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) {
|
@@ -887,27 +889,26 @@ var makeTriggerRegex = function(trigger) {
|
|
887
889
|
var _this$props4, _this$props$valueLink;
|
888
890
|
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
891
|
}), _defineProperty(_assertThisInitialized(_this), "handleChange", function(ev) {
|
890
|
-
if (isComposing = !1, (document.activeElement && document.activeElement.contentDocument || document).activeElement
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
}
|
892
|
+
if ((isComposing = !1, isIE()) && (document.activeElement && document.activeElement.contentDocument || document).activeElement !== ev.target) return;
|
893
|
+
var value = _this.props.value || "", config = readConfigFromChildren(_this.props.children), newPlainTextValue = ev.target.value, newValue = applyChangeToValue(value, newPlainTextValue, {
|
894
|
+
selectionStartBefore: _this.state.selectionStart,
|
895
|
+
selectionEndBefore: _this.state.selectionEnd,
|
896
|
+
selectionEndAfter: ev.target.selectionEnd
|
897
|
+
}, config);
|
898
|
+
newPlainTextValue = getPlainText(newValue, config);
|
899
|
+
var selectionStart = ev.target.selectionStart, selectionEnd = ev.target.selectionEnd, setSelectionAfterMentionChange = !1, startOfMention = findStartOfMentionInPlainText(value, config, selectionStart);
|
900
|
+
void 0 !== startOfMention && _this.state.selectionEnd > startOfMention && (selectionEnd = selectionStart = startOfMention,
|
901
|
+
setSelectionAfterMentionChange = !0), _this.setState({
|
902
|
+
selectionStart: selectionStart,
|
903
|
+
selectionEnd: selectionEnd,
|
904
|
+
setSelectionAfterMentionChange: setSelectionAfterMentionChange
|
905
|
+
});
|
906
|
+
var mentions = getMentions(newValue, config), eventMock = {
|
907
|
+
target: {
|
908
|
+
value: newValue
|
909
|
+
}
|
910
|
+
};
|
911
|
+
_this.executeOnChange(eventMock, newValue, newPlainTextValue, mentions);
|
911
912
|
}), _defineProperty(_assertThisInitialized(_this), "handleSelect", function(ev) {
|
912
913
|
if (_this.setState({
|
913
914
|
selectionStart: ev.target.selectionStart,
|
@@ -621,6 +621,10 @@ var getSubstringIndex = function getSubstringIndex(str, substr, ignoreAccents) {
|
|
621
621
|
return normalizeString(str).indexOf(normalizeString(substr));
|
622
622
|
};
|
623
623
|
|
624
|
+
var isIE = function isIE() {
|
625
|
+
return !!document.documentMode;
|
626
|
+
};
|
627
|
+
|
624
628
|
var isNumber = function isNumber(val) {
|
625
629
|
return typeof val === 'number';
|
626
630
|
};
|
@@ -1417,13 +1421,16 @@ function (_React$Component) {
|
|
1417
1421
|
});
|
1418
1422
|
|
1419
1423
|
_defineProperty(_assertThisInitialized(_this), "handleChange", function (ev) {
|
1420
|
-
isComposing = false;
|
1424
|
+
isComposing = false;
|
1421
1425
|
|
1422
|
-
|
1426
|
+
if (isIE()) {
|
1427
|
+
// if we are inside iframe, we need to find activeElement within its contentDocument
|
1428
|
+
var currentDocument = document.activeElement && document.activeElement.contentDocument || document;
|
1423
1429
|
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1430
|
+
if (currentDocument.activeElement !== ev.target) {
|
1431
|
+
// fix an IE bug (blur from empty input element with placeholder attribute trigger "input" event)
|
1432
|
+
return;
|
1433
|
+
}
|
1427
1434
|
}
|
1428
1435
|
|
1429
1436
|
var value = _this.props.value || '';
|