@chayns-components/emoji-input 5.0.0-beta.100

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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -0
  3. package/lib/api/item-storage/get.d.ts +8 -0
  4. package/lib/api/item-storage/get.js +37 -0
  5. package/lib/api/item-storage/get.js.map +1 -0
  6. package/lib/api/item-storage/put.d.ts +9 -0
  7. package/lib/api/item-storage/put.js +42 -0
  8. package/lib/api/item-storage/put.js.map +1 -0
  9. package/lib/components/emoji-input/EmojiInput.d.ts +49 -0
  10. package/lib/components/emoji-input/EmojiInput.js +157 -0
  11. package/lib/components/emoji-input/EmojiInput.js.map +1 -0
  12. package/lib/components/emoji-input/EmojiInput.styles.d.ts +13 -0
  13. package/lib/components/emoji-input/EmojiInput.styles.js +145 -0
  14. package/lib/components/emoji-input/EmojiInput.styles.js.map +1 -0
  15. package/lib/components/emoji-picker/EmojiPicker.d.ts +18 -0
  16. package/lib/components/emoji-picker/EmojiPicker.js +51 -0
  17. package/lib/components/emoji-picker/EmojiPicker.js.map +1 -0
  18. package/lib/components/emoji-picker/EmojiPicker.styles.d.ts +5 -0
  19. package/lib/components/emoji-picker/EmojiPicker.styles.js +25 -0
  20. package/lib/components/emoji-picker/EmojiPicker.styles.js.map +1 -0
  21. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.d.ts +9 -0
  22. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js +51 -0
  23. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js.map +1 -0
  24. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.d.ts +2 -0
  25. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js +27 -0
  26. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js.map +1 -0
  27. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.d.ts +11 -0
  28. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js +131 -0
  29. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js.map +1 -0
  30. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.d.ts +7 -0
  31. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js +99 -0
  32. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js.map +1 -0
  33. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.d.ts +9 -0
  34. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js +116 -0
  35. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +1 -0
  36. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.d.ts +1 -0
  37. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +21 -0
  38. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js.map +1 -0
  39. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.d.ts +18 -0
  40. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js +74 -0
  41. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +1 -0
  42. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.d.ts +11 -0
  43. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +104 -0
  44. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js.map +1 -0
  45. package/lib/components/emoji-picker-popup/EmojiPickerPopup.d.ts +36 -0
  46. package/lib/components/emoji-picker-popup/EmojiPickerPopup.js +150 -0
  47. package/lib/components/emoji-picker-popup/EmojiPickerPopup.js.map +1 -0
  48. package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.d.ts +7 -0
  49. package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.js +97 -0
  50. package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.js.map +1 -0
  51. package/lib/constants/alignment.d.ts +10 -0
  52. package/lib/constants/alignment.js +21 -0
  53. package/lib/constants/alignment.js.map +1 -0
  54. package/lib/constants/categories.d.ts +12 -0
  55. package/lib/constants/categories.js +20 -0
  56. package/lib/constants/categories.js.map +1 -0
  57. package/lib/constants/emoji-de-DE.json +3827 -0
  58. package/lib/constants/emoji.d.ts +8 -0
  59. package/lib/constants/emoji.js +3808 -0
  60. package/lib/constants/emoji.js.map +1 -0
  61. package/lib/constants/externalServerUrl.d.ts +1 -0
  62. package/lib/constants/externalServerUrl.js +9 -0
  63. package/lib/constants/externalServerUrl.js.map +1 -0
  64. package/lib/hooks/emojiHistory.d.ts +22 -0
  65. package/lib/hooks/emojiHistory.js +91 -0
  66. package/lib/hooks/emojiHistory.js.map +1 -0
  67. package/lib/index.d.ts +5 -0
  68. package/lib/index.js +42 -0
  69. package/lib/index.js.map +1 -0
  70. package/lib/types/api.d.ts +4 -0
  71. package/lib/types/api.js +6 -0
  72. package/lib/types/api.js.map +1 -0
  73. package/lib/types/category.d.ts +1 -0
  74. package/lib/types/category.js +6 -0
  75. package/lib/types/category.js.map +1 -0
  76. package/lib/utils/emoji.d.ts +2 -0
  77. package/lib/utils/emoji.js +96 -0
  78. package/lib/utils/emoji.js.map +1 -0
  79. package/lib/utils/environment.d.ts +9 -0
  80. package/lib/utils/environment.js +33 -0
  81. package/lib/utils/environment.js.map +1 -0
  82. package/lib/utils/font.d.ts +1 -0
  83. package/lib/utils/font.js +17 -0
  84. package/lib/utils/font.js.map +1 -0
  85. package/lib/utils/insert.d.ts +19 -0
  86. package/lib/utils/insert.js +50 -0
  87. package/lib/utils/insert.js.map +1 -0
  88. package/lib/utils/selection.d.ts +2 -0
  89. package/lib/utils/selection.js +43 -0
  90. package/lib/utils/selection.js.map +1 -0
  91. package/package.json +72 -0
@@ -0,0 +1 @@
1
+ export declare const ITEM_STORAGE_BASE_URL = "https://cube.tobit.cloud/item-storage/api/v1.0/schemes";
@@ -0,0 +1,9 @@
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 = 'https://cube.tobit.cloud/item-storage/api/v1.0/schemes';
8
+ exports.ITEM_STORAGE_BASE_URL = ITEM_STORAGE_BASE_URL;
9
+ //# 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,GAAG,wDAAwD;AAACC,OAAA,CAAAD,qBAAA,GAAAA,qBAAA"}
@@ -0,0 +1,22 @@
1
+ import type { Category } from '../types/category';
2
+ export interface HistoryItem {
3
+ count: number;
4
+ emoji: string;
5
+ modifiedTime: string;
6
+ name: string;
7
+ skin_tone_support: boolean;
8
+ }
9
+ interface UseEmojiHistoryOptions {
10
+ accessToken?: string;
11
+ personId?: string;
12
+ selectedCategory: Category;
13
+ }
14
+ export declare const useEmojiHistory: ({ accessToken, personId, selectedCategory, }: UseEmojiHistoryOptions) => {
15
+ addOrUpdateEmojiInHistory: ({ emoji, name, skin_tone_support, }: {
16
+ emoji: string;
17
+ name: string;
18
+ skin_tone_support: boolean;
19
+ }) => Promise<void>;
20
+ historyEmojis: HistoryItem[];
21
+ };
22
+ export {};
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useEmojiHistory = void 0;
7
+ var _react = require("react");
8
+ var _get = require("../api/item-storage/get");
9
+ var _put = require("../api/item-storage/put");
10
+ const useEmojiHistory = _ref => {
11
+ let {
12
+ accessToken,
13
+ personId,
14
+ selectedCategory
15
+ } = _ref;
16
+ const [historyEmojis, setHistoryEmojis] = (0, _react.useState)([]);
17
+ const tempHistoryEmojis = (0, _react.useRef)(null);
18
+ const addOrUpdateEmojiInHistory = (0, _react.useCallback)(async _ref2 => {
19
+ var _tempHistoryEmojis$cu, _historyItem$count, _historyItem;
20
+ let {
21
+ emoji,
22
+ name,
23
+ skin_tone_support
24
+ } = _ref2;
25
+ if (typeof accessToken !== 'string' || typeof personId !== 'string') {
26
+ return;
27
+ }
28
+ const newHistoryEmojis = Array.from((_tempHistoryEmojis$cu = tempHistoryEmojis.current) !== null && _tempHistoryEmojis$cu !== void 0 ? _tempHistoryEmojis$cu : historyEmojis);
29
+ const historyItemIndex = newHistoryEmojis.findIndex(item => item.emoji === emoji);
30
+ let historyItem;
31
+ if (historyItemIndex > -1) {
32
+ [historyItem] = newHistoryEmojis.splice(historyItemIndex, 1);
33
+ }
34
+ newHistoryEmojis.push({
35
+ count: ((_historyItem$count = (_historyItem = historyItem) === null || _historyItem === void 0 ? void 0 : _historyItem.count) !== null && _historyItem$count !== void 0 ? _historyItem$count : 0) + 1,
36
+ emoji,
37
+ modifiedTime: new Date().toISOString(),
38
+ name,
39
+ skin_tone_support
40
+ });
41
+ newHistoryEmojis.sort((a, b) => {
42
+ if (a.count === b.count) {
43
+ return new Date(b.modifiedTime).getTime() - new Date(a.modifiedTime).getTime();
44
+ }
45
+ return b.count - a.count;
46
+ });
47
+ const {
48
+ data
49
+ } = await (0, _put.putEmojiHistory)({
50
+ accessToken,
51
+ personId,
52
+ value: newHistoryEmojis.slice(0, 50)
53
+ });
54
+ if (data) {
55
+ if (selectedCategory === 'history') {
56
+ tempHistoryEmojis.current = data;
57
+ } else {
58
+ tempHistoryEmojis.current = null;
59
+ setHistoryEmojis(data);
60
+ }
61
+ }
62
+ }, [accessToken, historyEmojis, personId, selectedCategory]);
63
+ const loadHistoryEmojis = (0, _react.useCallback)(async () => {
64
+ if (typeof accessToken !== 'string' || typeof personId !== 'string') {
65
+ return;
66
+ }
67
+ const {
68
+ data
69
+ } = await (0, _get.getEmojiHistory)({
70
+ accessToken,
71
+ personId
72
+ });
73
+ if (data) {
74
+ setHistoryEmojis(data);
75
+ }
76
+ }, [accessToken, personId]);
77
+ (0, _react.useEffect)(() => {
78
+ void loadHistoryEmojis();
79
+ }, [loadHistoryEmojis]);
80
+ (0, _react.useEffect)(() => {
81
+ if (selectedCategory !== 'history' && tempHistoryEmojis.current) {
82
+ setHistoryEmojis(tempHistoryEmojis.current);
83
+ }
84
+ }, [selectedCategory]);
85
+ return {
86
+ addOrUpdateEmojiInHistory,
87
+ historyEmojis: historyEmojis.slice(0, 25)
88
+ };
89
+ };
90
+ exports.useEmojiHistory = useEmojiHistory;
91
+ //# sourceMappingURL=emojiHistory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emojiHistory.js","names":["_react","require","_get","_put","useEmojiHistory","_ref","accessToken","personId","selectedCategory","historyEmojis","setHistoryEmojis","useState","tempHistoryEmojis","useRef","addOrUpdateEmojiInHistory","useCallback","_ref2","_tempHistoryEmojis$cu","_historyItem$count","_historyItem","emoji","name","skin_tone_support","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 }, [selectedCateg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IAAS,CAAC,CAAC;IAEjE,IAAIkC,IAAI,EAAE;MACN/B,gBAAgB,CAAC+B,IAAI,CAAC;IAC1B;EACJ,CAAC,EAAE,CAACnC,WAAW,EAAEC,QAAQ,CAAC,CAAC;EAE3B,IAAAwC,gBAAS,EAAC,MAAM;IACZ,KAAKF,iBAAiB,EAAE;EAC5B,CAAC,EAAE,CAACA,iBAAiB,CAAC,CAAC;EAEvB,IAAAE,gBAAS,EAAC,MAAM;IACZ,IAAIvC,gBAAgB,KAAK,SAAS,IAAII,iBAAiB,CAACc,OAAO,EAAE;MAC7DhB,gBAAgB,CAACE,iBAAiB,CAACc,OAAO,CAAC;IAC/C;EACJ,CAAC,EAAE,CAAClB,gBAAgB,CAAC,CAAC;EAEtB,OAAO;IAAEM,yBAAyB;IAAEL,aAAa,EAAEA,aAAa,CAACmC,KAAK,CAAC,CAAC,EAAE,EAAE;EAAE,CAAC;AACnF,CAAC;AAACI,OAAA,CAAA5C,eAAA,GAAAA,eAAA"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { default as EmojiInput } from './components/emoji-input/EmojiInput';
2
+ export { default as EmojiPickerPopup } from './components/emoji-picker-popup/EmojiPickerPopup';
3
+ export { default as EmojiPicker } from './components/emoji-picker/EmojiPicker';
4
+ export { PopupAlignment } from './constants/alignment';
5
+ export { convertEmojisToUnicode } from './utils/emoji';
package/lib/index.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "EmojiInput", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _EmojiInput.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "EmojiPicker", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _EmojiPicker.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "EmojiPickerPopup", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _EmojiPickerPopup.default;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "PopupAlignment", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _alignment.PopupAlignment;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "convertEmojisToUnicode", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _emoji.convertEmojisToUnicode;
34
+ }
35
+ });
36
+ var _EmojiInput = _interopRequireDefault(require("./components/emoji-input/EmojiInput"));
37
+ var _EmojiPickerPopup = _interopRequireDefault(require("./components/emoji-picker-popup/EmojiPickerPopup"));
38
+ var _EmojiPicker = _interopRequireDefault(require("./components/emoji-picker/EmojiPicker"));
39
+ var _alignment = require("./constants/alignment");
40
+ var _emoji = require("./utils/emoji");
41
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_EmojiInput","_interopRequireDefault","require","_EmojiPickerPopup","_EmojiPicker","_alignment","_emoji","obj","__esModule","default"],"sources":["../src/index.ts"],"sourcesContent":["export { default as EmojiInput } 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;AACA,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,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA"}
@@ -0,0 +1,4 @@
1
+ export interface ApiFunctionResult<T = null> {
2
+ data?: T;
3
+ status?: number;
4
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=api.js.map
@@ -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":""}
@@ -0,0 +1 @@
1
+ export type Category = 'history' | 'smileys_emotion' | 'people_body' | 'animals_nature' | 'food_drink' | 'travel_places' | 'activities' | 'objects' | 'symbols' | 'flags';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=category.js.map
@@ -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":""}
@@ -0,0 +1,2 @@
1
+ export declare const convertEmojisToUnicode: (text: string) => string;
2
+ export declare const addSkinToneToEmoji: (emoji: string, skinTone: string) => string;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ 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(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
+ '&amp;': '&',
39
+ '&#38;': '&',
40
+ '&#x26;': '&',
41
+ '&lt;': '<',
42
+ '&#60;': '<',
43
+ '&#x3C;': '<',
44
+ '&gt;': '>',
45
+ '&#62;': '>',
46
+ '&#x3E;': '>',
47
+ '&quot;': '"',
48
+ '&#34;': '"',
49
+ '&#x22;': '"',
50
+ '&apos;': "'",
51
+ '&#39;': "'",
52
+ '&#x27;': "'"
53
+ };
54
+ return text.replace(/&(?:amp|#38|#x26|lt|#60|#x3C|gt|#62|#x3E|apos|#39|#x27|quot|#34|#x22);/gi, match => {
55
+ var _unescaped$match;
56
+ return (_unescaped$match = unescaped[match]) !== null && _unescaped$match !== void 0 ? _unescaped$match : match;
57
+ });
58
+ };
59
+ const convertEmojisToUnicode = text => {
60
+ let result = text;
61
+ result = result.replace(/https?:\/\/.*?(?=$|\s)/gi, fullMatch => fullMatch.replace(/:/g, '%3A'));
62
+ result = result.replace(_emoji.regShortnames, shortname => {
63
+ if (shortname) {
64
+ const unicode = _emoji.shortNameList[shortname];
65
+ if (unicode) {
66
+ return convert(unicode.toUpperCase());
67
+ }
68
+ }
69
+ return shortname;
70
+ });
71
+ result = result.replace(/https?%3A\/\/.*?(?=$|\s)/gi, fullMatch => fullMatch.replace(/%3A/g, ':'));
72
+ result = result.replace(_emoji.regAscii, (fullMatch, m1, m2, m3) => {
73
+ if (typeof m3 === 'string' && m3 !== '') {
74
+ const unicode = _emoji.asciiList[unescapeHTML(m3)];
75
+ if (unicode) {
76
+ return m2 + convert(unicode.toUpperCase());
77
+ }
78
+ }
79
+ return fullMatch;
80
+ });
81
+ return result;
82
+ };
83
+ exports.convertEmojisToUnicode = convertEmojisToUnicode;
84
+ const addSkinToneToEmoji = (emoji, skinTone) => emoji.split('\u{200D}').map(rawEmoji => {
85
+ var _emojiList$rawEmoji;
86
+ const parts = [rawEmoji.replace(/\ufe0f/, '')];
87
+
88
+ // @ts-expect-error: Difficult to type external json file
89
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
90
+ if ((_emojiList$rawEmoji = _dataByEmoji.default[rawEmoji]) !== null && _emojiList$rawEmoji !== void 0 && _emojiList$rawEmoji.skin_tone_support) {
91
+ parts.push(skinTone);
92
+ }
93
+ return parts.join('');
94
+ }).join('\u{200D}');
95
+ exports.addSkinToneToEmoji = addSkinToneToEmoji;
96
+ //# sourceMappingURL=emoji.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emoji.js","names":["_dataByEmoji","_interopRequireDefault","require","_emoji","obj","__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","_unescaped$match","convertEmojisToUnicode","result","fullMatch","regShortnames","shortname","shortNameList","toUpperCase","regAscii","m1","m2","m3","asciiList","exports","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\nconst unescapeHTML = (text: string) => {\n const unescaped: { [key: string]: string } = {\n '&amp;': '&',\n '&#38;': '&',\n '&#x26;': '&',\n '&lt;': '<',\n '&#60;': '<',\n '&#x3C;': '<',\n '&gt;': '>',\n '&#62;': '>',\n '&#x3E;': '>',\n '&quot;': '\"',\n '&#34;': '\"',\n '&#x22;': '\"',\n '&apos;': \"'\",\n '&#39;': \"'\",\n '&#x27;': \"'\",\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 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,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;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;QAC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B,CAAC,CAAC;EAEF,OAAOD,MAAM;AACjB,CAAC;AAACW,OAAA,CAAAZ,sBAAA,GAAAA,sBAAA;AAEK,MAAMa,kBAAkB,GAAGA,CAACC,KAAa,EAAEC,QAAgB,KAC9DD,KAAK,CACAjC,KAAK,CAAC,UAAU,CAAC,CACjBmC,GAAG,CAAEC,QAAQ,IAAK;EAAA,IAAAC,mBAAA;EACf,MAAMvC,KAAK,GAAG,CAACsC,QAAQ,CAACpB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;;EAE9C;EACA;EACA,KAAAqB,mBAAA,GAAIC,oBAAS,CAACF,QAAQ,CAAC,cAAAC,mBAAA,eAAnBA,mBAAA,CAAqBE,iBAAiB,EAAE;IACxCzC,KAAK,CAACa,IAAI,CAACuB,QAAQ,CAAC;EACxB;EAEA,OAAOpC,KAAK,CAACc,IAAI,CAAC,EAAE,CAAC;AACzB,CAAC,CAAC,CACDA,IAAI,CAAC,UAAU,CAAC;AAACmB,OAAA,CAAAC,kBAAA,GAAAA,kBAAA"}
@@ -0,0 +1,9 @@
1
+ declare enum DeviceType {
2
+ Desktop = 0,
3
+ Smartphone = 1,
4
+ Tablet = 2
5
+ }
6
+ export declare const getDeviceType: () => DeviceType;
7
+ export declare const getIsMacOS: () => boolean;
8
+ export declare const getIsMobile: () => boolean;
9
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getIsMobile = exports.getIsMacOS = exports.getDeviceType = void 0;
7
+ var DeviceType;
8
+ (function (DeviceType) {
9
+ DeviceType[DeviceType["Desktop"] = 0] = "Desktop";
10
+ DeviceType[DeviceType["Smartphone"] = 1] = "Smartphone";
11
+ DeviceType[DeviceType["Tablet"] = 2] = "Tablet";
12
+ })(DeviceType || (DeviceType = {}));
13
+ const getDeviceType = () => {
14
+ const {
15
+ userAgent
16
+ } = navigator;
17
+ if (/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(userAgent)) {
18
+ return DeviceType.Smartphone;
19
+ }
20
+ if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(userAgent)) {
21
+ return DeviceType.Tablet;
22
+ }
23
+ return DeviceType.Desktop;
24
+ };
25
+ exports.getDeviceType = getDeviceType;
26
+ const getIsMacOS = () => /Mac OS X/i.test(navigator.userAgent);
27
+ exports.getIsMacOS = getIsMacOS;
28
+ const getIsMobile = () => {
29
+ const deviceType = getDeviceType();
30
+ return deviceType === DeviceType.Smartphone || deviceType === DeviceType.Tablet;
31
+ };
32
+ exports.getIsMobile = getIsMobile;
33
+ //# sourceMappingURL=environment.js.map
@@ -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;AAAA,WAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;AAAA,GAAVA,UAAU,KAAVA,UAAU;AAMR,MAAMC,aAAa,GAAGA,CAAA,KAAkB;EAC3C,MAAM;IAAEC;EAAU,CAAC,GAAGC,SAAS;EAE/B,IACI,qGAAqG,CAACC,IAAI,CACtGF,SAAS,CACZ,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,EAAE;EAElC,OAAOU,UAAU,KAAKX,UAAU,CAACK,UAAU,IAAIM,UAAU,KAAKX,UAAU,CAACM,MAAM;AACnF,CAAC;AAACE,OAAA,CAAAE,WAAA,GAAAA,WAAA"}
@@ -0,0 +1 @@
1
+ export declare const getFontFamily: () => string;
@@ -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,KACxB,GAAEP,iBAAiB,EAAG,GAAE,IAAAQ,wBAAW,GAAE,IAAI,IAAAC,uBAAU,GAAE,GAAG,EAAE,GAAG,oBAAqB,SAAQ;AAACC,OAAA,CAAAH,aAAA,GAAAA,aAAA"}
@@ -0,0 +1,19 @@
1
+ interface InsertTextAtCursorPositionOptions {
2
+ editorElement: HTMLDivElement;
3
+ text: string;
4
+ }
5
+ /**
6
+ * This function inserts the passed text at the correct position in the editor element. If the
7
+ * element has the focus, the new emoji is inserted at the cursor position. If not, the emoji
8
+ * will be appended to the back of the input field content.
9
+ *
10
+ * In addition, this function also sets the cursor to the correct position when the input field
11
+ * has the focus. For this purpose, the current position of the cursor or a selection is read to
12
+ * calculate the cursor position after inserting the text.
13
+ *
14
+ * @param {Object} options - Object with element and text to insert
15
+ * @param {HTMLDivElement} options.editorElement - Element to insert text into
16
+ * @param {string} options.text - Text to insert into element
17
+ */
18
+ export declare const insertTextAtCursorPosition: ({ editorElement, text, }: InsertTextAtCursorPositionOptions) => void;
19
+ export {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.insertTextAtCursorPosition = void 0;
7
+ /**
8
+ * This function inserts the passed text at the correct position in the editor element. If the
9
+ * element has the focus, the new emoji is inserted at the cursor position. If not, the emoji
10
+ * will be appended to the back of the input field content.
11
+ *
12
+ * In addition, this function also sets the cursor to the correct position when the input field
13
+ * has the focus. For this purpose, the current position of the cursor or a selection is read to
14
+ * calculate the cursor position after inserting the text.
15
+ *
16
+ * @param {Object} options - Object with element and text to insert
17
+ * @param {HTMLDivElement} options.editorElement - Element to insert text into
18
+ * @param {string} options.text - Text to insert into element
19
+ */
20
+ const insertTextAtCursorPosition = _ref => {
21
+ let {
22
+ editorElement,
23
+ text
24
+ } = _ref;
25
+ const selection = window.getSelection();
26
+ if (selection !== null && selection !== void 0 && selection.anchorNode && editorElement.contains(selection.anchorNode)) {
27
+ const range = selection.getRangeAt(0);
28
+ const textNodes = text.split(/\r\n|\r|\n/).map(part => document.createTextNode(part));
29
+ range.deleteContents();
30
+ textNodes.forEach((textNode, index) => {
31
+ range.insertNode(textNode);
32
+ range.setEndAfter(textNode);
33
+ range.setStartAfter(textNode);
34
+ if (index !== textNodes.length - 1) {
35
+ const brElement = document.createElement('br');
36
+ range.insertNode(brElement);
37
+ range.setEndAfter(brElement);
38
+ range.setStartAfter(brElement);
39
+ }
40
+ });
41
+ range.collapse(false);
42
+ selection.removeAllRanges();
43
+ selection.addRange(range);
44
+ } else {
45
+ // eslint-disable-next-line no-param-reassign
46
+ editorElement.innerText += text;
47
+ }
48
+ };
49
+ exports.insertTextAtCursorPosition = insertTextAtCursorPosition;
50
+ //# sourceMappingURL=insert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert.js","names":["insertTextAtCursorPosition","_ref","editorElement","text","selection","window","getSelection","anchorNode","contains","range","getRangeAt","textNodes","split","map","part","document","createTextNode","deleteContents","forEach","textNode","index","insertNode","setEndAfter","setStartAfter","length","brElement","createElement","collapse","removeAllRanges","addRange","innerText","exports"],"sources":["../../src/utils/insert.ts"],"sourcesContent":["interface InsertTextAtCursorPositionOptions {\n editorElement: HTMLDivElement;\n text: string;\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}: InsertTextAtCursorPositionOptions) => {\n const selection = window.getSelection();\n\n if (selection?.anchorNode && editorElement.contains(selection.anchorNode)) {\n const range = selection.getRangeAt(0);\n\n const textNodes = text.split(/\\r\\n|\\r|\\n/).map((part) => document.createTextNode(part));\n\n range.deleteContents();\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 const 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 } else {\n // eslint-disable-next-line no-param-reassign\n editorElement.innerText += text;\n }\n};\n"],"mappings":";;;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,0BAA0B,GAAGC,IAAA,IAGD;EAAA,IAHE;IACvCC,aAAa;IACbC;EAC+B,CAAC,GAAAF,IAAA;EAChC,MAAMG,SAAS,GAAGC,MAAM,CAACC,YAAY,EAAE;EAEvC,IAAIF,SAAS,aAATA,SAAS,eAATA,SAAS,CAAEG,UAAU,IAAIL,aAAa,CAACM,QAAQ,CAACJ,SAAS,CAACG,UAAU,CAAC,EAAE;IACvE,MAAME,KAAK,GAAGL,SAAS,CAACM,UAAU,CAAC,CAAC,CAAC;IAErC,MAAMC,SAAS,GAAGR,IAAI,CAACS,KAAK,CAAC,YAAY,CAAC,CAACC,GAAG,CAAEC,IAAI,IAAKC,QAAQ,CAACC,cAAc,CAACF,IAAI,CAAC,CAAC;IAEvFL,KAAK,CAACQ,cAAc,EAAE;IAEtBN,SAAS,CAACO,OAAO,CAAC,CAACC,QAAQ,EAAEC,KAAK,KAAK;MACnCX,KAAK,CAACY,UAAU,CAACF,QAAQ,CAAC;MAC1BV,KAAK,CAACa,WAAW,CAACH,QAAQ,CAAC;MAC3BV,KAAK,CAACc,aAAa,CAACJ,QAAQ,CAAC;MAE7B,IAAIC,KAAK,KAAKT,SAAS,CAACa,MAAM,GAAG,CAAC,EAAE;QAChC,MAAMC,SAAS,GAAGV,QAAQ,CAACW,aAAa,CAAC,IAAI,CAAC;QAE9CjB,KAAK,CAACY,UAAU,CAACI,SAAS,CAAC;QAC3BhB,KAAK,CAACa,WAAW,CAACG,SAAS,CAAC;QAC5BhB,KAAK,CAACc,aAAa,CAACE,SAAS,CAAC;MAClC;IACJ,CAAC,CAAC;IAEFhB,KAAK,CAACkB,QAAQ,CAAC,KAAK,CAAC;IAErBvB,SAAS,CAACwB,eAAe,EAAE;IAC3BxB,SAAS,CAACyB,QAAQ,CAACpB,KAAK,CAAC;EAC7B,CAAC,MAAM;IACH;IACAP,aAAa,CAAC4B,SAAS,IAAI3B,IAAI;EACnC;AACJ,CAAC;AAAC4B,OAAA,CAAA/B,0BAAA,GAAAA,0BAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const saveSelection: (element: HTMLDivElement) => void;
2
+ export declare const restoreSelection: (element: HTMLDivElement) => void;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.saveSelection = exports.restoreSelection = void 0;
7
+ let childIndex = -1;
8
+ let endOffset = -1;
9
+ let startOffset = -1;
10
+ const saveSelection = element => {
11
+ const selection = window.getSelection();
12
+ if (!selection) {
13
+ return;
14
+ }
15
+ const node = selection.anchorNode;
16
+ if (!node) {
17
+ return;
18
+ }
19
+ const range = selection.getRangeAt(0);
20
+ childIndex = Array.from(element.childNodes).indexOf(node);
21
+ endOffset = range.endOffset;
22
+ startOffset = range.startOffset;
23
+ };
24
+ exports.saveSelection = saveSelection;
25
+ const restoreSelection = element => {
26
+ const childNode = element.childNodes[childIndex];
27
+ const selection = window.getSelection();
28
+ if (!childNode || !element || !selection) {
29
+ return;
30
+ }
31
+ const range = document.createRange();
32
+ if (childNode.nodeValue) {
33
+ endOffset = Math.min(endOffset, childNode.nodeValue.length);
34
+ startOffset = Math.min(startOffset, childNode.nodeValue.length);
35
+ }
36
+ range.setStart(childNode, startOffset);
37
+ range.setEnd(childNode, endOffset);
38
+ selection.removeAllRanges();
39
+ selection.addRange(range);
40
+ range.collapse(true);
41
+ };
42
+ exports.restoreSelection = restoreSelection;
43
+ //# sourceMappingURL=selection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection.js","names":["childIndex","endOffset","startOffset","saveSelection","element","selection","window","getSelection","node","anchorNode","range","getRangeAt","Array","from","childNodes","indexOf","exports","restoreSelection","childNode","document","createRange","nodeValue","Math","min","length","setStart","setEnd","removeAllRanges","addRange","collapse"],"sources":["../../src/utils/selection.ts"],"sourcesContent":["let childIndex = -1;\nlet endOffset = -1;\nlet startOffset = -1;\n\nexport const saveSelection = (element: HTMLDivElement) => {\n const selection = window.getSelection();\n\n if (!selection) {\n return;\n }\n\n const node = selection.anchorNode;\n\n if (!node) {\n return;\n }\n\n const range = selection.getRangeAt(0);\n\n childIndex = Array.from(element.childNodes).indexOf(node as ChildNode);\n\n endOffset = range.endOffset;\n startOffset = range.startOffset;\n};\n\nexport const restoreSelection = (element: HTMLDivElement) => {\n const childNode = element.childNodes[childIndex];\n const selection = window.getSelection();\n\n if (!childNode || !element || !selection) {\n return;\n }\n\n const range = document.createRange();\n\n if (childNode.nodeValue) {\n endOffset = Math.min(endOffset, childNode.nodeValue.length);\n startOffset = Math.min(startOffset, childNode.nodeValue.length);\n }\n\n range.setStart(childNode, startOffset);\n range.setEnd(childNode, endOffset);\n\n selection.removeAllRanges();\n selection.addRange(range);\n\n range.collapse(true);\n};\n"],"mappings":";;;;;;AAAA,IAAIA,UAAU,GAAG,CAAC,CAAC;AACnB,IAAIC,SAAS,GAAG,CAAC,CAAC;AAClB,IAAIC,WAAW,GAAG,CAAC,CAAC;AAEb,MAAMC,aAAa,GAAIC,OAAuB,IAAK;EACtD,MAAMC,SAAS,GAAGC,MAAM,CAACC,YAAY,EAAE;EAEvC,IAAI,CAACF,SAAS,EAAE;IACZ;EACJ;EAEA,MAAMG,IAAI,GAAGH,SAAS,CAACI,UAAU;EAEjC,IAAI,CAACD,IAAI,EAAE;IACP;EACJ;EAEA,MAAME,KAAK,GAAGL,SAAS,CAACM,UAAU,CAAC,CAAC,CAAC;EAErCX,UAAU,GAAGY,KAAK,CAACC,IAAI,CAACT,OAAO,CAACU,UAAU,CAAC,CAACC,OAAO,CAACP,IAAI,CAAc;EAEtEP,SAAS,GAAGS,KAAK,CAACT,SAAS;EAC3BC,WAAW,GAAGQ,KAAK,CAACR,WAAW;AACnC,CAAC;AAACc,OAAA,CAAAb,aAAA,GAAAA,aAAA;AAEK,MAAMc,gBAAgB,GAAIb,OAAuB,IAAK;EACzD,MAAMc,SAAS,GAAGd,OAAO,CAACU,UAAU,CAACd,UAAU,CAAC;EAChD,MAAMK,SAAS,GAAGC,MAAM,CAACC,YAAY,EAAE;EAEvC,IAAI,CAACW,SAAS,IAAI,CAACd,OAAO,IAAI,CAACC,SAAS,EAAE;IACtC;EACJ;EAEA,MAAMK,KAAK,GAAGS,QAAQ,CAACC,WAAW,EAAE;EAEpC,IAAIF,SAAS,CAACG,SAAS,EAAE;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