react-input-emoji 5.8.0 → 5.9.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.es.js +39 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +39 -14
- package/dist/index.js.map +1 -1
- package/dist/src/utils/input-event-utils.d.ts +9 -2
- package/package.json +4 -4
package/dist/index.es.js
CHANGED
@@ -619,9 +619,22 @@ function handleCopy(event) {
|
|
619
619
|
event.preventDefault();
|
620
620
|
}
|
621
621
|
|
622
|
+
/** @type {Range|undefined} */
|
623
|
+
/** @type {Range|undefined} */
|
624
|
+
var currentRangeCached;
|
625
|
+
|
622
626
|
/**
|
623
|
-
*
|
624
|
-
|
627
|
+
* Caches the current text selection range
|
628
|
+
*/
|
629
|
+
function cacheCurrentRange() {
|
630
|
+
var selection = window.getSelection();
|
631
|
+
if (!selection.rangeCount || (selection === null || selection === void 0 ? void 0 : selection.anchorNode['className']) !== 'react-input-emoji--input' && selection.anchorNode.parentNode['className'] !== 'react-input-emoji--input') return;
|
632
|
+
var range = selection.getRangeAt(0);
|
633
|
+
currentRangeCached = range.cloneRange();
|
634
|
+
}
|
635
|
+
|
636
|
+
/**
|
637
|
+
* @param {string} html - HTML string to be pasted at the caret position
|
625
638
|
*/
|
626
639
|
function handlePasteHtmlAtCaret(html) {
|
627
640
|
var sel;
|
@@ -631,7 +644,8 @@ function handlePasteHtmlAtCaret(html) {
|
|
631
644
|
sel = window.getSelection();
|
632
645
|
if (sel === null) return;
|
633
646
|
if (sel.getRangeAt && sel.rangeCount) {
|
634
|
-
|
647
|
+
var _currentRangeCached;
|
648
|
+
range = (_currentRangeCached = currentRangeCached) !== null && _currentRangeCached !== void 0 ? _currentRangeCached : sel.getRangeAt(0);
|
635
649
|
range.deleteContents();
|
636
650
|
|
637
651
|
// Range.createContextualFragment() would be useful here but is
|
@@ -649,6 +663,7 @@ function handlePasteHtmlAtCaret(html) {
|
|
649
663
|
// Preserve the selection
|
650
664
|
if (lastNode) {
|
651
665
|
range = range.cloneRange();
|
666
|
+
currentRangeCached = range;
|
652
667
|
range.setStartAfter(lastNode);
|
653
668
|
range.collapse(true);
|
654
669
|
sel.removeAllRanges();
|
@@ -1731,6 +1746,9 @@ var $f72b75cf796873c7$export$2e2bcd8739ae039 = {
|
|
1731
1746
|
};
|
1732
1747
|
const $c84d045dcc34faf5$var$CACHE = new Map();
|
1733
1748
|
const $c84d045dcc34faf5$var$VERSIONS = [{
|
1749
|
+
v: 15,
|
1750
|
+
emoji: "\uD83E\uDEE8"
|
1751
|
+
}, {
|
1734
1752
|
v: 14,
|
1735
1753
|
emoji: "\uD83E\uDEE0"
|
1736
1754
|
}, {
|
@@ -1910,8 +1928,8 @@ var $b247ea80b67298d5$export$2e2bcd8739ae039 = {
|
|
1910
1928
|
value: 24
|
1911
1929
|
},
|
1912
1930
|
emojiVersion: {
|
1913
|
-
value:
|
1914
|
-
choices: [1, 2, 3, 4, 5, 11, 12, 12.1, 13, 13.1, 14]
|
1931
|
+
value: 15,
|
1932
|
+
choices: [1, 2, 3, 4, 5, 11, 12, 12.1, 13, 13.1, 14, 15]
|
1915
1933
|
},
|
1916
1934
|
exceptEmojis: {
|
1917
1935
|
value: []
|
@@ -1922,7 +1940,7 @@ var $b247ea80b67298d5$export$2e2bcd8739ae039 = {
|
|
1922
1940
|
},
|
1923
1941
|
locale: {
|
1924
1942
|
value: "en",
|
1925
|
-
choices: ["en", "ar", "be", "cs", "de", "es", "fa", "fi", "fr", "hi", "it", "ja", "
|
1943
|
+
choices: ["en", "ar", "be", "cs", "de", "es", "fa", "fi", "fr", "hi", "it", "ja", "ko", "nl", "pl", "pt", "ru", "sa", "tr", "uk", "vi", "zh"]
|
1926
1944
|
},
|
1927
1945
|
maxFrequentRows: {
|
1928
1946
|
value: 4
|
@@ -2441,8 +2459,8 @@ function $254755d3f438722f$export$2e2bcd8739ae039(props) {
|
|
2441
2459
|
emoji || (emoji = ($c4d155af13ad4d4b$export$2e2bcd8739ae039).get(id || props.native));
|
2442
2460
|
if (!emoji) return props.fallback;
|
2443
2461
|
const emojiSkin = emoji.skins[skin - 1] || emoji.skins[0];
|
2444
|
-
const imageSrc = emojiSkin.src || (props.set != "native" && !props.spritesheet ? typeof props.getImageURL === "function" ? props.getImageURL(props.set, emojiSkin.unified) : `https://cdn.jsdelivr.net/npm/emoji-datasource-${props.set}@
|
2445
|
-
const spritesheetSrc = typeof props.getSpritesheetURL === "function" ? props.getSpritesheetURL(props.set) : `https://cdn.jsdelivr.net/npm/emoji-datasource-${props.set}@
|
2462
|
+
const imageSrc = emojiSkin.src || (props.set != "native" && !props.spritesheet ? typeof props.getImageURL === "function" ? props.getImageURL(props.set, emojiSkin.unified) : `https://cdn.jsdelivr.net/npm/emoji-datasource-${props.set}@15.0.1/img/${props.set}/64/${emojiSkin.unified}.png` : undefined);
|
2463
|
+
const spritesheetSrc = typeof props.getSpritesheetURL === "function" ? props.getSpritesheetURL(props.set) : `https://cdn.jsdelivr.net/npm/emoji-datasource-${props.set}@15.0.1/img/${props.set}/sheets-256/64.png`;
|
2446
2464
|
return /*#__PURE__*/($bd9dd35321b03dd4$export$34b9dba7ce09269b)("span", {
|
2447
2465
|
class: "emoji-mart-emoji",
|
2448
2466
|
"data-emoji-set": props.set,
|
@@ -2965,6 +2983,7 @@ class $89bd6bb200cc8fef$export$2e2bcd8739ae039 extends ($fb96b826c0c5f37a$export
|
|
2965
2983
|
}
|
2966
2984
|
unregister() {
|
2967
2985
|
document.removeEventListener("click", this.handleClickOutside);
|
2986
|
+
this.darkMedia?.removeEventListener("change", this.darkMediaCallback);
|
2968
2987
|
this.unobserve();
|
2969
2988
|
}
|
2970
2989
|
observe() {
|
@@ -3022,12 +3041,7 @@ class $89bd6bb200cc8fef$export$2e2bcd8739ae039 extends ($fb96b826c0c5f37a$export
|
|
3022
3041
|
if (!this.darkMedia) {
|
3023
3042
|
this.darkMedia = matchMedia("(prefers-color-scheme: dark)");
|
3024
3043
|
if (this.darkMedia.media.match(/^not/)) return "light";
|
3025
|
-
this.darkMedia.
|
3026
|
-
if (this.props.theme != "auto") return;
|
3027
|
-
this.setState({
|
3028
|
-
theme: this.darkMedia.matches ? "dark" : "light"
|
3029
|
-
});
|
3030
|
-
});
|
3044
|
+
this.darkMedia.addEventListener("change", this.darkMediaCallback);
|
3031
3045
|
}
|
3032
3046
|
return this.darkMedia.matches ? "dark" : "light";
|
3033
3047
|
}
|
@@ -3632,6 +3646,12 @@ class $89bd6bb200cc8fef$export$2e2bcd8739ae039 extends ($fb96b826c0c5f37a$export
|
|
3632
3646
|
}
|
3633
3647
|
constructor(props) {
|
3634
3648
|
super();
|
3649
|
+
($c770c458706daa72$export$2e2bcd8739ae039)(this, "darkMediaCallback", () => {
|
3650
|
+
if (this.props.theme != "auto") return;
|
3651
|
+
this.setState({
|
3652
|
+
theme: this.darkMedia.matches ? "dark" : "light"
|
3653
|
+
});
|
3654
|
+
});
|
3635
3655
|
($c770c458706daa72$export$2e2bcd8739ae039)(this, "handleClickOutside", e => {
|
3636
3656
|
const {
|
3637
3657
|
element: element
|
@@ -4050,6 +4070,11 @@ var EmojiPickerWrapper = function EmojiPickerWrapper(props) {
|
|
4050
4070
|
_useState6 = _slicedToArray(_useState5, 2),
|
4051
4071
|
emojiPickerPosition = _useState6[0],
|
4052
4072
|
setEmojiPickerPosition = _useState6[1];
|
4073
|
+
useEffect(function () {
|
4074
|
+
if (showPicker) {
|
4075
|
+
cacheCurrentRange();
|
4076
|
+
}
|
4077
|
+
}, [showPicker]);
|
4053
4078
|
useEffect(function () {
|
4054
4079
|
addSanitizeFn(replaceAllTextEmojiToString);
|
4055
4080
|
}, [addSanitizeFn]);
|