@chayns-components/emoji-input 5.0.0-beta.112 → 5.0.0-beta.1122
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 +536 -0
- package/lib/cjs/components/emoji-input/EmojiInput.js.map +1 -0
- package/lib/cjs/components/emoji-input/EmojiInput.styles.js +131 -0
- package/lib/cjs/components/emoji-input/EmojiInput.styles.js.map +1 -0
- package/lib/cjs/components/emoji-input/prefix-element/PrefixElement.js +44 -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 +64 -0
- package/lib/cjs/components/emoji-input/prefix-element/PrefixElement.styles.js.map +1 -0
- package/lib/{components → cjs/components}/emoji-picker/EmojiPicker.js +8 -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 +101 -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 +4 -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 +239 -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 +66 -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 +60 -33
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +1 -0
- package/lib/{components → cjs/components}/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +6 -3
- 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 +129 -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 +98 -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 +51 -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 +2 -4
- 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/{constants → cjs/constants}/emoji.js +4 -8
- 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} +1 -1
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/types/api.js.map +1 -0
- package/lib/cjs/types/category.js.map +1 -0
- package/lib/{utils → cjs/utils}/emoji.js +14 -6
- package/lib/cjs/utils/emoji.js.map +1 -0
- package/lib/cjs/utils/environment.js.map +1 -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 +281 -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 +518 -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 +74 -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} +1 -0
- 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 +263 -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 +96 -0
- package/lib/types/components/emoji-input/EmojiInput.styles.d.ts +26 -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 +6 -0
- package/lib/types/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.d.ts +9 -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 +22 -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/regex.d.ts +8 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/{utils → types/utils}/emoji.d.ts +2 -0
- package/lib/{utils → types/utils}/insert.d.ts +8 -1
- 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 +49 -31
- 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 -53
- package/lib/components/emoji-input/EmojiInput.js +0 -159
- package/lib/components/emoji-input/EmojiInput.js.map +0 -1
- package/lib/components/emoji-input/EmojiInput.styles.d.ts +0 -13
- package/lib/components/emoji-input/EmojiInput.styles.js +0 -145
- 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.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/emoji.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.map +0 -1
- package/lib/types/category.js.map +0 -1
- package/lib/utils/emoji.js.map +0 -1
- package/lib/utils/environment.js.map +0 -1
- package/lib/utils/font.js.map +0 -1
- package/lib/utils/insert.js +0 -50
- package/lib/utils/insert.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/{types → cjs/types}/api.js +0 -0
- /package/lib/{types → cjs/types}/category.js +0 -0
- /package/lib/{utils → cjs/utils}/environment.js +0 -0
- /package/lib/{utils → cjs/utils}/font.js +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}/emoji.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
- /package/lib/{utils → types/utils}/environment.d.ts +0 -0
- /package/lib/{utils → types/utils}/font.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: historyEmojis.slice(0, 25) };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,M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,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":[]}
|
|
@@ -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":[]}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.convertEmojisToUnicode = exports.addSkinToneToEmoji = void 0;
|
|
6
|
+
exports.unescapeHTML = exports.escapeHTML = exports.convertEmojisToUnicode = exports.addSkinToneToEmoji = void 0;
|
|
7
7
|
var _dataByEmoji = _interopRequireDefault(require("unicode-emoji-json/data-by-emoji.json"));
|
|
8
8
|
var _emoji = require("../constants/emoji");
|
|
9
|
-
function _interopRequireDefault(
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
const convert = unicode => {
|
|
11
11
|
if (unicode.indexOf('-') > -1) {
|
|
12
12
|
const parts = [];
|
|
@@ -51,11 +51,19 @@ const unescapeHTML = text => {
|
|
|
51
51
|
''': "'",
|
|
52
52
|
''': "'"
|
|
53
53
|
};
|
|
54
|
-
return text.replace(/&(?:amp|#38|#x26|lt|#60|#x3C|gt|#62|#x3E|apos|#39|#x27|quot|#34|#x22);/gi, match =>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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);
|
|
58
65
|
};
|
|
66
|
+
exports.escapeHTML = escapeHTML;
|
|
59
67
|
const convertEmojisToUnicode = text => {
|
|
60
68
|
let result = text;
|
|
61
69
|
result = result.replace(/https?:\/\/.*?(?=$|\s)/gi, fullMatch => fullMatch.replace(/:/g, '%3A'));
|
|
@@ -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,MAAM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IACzD,IAAI,OAAOA,EAAE,KAAK,QAAQ,IAAIA,EAAE,KAAK,EAAE,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":[]}
|
|
@@ -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 @@
|
|
|
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;IAEtB,IAAIP,SAAS,EAAE;MACX,IAAIV,SAAS,CAACI,UAAU,CAACc,QAAQ,KAAKC,IAAI,CAACC,SAAS,EAA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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":[]}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setChildIndex = exports.saveSelection = exports.restoreSelection = exports.moveSelectionOffset = exports.insertInvisibleCursorMarker = exports.getCharCodeThatWillBeDeleted = exports.findAndSelectText = void 0;
|
|
7
|
+
var _number = require("./number");
|
|
8
|
+
var _text = require("./text");
|
|
9
|
+
let childIndex = -1;
|
|
10
|
+
let endOffset = -1;
|
|
11
|
+
let startOffset = -1;
|
|
12
|
+
const saveSelection = (element, {
|
|
13
|
+
shouldIgnoreEmptyTextNodes
|
|
14
|
+
} = {}) => {
|
|
15
|
+
const selection = window.getSelection();
|
|
16
|
+
if (!selection) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const {
|
|
20
|
+
anchorNode
|
|
21
|
+
} = selection;
|
|
22
|
+
if (!anchorNode) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const range = selection.getRangeAt(0);
|
|
26
|
+
let childNodesArray = Array.from(element.childNodes);
|
|
27
|
+
if (shouldIgnoreEmptyTextNodes) {
|
|
28
|
+
childNodesArray = childNodesArray.filter(({
|
|
29
|
+
nodeType,
|
|
30
|
+
nodeValue
|
|
31
|
+
}) => nodeType !== Node.TEXT_NODE || nodeValue !== '' && nodeValue !== '\u200B');
|
|
32
|
+
}
|
|
33
|
+
childIndex = childNodesArray.indexOf(anchorNode);
|
|
34
|
+
endOffset = range.endOffset;
|
|
35
|
+
startOffset = range.startOffset;
|
|
36
|
+
};
|
|
37
|
+
exports.saveSelection = saveSelection;
|
|
38
|
+
const restoreSelection = element => {
|
|
39
|
+
// Search for \u200C in child nodes. If found, set the childIndex, startOffset, and endOffset to the
|
|
40
|
+
// position of the \u200C character. Also remove the \u200C character from the child node. If not found,
|
|
41
|
+
// the childIndex, startOffset, and endOffset will be like before.
|
|
42
|
+
const childNodesArray = Array.from(element.childNodes);
|
|
43
|
+
let hasFoundNoJoiner = false;
|
|
44
|
+
childNodesArray.forEach(node => {
|
|
45
|
+
if (!hasFoundNoJoiner && node.nodeType === Node.TEXT_NODE && typeof node.nodeValue === 'string') {
|
|
46
|
+
const noJoinerIndex = node.nodeValue.indexOf('\u200C');
|
|
47
|
+
if (noJoinerIndex !== -1) {
|
|
48
|
+
hasFoundNoJoiner = true;
|
|
49
|
+
childIndex = childNodesArray.indexOf(node);
|
|
50
|
+
startOffset = noJoinerIndex;
|
|
51
|
+
endOffset = noJoinerIndex;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Remove all no joiner characters from the child nodes if no joiner was found
|
|
57
|
+
if (hasFoundNoJoiner) {
|
|
58
|
+
childNodesArray.forEach(node => {
|
|
59
|
+
if (node.nodeType === Node.TEXT_NODE && typeof node.nodeValue === 'string') {
|
|
60
|
+
// eslint-disable-next-line no-param-reassign
|
|
61
|
+
node.nodeValue = node.nodeValue.replace(/\u200C/g, '');
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
let childNode = element.childNodes[childIndex];
|
|
66
|
+
const selection = window.getSelection();
|
|
67
|
+
if (!childNode || !element || !selection) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// noinspection SuspiciousTypeOfGuard
|
|
72
|
+
if (typeof childNode.nodeValue !== 'string') {
|
|
73
|
+
const elementTextLength = (0, _text.getElementTextLength)(childNode);
|
|
74
|
+
if (childNode.nextSibling) {
|
|
75
|
+
childNode = childNode.nextSibling;
|
|
76
|
+
if (childNode.nodeType === Node.TEXT_NODE && childNode.nodeValue) {
|
|
77
|
+
endOffset -= elementTextLength;
|
|
78
|
+
startOffset -= elementTextLength;
|
|
79
|
+
if (childNode.nodeValue.charCodeAt(endOffset) === 8203) {
|
|
80
|
+
endOffset += 1;
|
|
81
|
+
startOffset += 1;
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
var _childNode$parentNode;
|
|
85
|
+
const textNode = document.createTextNode('\u200B');
|
|
86
|
+
(_childNode$parentNode = childNode.parentNode) === null || _childNode$parentNode === void 0 || _childNode$parentNode.insertBefore(textNode, childNode.nextSibling);
|
|
87
|
+
childNode = textNode;
|
|
88
|
+
endOffset = textNode.length;
|
|
89
|
+
startOffset = textNode.length;
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
var _childNode$parentNode2;
|
|
93
|
+
const textNode = document.createTextNode('\u200B');
|
|
94
|
+
(_childNode$parentNode2 = childNode.parentNode) === null || _childNode$parentNode2 === void 0 || _childNode$parentNode2.insertBefore(textNode, childNode.nextSibling);
|
|
95
|
+
childNode = textNode;
|
|
96
|
+
endOffset = textNode.length;
|
|
97
|
+
startOffset = textNode.length;
|
|
98
|
+
}
|
|
99
|
+
} else if (childNode.nodeValue && endOffset > childNode.nodeValue.length) {
|
|
100
|
+
var _childNode$nextSiblin;
|
|
101
|
+
if ((_childNode$nextSiblin = childNode.nextSibling) !== null && _childNode$nextSiblin !== void 0 && _childNode$nextSiblin.nodeValue) {
|
|
102
|
+
let elementTextLength = childNode.nodeValue.length;
|
|
103
|
+
childNode = childNode.nextSibling;
|
|
104
|
+
|
|
105
|
+
// noinspection SuspiciousTypeOfGuard
|
|
106
|
+
if (typeof childNode.nodeValue !== 'string') {
|
|
107
|
+
var _childNode$nextSiblin2;
|
|
108
|
+
elementTextLength += (0, _text.getElementTextLength)(childNode);
|
|
109
|
+
if ((_childNode$nextSiblin2 = childNode.nextSibling) !== null && _childNode$nextSiblin2 !== void 0 && _childNode$nextSiblin2.nodeValue) {
|
|
110
|
+
childNode = childNode.nextSibling;
|
|
111
|
+
if (childNode.nodeType === Node.TEXT_NODE && childNode.nodeValue) {
|
|
112
|
+
endOffset -= elementTextLength;
|
|
113
|
+
startOffset -= elementTextLength;
|
|
114
|
+
if (childNode.nodeValue.charCodeAt(endOffset) === 8203) {
|
|
115
|
+
endOffset += 1;
|
|
116
|
+
startOffset += 1;
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
var _childNode$parentNode3;
|
|
120
|
+
const textNode = document.createTextNode('\u200B');
|
|
121
|
+
(_childNode$parentNode3 = childNode.parentNode) === null || _childNode$parentNode3 === void 0 || _childNode$parentNode3.insertBefore(textNode, childNode.nextSibling);
|
|
122
|
+
childNode = textNode;
|
|
123
|
+
endOffset = textNode.length;
|
|
124
|
+
startOffset = textNode.length;
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
var _childNode$parentNode4;
|
|
128
|
+
const textNode = document.createTextNode('\u200B');
|
|
129
|
+
(_childNode$parentNode4 = childNode.parentNode) === null || _childNode$parentNode4 === void 0 || _childNode$parentNode4.insertBefore(textNode, childNode.nextSibling);
|
|
130
|
+
childNode = textNode;
|
|
131
|
+
endOffset = textNode.length;
|
|
132
|
+
startOffset = textNode.length;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
endOffset = childNode.nodeValue.length;
|
|
137
|
+
startOffset = childNode.nodeValue.length;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const range = document.createRange();
|
|
141
|
+
|
|
142
|
+
// noinspection SuspiciousTypeOfGuard
|
|
143
|
+
if (typeof childNode.nodeValue === 'string') {
|
|
144
|
+
startOffset = (0, _number.clamp)(startOffset, 0, childNode.nodeValue.length);
|
|
145
|
+
endOffset = (0, _number.clamp)(endOffset, 0, childNode.nodeValue.length);
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
range.setStart(childNode, startOffset);
|
|
149
|
+
range.setEnd(childNode, endOffset);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
// Do nothing
|
|
152
|
+
}
|
|
153
|
+
selection.removeAllRanges();
|
|
154
|
+
selection.addRange(range);
|
|
155
|
+
range.collapse(true);
|
|
156
|
+
};
|
|
157
|
+
exports.restoreSelection = restoreSelection;
|
|
158
|
+
const insertInvisibleCursorMarker = () => {
|
|
159
|
+
const selection = window.getSelection();
|
|
160
|
+
if (!selection || selection.rangeCount === 0) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const range = selection.getRangeAt(0);
|
|
164
|
+
const textNode = range.startContainer;
|
|
165
|
+
const offset = range.startOffset;
|
|
166
|
+
|
|
167
|
+
// noinspection JSDeprecatedSymbols
|
|
168
|
+
document.execCommand('delete', false);
|
|
169
|
+
const span = document.createElement('span');
|
|
170
|
+
span.style.display = 'inline-block';
|
|
171
|
+
span.style.width = '0';
|
|
172
|
+
span.style.height = '0';
|
|
173
|
+
span.className = 'invisible-cursor-marker';
|
|
174
|
+
const parent = textNode.parentNode;
|
|
175
|
+
if (parent) {
|
|
176
|
+
if (textNode.nodeType === Node.TEXT_NODE) {
|
|
177
|
+
const textContent = textNode.textContent || '';
|
|
178
|
+
const beforeText = textContent.slice(0, offset);
|
|
179
|
+
const afterText = textContent.slice(offset);
|
|
180
|
+
textNode.textContent = beforeText;
|
|
181
|
+
parent.insertBefore(span, textNode.nextSibling);
|
|
182
|
+
const afterTextNode = document.createTextNode(afterText);
|
|
183
|
+
parent.insertBefore(afterTextNode, span.nextSibling);
|
|
184
|
+
setTimeout(() => {
|
|
185
|
+
// Set cursor to cursor element
|
|
186
|
+
const newRange = document.createRange();
|
|
187
|
+
newRange.setStartAfter(span);
|
|
188
|
+
newRange.setEndAfter(span);
|
|
189
|
+
selection.removeAllRanges();
|
|
190
|
+
selection.addRange(newRange);
|
|
191
|
+
|
|
192
|
+
// Remove cursor element
|
|
193
|
+
span.remove();
|
|
194
|
+
}, 10);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
exports.insertInvisibleCursorMarker = insertInvisibleCursorMarker;
|
|
199
|
+
const moveSelectionOffset = distance => {
|
|
200
|
+
endOffset += distance;
|
|
201
|
+
startOffset += distance;
|
|
202
|
+
};
|
|
203
|
+
exports.moveSelectionOffset = moveSelectionOffset;
|
|
204
|
+
const setChildIndex = index => {
|
|
205
|
+
childIndex = index;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* This function returns the code of the character that will be removed by the KeyDown event in the
|
|
210
|
+
* next step, if the "Backspace" or "Delete" key was pressed and there is no selection of multiple
|
|
211
|
+
* characters.
|
|
212
|
+
*
|
|
213
|
+
* @param event - Keyboard event from "onKeyDown"
|
|
214
|
+
*/
|
|
215
|
+
exports.setChildIndex = setChildIndex;
|
|
216
|
+
const getCharCodeThatWillBeDeleted = event => {
|
|
217
|
+
var _window$getSelection, _nextSibling$nodeValu;
|
|
218
|
+
const range = (_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.getRangeAt(0);
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* At this point the function is aborted if there is no selection range, several characters have
|
|
222
|
+
* been selected and therefore no single letter is removed or neither the "Backspace" nor the
|
|
223
|
+
* "Delete" key has been pressed.
|
|
224
|
+
*/
|
|
225
|
+
if (!range || range.endOffset !== range.startOffset || event.key !== 'Backspace' && event.key !== 'Delete' && event.key !== 'Unidentified') {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
if (event.key === 'Backspace' || event.key === 'Unidentified') {
|
|
229
|
+
var _previousSibling$node;
|
|
230
|
+
const {
|
|
231
|
+
nodeValue,
|
|
232
|
+
previousSibling
|
|
233
|
+
} = range.startContainer;
|
|
234
|
+
if (range.startOffset > 0) {
|
|
235
|
+
return nodeValue === null || nodeValue === void 0 ? void 0 : nodeValue.charCodeAt(range.startOffset - 1);
|
|
236
|
+
}
|
|
237
|
+
return previousSibling === null || previousSibling === void 0 || (_previousSibling$node = previousSibling.nodeValue) === null || _previousSibling$node === void 0 ? void 0 : _previousSibling$node.charCodeAt(previousSibling.nodeValue.length - 1);
|
|
238
|
+
}
|
|
239
|
+
const {
|
|
240
|
+
nextSibling,
|
|
241
|
+
nodeValue
|
|
242
|
+
} = range.endContainer;
|
|
243
|
+
if (range.endOffset < ((nodeValue === null || nodeValue === void 0 ? void 0 : nodeValue.length) ?? 0)) {
|
|
244
|
+
return nodeValue === null || nodeValue === void 0 ? void 0 : nodeValue.charCodeAt(range.endOffset);
|
|
245
|
+
}
|
|
246
|
+
return nextSibling === null || nextSibling === void 0 || (_nextSibling$nodeValu = nextSibling.nodeValue) === null || _nextSibling$nodeValu === void 0 ? void 0 : _nextSibling$nodeValu.charCodeAt(0);
|
|
247
|
+
};
|
|
248
|
+
exports.getCharCodeThatWillBeDeleted = getCharCodeThatWillBeDeleted;
|
|
249
|
+
const findAndSelectText = ({
|
|
250
|
+
editorElement,
|
|
251
|
+
searchText
|
|
252
|
+
}) => {
|
|
253
|
+
var _editorElement$textCo;
|
|
254
|
+
if (!((_editorElement$textCo = editorElement.textContent) !== null && _editorElement$textCo !== void 0 && _editorElement$textCo.includes(searchText))) {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
const range = document.createRange();
|
|
258
|
+
let startNode = null;
|
|
259
|
+
let offset = -1;
|
|
260
|
+
const searchNodesForText = node => {
|
|
261
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
262
|
+
var _node$textContent;
|
|
263
|
+
const index = (_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.indexOf(searchText);
|
|
264
|
+
if (typeof index === 'number' && index !== -1) {
|
|
265
|
+
startNode = node;
|
|
266
|
+
offset = index;
|
|
267
|
+
range.setStart(node, index);
|
|
268
|
+
range.setEnd(node, index + searchText.length);
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
} else if (node.nodeName !== 'LC_MENTION') {
|
|
272
|
+
return Array.from(node.childNodes).some(searchNodesForText);
|
|
273
|
+
}
|
|
274
|
+
return false;
|
|
275
|
+
};
|
|
276
|
+
searchNodesForText(editorElement);
|
|
277
|
+
if (startNode && offset !== -1) return range;
|
|
278
|
+
return null;
|
|
279
|
+
};
|
|
280
|
+
exports.findAndSelectText = findAndSelectText;
|
|
281
|
+
//# sourceMappingURL=selection.js.map
|