@chayns-components/emoji-input 5.0.0-beta.90 → 5.0.0-beta.901
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 +4 -15
- package/lib/{api → cjs/api}/item-storage/get.js +4 -5
- package/lib/cjs/api/item-storage/get.js.map +1 -0
- package/lib/{api → cjs/api}/item-storage/put.js +5 -6
- package/lib/cjs/api/item-storage/put.js.map +1 -0
- package/lib/cjs/components/emoji-input/EmojiInput.js +510 -0
- package/lib/cjs/components/emoji-input/EmojiInput.js.map +1 -0
- package/lib/cjs/components/emoji-input/EmojiInput.styles.js +132 -0
- package/lib/cjs/components/emoji-input/EmojiInput.styles.js.map +1 -0
- package/lib/cjs/components/emoji-input/prefix-element/PrefixElement.js +45 -0
- package/lib/cjs/components/emoji-input/prefix-element/PrefixElement.js.map +1 -0
- package/lib/cjs/components/emoji-input/prefix-element/PrefixElement.styles.js +65 -0
- package/lib/cjs/components/emoji-input/prefix-element/PrefixElement.styles.js.map +1 -0
- package/lib/{components → cjs/components}/emoji-picker/EmojiPicker.js +9 -11
- package/lib/cjs/components/emoji-picker/EmojiPicker.js.map +1 -0
- package/lib/{components → cjs/components}/emoji-picker/EmojiPicker.styles.js +3 -5
- package/lib/cjs/components/emoji-picker/EmojiPicker.styles.js.map +1 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js +102 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js.map +1 -0
- package/lib/{components → cjs/components}/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js +5 -6
- package/lib/cjs/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js.map +1 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js +240 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js.map +1 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js +69 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js.map +1 -0
- package/lib/{components → cjs/components}/emoji-picker/emoji-picker-emojis/emoji/Emoji.js +49 -21
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +1 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +24 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js.map +1 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js +130 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +1 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +99 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js.map +1 -0
- package/lib/cjs/components/emoji-picker-popup/EmojiPickerPopup.js +52 -0
- package/lib/cjs/components/emoji-picker-popup/EmojiPickerPopup.js.map +1 -0
- package/lib/cjs/components/emoji-picker-popup/EmojiPickerPopup.styles.js +15 -0
- package/lib/cjs/components/emoji-picker-popup/EmojiPickerPopup.styles.js.map +1 -0
- package/lib/{constants → cjs/constants}/alignment.js +6 -8
- package/lib/cjs/constants/alignment.js.map +1 -0
- package/lib/{constants → cjs/constants}/categories.js +1 -2
- package/lib/cjs/constants/categories.js.map +1 -0
- package/lib/cjs/constants/emoji.js +3804 -0
- package/lib/cjs/constants/emoji.js.map +1 -0
- package/lib/cjs/constants/externalServerUrl.js +8 -0
- package/lib/cjs/constants/externalServerUrl.js.map +1 -0
- package/lib/cjs/constants/regex.js +15 -0
- package/lib/cjs/constants/regex.js.map +1 -0
- package/lib/{hooks → cjs/hooks}/emojiHistory.js +13 -15
- package/lib/cjs/hooks/emojiHistory.js.map +1 -0
- package/lib/{index.js → cjs/index.js} +3 -3
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/types/api.js +2 -0
- package/lib/cjs/types/api.js.map +1 -0
- package/lib/cjs/types/category.js +2 -0
- package/lib/cjs/types/category.js.map +1 -0
- package/lib/cjs/utils/emoji.js +104 -0
- package/lib/cjs/utils/emoji.js.map +1 -0
- package/lib/{utils → cjs/utils}/environment.js +6 -4
- package/lib/cjs/utils/environment.js.map +1 -0
- package/lib/cjs/utils/font.js +17 -0
- package/lib/cjs/utils/font.js.map +1 -0
- package/lib/cjs/utils/insert.js +110 -0
- package/lib/cjs/utils/insert.js.map +1 -0
- package/lib/cjs/utils/number.js +17 -0
- package/lib/cjs/utils/number.js.map +1 -0
- package/lib/cjs/utils/selection.js +255 -0
- package/lib/cjs/utils/selection.js.map +1 -0
- package/lib/cjs/utils/text.js +57 -0
- package/lib/cjs/utils/text.js.map +1 -0
- package/lib/esm/api/item-storage/get.js +30 -0
- package/lib/esm/api/item-storage/get.js.map +1 -0
- package/lib/esm/api/item-storage/put.js +35 -0
- package/lib/esm/api/item-storage/put.js.map +1 -0
- package/lib/esm/components/emoji-input/EmojiInput.js +497 -0
- package/lib/esm/components/emoji-input/EmojiInput.js.map +1 -0
- package/lib/esm/components/emoji-input/EmojiInput.styles.js +151 -0
- package/lib/esm/components/emoji-input/EmojiInput.styles.js.map +1 -0
- package/lib/esm/components/emoji-input/prefix-element/PrefixElement.js +38 -0
- package/lib/esm/components/emoji-input/prefix-element/PrefixElement.js.map +1 -0
- package/lib/esm/components/emoji-input/prefix-element/PrefixElement.styles.js +69 -0
- package/lib/esm/components/emoji-input/prefix-element/PrefixElement.styles.js.map +1 -0
- package/lib/esm/components/emoji-picker/EmojiPicker.js +40 -0
- package/lib/esm/components/emoji-picker/EmojiPicker.js.map +1 -0
- package/lib/esm/components/emoji-picker/EmojiPicker.styles.js +16 -0
- package/lib/esm/components/emoji-picker/EmojiPicker.styles.js.map +1 -0
- package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js +96 -0
- package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js.map +1 -0
- package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js +18 -0
- package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js.map +1 -0
- package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js +240 -0
- package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js.map +1 -0
- package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js +76 -0
- package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js.map +1 -0
- package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js +136 -0
- package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +1 -0
- package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +20 -0
- package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js.map +1 -0
- package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js +121 -0
- package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +1 -0
- package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +98 -0
- package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js.map +1 -0
- package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.js +43 -0
- package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.js.map +1 -0
- package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.styles.js +8 -0
- package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.styles.js.map +1 -0
- package/lib/esm/constants/alignment.js +13 -0
- package/lib/esm/constants/alignment.js.map +1 -0
- package/lib/esm/constants/categories.js +13 -0
- package/lib/esm/constants/categories.js.map +1 -0
- package/lib/esm/constants/emoji-de-DE.json +3827 -0
- package/lib/esm/constants/emoji.js +3798 -0
- package/lib/esm/constants/emoji.js.map +1 -0
- package/lib/esm/constants/externalServerUrl.js +2 -0
- package/lib/esm/constants/externalServerUrl.js.map +1 -0
- package/lib/esm/constants/regex.js +9 -0
- package/lib/esm/constants/regex.js.map +1 -0
- package/lib/esm/hooks/emojiHistory.js +83 -0
- package/lib/esm/hooks/emojiHistory.js.map +1 -0
- package/lib/{index.d.ts → esm/index.js} +2 -1
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/types/api.js +2 -0
- package/lib/esm/types/api.js.map +1 -0
- package/lib/esm/types/category.js +2 -0
- package/lib/esm/types/category.js.map +1 -0
- package/lib/esm/utils/emoji.js +92 -0
- package/lib/esm/utils/emoji.js.map +1 -0
- package/lib/esm/utils/environment.js +24 -0
- package/lib/esm/utils/environment.js.map +1 -0
- package/lib/esm/utils/font.js +10 -0
- package/lib/esm/utils/font.js.map +1 -0
- package/lib/esm/utils/insert.js +104 -0
- package/lib/esm/utils/insert.js.map +1 -0
- package/lib/esm/utils/number.js +10 -0
- package/lib/esm/utils/number.js.map +1 -0
- package/lib/esm/utils/selection.js +237 -0
- package/lib/esm/utils/selection.js.map +1 -0
- package/lib/esm/utils/text.js +48 -0
- package/lib/esm/utils/text.js.map +1 -0
- package/lib/types/components/emoji-input/EmojiInput.d.ts +94 -0
- package/lib/types/components/emoji-input/EmojiInput.styles.d.ts +549 -0
- package/lib/types/components/emoji-input/prefix-element/PrefixElement.d.ts +8 -0
- package/lib/types/components/emoji-input/prefix-element/PrefixElement.styles.d.ts +12 -0
- package/lib/types/components/emoji-picker/EmojiPicker.styles.d.ts +5 -0
- package/lib/types/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.d.ts +267 -0
- package/lib/types/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.d.ts +10 -0
- package/lib/{components → types/components}/emoji-picker/emoji-picker-emojis/emoji/Emoji.d.ts +5 -0
- package/lib/types/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.d.ts +6 -0
- package/lib/types/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.d.ts +283 -0
- package/lib/{components → types/components}/emoji-picker-popup/EmojiPickerPopup.d.ts +0 -13
- package/lib/types/components/emoji-picker-popup/EmojiPickerPopup.styles.d.ts +1 -0
- package/lib/types/constants/emoji.d.ts +8 -0
- package/lib/types/constants/regex.d.ts +8 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/utils/emoji.d.ts +4 -0
- package/lib/{utils → types/utils}/environment.d.ts +1 -0
- package/lib/types/utils/font.d.ts +1 -0
- package/lib/types/utils/insert.d.ts +26 -0
- package/lib/types/utils/number.d.ts +1 -0
- package/lib/types/utils/selection.d.ts +23 -0
- package/lib/types/utils/text.d.ts +3 -0
- package/package.json +48 -30
- package/lib/api/item-storage/get.js.map +0 -1
- package/lib/api/item-storage/put.js.map +0 -1
- package/lib/components/emoji-input/EmojiInput.d.ts +0 -49
- package/lib/components/emoji-input/EmojiInput.js +0 -168
- package/lib/components/emoji-input/EmojiInput.js.map +0 -1
- package/lib/components/emoji-input/EmojiInput.styles.d.ts +0 -16
- package/lib/components/emoji-input/EmojiInput.styles.js +0 -152
- package/lib/components/emoji-input/EmojiInput.styles.js.map +0 -1
- package/lib/components/emoji-picker/EmojiPicker.js.map +0 -1
- package/lib/components/emoji-picker/EmojiPicker.styles.d.ts +0 -5
- package/lib/components/emoji-picker/EmojiPicker.styles.js.map +0 -1
- package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js +0 -51
- package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js.map +0 -1
- package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.d.ts +0 -2
- package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js.map +0 -1
- package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js +0 -131
- package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js.map +0 -1
- package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.d.ts +0 -7
- package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js +0 -99
- package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js.map +0 -1
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +0 -1
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.d.ts +0 -1
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +0 -20
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js.map +0 -1
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js +0 -74
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +0 -1
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.d.ts +0 -11
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +0 -104
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js.map +0 -1
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.js +0 -150
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.js.map +0 -1
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.d.ts +0 -7
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.js +0 -97
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.js.map +0 -1
- package/lib/constants/alignment.js.map +0 -1
- package/lib/constants/categories.js.map +0 -1
- package/lib/constants/externalServerUrl.js +0 -9
- package/lib/constants/externalServerUrl.js.map +0 -1
- package/lib/hooks/emojiHistory.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/types/api.js +0 -6
- package/lib/types/api.js.map +0 -1
- package/lib/types/category.js +0 -6
- package/lib/types/category.js.map +0 -1
- package/lib/utils/emoji.d.ts +0 -2
- package/lib/utils/emoji.js +0 -205
- package/lib/utils/emoji.js.map +0 -1
- package/lib/utils/environment.js.map +0 -1
- package/lib/utils/font.d.ts +0 -1
- package/lib/utils/font.js +0 -15
- package/lib/utils/font.js.map +0 -1
- package/lib/utils/selection.d.ts +0 -2
- package/lib/utils/selection.js +0 -43
- package/lib/utils/selection.js.map +0 -1
- /package/lib/{constants → cjs/constants}/emoji-de-DE.json +0 -0
- /package/lib/{api → types/api}/item-storage/get.d.ts +0 -0
- /package/lib/{api → types/api}/item-storage/put.d.ts +0 -0
- /package/lib/{components → types/components}/emoji-picker/EmojiPicker.d.ts +0 -0
- /package/lib/{components → types/components}/emoji-picker/emoji-picker-categories/EmojiPickerCategories.d.ts +0 -0
- /package/lib/{components → types/components}/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.d.ts +0 -0
- /package/lib/{components → types/components}/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.d.ts +0 -0
- /package/lib/{constants → types/constants}/alignment.d.ts +0 -0
- /package/lib/{constants → types/constants}/categories.d.ts +0 -0
- /package/lib/{constants → types/constants}/externalServerUrl.d.ts +0 -0
- /package/lib/{hooks → types/hooks}/emojiHistory.d.ts +0 -0
- /package/lib/types/{api.d.ts → types/api.d.ts} +0 -0
- /package/lib/types/{category.d.ts → types/category.d.ts} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ITEM_STORAGE_BASE_URL = void 0;
|
|
7
|
+
const ITEM_STORAGE_BASE_URL = exports.ITEM_STORAGE_BASE_URL = 'https://cube.tobit.cloud/item-storage/api/v1.0/schemes';
|
|
8
|
+
//# sourceMappingURL=externalServerUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"externalServerUrl.js","names":["ITEM_STORAGE_BASE_URL","exports"],"sources":["../../../src/constants/externalServerUrl.ts"],"sourcesContent":["export const ITEM_STORAGE_BASE_URL = 'https://cube.tobit.cloud/item-storage/api/v1.0/schemes';\n"],"mappings":";;;;;;AAAO,MAAMA,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,wDAAwD","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.HTML_NER_REPLACE_REGEX = exports.HTML_NER_IGNORE_REGEX = exports.HTML_LC_MENTION_REGEX = exports.HTML_BOLD_REGEX = exports.HTML_A_TAG_REGEX = exports.BB_NER_REPLACE_REGEX = exports.BB_NER_IGNORE_REGEX = exports.BB_LC_MENTION_REGEX = void 0;
|
|
7
|
+
const BB_LC_MENTION_REGEX = exports.BB_LC_MENTION_REGEX = /\[lc_mention.+?id="([^"]+?)"](.+?)\[\/lc_mention]/g;
|
|
8
|
+
const BB_NER_IGNORE_REGEX = exports.BB_NER_IGNORE_REGEX = /\[nerIgnore](.+?)\[\/nerIgnore]/g;
|
|
9
|
+
const BB_NER_REPLACE_REGEX = exports.BB_NER_REPLACE_REGEX = /\[nerReplace\s*(?:prefix="(.*?)")?\s*type="(.*?)"\s*value="(.*?)"](.*?)\[\/nerReplace]/gi;
|
|
10
|
+
const HTML_LC_MENTION_REGEX = exports.HTML_LC_MENTION_REGEX = /<lc_mention.+?id="([^"]+?)">(?:<span.*?<\/span>)*(.+?)<\/lc_mention>/g;
|
|
11
|
+
const HTML_NER_IGNORE_REGEX = exports.HTML_NER_IGNORE_REGEX = /<nerIgnore>(.+?)<\/nerIgnore>/g;
|
|
12
|
+
const HTML_NER_REPLACE_REGEX = exports.HTML_NER_REPLACE_REGEX = /<nerReplace\s*(?:prefix="(.*?)")?\s*type="(.*?)"\s*value="(.*?)">(.*?)<\/nerReplace>/gi;
|
|
13
|
+
const HTML_BOLD_REGEX = exports.HTML_BOLD_REGEX = /<b>(.+?)<\/b>/g;
|
|
14
|
+
const HTML_A_TAG_REGEX = exports.HTML_A_TAG_REGEX = /(?:<|<)a\b[^>]*?(?:>|>)(.*?)(?:<|<)\/a(?:>|>)/g;
|
|
15
|
+
//# sourceMappingURL=regex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regex.js","names":["BB_LC_MENTION_REGEX","exports","BB_NER_IGNORE_REGEX","BB_NER_REPLACE_REGEX","HTML_LC_MENTION_REGEX","HTML_NER_IGNORE_REGEX","HTML_NER_REPLACE_REGEX","HTML_BOLD_REGEX","HTML_A_TAG_REGEX"],"sources":["../../../src/constants/regex.ts"],"sourcesContent":["export const BB_LC_MENTION_REGEX = /\\[lc_mention.+?id=\"([^\"]+?)\"](.+?)\\[\\/lc_mention]/g;\nexport const BB_NER_IGNORE_REGEX = /\\[nerIgnore](.+?)\\[\\/nerIgnore]/g;\nexport const BB_NER_REPLACE_REGEX =\n /\\[nerReplace\\s*(?:prefix=\"(.*?)\")?\\s*type=\"(.*?)\"\\s*value=\"(.*?)\"](.*?)\\[\\/nerReplace]/gi;\n\nexport const HTML_LC_MENTION_REGEX =\n /<lc_mention.+?id=\"([^\"]+?)\">(?:<span.*?<\\/span>)*(.+?)<\\/lc_mention>/g;\nexport const HTML_NER_IGNORE_REGEX = /<nerIgnore>(.+?)<\\/nerIgnore>/g;\nexport const HTML_NER_REPLACE_REGEX =\n /<nerReplace\\s*(?:prefix=\"(.*?)\")?\\s*type=\"(.*?)\"\\s*value=\"(.*?)\">(.*?)<\\/nerReplace>/gi;\nexport const HTML_BOLD_REGEX = /<b>(.+?)<\\/b>/g;\nexport const HTML_A_TAG_REGEX = /(?:<|<)a\\b[^>]*?(?:>|>)(.*?)(?:<|<)\\/a(?:>|>)/g;\n"],"mappings":";;;;;;AAAO,MAAMA,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,oDAAoD;AAChF,MAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAG,kCAAkC;AAC9D,MAAMC,oBAAoB,GAAAF,OAAA,CAAAE,oBAAA,GAC7B,0FAA0F;AAEvF,MAAMC,qBAAqB,GAAAH,OAAA,CAAAG,qBAAA,GAC9B,uEAAuE;AACpE,MAAMC,qBAAqB,GAAAJ,OAAA,CAAAI,qBAAA,GAAG,gCAAgC;AAC9D,MAAMC,sBAAsB,GAAAL,OAAA,CAAAK,sBAAA,GAC/B,wFAAwF;AACrF,MAAMC,eAAe,GAAAN,OAAA,CAAAM,eAAA,GAAG,gBAAgB;AACxC,MAAMC,gBAAgB,GAAAP,OAAA,CAAAO,gBAAA,GAAG,4DAA4D","ignoreList":[]}
|
|
@@ -7,32 +7,30 @@ exports.useEmojiHistory = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _get = require("../api/item-storage/get");
|
|
9
9
|
var _put = require("../api/item-storage/put");
|
|
10
|
-
const useEmojiHistory =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} = _ref;
|
|
10
|
+
const useEmojiHistory = ({
|
|
11
|
+
accessToken,
|
|
12
|
+
personId,
|
|
13
|
+
selectedCategory
|
|
14
|
+
}) => {
|
|
16
15
|
const [historyEmojis, setHistoryEmojis] = (0, _react.useState)([]);
|
|
17
16
|
const tempHistoryEmojis = (0, _react.useRef)(null);
|
|
18
|
-
const addOrUpdateEmojiInHistory = (0, _react.useCallback)(async
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} = _ref2;
|
|
17
|
+
const addOrUpdateEmojiInHistory = (0, _react.useCallback)(async ({
|
|
18
|
+
emoji,
|
|
19
|
+
name,
|
|
20
|
+
skin_tone_support
|
|
21
|
+
}) => {
|
|
22
|
+
var _historyItem;
|
|
25
23
|
if (typeof accessToken !== 'string' || typeof personId !== 'string') {
|
|
26
24
|
return;
|
|
27
25
|
}
|
|
28
|
-
const newHistoryEmojis = Array.from(
|
|
26
|
+
const newHistoryEmojis = Array.from(tempHistoryEmojis.current ?? historyEmojis);
|
|
29
27
|
const historyItemIndex = newHistoryEmojis.findIndex(item => item.emoji === emoji);
|
|
30
28
|
let historyItem;
|
|
31
29
|
if (historyItemIndex > -1) {
|
|
32
30
|
[historyItem] = newHistoryEmojis.splice(historyItemIndex, 1);
|
|
33
31
|
}
|
|
34
32
|
newHistoryEmojis.push({
|
|
35
|
-
count: ((
|
|
33
|
+
count: (((_historyItem = historyItem) === null || _historyItem === void 0 ? void 0 : _historyItem.count) ?? 0) + 1,
|
|
36
34
|
emoji,
|
|
37
35
|
modifiedTime: new Date().toISOString(),
|
|
38
36
|
name,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emojiHistory.js","names":["_react","require","_get","_put","useEmojiHistory","accessToken","personId","selectedCategory","historyEmojis","setHistoryEmojis","useState","tempHistoryEmojis","useRef","addOrUpdateEmojiInHistory","useCallback","emoji","name","skin_tone_support","_historyItem","newHistoryEmojis","Array","from","current","historyItemIndex","findIndex","item","historyItem","splice","push","count","modifiedTime","Date","toISOString","sort","a","b","getTime","data","putEmojiHistory","value","slice","loadHistoryEmojis","getEmojiHistory","useEffect","exports"],"sources":["../../../src/hooks/emojiHistory.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { getEmojiHistory } from '../api/item-storage/get';\nimport { putEmojiHistory } from '../api/item-storage/put';\nimport type { Category } from '../types/category';\n\nexport interface HistoryItem {\n count: number;\n emoji: string;\n modifiedTime: string;\n name: string;\n skin_tone_support: boolean;\n}\n\ninterface UseEmojiHistoryOptions {\n accessToken?: string;\n personId?: string;\n selectedCategory: Category;\n}\n\nexport const useEmojiHistory = ({\n accessToken,\n personId,\n selectedCategory,\n}: UseEmojiHistoryOptions) => {\n const [historyEmojis, setHistoryEmojis] = useState<HistoryItem[]>([]);\n\n const tempHistoryEmojis = useRef<HistoryItem[] | null>(null);\n\n const addOrUpdateEmojiInHistory = useCallback(\n async ({\n emoji,\n name,\n skin_tone_support,\n }: {\n emoji: string;\n name: string;\n skin_tone_support: boolean;\n }) => {\n if (typeof accessToken !== 'string' || typeof personId !== 'string') {\n return;\n }\n\n const newHistoryEmojis = Array.from(tempHistoryEmojis.current ?? historyEmojis);\n\n const historyItemIndex = newHistoryEmojis.findIndex((item) => item.emoji === emoji);\n\n let historyItem;\n\n if (historyItemIndex > -1) {\n [historyItem] = newHistoryEmojis.splice(historyItemIndex, 1);\n }\n\n newHistoryEmojis.push({\n count: (historyItem?.count ?? 0) + 1,\n emoji,\n modifiedTime: new Date().toISOString(),\n name,\n skin_tone_support,\n });\n\n newHistoryEmojis.sort((a, b) => {\n if (a.count === b.count) {\n return new Date(b.modifiedTime).getTime() - new Date(a.modifiedTime).getTime();\n }\n\n return b.count - a.count;\n });\n\n const { data } = await putEmojiHistory({\n accessToken,\n personId,\n value: newHistoryEmojis.slice(0, 50),\n });\n\n if (data) {\n if (selectedCategory === 'history') {\n tempHistoryEmojis.current = data;\n } else {\n tempHistoryEmojis.current = null;\n\n setHistoryEmojis(data);\n }\n }\n },\n [accessToken, historyEmojis, personId, selectedCategory]\n );\n\n const loadHistoryEmojis = useCallback(async () => {\n if (typeof accessToken !== 'string' || typeof personId !== 'string') {\n return;\n }\n\n const { data } = await getEmojiHistory({ accessToken, personId });\n\n if (data) {\n setHistoryEmojis(data);\n }\n }, [accessToken, personId]);\n\n useEffect(() => {\n void loadHistoryEmojis();\n }, [loadHistoryEmojis]);\n\n useEffect(() => {\n if (selectedCategory !== 'history' && tempHistoryEmojis.current) {\n setHistoryEmojis(tempHistoryEmojis.current);\n }\n }, [selectedCategory]);\n\n return { addOrUpdateEmojiInHistory, historyEmojis: histor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M;IACZ,KAAKF,iBAAiB,CAAC,CAAC;EAC5B,CAAC,EAAE,CAACA,iBAAiB,CAAC,CAAC;EAEvB,IAAAE,gBAAS,EAAC,MAAM;IACZ,IAAIpC,gBAAgB,KAAK,SAAS,IAAII,iBAAiB,CAACW,OAAO,EAAE;MAC7Db,gBAAgB,CAACE,iBAAiB,CAACW,OAAO,CAAC;IAC/C;EACJ,CAAC,EAAE,CAACf,gBAAgB,CAAC,CAAC;EAEtB,OAAO;IAAEM,yBAAyB;IAAEL,aAAa,EAAEA,aAAa,CAACgC,KAAK,CAAC,CAAC,EAAE,EAAE;EAAE,CAAC;AACnF,CAAC;AAACI,OAAA,CAAAxC,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -27,10 +27,10 @@ Object.defineProperty(exports, "PopupAlignment", {
|
|
|
27
27
|
return _alignment.PopupAlignment;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(exports, "
|
|
30
|
+
Object.defineProperty(exports, "convertEmojisToUnicode", {
|
|
31
31
|
enumerable: true,
|
|
32
32
|
get: function () {
|
|
33
|
-
return _emoji.
|
|
33
|
+
return _emoji.convertEmojisToUnicode;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
var _EmojiInput = _interopRequireDefault(require("./components/emoji-input/EmojiInput"));
|
|
@@ -38,5 +38,5 @@ var _EmojiPickerPopup = _interopRequireDefault(require("./components/emoji-picke
|
|
|
38
38
|
var _EmojiPicker = _interopRequireDefault(require("./components/emoji-picker/EmojiPicker"));
|
|
39
39
|
var _alignment = require("./constants/alignment");
|
|
40
40
|
var _emoji = require("./utils/emoji");
|
|
41
|
-
function _interopRequireDefault(
|
|
41
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
42
42
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_EmojiInput","_interopRequireDefault","require","_EmojiPickerPopup","_EmojiPicker","_alignment","_emoji","e","__esModule","default"],"sources":["../../src/index.ts"],"sourcesContent":["export { default as EmojiInput } from './components/emoji-input/EmojiInput';\nexport type { EmojiInputRef } from './components/emoji-input/EmojiInput';\nexport { default as EmojiPickerPopup } from './components/emoji-picker-popup/EmojiPickerPopup';\nexport { default as EmojiPicker } from './components/emoji-picker/EmojiPicker';\nexport { PopupAlignment } from './constants/alignment';\nexport { convertEmojisToUnicode } from './utils/emoji';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAAuD,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","names":[],"sources":["../../../src/types/api.ts"],"sourcesContent":["export interface ApiFunctionResult<T = null> {\n data?: T;\n status?: number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category.js","names":[],"sources":["../../../src/types/category.ts"],"sourcesContent":["export type Category =\n | 'history'\n | 'smileys_emotion'\n | 'people_body'\n | 'animals_nature'\n | 'food_drink'\n | 'travel_places'\n | 'activities'\n | 'objects'\n | 'symbols'\n | 'flags';\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.unescapeHTML = exports.escapeHTML = exports.convertEmojisToUnicode = exports.addSkinToneToEmoji = void 0;
|
|
7
|
+
var _dataByEmoji = _interopRequireDefault(require("unicode-emoji-json/data-by-emoji.json"));
|
|
8
|
+
var _emoji = require("../constants/emoji");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const convert = unicode => {
|
|
11
|
+
if (unicode.indexOf('-') > -1) {
|
|
12
|
+
const parts = [];
|
|
13
|
+
const s = unicode.split('-');
|
|
14
|
+
for (let i = 0; i < s.length; i++) {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
16
|
+
let part = parseInt(s[i], 16);
|
|
17
|
+
if (part >= 0x10000 && part <= 0x10ffff) {
|
|
18
|
+
const hi = Math.floor((part - 0x10000) / 0x400) + 0xd800;
|
|
19
|
+
const lo = (part - 0x10000) % 0x400 + 0xdc00;
|
|
20
|
+
part = String.fromCharCode(hi) + String.fromCharCode(lo);
|
|
21
|
+
} else {
|
|
22
|
+
part = String.fromCharCode(part);
|
|
23
|
+
}
|
|
24
|
+
parts.push(part);
|
|
25
|
+
}
|
|
26
|
+
return parts.join('');
|
|
27
|
+
}
|
|
28
|
+
const s = parseInt(unicode, 16);
|
|
29
|
+
if (s >= 0x10000 && s <= 0x10ffff) {
|
|
30
|
+
const hi = Math.floor((s - 0x10000) / 0x400) + 0xd800;
|
|
31
|
+
const lo = (s - 0x10000) % 0x400 + 0xdc00;
|
|
32
|
+
return String.fromCharCode(hi) + String.fromCharCode(lo);
|
|
33
|
+
}
|
|
34
|
+
return String.fromCharCode(s);
|
|
35
|
+
};
|
|
36
|
+
const unescapeHTML = text => {
|
|
37
|
+
const unescaped = {
|
|
38
|
+
'&': '&',
|
|
39
|
+
'&': '&',
|
|
40
|
+
'&': '&',
|
|
41
|
+
'<': '<',
|
|
42
|
+
'<': '<',
|
|
43
|
+
'<': '<',
|
|
44
|
+
'>': '>',
|
|
45
|
+
'>': '>',
|
|
46
|
+
'>': '>',
|
|
47
|
+
'"': '"',
|
|
48
|
+
'"': '"',
|
|
49
|
+
'"': '"',
|
|
50
|
+
''': "'",
|
|
51
|
+
''': "'",
|
|
52
|
+
''': "'"
|
|
53
|
+
};
|
|
54
|
+
return text.replace(/&(?:amp|#38|#x26|lt|#60|#x3C|gt|#62|#x3E|apos|#39|#x27|quot|#34|#x22);/gi, match => unescaped[match] ?? match);
|
|
55
|
+
};
|
|
56
|
+
exports.unescapeHTML = unescapeHTML;
|
|
57
|
+
const escapeHTML = text => {
|
|
58
|
+
const escaped = {
|
|
59
|
+
'<': '<',
|
|
60
|
+
'>': '>',
|
|
61
|
+
'"': '"',
|
|
62
|
+
"'": '''
|
|
63
|
+
};
|
|
64
|
+
return text.replace(/[&<>"']/g, match => escaped[match] ?? match);
|
|
65
|
+
};
|
|
66
|
+
exports.escapeHTML = escapeHTML;
|
|
67
|
+
const convertEmojisToUnicode = text => {
|
|
68
|
+
let result = text;
|
|
69
|
+
result = result.replace(/https?:\/\/.*?(?=$|\s)/gi, fullMatch => fullMatch.replace(/:/g, '%3A'));
|
|
70
|
+
result = result.replace(_emoji.regShortnames, shortname => {
|
|
71
|
+
if (shortname) {
|
|
72
|
+
const unicode = _emoji.shortNameList[shortname];
|
|
73
|
+
if (unicode) {
|
|
74
|
+
return convert(unicode.toUpperCase());
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return shortname;
|
|
78
|
+
});
|
|
79
|
+
result = result.replace(/https?%3A\/\/.*?(?=$|\s)/gi, fullMatch => fullMatch.replace(/%3A/g, ':'));
|
|
80
|
+
result = result.replace(_emoji.regAscii, (fullMatch, m1, m2, m3) => {
|
|
81
|
+
if (typeof m3 === 'string' && m3 !== '') {
|
|
82
|
+
const unicode = _emoji.asciiList[unescapeHTML(m3)];
|
|
83
|
+
if (unicode) {
|
|
84
|
+
return m2 + convert(unicode.toUpperCase());
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return fullMatch;
|
|
88
|
+
});
|
|
89
|
+
return result;
|
|
90
|
+
};
|
|
91
|
+
exports.convertEmojisToUnicode = convertEmojisToUnicode;
|
|
92
|
+
const addSkinToneToEmoji = (emoji, skinTone) => emoji.split('\u{200D}').map(rawEmoji => {
|
|
93
|
+
var _emojiList$rawEmoji;
|
|
94
|
+
const parts = [rawEmoji.replace(/\ufe0f/, '')];
|
|
95
|
+
|
|
96
|
+
// @ts-expect-error: Difficult to type external json file
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
98
|
+
if ((_emojiList$rawEmoji = _dataByEmoji.default[rawEmoji]) !== null && _emojiList$rawEmoji !== void 0 && _emojiList$rawEmoji.skin_tone_support) {
|
|
99
|
+
parts.push(skinTone);
|
|
100
|
+
}
|
|
101
|
+
return parts.join('');
|
|
102
|
+
}).join('\u{200D}');
|
|
103
|
+
exports.addSkinToneToEmoji = addSkinToneToEmoji;
|
|
104
|
+
//# sourceMappingURL=emoji.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emoji.js","names":["_dataByEmoji","_interopRequireDefault","require","_emoji","e","__esModule","default","convert","unicode","indexOf","parts","s","split","i","length","part","parseInt","hi","Math","floor","lo","String","fromCharCode","push","join","unescapeHTML","text","unescaped","replace","match","exports","escapeHTML","escaped","convertEmojisToUnicode","result","fullMatch","regShortnames","shortname","shortNameList","toUpperCase","regAscii","m1","m2","m3","asciiList","addSkinToneToEmoji","emoji","skinTone","map","rawEmoji","_emojiList$rawEmoji","emojiList","skin_tone_support"],"sources":["../../../src/utils/emoji.ts"],"sourcesContent":["import emojiList from 'unicode-emoji-json/data-by-emoji.json';\nimport { asciiList, regAscii, regShortnames, shortNameList } from '../constants/emoji';\n\nconst convert = (unicode: string) => {\n if (unicode.indexOf('-') > -1) {\n const parts = [];\n\n const s = unicode.split('-');\n\n for (let i = 0; i < s.length; i++) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n let part: number | string = parseInt(s[i]!, 16);\n\n if (part >= 0x10000 && part <= 0x10ffff) {\n const hi = Math.floor((part - 0x10000) / 0x400) + 0xd800;\n const lo = ((part - 0x10000) % 0x400) + 0xdc00;\n\n part = String.fromCharCode(hi) + String.fromCharCode(lo);\n } else {\n part = String.fromCharCode(part);\n }\n\n parts.push(part);\n }\n\n return parts.join('');\n }\n\n const s = parseInt(unicode, 16);\n\n if (s >= 0x10000 && s <= 0x10ffff) {\n const hi = Math.floor((s - 0x10000) / 0x400) + 0xd800;\n const lo = ((s - 0x10000) % 0x400) + 0xdc00;\n\n return String.fromCharCode(hi) + String.fromCharCode(lo);\n }\n\n return String.fromCharCode(s);\n};\n\nexport const unescapeHTML = (text: string) => {\n const unescaped: { [key: string]: string } = {\n '&': '&',\n '&': '&',\n '&': '&',\n '<': '<',\n '<': '<',\n '<': '<',\n '>': '>',\n '>': '>',\n '>': '>',\n '"': '\"',\n '"': '\"',\n '"': '\"',\n ''': \"'\",\n ''': \"'\",\n ''': \"'\",\n };\n\n return text.replace(\n /&(?:amp|#38|#x26|lt|#60|#x3C|gt|#62|#x3E|apos|#39|#x27|quot|#34|#x22);/gi,\n (match) => unescaped[match] ?? match,\n );\n};\n\nexport const escapeHTML = (text: string) => {\n const escaped: { [key: string]: string } = {\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n };\n\n return text.replace(/[&<>\"']/g, (match) => escaped[match] ?? match);\n};\n\nexport const convertEmojisToUnicode = (text: string): string => {\n let result = text;\n\n result = result.replace(/https?:\\/\\/.*?(?=$|\\s)/gi, (fullMatch) =>\n fullMatch.replace(/:/g, '%3A'),\n );\n\n result = result.replace(regShortnames, (shortname) => {\n if (shortname) {\n const unicode = shortNameList[shortname];\n\n if (unicode) {\n return convert(unicode.toUpperCase());\n }\n }\n\n return shortname;\n });\n\n result = result.replace(/https?%3A\\/\\/.*?(?=$|\\s)/gi, (fullMatch) =>\n fullMatch.replace(/%3A/g, ':'),\n );\n\n result = result.replace(regAscii, (fullMatch, m1, m2, m3) => {\n if (typeof m3 === 'string' && m3 !== '') {\n const unicode = asciiList[unescapeHTML(m3)];\n\n if (unicode) {\n return (m2 as string) + convert(unicode.toUpperCase());\n }\n }\n\n return fullMatch;\n });\n\n return result;\n};\n\nexport const addSkinToneToEmoji = (emoji: string, skinTone: string): string =>\n emoji\n .split('\\u{200D}')\n .map((rawEmoji) => {\n const parts = [rawEmoji.replace(/\\ufe0f/, '')];\n\n // @ts-expect-error: Difficult to type external json file\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (emojiList[rawEmoji]?.skin_tone_support) {\n parts.push(skinTone);\n }\n\n return parts.join('');\n })\n .join('\\u{200D}');\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAuF,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEvF,MAAMG,OAAO,GAAIC,OAAe,IAAK;EACjC,IAAIA,OAAO,CAACC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;IAC3B,MAAMC,KAAK,GAAG,EAAE;IAEhB,MAAMC,CAAC,GAAGH,OAAO,CAACI,KAAK,CAAC,GAAG,CAAC;IAE5B,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,CAAC,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;MAC/B;MACA,IAAIE,IAAqB,GAAGC,QAAQ,CAACL,CAAC,CAACE,CAAC,CAAC,EAAG,EAAE,CAAC;MAE/C,IAAIE,IAAI,IAAI,OAAO,IAAIA,IAAI,IAAI,QAAQ,EAAE;QACrC,MAAME,EAAE,GAAGC,IAAI,CAACC,KAAK,CAAC,CAACJ,IAAI,GAAG,OAAO,IAAI,KAAK,CAAC,GAAG,MAAM;QACxD,MAAMK,EAAE,GAAI,CAACL,IAAI,GAAG,OAAO,IAAI,KAAK,GAAI,MAAM;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,EAAE;MACrC,MAAMnC,OAAO,GAAGoC,gBAAS,CAACnB,YAAY,CAACkB,EAAE,CAAC,CAAC;MAE3C,IAAInC,OAAO,EAAE;QACT,OAAQkC,EAAE,GAAcnC,OAAO,CAACC,OAAO,CAAC+B,WAAW,CAAC,CAAC,CAAC;MAC1D;IACJ;IAEA,OAAOJ,SAAS;EACpB,CAAC,CAAC;EAEF,OAAOD,MAAM;AACjB,CAAC;AAACJ,OAAA,CAAAG,sBAAA,GAAAA,sBAAA;AAEK,MAAMY,kBAAkB,GAAGA,CAACC,KAAa,EAAEC,QAAgB,KAC9DD,KAAK,CACAlC,KAAK,CAAC,UAAU,CAAC,CACjBoC,GAAG,CAAEC,QAAQ,IAAK;EAAA,IAAAC,mBAAA;EACf,MAAMxC,KAAK,GAAG,CAACuC,QAAQ,CAACrB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;;EAE9C;EACA;EACA,KAAAsB,mBAAA,GAAIC,oBAAS,CAACF,QAAQ,CAAC,cAAAC,mBAAA,eAAnBA,mBAAA,CAAqBE,iBAAiB,EAAE;IACxC1C,KAAK,CAACa,IAAI,CAACwB,QAAQ,CAAC;EACxB;EAEA,OAAOrC,KAAK,CAACc,IAAI,CAAC,EAAE,CAAC;AACzB,CAAC,CAAC,CACDA,IAAI,CAAC,UAAU,CAAC;AAACM,OAAA,CAAAe,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getIsMobile = exports.getDeviceType = void 0;
|
|
7
|
-
var DeviceType
|
|
8
|
-
(function (DeviceType) {
|
|
6
|
+
exports.getIsMobile = exports.getIsMacOS = exports.getDeviceType = void 0;
|
|
7
|
+
var DeviceType = /*#__PURE__*/function (DeviceType) {
|
|
9
8
|
DeviceType[DeviceType["Desktop"] = 0] = "Desktop";
|
|
10
9
|
DeviceType[DeviceType["Smartphone"] = 1] = "Smartphone";
|
|
11
10
|
DeviceType[DeviceType["Tablet"] = 2] = "Tablet";
|
|
12
|
-
|
|
11
|
+
return DeviceType;
|
|
12
|
+
}(DeviceType || {});
|
|
13
13
|
const getDeviceType = () => {
|
|
14
14
|
const {
|
|
15
15
|
userAgent
|
|
@@ -23,6 +23,8 @@ const getDeviceType = () => {
|
|
|
23
23
|
return DeviceType.Desktop;
|
|
24
24
|
};
|
|
25
25
|
exports.getDeviceType = getDeviceType;
|
|
26
|
+
const getIsMacOS = () => /Mac OS X/i.test(navigator.userAgent);
|
|
27
|
+
exports.getIsMacOS = getIsMacOS;
|
|
26
28
|
const getIsMobile = () => {
|
|
27
29
|
const deviceType = getDeviceType();
|
|
28
30
|
return deviceType === DeviceType.Smartphone || deviceType === DeviceType.Tablet;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","names":["DeviceType","getDeviceType","userAgent","navigator","test","Smartphone","Tablet","Desktop","exports","getIsMacOS","getIsMobile","deviceType"],"sources":["../../../src/utils/environment.ts"],"sourcesContent":["enum DeviceType {\n Desktop,\n Smartphone,\n Tablet,\n}\n\nexport const getDeviceType = (): DeviceType => {\n const { userAgent } = navigator;\n\n if (\n /Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(\n userAgent,\n )\n ) {\n return DeviceType.Smartphone;\n }\n\n if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(userAgent)) {\n return DeviceType.Tablet;\n }\n\n return DeviceType.Desktop;\n};\n\nexport const getIsMacOS = () => /Mac OS X/i.test(navigator.userAgent);\n\nexport const getIsMobile = (): boolean => {\n const deviceType = getDeviceType();\n\n return deviceType === DeviceType.Smartphone || deviceType === DeviceType.Tablet;\n};\n"],"mappings":";;;;;;IAAKA,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA,EAAVA,UAAU;AAMR,MAAMC,aAAa,GAAGA,CAAA,KAAkB;EAC3C,MAAM;IAAEC;EAAU,CAAC,GAAGC,SAAS;EAE/B,IACI,qGAAqG,CAACC,IAAI,CACtGF,SACJ,CAAC,EACH;IACE,OAAOF,UAAU,CAACK,UAAU;EAChC;EAEA,IAAI,kDAAkD,CAACD,IAAI,CAACF,SAAS,CAAC,EAAE;IACpE,OAAOF,UAAU,CAACM,MAAM;EAC5B;EAEA,OAAON,UAAU,CAACO,OAAO;AAC7B,CAAC;AAACC,OAAA,CAAAP,aAAA,GAAAA,aAAA;AAEK,MAAMQ,UAAU,GAAGA,CAAA,KAAM,WAAW,CAACL,IAAI,CAACD,SAAS,CAACD,SAAS,CAAC;AAACM,OAAA,CAAAC,UAAA,GAAAA,UAAA;AAE/D,MAAMC,WAAW,GAAGA,CAAA,KAAe;EACtC,MAAMC,UAAU,GAAGV,aAAa,CAAC,CAAC;EAElC,OAAOU,UAAU,KAAKX,UAAU,CAACK,UAAU,IAAIM,UAAU,KAAKX,UAAU,CAACM,MAAM;AACnF,CAAC;AAACE,OAAA,CAAAE,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getFontFamily = void 0;
|
|
7
|
+
var _environment = require("./environment");
|
|
8
|
+
const getRootFontFamily = () => {
|
|
9
|
+
const rootElement = document.querySelector(':root');
|
|
10
|
+
if (!rootElement) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
return window.getComputedStyle(rootElement).getPropertyValue('font-family');
|
|
14
|
+
};
|
|
15
|
+
const getFontFamily = () => `${getRootFontFamily()}${(0, _environment.getIsMobile)() || (0, _environment.getIsMacOS)() ? '' : ', Noto Color Emoji'}, serif`;
|
|
16
|
+
exports.getFontFamily = getFontFamily;
|
|
17
|
+
//# sourceMappingURL=font.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font.js","names":["_environment","require","getRootFontFamily","rootElement","document","querySelector","window","getComputedStyle","getPropertyValue","getFontFamily","getIsMobile","getIsMacOS","exports"],"sources":["../../../src/utils/font.ts"],"sourcesContent":["import { getIsMacOS, getIsMobile } from './environment';\n\nconst getRootFontFamily = () => {\n const rootElement = document.querySelector(':root');\n\n if (!rootElement) {\n return '';\n }\n\n return window.getComputedStyle(rootElement).getPropertyValue('font-family');\n};\n\nexport const getFontFamily = () =>\n `${getRootFontFamily()}${getIsMobile() || getIsMacOS() ? '' : ', Noto Color Emoji'}, serif`;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EAC5B,MAAMC,WAAW,GAAGC,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC;EAEnD,IAAI,CAACF,WAAW,EAAE;IACd,OAAO,EAAE;EACb;EAEA,OAAOG,MAAM,CAACC,gBAAgB,CAACJ,WAAW,CAAC,CAACK,gBAAgB,CAAC,aAAa,CAAC;AAC/E,CAAC;AAEM,MAAMC,aAAa,GAAGA,CAAA,KACzB,GAAGP,iBAAiB,CAAC,CAAC,GAAG,IAAAQ,wBAAW,EAAC,CAAC,IAAI,IAAAC,uBAAU,EAAC,CAAC,GAAG,EAAE,GAAG,oBAAoB,SAAS;AAACC,OAAA,CAAAH,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.replaceText = exports.insertTextAtCursorPosition = void 0;
|
|
7
|
+
var _selection = require("./selection");
|
|
8
|
+
/**
|
|
9
|
+
* This function inserts the passed text at the correct position in the editor element. If the
|
|
10
|
+
* element has the focus, the new emoji is inserted at the cursor position. If not, the emoji
|
|
11
|
+
* will be appended to the back of the input field content.
|
|
12
|
+
*
|
|
13
|
+
* In addition, this function also sets the cursor to the correct position when the input field
|
|
14
|
+
* has the focus. For this purpose, the current position of the cursor or a selection is read to
|
|
15
|
+
* calculate the cursor position after inserting the text.
|
|
16
|
+
*
|
|
17
|
+
* @param {Object} options - Object with element and text to insert
|
|
18
|
+
* @param {HTMLDivElement} options.editorElement - Element to insert text into
|
|
19
|
+
* @param {string} options.text - Text to insert into element
|
|
20
|
+
*/
|
|
21
|
+
const insertTextAtCursorPosition = ({
|
|
22
|
+
editorElement,
|
|
23
|
+
text,
|
|
24
|
+
shouldUseSavedSelection = false
|
|
25
|
+
}) => {
|
|
26
|
+
if (shouldUseSavedSelection) {
|
|
27
|
+
(0, _selection.restoreSelection)(editorElement);
|
|
28
|
+
}
|
|
29
|
+
const selection = window.getSelection();
|
|
30
|
+
(0, _selection.saveSelection)(editorElement);
|
|
31
|
+
if (selection !== null && selection !== void 0 && selection.anchorNode && editorElement.contains(selection.anchorNode)) {
|
|
32
|
+
let range = selection.getRangeAt(0);
|
|
33
|
+
const parts = text.split(/\r\n|\r|\n/);
|
|
34
|
+
const firstPart = parts.shift();
|
|
35
|
+
const textNodes = parts.map(part => document.createTextNode(part));
|
|
36
|
+
range.deleteContents();
|
|
37
|
+
if (firstPart) {
|
|
38
|
+
if (selection.anchorNode.nodeType === Node.TEXT_NODE) {
|
|
39
|
+
const {
|
|
40
|
+
nodeValue
|
|
41
|
+
} = selection.anchorNode;
|
|
42
|
+
if (typeof nodeValue === 'string') {
|
|
43
|
+
selection.anchorNode.nodeValue = nodeValue.slice(0, range.startOffset) + firstPart + nodeValue.slice(range.startOffset);
|
|
44
|
+
(0, _selection.moveSelectionOffset)(firstPart.length);
|
|
45
|
+
}
|
|
46
|
+
} else if (selection.anchorNode === editorElement) {
|
|
47
|
+
const textNode = document.createTextNode(firstPart);
|
|
48
|
+
|
|
49
|
+
// Inserts the text node before the node at the anchor offset.
|
|
50
|
+
// If that node doesn't exist, the text node is appended to the editor, as a fallback. I'm not sure if there is any case where this would happen.
|
|
51
|
+
const insertBefore = editorElement.childNodes[selection.anchorOffset];
|
|
52
|
+
if (insertBefore) {
|
|
53
|
+
insertBefore.before(textNode);
|
|
54
|
+
} else {
|
|
55
|
+
editorElement.appendChild(textNode);
|
|
56
|
+
}
|
|
57
|
+
const textNodeIndex = Array.from(editorElement.childNodes).indexOf(textNode);
|
|
58
|
+
(0, _selection.moveSelectionOffset)(firstPart.length);
|
|
59
|
+
(0, _selection.setChildIndex)(textNodeIndex);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
(0, _selection.restoreSelection)(editorElement);
|
|
63
|
+
if (textNodes.length > 0) {
|
|
64
|
+
range = selection.getRangeAt(0);
|
|
65
|
+
let brElement = document.createElement('br');
|
|
66
|
+
range.insertNode(brElement);
|
|
67
|
+
range.setEndAfter(brElement);
|
|
68
|
+
range.setStartAfter(brElement);
|
|
69
|
+
textNodes.forEach((textNode, index) => {
|
|
70
|
+
range.insertNode(textNode);
|
|
71
|
+
range.setEndAfter(textNode);
|
|
72
|
+
range.setStartAfter(textNode);
|
|
73
|
+
if (index !== textNodes.length - 1) {
|
|
74
|
+
brElement = document.createElement('br');
|
|
75
|
+
range.insertNode(brElement);
|
|
76
|
+
range.setEndAfter(brElement);
|
|
77
|
+
range.setStartAfter(brElement);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
range.collapse(false);
|
|
81
|
+
selection.removeAllRanges();
|
|
82
|
+
selection.addRange(range);
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
// eslint-disable-next-line no-param-reassign
|
|
86
|
+
editorElement.innerText += text;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
exports.insertTextAtCursorPosition = insertTextAtCursorPosition;
|
|
90
|
+
const replaceText = ({
|
|
91
|
+
editorElement,
|
|
92
|
+
searchText,
|
|
93
|
+
pasteText
|
|
94
|
+
}) => {
|
|
95
|
+
const selection = window.getSelection();
|
|
96
|
+
const rangeToReplace = (0, _selection.findAndSelectText)({
|
|
97
|
+
editorElement,
|
|
98
|
+
searchText
|
|
99
|
+
});
|
|
100
|
+
if (rangeToReplace && selection) {
|
|
101
|
+
selection.removeAllRanges();
|
|
102
|
+
selection.addRange(rangeToReplace);
|
|
103
|
+
insertTextAtCursorPosition({
|
|
104
|
+
editorElement,
|
|
105
|
+
text: pasteText
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
exports.replaceText = replaceText;
|
|
110
|
+
//# sourceMappingURL=insert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert.js","names":["_selection","require","insertTextAtCursorPosition","editorElement","text","shouldUseSavedSelection","restoreSelection","selection","window","getSelection","saveSelection","anchorNode","contains","range","getRangeAt","parts","split","firstPart","shift","textNodes","map","part","document","createTextNode","deleteContents","nodeType","Node","TEXT_NODE","nodeValue","slice","startOffset","moveSelectionOffset","length","textNode","insertBefore","childNodes","anchorOffset","before","appendChild","textNodeIndex","Array","from","indexOf","setChildIndex","brElement","createElement","insertNode","setEndAfter","setStartAfter","forEach","index","collapse","removeAllRanges","addRange","innerText","exports","replaceText","searchText","pasteText","rangeToReplace","findAndSelectText"],"sources":["../../../src/utils/insert.ts"],"sourcesContent":["import {\n findAndSelectText,\n moveSelectionOffset,\n restoreSelection,\n saveSelection,\n setChildIndex,\n} from './selection';\n\ninterface InsertTextAtCursorPositionOptions {\n editorElement: HTMLDivElement;\n text: string;\n shouldUseSavedSelection?: boolean;\n}\n\n/**\n * This function inserts the passed text at the correct position in the editor element. If the\n * element has the focus, the new emoji is inserted at the cursor position. If not, the emoji\n * will be appended to the back of the input field content.\n *\n * In addition, this function also sets the cursor to the correct position when the input field\n * has the focus. For this purpose, the current position of the cursor or a selection is read to\n * calculate the cursor position after inserting the text.\n *\n * @param {Object} options - Object with element and text to insert\n * @param {HTMLDivElement} options.editorElement - Element to insert text into\n * @param {string} options.text - Text to insert into element\n */\nexport const insertTextAtCursorPosition = ({\n editorElement,\n text,\n shouldUseSavedSelection = false,\n}: InsertTextAtCursorPositionOptions) => {\n if (shouldUseSavedSelection) {\n restoreSelection(editorElement);\n }\n\n const selection = window.getSelection();\n\n saveSelection(editorElement);\n\n if (selection?.anchorNode && editorElement.contains(selection.anchorNode)) {\n let range = selection.getRangeAt(0);\n\n const parts = text.split(/\\r\\n|\\r|\\n/);\n\n const firstPart = parts.shift();\n\n const textNodes = parts.map((part) => document.createTextNode(part));\n\n range.deleteContents();\n\n if (firstPart) {\n if (selection.anchorNode.nodeType === Node.TEXT_NODE) {\n const { nodeValue } = selection.anchorNode;\n\n if (typeof nodeValue === 'string') {\n selection.anchorNode.nodeValue =\n nodeValue.slice(0, range.startOffset) +\n firstPart +\n nodeValue.slice(range.startOffset);\n\n moveSelectionOffset(firstPart.length);\n }\n } else if (selection.anchorNode === editorElement) {\n const textNode = document.createTextNode(firstPart);\n\n // Inserts the text node before the node at the anchor offset.\n // If that node doesn't exist, the text node is appended to the editor, as a fallback. I'm not sure if there is any case where this would happen.\n const insertBefore = editorElement.childNodes[selection.anchorOffset];\n if (insertBefore) {\n insertBefore.before(textNode);\n } else {\n editorElement.appendChild(textNode);\n }\n\n const textNodeIndex = Array.from(editorElement.childNodes).indexOf(textNode);\n\n moveSelectionOffset(firstPart.length);\n setChildIndex(textNodeIndex);\n }\n }\n\n restoreSelection(editorElement);\n\n if (textNodes.length > 0) {\n range = selection.getRangeAt(0);\n\n let brElement = document.createElement('br');\n\n range.insertNode(brElement);\n range.setEndAfter(brElement);\n range.setStartAfter(brElement);\n\n textNodes.forEach((textNode, index) => {\n range.insertNode(textNode);\n range.setEndAfter(textNode);\n range.setStartAfter(textNode);\n\n if (index !== textNodes.length - 1) {\n brElement = document.createElement('br');\n\n range.insertNode(brElement);\n range.setEndAfter(brElement);\n range.setStartAfter(brElement);\n }\n });\n\n range.collapse(false);\n\n selection.removeAllRanges();\n selection.addRange(range);\n }\n } else {\n // eslint-disable-next-line no-param-reassign\n editorElement.innerText += text;\n }\n};\n\nexport interface ReplaceTextOptions {\n editorElement: HTMLDivElement;\n searchText: string;\n pasteText: string;\n}\n\nexport const replaceText = ({ editorElement, searchText, pasteText }: ReplaceTextOptions) => {\n const selection = window.getSelection();\n\n const rangeToReplace = findAndSelectText({ editorElement, searchText });\n\n if (rangeToReplace && selection) {\n selection.removeAllRanges();\n selection.addRange(rangeToReplace);\n\n insertTextAtCursorPosition({ editorElement, text: pasteText });\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,0BAA0B,GAAGA,CAAC;EACvCC,aAAa;EACbC,IAAI;EACJC,uBAAuB,GAAG;AACK,CAAC,KAAK;EACrC,IAAIA,uBAAuB,EAAE;IACzB,IAAAC,2BAAgB,EAACH,aAAa,CAAC;EACnC;EAEA,MAAMI,SAAS,GAAGC,MAAM,CAACC,YAAY,CAAC,CAAC;EAEvC,IAAAC,wBAAa,EAACP,aAAa,CAAC;EAE5B,IAAII,SAAS,aAATA,SAAS,eAATA,SAAS,CAAEI,UAAU,IAAIR,aAAa,CAACS,QAAQ,CAACL,SAAS,CAACI,UAAU,CAAC,EAAE;IACvE,IAAIE,KAAK,GAAGN,SAAS,CAACO,UAAU,CAAC,CAAC,CAAC;IAEnC,MAAMC,KAAK,GAAGX,IAAI,CAACY,KAAK,CAAC,YAAY,CAAC;IAEtC,MAAMC,SAAS,GAAGF,KAAK,CAACG,KAAK,CAAC,CAAC;IAE/B,MAAMC,SAAS,GAAGJ,KAAK,CAACK,GAAG,CAAEC,IAAI,IAAKC,QAAQ,CAACC,cAAc,CAACF,IAAI,CAAC,CAAC;IAEpER,KAAK,CAACW,cAAc,CAAC,CAAC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e,CAAC,CAAC;IAC3B7C,SAAS,CAAC8C,QAAQ,CAACM,cAAc,CAAC;IAElCzD,0BAA0B,CAAC;MAAEC,aAAa;MAAEC,IAAI,EAAEsD;IAAU,CAAC,CAAC;EAClE;AACJ,CAAC;AAACH,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.clamp = void 0;
|
|
7
|
+
const clamp = (value, min, max) => {
|
|
8
|
+
if (value < min) {
|
|
9
|
+
return min;
|
|
10
|
+
}
|
|
11
|
+
if (value > max) {
|
|
12
|
+
return max;
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
};
|
|
16
|
+
exports.clamp = clamp;
|
|
17
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.js","names":["clamp","value","min","max","exports"],"sources":["../../../src/utils/number.ts"],"sourcesContent":["export const clamp = (value: number, min: number, max: number) => {\n if (value < min) {\n return min;\n }\n\n if (value > max) {\n return max;\n }\n\n return value;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,KAAK,GAAGA,CAACC,KAAa,EAAEC,GAAW,EAAEC,GAAW,KAAK;EAC9D,IAAIF,KAAK,GAAGC,GAAG,EAAE;IACb,OAAOA,GAAG;EACd;EAEA,IAAID,KAAK,GAAGE,GAAG,EAAE;IACb,OAAOA,GAAG;EACd;EAEA,OAAOF,KAAK;AAChB,CAAC;AAACG,OAAA,CAAAJ,KAAA,GAAAA,KAAA","ignoreList":[]}
|