react-input-emoji 5.7.1 → 5.8.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -0
- package/dist/index.es.js +247 -8
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +247 -8
- package/dist/index.js.map +1 -1
- package/dist/src/hooks/use-expose.d.ts +3 -1
- package/dist/src/hooks/use-sanitize.d.ts +2 -1
- package/dist/src/index.d.ts +2 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
3
|
var React = require('react');
|
4
|
+
var server = require('react-dom/server');
|
4
5
|
var ReactDOM = require('react-dom');
|
5
6
|
|
6
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
@@ -787,7 +788,213 @@ function addLineBreak() {
|
|
787
788
|
}
|
788
789
|
}
|
789
790
|
|
791
|
+
// Inspiration: https://github.com/facebook/react/issues/3386
|
792
|
+
|
793
|
+
function replace(string, regexpOrSubstr, newValueOrFn, globalOffset) {
|
794
|
+
if (typeof string !== 'string') throw new Error('First param must be a string');
|
795
|
+
if (typeof regexpOrSubstr !== 'string' && !(regexpOrSubstr instanceof RegExp)) throw new Error('Second param must be a string pattern or a regular expression');
|
796
|
+
var fn = typeof regexpOrSubstr === 'string' ? replaceUsingString : replaceUsingRegexp;
|
797
|
+
return fn(string, regexpOrSubstr, newValueOrFn, globalOffset);
|
798
|
+
}
|
799
|
+
function replaceUsingString(string, patternString, newValueOrFn, globalOffset) {
|
800
|
+
var index = string.indexOf(patternString);
|
801
|
+
if (index >= 0) {
|
802
|
+
var arr = [];
|
803
|
+
var endIndex = index + patternString.length;
|
804
|
+
if (index > 0) {
|
805
|
+
arr.push(string.substring(0, index));
|
806
|
+
}
|
807
|
+
arr.push(typeof newValueOrFn === 'function' ? newValueOrFn(string.substring(index, endIndex), index + globalOffset, string) : newValueOrFn);
|
808
|
+
if (endIndex < string.length) {
|
809
|
+
arr.push(string.substring(endIndex));
|
810
|
+
}
|
811
|
+
return arr;
|
812
|
+
} else {
|
813
|
+
return [string];
|
814
|
+
}
|
815
|
+
}
|
816
|
+
function replaceUsingRegexp(string, regexp, newValueOrFn, globalOffset) {
|
817
|
+
var output = [];
|
818
|
+
var replacerIsFn = typeof newValueOrFn === 'function';
|
819
|
+
var storedLastIndex = regexp.lastIndex;
|
820
|
+
regexp.lastIndex = 0;
|
821
|
+
var result;
|
822
|
+
var lastIndex = 0;
|
823
|
+
while (result = regexp.exec(string)) {
|
824
|
+
var index = result.index;
|
825
|
+
if (result[0] === '') {
|
826
|
+
// When the regexp is an empty string
|
827
|
+
// we still want to advance our cursor to the next item.
|
828
|
+
// This is the behavior of String.replace.
|
829
|
+
regexp.lastIndex++;
|
830
|
+
}
|
831
|
+
if (index !== lastIndex) {
|
832
|
+
output.push(string.substring(lastIndex, index));
|
833
|
+
}
|
834
|
+
var match = result[0];
|
835
|
+
lastIndex = index + match.length;
|
836
|
+
var out = replacerIsFn ? newValueOrFn.apply(this, result.concat(index + globalOffset, result.input)) : newValueOrFn;
|
837
|
+
output.push(out);
|
838
|
+
if (!regexp.global) {
|
839
|
+
break;
|
840
|
+
}
|
841
|
+
}
|
842
|
+
if (lastIndex < string.length) {
|
843
|
+
output.push(string.substring(lastIndex));
|
844
|
+
}
|
845
|
+
regexp.lastIndex = storedLastIndex;
|
846
|
+
return output;
|
847
|
+
}
|
848
|
+
var stringReplaceToArray = function stringReplaceToArray(stringOrArray, regexpOrSubstr, newSubStrOrFn) {
|
849
|
+
if (typeof stringOrArray === 'string') {
|
850
|
+
return replace(stringOrArray, regexpOrSubstr, newSubStrOrFn, 0);
|
851
|
+
} else if (!Array.isArray(stringOrArray) || !stringOrArray[0]) {
|
852
|
+
throw new TypeError('First argument must be an array or non-empty string');
|
853
|
+
} else {
|
854
|
+
var len = stringOrArray.length;
|
855
|
+
var output = [];
|
856
|
+
var globalOffset = 0;
|
857
|
+
for (var i = 0; i < len; ++i) {
|
858
|
+
var arrayItem = stringOrArray[i];
|
859
|
+
if (typeof arrayItem === 'string') {
|
860
|
+
output.push.apply(output, replace(arrayItem, regexpOrSubstr, newSubStrOrFn, globalOffset));
|
861
|
+
globalOffset += arrayItem.length;
|
862
|
+
} else {
|
863
|
+
output.push(arrayItem);
|
864
|
+
}
|
865
|
+
}
|
866
|
+
return output;
|
867
|
+
}
|
868
|
+
};
|
869
|
+
|
870
|
+
// This is based off of https://github.com/twitter/twemoji/blob/gh-pages/2/twemoji.js
|
871
|
+
//
|
872
|
+
// Ideally we'd use twemoji instead of replicating its logic.
|
873
|
+
// The reason we can't is that we need to run our own replace.
|
874
|
+
//
|
875
|
+
// We could use it for most things (by essentially running twemoji.parse for each
|
876
|
+
// regex match, and reading the code from the callback), but the one thing we'd always need
|
877
|
+
// to copy and paste into this file is the regex since we need it to run the replace.
|
878
|
+
//
|
879
|
+
// Another option is to fork twemoji and expose a method in it that could help us, then
|
880
|
+
// ask them to pull it in.
|
881
|
+
//
|
882
|
+
|
883
|
+
// RegExp based on emoji's official Unicode standards
|
884
|
+
// http://www.unicode.org/Public/UNIDATA/EmojiSources.txt
|
885
|
+
var re = /(?:\ud83d\udc68\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffc-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb\udffd-\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb\udffc\udffe\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb-\udffd\udfff]|\ud83e\uddd1\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb-\udffe]|\ud83d\udc68\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc68\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc68\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffe]|\ud83e\uddd1\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffc-\udfff]|\ud83e\uddd1\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb\udffd-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb\udffc\udffe\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb-\udffd\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb-\udffe]|\ud83e\uddd1\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83e\udef1\ud83c\udffb\u200d\ud83e\udef2\ud83c[\udffc-\udfff]|\ud83e\udef1\ud83c\udffc\u200d\ud83e\udef2\ud83c[\udffb\udffd-\udfff]|\ud83e\udef1\ud83c\udffd\u200d\ud83e\udef2\ud83c[\udffb\udffc\udffe\udfff]|\ud83e\udef1\ud83c\udffe\u200d\ud83e\udef2\ud83c[\udffb-\udffd\udfff]|\ud83e\udef1\ud83c\udfff\u200d\ud83e\udef2\ud83c[\udffb-\udffe]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83e\uddd1\u200d\ud83e\udd1d\u200d\ud83e\uddd1|\ud83d\udc6b\ud83c[\udffb-\udfff]|\ud83d\udc6c\ud83c[\udffb-\udfff]|\ud83d\udc6d\ud83c[\udffb-\udfff]|\ud83d\udc8f\ud83c[\udffb-\udfff]|\ud83d\udc91\ud83c[\udffb-\udfff]|\ud83e\udd1d\ud83c[\udffb-\udfff]|\ud83d[\udc6b-\udc6d\udc8f\udc91]|\ud83e\udd1d)|(?:\ud83d[\udc68\udc69]|\ud83e\uddd1)(?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf7c\udf84\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92]|\ud83e[\uddaf-\uddb3\uddbc\uddbd])|(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75]|\u26f9)((?:\ud83c[\udffb-\udfff]|\ufe0f)\u200d[\u2640\u2642]\ufe0f)|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc70\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd35\udd37-\udd39\udd3d\udd3e\uddb8\uddb9\uddcd-\uddcf\uddd4\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|(?:\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83d\ude36\u200d\ud83c\udf2b\ufe0f|\u2764\ufe0f\u200d\ud83d\udd25|\u2764\ufe0f\u200d\ud83e\ude79|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc15\u200d\ud83e\uddba|\ud83d\udc3b\u200d\u2744\ufe0f|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83d\ude2e\u200d\ud83d\udca8|\ud83d\ude35\u200d\ud83d\udcab|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f|\ud83d\udc08\u200d\u2b1b)|[#*0-9]\ufe0f?\u20e3|(?:[©®\u2122\u265f]\ufe0f)|(?:\ud83c[\udc04\udd70\udd71\udd7e\udd7f\ude02\ude1a\ude2f\ude37\udf21\udf24-\udf2c\udf36\udf7d\udf96\udf97\udf99-\udf9b\udf9e\udf9f\udfcd\udfce\udfd4-\udfdf\udff3\udff5\udff7]|\ud83d[\udc3f\udc41\udcfd\udd49\udd4a\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa\udecb\udecd-\udecf\udee0-\udee5\udee9\udef0\udef3]|[\u203c\u2049\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23ed-\u23ef\u23f1\u23f2\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638-\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b\u269c\u26a0\u26a1\u26a7\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u2764\u27a1\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299])(?:\ufe0f|(?!\ufe0e))|(?:(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75\udd90]|[\u261d\u26f7\u26f9\u270c\u270d])(?:\ufe0f|(?!\ufe0e))|(?:\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd7a\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd0c\udd0f\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\udd77\uddb5\uddb6\uddb8\uddb9\uddbb\uddcd-\uddcf\uddd1-\udddd\udec3-\udec5\udef0-\udef6]|[\u270a\u270b]))(?:\ud83c[\udffb-\udfff])?|(?:\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\ud83c[\udccf\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude32-\ude36\ude38-\ude3a\ude50\ude51\udf00-\udf20\udf2d-\udf35\udf37-\udf7c\udf7e-\udf84\udf86-\udf93\udfa0-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcf-\udfd3\udfe0-\udff0\udff4\udff8-\udfff]|\ud83d[\udc00-\udc3e\udc40\udc44\udc45\udc51-\udc65\udc6a\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udc8e\udc90\udc92-\udca9\udcab-\udcfc\udcff-\udd3d\udd4b-\udd4e\udd50-\udd67\udda4\uddfb-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\uded0-\uded2\uded5-\uded7\udedd-\udedf\udeeb\udeec\udef4-\udefc\udfe0-\udfeb\udff0]|\ud83e[\udd0d\udd0e\udd10-\udd17\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd3f-\udd45\udd47-\udd76\udd78-\uddb4\uddb7\uddba\uddbc-\uddcc\uddd0\uddde-\uddff\ude70-\ude74\ude78-\ude7c\ude80-\ude86\ude90-\udeac\udeb0-\udeba\udec0-\udec2\uded0-\uded9\udee0-\udee7]|[\u23e9-\u23ec\u23f0\u23f3\u267e\u26ce\u2705\u2728\u274c\u274e\u2753-\u2755\u2795-\u2797\u27b0\u27bf\ue50a])|\ufe0f/g;
|
886
|
+
function toCodePoint(unicodeSurrogates, sep) {
|
887
|
+
var r = [],
|
888
|
+
c = 0,
|
889
|
+
p = 0,
|
890
|
+
i = 0;
|
891
|
+
while (i < unicodeSurrogates.length) {
|
892
|
+
c = unicodeSurrogates.charCodeAt(i++);
|
893
|
+
if (p) {
|
894
|
+
r.push((0x10000 + (p - 0xD800 << 10) + (c - 0xDC00)).toString(16));
|
895
|
+
p = 0;
|
896
|
+
} else if (0xD800 <= c && c <= 0xDBFF) {
|
897
|
+
p = c;
|
898
|
+
} else {
|
899
|
+
r.push(c.toString(16));
|
900
|
+
}
|
901
|
+
}
|
902
|
+
return r.join(sep || '-');
|
903
|
+
}
|
904
|
+
|
905
|
+
// avoid runtime RegExp creation for not so smart,
|
906
|
+
// not JIT based, and old browsers / engines
|
907
|
+
var UFE0Fg = /\uFE0F/g;
|
908
|
+
|
909
|
+
// avoid using a string literal like '\u200D' here because minifiers expand it inline
|
910
|
+
var U200D = String.fromCharCode(0x200D);
|
911
|
+
|
912
|
+
/**
|
913
|
+
* Used to both remove the possible variant
|
914
|
+
* and to convert utf16 into code points.
|
915
|
+
* If there is a zero-width-joiner (U+200D), leave the variants in.
|
916
|
+
* @param string the raw text of the emoji match
|
917
|
+
*/
|
918
|
+
function grabTheRightIcon(rawText) {
|
919
|
+
// if variant is present as \uFE0F
|
920
|
+
return toCodePoint(rawText.indexOf(U200D) < 0 ? rawText.replace(UFE0Fg, '') : rawText);
|
921
|
+
}
|
922
|
+
var replaceEmoji$1 = function replaceEmoji(string, render) {
|
923
|
+
// Note: the latest regex added an empty matching group, so we ignore it.
|
924
|
+
return stringReplaceToArray(string, re, function emojiReplacer(match, _, offset) {
|
925
|
+
var icon = grabTheRightIcon(match);
|
926
|
+
return render(icon, match, offset);
|
927
|
+
});
|
928
|
+
};
|
929
|
+
|
930
|
+
var createElement = React__default["default"].createElement;
|
931
|
+
var pageProtocol = typeof location === 'undefined' ? '' : location.protocol === 'https:' ? 'https:' : 'http:';
|
932
|
+
var emojiStyle = {
|
933
|
+
height: '1em',
|
934
|
+
width: '1em',
|
935
|
+
margin: '0 .05em 0 .1em',
|
936
|
+
verticalAlign: '-0.1em'
|
937
|
+
};
|
938
|
+
|
939
|
+
// Accept protocol with or without a colon
|
940
|
+
function normalizeProtocol(protocol) {
|
941
|
+
if (protocol && protocol.length > 0 && protocol.charAt(protocol.length - 1) !== ':') {
|
942
|
+
return protocol + ':';
|
943
|
+
}
|
944
|
+
return protocol;
|
945
|
+
}
|
946
|
+
var makeTwemojiRenderer$1 = function makeTwemojiRenderer(options) {
|
947
|
+
options = merge({
|
948
|
+
protocol: pageProtocol,
|
949
|
+
baseUrl: '//cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/',
|
950
|
+
size: '72x72',
|
951
|
+
ext: '.png',
|
952
|
+
props: null
|
953
|
+
}, options);
|
954
|
+
return function renderTwemoji(icon, match, offset) {
|
955
|
+
var src = '';
|
956
|
+
if (options.baseUrl.indexOf('http') !== 0) {
|
957
|
+
src += normalizeProtocol(options.protocol);
|
958
|
+
}
|
959
|
+
src += options.baseUrl + options.size + '/' + icon + options.ext;
|
960
|
+
return createElement('img', merge({
|
961
|
+
key: offset,
|
962
|
+
alt: match,
|
963
|
+
draggable: false,
|
964
|
+
src: src,
|
965
|
+
style: emojiStyle
|
966
|
+
}, options.props));
|
967
|
+
};
|
968
|
+
};
|
969
|
+
function merge() {
|
970
|
+
var out = {},
|
971
|
+
len = arguments.length;
|
972
|
+
for (var i = 0; i < len; ++i) {
|
973
|
+
var source = arguments[i];
|
974
|
+
if (source) {
|
975
|
+
for (var key in source) {
|
976
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
977
|
+
out[key] = source[key];
|
978
|
+
}
|
979
|
+
}
|
980
|
+
}
|
981
|
+
}
|
982
|
+
return out;
|
983
|
+
}
|
984
|
+
|
985
|
+
var replaceEmoji = replaceEmoji$1;
|
986
|
+
|
987
|
+
var makeTwemojiRenderer = makeTwemojiRenderer$1;
|
988
|
+
|
989
|
+
var reactEasyEmoji = function reactEasyEmoji(element, optionsOrFn) {
|
990
|
+
var render = typeof optionsOrFn === 'function' ? optionsOrFn : makeTwemojiRenderer(optionsOrFn);
|
991
|
+
return replaceEmoji(element, render);
|
992
|
+
};
|
993
|
+
|
994
|
+
var emoji = reactEasyEmoji;
|
995
|
+
|
790
996
|
// @ts-check
|
997
|
+
var EMOJI_REGEX = new RegExp(/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?)*/g);
|
791
998
|
|
792
999
|
/**
|
793
1000
|
* @typedef {import('../types/types').SanitizeFn} SanitizeFn
|
@@ -796,8 +1003,9 @@ function addLineBreak() {
|
|
796
1003
|
// eslint-disable-next-line valid-jsdoc
|
797
1004
|
/**
|
798
1005
|
* @param {boolean} shouldReturn
|
1006
|
+
* @param {boolean} shouldConvertEmojiToImage
|
799
1007
|
*/
|
800
|
-
function useSanitize(shouldReturn) {
|
1008
|
+
function useSanitize(shouldReturn, shouldConvertEmojiToImage) {
|
801
1009
|
/** @type {React.MutableRefObject<SanitizeFn[]>} */
|
802
1010
|
var sanitizeFnsRef = React.useRef([]);
|
803
1011
|
var sanitizedTextRef = React.useRef("");
|
@@ -813,9 +1021,12 @@ function useSanitize(shouldReturn) {
|
|
813
1021
|
return fn(acc);
|
814
1022
|
}, html);
|
815
1023
|
result = replaceAllHtmlToString(result, shouldReturn);
|
1024
|
+
if (shouldConvertEmojiToImage) {
|
1025
|
+
result = convertEmojiToImage(result);
|
1026
|
+
}
|
816
1027
|
sanitizedTextRef.current = result;
|
817
1028
|
return result;
|
818
|
-
}, []);
|
1029
|
+
}, [shouldReturn, shouldConvertEmojiToImage]);
|
819
1030
|
return {
|
820
1031
|
addSanitizeFn: addSanitizeFn,
|
821
1032
|
sanitize: sanitize,
|
@@ -844,6 +1055,28 @@ function replaceAllHtmlToString(html, shouldReturn) {
|
|
844
1055
|
return text;
|
845
1056
|
}
|
846
1057
|
|
1058
|
+
/**
|
1059
|
+
*
|
1060
|
+
* @param {string} text
|
1061
|
+
* @return {string}
|
1062
|
+
*/
|
1063
|
+
function convertEmojiToImage(text) {
|
1064
|
+
text = handleEmoji(text);
|
1065
|
+
text = server.renderToString(emoji(text));
|
1066
|
+
text = text.replace(new RegExp('<span class="message-emoji">', 'g'), '<span class="message-emoji">');
|
1067
|
+
text = text.replace(new RegExp('</span>', 'g'), '</span>');
|
1068
|
+
return text;
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
/**
|
1072
|
+
*
|
1073
|
+
* @param {string} text
|
1074
|
+
* @return {string}
|
1075
|
+
*/
|
1076
|
+
function handleEmoji(text) {
|
1077
|
+
return text.replace(EMOJI_REGEX, '<span class="message-emoji">$&</span>');
|
1078
|
+
}
|
1079
|
+
|
847
1080
|
// @ts-check
|
848
1081
|
|
849
1082
|
/**
|
@@ -852,6 +1085,7 @@ function replaceAllHtmlToString(html, shouldReturn) {
|
|
852
1085
|
* @property {React.MutableRefObject<import('../text-input').Ref | null>} textInputRef
|
853
1086
|
* @property {(value: string) => void} setValue
|
854
1087
|
* @property {() => void} emitChange
|
1088
|
+
* @property {boolean=} shouldConvertEmojiToImage
|
855
1089
|
*/
|
856
1090
|
|
857
1091
|
/**
|
@@ -862,8 +1096,9 @@ function useExpose(_ref) {
|
|
862
1096
|
var ref = _ref.ref,
|
863
1097
|
textInputRef = _ref.textInputRef,
|
864
1098
|
setValue = _ref.setValue,
|
865
|
-
emitChange = _ref.emitChange
|
866
|
-
|
1099
|
+
emitChange = _ref.emitChange,
|
1100
|
+
shouldConvertEmojiToImage = _ref.shouldConvertEmojiToImage;
|
1101
|
+
var _useSanitize = useSanitize(false, shouldConvertEmojiToImage),
|
867
1102
|
sanitize = _useSanitize.sanitize,
|
868
1103
|
sanitizedTextRef = _useSanitize.sanitizedTextRef;
|
869
1104
|
React.useImperativeHandle(ref, function () {
|
@@ -4523,7 +4758,7 @@ function usePollute() {
|
|
4523
4758
|
* @property {() => void=} onClick
|
4524
4759
|
* @property {() => void=} onFocus
|
4525
4760
|
* @property {() => void=} onBlur
|
4526
|
-
* @property {boolean
|
4761
|
+
* @property {boolean} shouldReturn
|
4527
4762
|
* @property {number=} maxLength
|
4528
4763
|
* @property {boolean=} keepOpened
|
4529
4764
|
* @property {(event: KeyboardEvent) => void=} onKeyDown
|
@@ -4541,6 +4776,7 @@ function usePollute() {
|
|
4541
4776
|
* @property {(text: string) => Promise<MetionUser[]>=} searchMention
|
4542
4777
|
* @property {HTMLDivElement=} buttonElement
|
4543
4778
|
* @property {React.MutableRefObject=} buttonRef
|
4779
|
+
* @property {boolean} shouldConvertEmojiToImage
|
4544
4780
|
*/
|
4545
4781
|
|
4546
4782
|
/**
|
@@ -4552,7 +4788,6 @@ function usePollute() {
|
|
4552
4788
|
function InputEmoji(props, ref) {
|
4553
4789
|
var onChange = props.onChange,
|
4554
4790
|
onEnter = props.onEnter,
|
4555
|
-
shouldReturn = props.shouldReturn,
|
4556
4791
|
onResize = props.onResize,
|
4557
4792
|
onClick = props.onClick,
|
4558
4793
|
onFocus = props.onFocus,
|
@@ -4572,6 +4807,8 @@ function InputEmoji(props, ref) {
|
|
4572
4807
|
searchMention = props.searchMention,
|
4573
4808
|
buttonElement = props.buttonElement,
|
4574
4809
|
buttonRef = props.buttonRef,
|
4810
|
+
shouldReturn = props.shouldReturn,
|
4811
|
+
shouldConvertEmojiToImage = props.shouldConvertEmojiToImage,
|
4575
4812
|
borderRadius = props.borderRadius,
|
4576
4813
|
borderColor = props.borderColor,
|
4577
4814
|
fontSize = props.fontSize,
|
@@ -4585,7 +4822,7 @@ function InputEmoji(props, ref) {
|
|
4585
4822
|
var _useEventListeners = useEventListeners(),
|
4586
4823
|
addEventListener = _useEventListeners.addEventListener,
|
4587
4824
|
listeners = _useEventListeners.listeners;
|
4588
|
-
var _useSanitize = useSanitize(
|
4825
|
+
var _useSanitize = useSanitize(shouldReturn, shouldConvertEmojiToImage),
|
4589
4826
|
addSanitizeFn = _useSanitize.addSanitizeFn,
|
4590
4827
|
sanitize = _useSanitize.sanitize,
|
4591
4828
|
sanitizedTextRef = _useSanitize.sanitizedTextRef;
|
@@ -4611,7 +4848,8 @@ function InputEmoji(props, ref) {
|
|
4611
4848
|
ref: ref,
|
4612
4849
|
setValue: setValue,
|
4613
4850
|
textInputRef: textInputRef,
|
4614
|
-
emitChange: emitChange
|
4851
|
+
emitChange: emitChange,
|
4852
|
+
shouldConvertEmojiToImage: shouldConvertEmojiToImage
|
4615
4853
|
});
|
4616
4854
|
React.useEffect(function () {
|
4617
4855
|
if (sanitizedTextRef.current !== value) {
|
@@ -4781,6 +5019,7 @@ InputEmojiWithRef.defaultProps = {
|
|
4781
5019
|
background: "white",
|
4782
5020
|
tabIndex: 0,
|
4783
5021
|
shouldReturn: false,
|
5022
|
+
shouldConvertEmojiToImage: false,
|
4784
5023
|
customEmojis: [],
|
4785
5024
|
language: undefined
|
4786
5025
|
};
|