react-mentions 4.4.6 → 4.4.8
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +18 -0
- package/README.md +1 -3
- package/dist/react-mentions.cjs.dev.js +259 -311
- package/dist/react-mentions.cjs.prod.js +169 -246
- package/dist/react-mentions.esm.js +260 -312
- package/package.json +1 -1
@@ -420,6 +420,29 @@ var _toConsumableArray = _interopDefault(require("@babel/runtime/helpers/toConsu
|
|
420
420
|
}, {});
|
421
421
|
}, _excluded = [ "style", "className", "classNames" ];
|
422
422
|
|
423
|
+
function ownKeys(object, enumerableOnly) {
|
424
|
+
var keys = Object.keys(object);
|
425
|
+
if (Object.getOwnPropertySymbols) {
|
426
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
427
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
428
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
429
|
+
})), keys.push.apply(keys, symbols);
|
430
|
+
}
|
431
|
+
return keys;
|
432
|
+
}
|
433
|
+
|
434
|
+
function _objectSpread(target) {
|
435
|
+
for (var i = 1; i < arguments.length; i++) {
|
436
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
437
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
|
438
|
+
_defineProperty(target, key, source[key]);
|
439
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
440
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
441
|
+
});
|
442
|
+
}
|
443
|
+
return target;
|
444
|
+
}
|
445
|
+
|
423
446
|
function createDefaultStyle(defaultStyle, getModifiers) {
|
424
447
|
return function(ComponentToWrap) {
|
425
448
|
var DefaultStyleEnhancer = function(_ref) {
|
@@ -433,123 +456,73 @@ function createDefaultStyle(defaultStyle, getModifiers) {
|
|
433
456
|
}));
|
434
457
|
}, displayName = ComponentToWrap.displayName || ComponentToWrap.name || "Component";
|
435
458
|
return DefaultStyleEnhancer.displayName = "defaultStyle(".concat(displayName, ")"),
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
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);
|
459
|
+
React__default.forwardRef(function(props, ref) {
|
460
|
+
return DefaultStyleEnhancer(_objectSpread(_objectSpread({}, props), {}, {
|
461
|
+
ref: ref
|
462
|
+
}));
|
463
|
+
});
|
449
464
|
};
|
450
465
|
}
|
451
466
|
|
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
|
-
|
464
467
|
var _generateComponentKey = function(usedKeys, id) {
|
465
468
|
return usedKeys.hasOwnProperty(id) ? usedKeys[id]++ : usedKeys[id] = 0, id + "_" + usedKeys[id];
|
466
|
-
}
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
value: function() {
|
487
|
-
this.notifyCaretPosition();
|
488
|
-
}
|
489
|
-
}, {
|
490
|
-
key: "notifyCaretPosition",
|
491
|
-
value: function() {
|
492
|
-
if (this.caretElement) {
|
493
|
-
var _this$caretElement = this.caretElement, offsetLeft = _this$caretElement.offsetLeft, offsetTop = _this$caretElement.offsetTop;
|
494
|
-
if (this.state.left !== offsetLeft || this.state.top !== offsetTop) {
|
495
|
-
var newPosition = {
|
496
|
-
left: offsetLeft,
|
497
|
-
top: offsetTop
|
498
|
-
};
|
499
|
-
this.setState(newPosition), this.props.onCaretPositionChange(newPosition);
|
500
|
-
}
|
469
|
+
};
|
470
|
+
|
471
|
+
function Highlighter(_ref) {
|
472
|
+
var selectionStart = _ref.selectionStart, selectionEnd = _ref.selectionEnd, _ref$value = _ref.value, value = void 0 === _ref$value ? "" : _ref$value, onCaretPositionChange = _ref.onCaretPositionChange, containerRef = _ref.containerRef, children = _ref.children, style = (_ref.singleLine,
|
473
|
+
_ref.style), _useState = React.useState({
|
474
|
+
left: void 0,
|
475
|
+
top: void 0
|
476
|
+
}), _useState2 = _slicedToArray(_useState, 2), position = _useState2[0], setPosition = _useState2[1], _useState3 = React.useState(), _useState4 = _slicedToArray(_useState3, 2), caretElement = _useState4[0], setCaretElement = _useState4[1];
|
477
|
+
React.useEffect(function() {
|
478
|
+
notifyCaretPosition();
|
479
|
+
});
|
480
|
+
var caretPositionInMarkup, notifyCaretPosition = function() {
|
481
|
+
if (caretElement) {
|
482
|
+
var offsetLeft = caretElement.offsetLeft, offsetTop = caretElement.offsetTop;
|
483
|
+
if (position.left !== offsetLeft || position.top !== offsetTop) {
|
484
|
+
var newPosition = {
|
485
|
+
left: offsetLeft,
|
486
|
+
top: offsetTop
|
487
|
+
};
|
488
|
+
setPosition(newPosition), onCaretPositionChange(newPosition);
|
501
489
|
}
|
502
490
|
}
|
503
|
-
},
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
display: display,
|
537
|
-
key: key
|
538
|
-
}, child = React.Children.toArray(this.props.children)[mentionChildIndex];
|
539
|
-
return React__default.cloneElement(child, props);
|
540
|
-
}
|
541
|
-
}, {
|
542
|
-
key: "renderHighlighterCaret",
|
543
|
-
value: function(children) {
|
544
|
-
return React__default.createElement("span", _extends({}, this.props.style("caret"), {
|
545
|
-
ref: this.setCaretElement,
|
546
|
-
key: "caret"
|
547
|
-
}), children);
|
548
|
-
}
|
549
|
-
} ]), Highlighter;
|
550
|
-
}(React.Component);
|
491
|
+
}, config = readConfigFromChildren(children);
|
492
|
+
selectionEnd === selectionStart && (caretPositionInMarkup = mapPlainTextIndex(value, config, selectionStart, "START"));
|
493
|
+
var resultComponents = [], componentKeys = {}, components = resultComponents, substringComponentKey = 0, renderSubstring = function(string, key) {
|
494
|
+
return React__default.createElement("span", _extends({}, style("substring"), {
|
495
|
+
key: key
|
496
|
+
}), string);
|
497
|
+
}, getMentionComponentForMatch = function(id, display, mentionChildIndex, key) {
|
498
|
+
var props = {
|
499
|
+
id: id,
|
500
|
+
display: display,
|
501
|
+
key: key
|
502
|
+
}, child = React.Children.toArray(children)[mentionChildIndex];
|
503
|
+
return React__default.cloneElement(child, props);
|
504
|
+
};
|
505
|
+
return iterateMentionsMarkup(value, config, function(markup, index, indexInPlainText, id, display, mentionChildIndex, lastMentionEndIndex) {
|
506
|
+
var key = _generateComponentKey(componentKeys, id);
|
507
|
+
components.push(getMentionComponentForMatch(id, display, mentionChildIndex, key));
|
508
|
+
}, function(substr, index, indexInPlainText) {
|
509
|
+
if (isNumber(caretPositionInMarkup) && caretPositionInMarkup >= index && caretPositionInMarkup <= index + substr.length) {
|
510
|
+
var splitIndex = caretPositionInMarkup - index;
|
511
|
+
components.push(renderSubstring(substr.substring(0, splitIndex), substringComponentKey)),
|
512
|
+
components = [ renderSubstring(substr.substring(splitIndex), substringComponentKey) ];
|
513
|
+
} else components.push(renderSubstring(substr, substringComponentKey));
|
514
|
+
substringComponentKey++;
|
515
|
+
}), components.push(" "), components !== resultComponents && resultComponents.push(function(children) {
|
516
|
+
return React__default.createElement("span", _extends({}, style("caret"), {
|
517
|
+
ref: setCaretElement,
|
518
|
+
key: "caret"
|
519
|
+
}), children);
|
520
|
+
}(components)), React__default.createElement("div", _extends({}, style, {
|
521
|
+
ref: containerRef
|
522
|
+
}), resultComponents);
|
523
|
+
}
|
551
524
|
|
552
|
-
|
525
|
+
Highlighter.propTypes = {
|
553
526
|
selectionStart: PropTypes.number,
|
554
527
|
selectionEnd: PropTypes.number,
|
555
528
|
value: PropTypes.string.isRequired,
|
@@ -558,9 +531,7 @@ _defineProperty(Highlighter, "propTypes", {
|
|
558
531
|
current: "undefined" == typeof Element ? PropTypes.any : PropTypes.instanceOf(Element)
|
559
532
|
}) ]),
|
560
533
|
children: PropTypes.oneOfType([ PropTypes.element, PropTypes.arrayOf(PropTypes.element) ]).isRequired
|
561
|
-
}
|
562
|
-
value: ""
|
563
|
-
});
|
534
|
+
};
|
564
535
|
|
565
536
|
var styled = createDefaultStyle({
|
566
537
|
position: "relative",
|
@@ -638,116 +609,68 @@ function LoadingIndicator(_ref) {
|
|
638
609
|
|
639
610
|
var defaultstyle = {};
|
640
611
|
|
641
|
-
function
|
642
|
-
var
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
612
|
+
function SuggestionsOverlay(_ref) {
|
613
|
+
var id = _ref.id, _ref$suggestions = _ref.suggestions, suggestions = void 0 === _ref$suggestions ? {} : _ref$suggestions, a11ySuggestionsListLabel = _ref.a11ySuggestionsListLabel, focusIndex = _ref.focusIndex, position = _ref.position, left = _ref.left, right = _ref.right, top = _ref.top, scrollFocusedIntoView = _ref.scrollFocusedIntoView, isLoading = _ref.isLoading, isOpened = _ref.isOpened, _ref$onSelect = _ref.onSelect, onSelect = void 0 === _ref$onSelect ? function() {
|
614
|
+
return null;
|
615
|
+
} : _ref$onSelect, ignoreAccents = _ref.ignoreAccents, containerRef = _ref.containerRef, children = _ref.children, style = _ref.style, customSuggestionsContainer = _ref.customSuggestionsContainer, onMouseDown = _ref.onMouseDown, onMouseEnter = _ref.onMouseEnter, _useState = React.useState(void 0), _useState2 = _slicedToArray(_useState, 2), ulElement = _useState2[0], setUlElement = _useState2[1];
|
616
|
+
React.useEffect(function() {
|
617
|
+
if (ulElement && !(ulElement.offsetHeight >= ulElement.scrollHeight) && scrollFocusedIntoView) {
|
618
|
+
var scrollTop = ulElement.scrollTop, _ulElement$children$f = ulElement.children[focusIndex].getBoundingClientRect(), top = _ulElement$children$f.top, bottom = _ulElement$children$f.bottom, topContainer = ulElement.getBoundingClientRect().top;
|
619
|
+
bottom = bottom - topContainer + scrollTop, (top = top - topContainer + scrollTop) < scrollTop ? ulElement.scrollTop = top : bottom > ulElement.offsetHeight && (ulElement.scrollTop = bottom - ulElement.offsetHeight);
|
620
|
+
}
|
621
|
+
}, [ focusIndex, scrollFocusedIntoView, ulElement ]);
|
622
|
+
var suggestionsToRender, renderSuggestion = function(result, queryInfo, index) {
|
623
|
+
var isFocused = index === focusIndex, childIndex = queryInfo.childIndex, query = queryInfo.query, renderSuggestion = React.Children.toArray(children)[childIndex].props.renderSuggestion;
|
624
|
+
return React__default.createElement(Suggestion$1, {
|
625
|
+
style: style("item"),
|
626
|
+
key: "".concat(childIndex, "-").concat(getID(result)),
|
627
|
+
id: getSuggestionHtmlId(id, index),
|
628
|
+
query: query,
|
629
|
+
index: index,
|
630
|
+
ignoreAccents: ignoreAccents,
|
631
|
+
renderSuggestion: renderSuggestion,
|
632
|
+
suggestion: result,
|
633
|
+
focused: isFocused,
|
634
|
+
onClick: function() {
|
635
|
+
return select(result, queryInfo);
|
636
|
+
},
|
637
|
+
onMouseEnter: function() {
|
638
|
+
return handleMouseEnter(index);
|
639
|
+
}
|
640
|
+
});
|
641
|
+
}, handleMouseEnter = function(index, ev) {
|
642
|
+
onMouseEnter && onMouseEnter(index);
|
643
|
+
}, select = function(suggestion, queryInfo) {
|
644
|
+
onSelect(suggestion, queryInfo);
|
645
|
+
}, getID = function(suggestion) {
|
646
|
+
return "string" == typeof suggestion ? suggestion : suggestion.id;
|
650
647
|
};
|
648
|
+
return isOpened ? React__default.createElement("div", _extends({}, useStyles.inline({
|
649
|
+
position: position || "absolute",
|
650
|
+
left: left,
|
651
|
+
right: right,
|
652
|
+
top: top
|
653
|
+
}, style), {
|
654
|
+
onMouseDown: onMouseDown,
|
655
|
+
ref: containerRef
|
656
|
+
}), (suggestionsToRender = React__default.createElement("ul", _extends({
|
657
|
+
ref: setUlElement,
|
658
|
+
id: id,
|
659
|
+
role: "listbox",
|
660
|
+
"aria-label": a11ySuggestionsListLabel
|
661
|
+
}, style("list")), Object.values(suggestions).reduce(function(accResults, _ref2) {
|
662
|
+
var results = _ref2.results, queryInfo = _ref2.queryInfo;
|
663
|
+
return [].concat(_toConsumableArray(accResults), _toConsumableArray(results.map(function(result, index) {
|
664
|
+
return renderSuggestion(result, queryInfo, accResults.length + index);
|
665
|
+
})));
|
666
|
+
}, [])), customSuggestionsContainer ? customSuggestionsContainer(suggestionsToRender) : suggestionsToRender), function() {
|
667
|
+
if (isLoading) return React__default.createElement(LoadingIndicator, {
|
668
|
+
style: style("loadingIndicator")
|
669
|
+
});
|
670
|
+
}()) : null;
|
651
671
|
}
|
652
672
|
|
653
|
-
|
654
|
-
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
655
|
-
if (Reflect.construct.sham) return !1;
|
656
|
-
if ("function" == typeof Proxy) return !0;
|
657
|
-
try {
|
658
|
-
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
659
|
-
!0;
|
660
|
-
} catch (e) {
|
661
|
-
return !1;
|
662
|
-
}
|
663
|
-
}
|
664
|
-
|
665
|
-
var SuggestionsOverlay = function(_Component) {
|
666
|
-
_inherits(SuggestionsOverlay, _Component);
|
667
|
-
var _super = _createSuper$1(SuggestionsOverlay);
|
668
|
-
function SuggestionsOverlay() {
|
669
|
-
var _this;
|
670
|
-
_classCallCheck(this, SuggestionsOverlay);
|
671
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
|
672
|
-
return _this = _super.call.apply(_super, [ this ].concat(args)), _defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function(index, ev) {
|
673
|
-
_this.props.onMouseEnter && _this.props.onMouseEnter(index);
|
674
|
-
}), _defineProperty(_assertThisInitialized(_this), "select", function(suggestion, queryInfo) {
|
675
|
-
_this.props.onSelect(suggestion, queryInfo);
|
676
|
-
}), _defineProperty(_assertThisInitialized(_this), "setUlElement", function(el) {
|
677
|
-
_this.ulElement = el;
|
678
|
-
}), _this;
|
679
|
-
}
|
680
|
-
return _createClass(SuggestionsOverlay, [ {
|
681
|
-
key: "componentDidUpdate",
|
682
|
-
value: function() {
|
683
|
-
if (this.ulElement && !(this.ulElement.offsetHeight >= this.ulElement.scrollHeight) && this.props.scrollFocusedIntoView) {
|
684
|
-
var scrollTop = this.ulElement.scrollTop, _this$ulElement$child = this.ulElement.children[this.props.focusIndex].getBoundingClientRect(), top = _this$ulElement$child.top, bottom = _this$ulElement$child.bottom, topContainer = this.ulElement.getBoundingClientRect().top;
|
685
|
-
bottom = bottom - topContainer + scrollTop, (top = top - topContainer + scrollTop) < scrollTop ? this.ulElement.scrollTop = top : bottom > this.ulElement.offsetHeight && (this.ulElement.scrollTop = bottom - this.ulElement.offsetHeight);
|
686
|
-
}
|
687
|
-
}
|
688
|
-
}, {
|
689
|
-
key: "render",
|
690
|
-
value: function() {
|
691
|
-
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;
|
692
|
-
return isOpened ? React__default.createElement("div", _extends({}, useStyles.inline({
|
693
|
-
position: position || "absolute",
|
694
|
-
left: left,
|
695
|
-
right: right,
|
696
|
-
top: top
|
697
|
-
}, style), {
|
698
|
-
onMouseDown: onMouseDown,
|
699
|
-
ref: containerRef
|
700
|
-
}), React__default.createElement("ul", _extends({
|
701
|
-
ref: this.setUlElement,
|
702
|
-
id: id,
|
703
|
-
role: "listbox",
|
704
|
-
"aria-label": a11ySuggestionsListLabel
|
705
|
-
}, style("list")), this.renderSuggestions()), this.renderLoadingIndicator()) : null;
|
706
|
-
}
|
707
|
-
}, {
|
708
|
-
key: "renderSuggestions",
|
709
|
-
value: function() {
|
710
|
-
var _this2 = this, customSuggestionsContainer = this.props.customSuggestionsContainer, suggestions = Object.values(this.props.suggestions).reduce(function(accResults, _ref) {
|
711
|
-
var results = _ref.results, queryInfo = _ref.queryInfo;
|
712
|
-
return [].concat(_toConsumableArray(accResults), _toConsumableArray(results.map(function(result, index) {
|
713
|
-
return _this2.renderSuggestion(result, queryInfo, accResults.length + index);
|
714
|
-
})));
|
715
|
-
}, []);
|
716
|
-
return customSuggestionsContainer ? customSuggestionsContainer(suggestions) : suggestions;
|
717
|
-
}
|
718
|
-
}, {
|
719
|
-
key: "renderSuggestion",
|
720
|
-
value: function(result, queryInfo, index) {
|
721
|
-
var _this3 = this, isFocused = index === this.props.focusIndex, childIndex = queryInfo.childIndex, query = queryInfo.query, renderSuggestion = React.Children.toArray(this.props.children)[childIndex].props.renderSuggestion, ignoreAccents = this.props.ignoreAccents;
|
722
|
-
return React__default.createElement(Suggestion$1, {
|
723
|
-
style: this.props.style("item"),
|
724
|
-
key: "".concat(childIndex, "-").concat(getID(result)),
|
725
|
-
id: getSuggestionHtmlId(this.props.id, index),
|
726
|
-
query: query,
|
727
|
-
index: index,
|
728
|
-
ignoreAccents: ignoreAccents,
|
729
|
-
renderSuggestion: renderSuggestion,
|
730
|
-
suggestion: result,
|
731
|
-
focused: isFocused,
|
732
|
-
onClick: function() {
|
733
|
-
return _this3.select(result, queryInfo);
|
734
|
-
},
|
735
|
-
onMouseEnter: function() {
|
736
|
-
return _this3.handleMouseEnter(index);
|
737
|
-
}
|
738
|
-
});
|
739
|
-
}
|
740
|
-
}, {
|
741
|
-
key: "renderLoadingIndicator",
|
742
|
-
value: function() {
|
743
|
-
if (this.props.isLoading) return React__default.createElement(LoadingIndicator, {
|
744
|
-
style: this.props.style("loadingIndicator")
|
745
|
-
});
|
746
|
-
}
|
747
|
-
} ]), SuggestionsOverlay;
|
748
|
-
}(React.Component);
|
749
|
-
|
750
|
-
_defineProperty(SuggestionsOverlay, "propTypes", {
|
673
|
+
SuggestionsOverlay.propTypes = {
|
751
674
|
id: PropTypes.string.isRequired,
|
752
675
|
suggestions: PropTypes.object.isRequired,
|
753
676
|
a11ySuggestionsListLabel: PropTypes.string,
|
@@ -761,20 +684,13 @@ _defineProperty(SuggestionsOverlay, "propTypes", {
|
|
761
684
|
isOpened: PropTypes.bool.isRequired,
|
762
685
|
onSelect: PropTypes.func,
|
763
686
|
ignoreAccents: PropTypes.bool,
|
687
|
+
customSuggestionsContainer: PropTypes.func,
|
764
688
|
containerRef: PropTypes.oneOfType([ PropTypes.func, PropTypes.shape({
|
765
689
|
current: "undefined" == typeof Element ? PropTypes.any : PropTypes.instanceOf(Element)
|
766
|
-
}) ])
|
767
|
-
|
768
|
-
}), _defineProperty(SuggestionsOverlay, "defaultProps", {
|
769
|
-
suggestions: {},
|
770
|
-
onSelect: function() {
|
771
|
-
return null;
|
772
|
-
}
|
773
|
-
});
|
690
|
+
}) ])
|
691
|
+
};
|
774
692
|
|
775
|
-
var
|
776
|
-
return "string" == typeof suggestion ? suggestion : suggestion.id;
|
777
|
-
}, styled$2 = createDefaultStyle({
|
693
|
+
var styled$2 = createDefaultStyle({
|
778
694
|
zIndex: 1,
|
779
695
|
backgroundColor: "white",
|
780
696
|
marginTop: 14,
|
@@ -786,7 +702,7 @@ var getID = function(suggestion) {
|
|
786
702
|
}
|
787
703
|
}), SuggestionsOverlay$1 = styled$2(SuggestionsOverlay);
|
788
704
|
|
789
|
-
function ownKeys(object, enumerableOnly) {
|
705
|
+
function ownKeys$1(object, enumerableOnly) {
|
790
706
|
var keys = Object.keys(object);
|
791
707
|
if (Object.getOwnPropertySymbols) {
|
792
708
|
var symbols = Object.getOwnPropertySymbols(object);
|
@@ -797,20 +713,20 @@ function ownKeys(object, enumerableOnly) {
|
|
797
713
|
return keys;
|
798
714
|
}
|
799
715
|
|
800
|
-
function _objectSpread(target) {
|
716
|
+
function _objectSpread$1(target) {
|
801
717
|
for (var i = 1; i < arguments.length; i++) {
|
802
718
|
var source = null != arguments[i] ? arguments[i] : {};
|
803
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
|
719
|
+
i % 2 ? ownKeys$1(Object(source), !0).forEach(function(key) {
|
804
720
|
_defineProperty(target, key, source[key]);
|
805
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
721
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function(key) {
|
806
722
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
807
723
|
});
|
808
724
|
}
|
809
725
|
return target;
|
810
726
|
}
|
811
727
|
|
812
|
-
function _createSuper
|
813
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct
|
728
|
+
function _createSuper(Derived) {
|
729
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
814
730
|
return function() {
|
815
731
|
var result, Super = _getPrototypeOf(Derived);
|
816
732
|
if (hasNativeReflectConstruct) {
|
@@ -821,7 +737,7 @@ function _createSuper$2(Derived) {
|
|
821
737
|
};
|
822
738
|
}
|
823
739
|
|
824
|
-
function _isNativeReflectConstruct
|
740
|
+
function _isNativeReflectConstruct() {
|
825
741
|
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
826
742
|
if (Reflect.construct.sham) return !1;
|
827
743
|
if ("function" == typeof Proxy) return !0;
|
@@ -872,7 +788,7 @@ var makeTriggerRegex = function(trigger) {
|
|
872
788
|
children: PropTypes.oneOfType([ PropTypes.element, PropTypes.arrayOf(PropTypes.element) ]).isRequired
|
873
789
|
}, MentionsInput = function(_React$Component) {
|
874
790
|
_inherits(MentionsInput, _React$Component);
|
875
|
-
var _super = _createSuper
|
791
|
+
var _super = _createSuper(MentionsInput);
|
876
792
|
function MentionsInput(_props) {
|
877
793
|
var _this;
|
878
794
|
return _classCallCheck(this, MentionsInput), _this = _super.call(this, _props),
|
@@ -880,7 +796,7 @@ var makeTriggerRegex = function(trigger) {
|
|
880
796
|
_this.containerElement = el;
|
881
797
|
}), _defineProperty(_assertThisInitialized(_this), "getInputProps", function() {
|
882
798
|
var _this$props = _this.props, readOnly = _this$props.readOnly, disabled = _this$props.disabled, style = _this$props.style;
|
883
|
-
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, omit(_this.props, [ "style", "classNames", "className" ], keys(propTypes))), style("input")), {}, {
|
799
|
+
return _objectSpread$1(_objectSpread$1(_objectSpread$1(_objectSpread$1({}, omit(_this.props, [ "style", "classNames", "className" ], keys(propTypes))), style("input")), {}, {
|
884
800
|
value: _this.getPlainText(),
|
885
801
|
onScroll: _this.updateHighlighterScroll
|
886
802
|
}, !readOnly && !disabled && {
|
@@ -908,6 +824,7 @@ var makeTriggerRegex = function(trigger) {
|
|
908
824
|
}, props));
|
909
825
|
}), _defineProperty(_assertThisInitialized(_this), "renderTextarea", function(props) {
|
910
826
|
return React__default.createElement("textarea", _extends({
|
827
|
+
autoFocus: !0,
|
911
828
|
ref: _this.setInputRef
|
912
829
|
}, props));
|
913
830
|
}), _defineProperty(_assertThisInitialized(_this), "setInputRef", function(el) {
|
@@ -1116,7 +1033,7 @@ var makeTriggerRegex = function(trigger) {
|
|
1116
1033
|
syncResult instanceof Array && _this.updateSuggestions(_this._queryId, childIndex, query, querySequenceStart, querySequenceEnd, plainTextValue, syncResult);
|
1117
1034
|
}), _defineProperty(_assertThisInitialized(_this), "updateSuggestions", function(queryId, childIndex, query, querySequenceStart, querySequenceEnd, plainTextValue, results) {
|
1118
1035
|
if (queryId === _this._queryId) {
|
1119
|
-
_this.suggestions = _objectSpread(_objectSpread({}, _this.suggestions), {}, _defineProperty({}, childIndex, {
|
1036
|
+
_this.suggestions = _objectSpread$1(_objectSpread$1({}, _this.suggestions), {}, _defineProperty({}, childIndex, {
|
1120
1037
|
queryInfo: {
|
1121
1038
|
childIndex: childIndex,
|
1122
1039
|
query: query,
|
@@ -1168,7 +1085,8 @@ var makeTriggerRegex = function(trigger) {
|
|
1168
1085
|
selectionEnd: null,
|
1169
1086
|
suggestions: {},
|
1170
1087
|
caretPosition: null,
|
1171
|
-
suggestionsPosition: {}
|
1088
|
+
suggestionsPosition: {},
|
1089
|
+
setSelectionAfterHandlePaste: !1
|
1172
1090
|
}, _this;
|
1173
1091
|
}
|
1174
1092
|
return _createClass(MentionsInput, [ {
|
@@ -1183,6 +1101,8 @@ var makeTriggerRegex = function(trigger) {
|
|
1183
1101
|
prevState.suggestionsPosition === this.state.suggestionsPosition && this.updateSuggestionsPosition(),
|
1184
1102
|
this.state.setSelectionAfterMentionChange && (this.setState({
|
1185
1103
|
setSelectionAfterMentionChange: !1
|
1104
|
+
}), this.setSelection(this.state.selectionStart, this.state.selectionEnd)), this.state.setSelectionAfterHandlePaste && (this.setState({
|
1105
|
+
setSelectionAfterHandlePaste: !1
|
1186
1106
|
}), this.setSelection(this.state.selectionStart, this.state.selectionEnd));
|
1187
1107
|
}
|
1188
1108
|
}, {
|
@@ -1202,15 +1122,18 @@ var makeTriggerRegex = function(trigger) {
|
|
1202
1122
|
key: "handlePaste",
|
1203
1123
|
value: function(event) {
|
1204
1124
|
if (event.target === this.inputElement && this.supportsClipboardActions(event)) {
|
1205
|
-
event.preventDefault();
|
1206
1125
|
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 = {
|
1207
|
-
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
1126
|
+
target: _objectSpread$1(_objectSpread$1({}, event.target), {}, {
|
1208
1127
|
value: newValue
|
1209
1128
|
})
|
1210
1129
|
};
|
1211
1130
|
this.executeOnChange(eventMock, newValue, newPlainTextValue, getMentions(newValue, config));
|
1212
1131
|
var nextPos = (findStartOfMentionInPlainText(value, config, selectionStart) || selectionStart) + getPlainText(pastedMentions || pastedData, config).length;
|
1213
|
-
this.
|
1132
|
+
this.setState({
|
1133
|
+
selectionStart: nextPos,
|
1134
|
+
selectionEnd: nextPos,
|
1135
|
+
setSelectionAfterHandlePaste: !0
|
1136
|
+
});
|
1214
1137
|
}
|
1215
1138
|
}
|
1216
1139
|
}, {
|
@@ -1237,7 +1160,7 @@ var makeTriggerRegex = function(trigger) {
|
|
1237
1160
|
if (event.target === this.inputElement && this.supportsClipboardActions(event)) {
|
1238
1161
|
event.preventDefault(), this.saveSelectionToClipboard(event);
|
1239
1162
|
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 = {
|
1240
|
-
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
1163
|
+
target: _objectSpread$1(_objectSpread$1({}, event.target), {}, {
|
1241
1164
|
value: newPlainTextValue
|
1242
1165
|
})
|
1243
1166
|
};
|
@@ -1282,7 +1205,7 @@ var getComputedStyleLengthProp = function(forElement, propertyName) {
|
|
1282
1205
|
letterSpacing: "inherit"
|
1283
1206
|
},
|
1284
1207
|
"&multiLine": {
|
1285
|
-
input: _objectSpread({
|
1208
|
+
input: _objectSpread$1({
|
1286
1209
|
height: "100%",
|
1287
1210
|
bottom: 0,
|
1288
1211
|
overflow: "hidden",
|