@chayns-components/emoji-input 5.0.0-beta.132 → 5.0.0-beta.1320
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 +561 -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/cjs/components/emoji-picker/EmojiPicker.js +47 -0
- 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 +99 -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 +260 -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 +63 -34
- 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 +130 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +1 -0
- package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +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/cjs/constants/emoji.js +126 -0
- package/lib/cjs/constants/emoji.js.map +1 -0
- package/lib/cjs/constants/externalServerUrl.js +8 -0
- package/lib/cjs/constants/externalServerUrl.js.map +1 -0
- package/lib/cjs/constants/regex.js +15 -0
- package/lib/cjs/constants/regex.js.map +1 -0
- package/lib/cjs/hooks/cursor.js +110 -0
- package/lib/cjs/hooks/cursor.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} +28 -3
- 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/cjs/utils/asyncEmojiData.js +10 -0
- package/lib/cjs/utils/asyncEmojiData.js.map +1 -0
- package/lib/cjs/utils/convertEmojisToUnicodeAsync.js +29 -0
- package/lib/cjs/utils/convertEmojisToUnicodeAsync.js.map +1 -0
- package/lib/{utils → cjs/utils}/emoji.js +17 -13
- package/lib/cjs/utils/emoji.js.map +1 -0
- package/lib/{constants/emoji.js → cjs/utils/emojiShortList.js} +4 -127
- package/lib/cjs/utils/emojiShortList.js.map +1 -0
- package/lib/cjs/utils/environment.js.map +1 -0
- package/lib/cjs/utils/font.js.map +1 -0
- package/lib/{utils → cjs/utils}/insert.js +47 -9
- 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/scroll.js +65 -0
- package/lib/cjs/utils/scroll.js.map +1 -0
- package/lib/cjs/utils/selection.js +351 -0
- package/lib/cjs/utils/selection.js.map +1 -0
- package/lib/cjs/utils/text.js +63 -0
- package/lib/cjs/utils/text.js.map +1 -0
- package/lib/esm/api/item-storage/get.js +29 -0
- package/lib/esm/api/item-storage/get.js.map +1 -0
- package/lib/esm/api/item-storage/put.js +34 -0
- package/lib/esm/api/item-storage/put.js.map +1 -0
- package/lib/esm/components/emoji-input/EmojiInput.js +542 -0
- package/lib/esm/components/emoji-input/EmojiInput.js.map +1 -0
- package/lib/esm/components/emoji-input/EmojiInput.styles.js +124 -0
- package/lib/esm/components/emoji-input/EmojiInput.styles.js.map +1 -0
- package/lib/esm/components/emoji-input/prefix-element/PrefixElement.js +37 -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 +57 -0
- package/lib/esm/components/emoji-input/prefix-element/PrefixElement.styles.js.map +1 -0
- package/lib/esm/components/emoji-picker/EmojiPicker.js +39 -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 +91 -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 +251 -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 +59 -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 +137 -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 +17 -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 +120 -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 +91 -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 +42 -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 +120 -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/cursor.js +103 -0
- package/lib/esm/hooks/cursor.js.map +1 -0
- package/lib/esm/hooks/emojiHistory.js +81 -0
- package/lib/esm/hooks/emojiHistory.js.map +1 -0
- package/lib/{index.d.ts → esm/index.js} +3 -1
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/types/api.js +2 -0
- package/lib/esm/types/api.js.map +1 -0
- package/lib/esm/types/category.js +2 -0
- package/lib/esm/types/category.js.map +1 -0
- package/lib/esm/utils/asyncEmojiData.js +2 -0
- package/lib/esm/utils/asyncEmojiData.js.map +1 -0
- package/lib/esm/utils/convertEmojisToUnicodeAsync.js +20 -0
- package/lib/esm/utils/convertEmojisToUnicodeAsync.js.map +1 -0
- package/lib/esm/utils/emoji.js +90 -0
- package/lib/esm/utils/emoji.js.map +1 -0
- package/lib/esm/utils/emojiShortList.js +3679 -0
- package/lib/esm/utils/emojiShortList.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/scroll.js +58 -0
- package/lib/esm/utils/scroll.js.map +1 -0
- package/lib/esm/utils/selection.js +324 -0
- package/lib/esm/utils/selection.js.map +1 -0
- package/lib/esm/utils/text.js +54 -0
- package/lib/esm/utils/text.js.map +1 -0
- package/lib/types/components/emoji-input/EmojiInput.d.ts +101 -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 +4 -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 +10 -0
- package/lib/types/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.d.ts +6 -0
- package/lib/{components → types/components}/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.d.ts +5 -0
- package/lib/types/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.d.ts +20 -0
- package/lib/{components → types/components}/emoji-picker-popup/EmojiPickerPopup.d.ts +0 -13
- package/lib/types/components/emoji-picker-popup/EmojiPickerPopup.styles.d.ts +1 -0
- package/lib/types/constants/emoji.d.ts +4 -0
- package/lib/types/constants/regex.d.ts +8 -0
- package/lib/types/hooks/cursor.d.ts +11 -0
- package/lib/types/index.d.ts +7 -0
- package/lib/types/utils/asyncEmojiData.d.ts +1 -0
- package/lib/types/utils/convertEmojisToUnicodeAsync.d.ts +3 -0
- package/lib/types/utils/emoji.d.ts +10 -0
- package/lib/{constants/emoji.d.ts → types/utils/emojiShortList.d.ts} +0 -4
- package/lib/{utils → types/utils}/insert.d.ts +10 -1
- package/lib/types/utils/number.d.ts +1 -0
- package/lib/types/utils/scroll.d.ts +1 -0
- package/lib/types/utils/selection.d.ts +30 -0
- package/lib/types/utils/text.d.ts +5 -0
- package/package.json +50 -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 -55
- package/lib/components/emoji-input/EmojiInput.js +0 -163
- 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 -154
- package/lib/components/emoji-input/EmojiInput.styles.js.map +0 -1
- package/lib/components/emoji-picker/EmojiPicker.js +0 -51
- 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/constants/regex.d.ts +0 -2
- package/lib/constants/regex.js +0 -11
- package/lib/constants/regex.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.d.ts +0 -3
- 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.map +0 -1
- package/lib/utils/selection.d.ts +0 -8
- package/lib/utils/selection.js +0 -98
- package/lib/utils/selection.js.map +0 -1
- package/lib/utils/text.d.ts +0 -2
- package/lib/utils/text.js +0 -22
- package/lib/utils/text.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/{constants → types/constants}/alignment.d.ts +0 -0
- /package/lib/{constants → types/constants}/categories.d.ts +0 -0
- /package/lib/{constants → types/constants}/externalServerUrl.d.ts +0 -0
- /package/lib/{hooks → types/hooks}/emojiHistory.d.ts +0 -0
- /package/lib/types/{api.d.ts → types/api.d.ts} +0 -0
- /package/lib/types/{category.d.ts → types/category.d.ts} +0 -0
- /package/lib/{utils → types/utils}/environment.d.ts +0 -0
- /package/lib/{utils → types/utils}/font.d.ts +0 -0
|
@@ -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":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.insertTextAtCursorPosition = void 0;
|
|
6
|
+
exports.replaceText = exports.insertTextAtCursorPosition = void 0;
|
|
7
7
|
var _selection = require("./selection");
|
|
8
8
|
/**
|
|
9
9
|
* This function inserts the passed text at the correct position in the editor element. If the
|
|
@@ -18,11 +18,14 @@ var _selection = require("./selection");
|
|
|
18
18
|
* @param {HTMLDivElement} options.editorElement - Element to insert text into
|
|
19
19
|
* @param {string} options.text - Text to insert into element
|
|
20
20
|
*/
|
|
21
|
-
const insertTextAtCursorPosition =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
const insertTextAtCursorPosition = ({
|
|
22
|
+
editorElement,
|
|
23
|
+
text,
|
|
24
|
+
shouldUseSavedSelection = false
|
|
25
|
+
}) => {
|
|
26
|
+
if (shouldUseSavedSelection) {
|
|
27
|
+
(0, _selection.restoreSelection)(editorElement);
|
|
28
|
+
}
|
|
26
29
|
const selection = window.getSelection();
|
|
27
30
|
(0, _selection.saveSelection)(editorElement);
|
|
28
31
|
if (selection !== null && selection !== void 0 && selection.anchorNode && editorElement.contains(selection.anchorNode)) {
|
|
@@ -33,11 +36,24 @@ const insertTextAtCursorPosition = _ref => {
|
|
|
33
36
|
range.deleteContents();
|
|
34
37
|
if (firstPart) {
|
|
35
38
|
if (selection.anchorNode.nodeType === Node.TEXT_NODE) {
|
|
36
|
-
|
|
37
|
-
|
|
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
|
+
}
|
|
38
46
|
} else if (selection.anchorNode === editorElement) {
|
|
39
47
|
const textNode = document.createTextNode(firstPart);
|
|
40
|
-
|
|
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
|
+
}
|
|
41
57
|
const textNodeIndex = Array.from(editorElement.childNodes).indexOf(textNode);
|
|
42
58
|
(0, _selection.moveSelectionOffset)(firstPart.length);
|
|
43
59
|
(0, _selection.setChildIndex)(textNodeIndex);
|
|
@@ -71,4 +87,26 @@ const insertTextAtCursorPosition = _ref => {
|
|
|
71
87
|
}
|
|
72
88
|
};
|
|
73
89
|
exports.insertTextAtCursorPosition = insertTextAtCursorPosition;
|
|
90
|
+
const replaceText = ({
|
|
91
|
+
editorElement,
|
|
92
|
+
searchText,
|
|
93
|
+
pasteText,
|
|
94
|
+
options
|
|
95
|
+
}) => {
|
|
96
|
+
const selection = window.getSelection();
|
|
97
|
+
const rangeToReplace = (0, _selection.findAndSelectText)({
|
|
98
|
+
editorElement,
|
|
99
|
+
searchText,
|
|
100
|
+
options
|
|
101
|
+
});
|
|
102
|
+
if (rangeToReplace && selection) {
|
|
103
|
+
selection.removeAllRanges();
|
|
104
|
+
selection.addRange(rangeToReplace);
|
|
105
|
+
insertTextAtCursorPosition({
|
|
106
|
+
editorElement,
|
|
107
|
+
text: pasteText
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
exports.replaceText = replaceText;
|
|
74
112
|
//# 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","options","rangeToReplace","findAndSelectText"],"sources":["../../../src/utils/insert.ts"],"sourcesContent":["import {\n findAndSelectText,\n moveSelectionOffset,\n restoreSelection,\n saveSelection,\n setChildIndex,\n type ReplaceTextOptions as IReplaceTextOptions,\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 options?: IReplaceTextOptions;\n}\n\nexport const replaceText = ({\n editorElement,\n searchText,\n pasteText,\n options,\n}: ReplaceTextOptions) => {\n const selection = window.getSelection();\n\n const rangeToReplace = findAndSelectText({ editorElement, searchText, options });\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;AAeA;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;IAEt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AAMpD,SAAS,GAAGC,MAAM,CAACC,YAAY,CAAC,CAAC;EAEvC,MAAMmD,cAAc,GAAG,IAAAC,4BAAiB,EAAC;IAAE1D,aAAa;IAAEsD,UAAU;IAAEE;EAAQ,CAAC,CAAC;EAEhF,IAAIC,cAAc,IAAIrD,SAAS,EAAE;IAC7BA,SAAS,CAAC6C,eAAe,CAAC,CAAC;IAC3B7C,SAAS,CAAC8C,QAAQ,CAACO,cAAc,CAAC;IAElC1D,0BAA0B,CAAC;MAAEC,aAAa;MAAEC,IAAI,EAAEsD;IAAU,CAAC,CAAC;EAClE;AACJ,CAAC;AAACH,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.clamp = void 0;
|
|
7
|
+
const clamp = (value, min, max) => {
|
|
8
|
+
if (value < min) {
|
|
9
|
+
return min;
|
|
10
|
+
}
|
|
11
|
+
if (value > max) {
|
|
12
|
+
return max;
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
};
|
|
16
|
+
exports.clamp = clamp;
|
|
17
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.js","names":["clamp","value","min","max","exports"],"sources":["../../../src/utils/number.ts"],"sourcesContent":["export const clamp = (value: number, min: number, max: number) => {\n if (value < min) {\n return min;\n }\n\n if (value > max) {\n return max;\n }\n\n return value;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,KAAK,GAAGA,CAACC,KAAa,EAAEC,GAAW,EAAEC,GAAW,KAAK;EAC9D,IAAIF,KAAK,GAAGC,GAAG,EAAE;IACb,OAAOA,GAAG;EACd;EAEA,IAAID,KAAK,GAAGE,GAAG,EAAE;IACb,OAAOA,GAAG;EACd;EAEA,OAAOF,KAAK;AAChB,CAAC;AAACG,OAAA,CAAAJ,KAAA,GAAAA,KAAA","ignoreList":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.scrollCursorIntoView = void 0;
|
|
7
|
+
const getCaretClientRect = () => {
|
|
8
|
+
const sel = window.getSelection();
|
|
9
|
+
if (!sel || sel.rangeCount === 0) return null;
|
|
10
|
+
|
|
11
|
+
// Clone the current range so we don't mess with the actual selection
|
|
12
|
+
const range = sel.getRangeAt(0).cloneRange();
|
|
13
|
+
if (!range.collapsed) range.collapse(false);
|
|
14
|
+
|
|
15
|
+
// Try getting the rect directly
|
|
16
|
+
let rect = range.getBoundingClientRect();
|
|
17
|
+
const isEmptyRect = rect && rect.top === 0 && rect.bottom === 0;
|
|
18
|
+
if (!rect || isEmptyRect) {
|
|
19
|
+
// Fallback: insert a temporary invisible element to measure the caret position
|
|
20
|
+
const span = document.createElement('span');
|
|
21
|
+
span.appendChild(document.createTextNode('\u200B')); // zero-width space
|
|
22
|
+
|
|
23
|
+
range.insertNode(span);
|
|
24
|
+
|
|
25
|
+
// Move selection right after the temporary span
|
|
26
|
+
const newRange = document.createRange();
|
|
27
|
+
newRange.setStartAfter(span);
|
|
28
|
+
newRange.collapse(true);
|
|
29
|
+
sel.removeAllRanges();
|
|
30
|
+
sel.addRange(newRange);
|
|
31
|
+
|
|
32
|
+
// Measure the span's position
|
|
33
|
+
rect = span.getBoundingClientRect();
|
|
34
|
+
|
|
35
|
+
// Remove the temporary span
|
|
36
|
+
if (span.parentNode) {
|
|
37
|
+
span.parentNode.removeChild(span);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return rect;
|
|
41
|
+
};
|
|
42
|
+
const scrollCursorIntoView = (container, padding = 8) => {
|
|
43
|
+
const rect = getCaretClientRect();
|
|
44
|
+
|
|
45
|
+
// Fallback: scroll to bottom if caret position can't be determined
|
|
46
|
+
if (!rect) {
|
|
47
|
+
// eslint-disable-next-line no-param-reassign
|
|
48
|
+
container.scrollTop = container.scrollHeight;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const containerRect = container.getBoundingClientRect();
|
|
52
|
+
|
|
53
|
+
// Scroll down if caret is below the visible area
|
|
54
|
+
if (rect.bottom > containerRect.bottom - padding) {
|
|
55
|
+
// eslint-disable-next-line no-param-reassign
|
|
56
|
+
container.scrollTop += rect.bottom - containerRect.bottom + padding;
|
|
57
|
+
}
|
|
58
|
+
// Scroll up if caret is above the visible area
|
|
59
|
+
else if (rect.top < containerRect.top + padding) {
|
|
60
|
+
// eslint-disable-next-line no-param-reassign
|
|
61
|
+
container.scrollTop -= containerRect.top + padding - rect.top;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.scrollCursorIntoView = scrollCursorIntoView;
|
|
65
|
+
//# sourceMappingURL=scroll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll.js","names":["getCaretClientRect","sel","window","getSelection","rangeCount","range","getRangeAt","cloneRange","collapsed","collapse","rect","getBoundingClientRect","isEmptyRect","top","bottom","span","document","createElement","appendChild","createTextNode","insertNode","newRange","createRange","setStartAfter","removeAllRanges","addRange","parentNode","removeChild","scrollCursorIntoView","container","padding","scrollTop","scrollHeight","containerRect","exports"],"sources":["../../../src/utils/scroll.ts"],"sourcesContent":["const getCaretClientRect = (): DOMRect | null => {\n const sel = window.getSelection();\n\n if (!sel || sel.rangeCount === 0) return null;\n\n // Clone the current range so we don't mess with the actual selection\n const range = sel.getRangeAt(0).cloneRange();\n\n if (!range.collapsed) range.collapse(false);\n\n // Try getting the rect directly\n let rect = range.getBoundingClientRect();\n\n const isEmptyRect = rect && rect.top === 0 && rect.bottom === 0;\n\n if (!rect || isEmptyRect) {\n // Fallback: insert a temporary invisible element to measure the caret position\n const span = document.createElement('span');\n\n span.appendChild(document.createTextNode('\\u200B')); // zero-width space\n\n range.insertNode(span);\n\n // Move selection right after the temporary span\n const newRange = document.createRange();\n\n newRange.setStartAfter(span);\n newRange.collapse(true);\n\n sel.removeAllRanges();\n sel.addRange(newRange);\n\n // Measure the span's position\n rect = span.getBoundingClientRect();\n\n // Remove the temporary span\n if (span.parentNode) {\n span.parentNode.removeChild(span);\n }\n }\n\n return rect;\n};\n\nexport const scrollCursorIntoView = (container: HTMLElement, padding = 8): void => {\n const rect = getCaretClientRect();\n\n // Fallback: scroll to bottom if caret position can't be determined\n if (!rect) {\n // eslint-disable-next-line no-param-reassign\n container.scrollTop = container.scrollHeight;\n\n return;\n }\n\n const containerRect = container.getBoundingClientRect();\n\n // Scroll down if caret is below the visible area\n if (rect.bottom > containerRect.bottom - padding) {\n // eslint-disable-next-line no-param-reassign\n container.scrollTop += rect.bottom - containerRect.bottom + padding;\n }\n // Scroll up if caret is above the visible area\n else if (rect.top < containerRect.top + padding) {\n // eslint-disable-next-line no-param-reassign\n container.scrollTop -= containerRect.top + padding - rect.top;\n }\n};\n"],"mappings":";;;;;;AAAA,MAAMA,kBAAkB,GAAGA,CAAA,KAAsB;EAC7C,MAAMC,GAAG,GAAGC,MAAM,CAACC,YAAY,CAAC,CAAC;EAEjC,IAAI,CAACF,GAAG,IAAIA,GAAG,CAACG,UAAU,KAAK,CAAC,EAAE,OAAO,IAAI;;EAE7C;EACA,MAAMC,KAAK,GAAGJ,GAAG,CAACK,UAAU,CAAC,CAAC,CAAC,CAACC,UAAU,CAAC,CAAC;EAE5C,IAAI,CAACF,KAAK,CAACG,SAAS,EAAEH,KAAK,CAACI,QAAQ,CAAC,KAAK,CAAC;;EAE3C;EACA,IAAIC,IAAI,GAAGL,KAAK,CAACM,qBAAqB,CAAC,CAAC;EAExC,MAAMC,WAAW,GAAGF,IAAI,IAAIA,IAAI,CAACG,GAAG,KAAK,CAAC,IAAIH,IAAI,CAACI,MAAM,KAAK,CAAC;EAE/D,IAAI,CAACJ,IAAI,IAAIE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O,EAAE;IAC7C;IACAD,SAAS,CAACE,SAAS,IAAIE,aAAa,CAACpB,GAAG,GAAGiB,OAAO,GAAGpB,IAAI,CAACG,GAAG;EACjE;AACJ,CAAC;AAACqB,OAAA,CAAAN,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setChildIndex = exports.saveSelection = exports.restoreSelection = exports.moveSelectionOffset = exports.insertPseudoMarker = exports.insertInvisibleCursorMarker = exports.insertCursorAtMarker = exports.getCurrentCursorPosition = 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 insertPseudoMarker = () => {
|
|
200
|
+
const selection = window.getSelection();
|
|
201
|
+
if (selection && selection.rangeCount > 0) {
|
|
202
|
+
const range = selection.getRangeAt(0);
|
|
203
|
+
const marker = document.createElement('span');
|
|
204
|
+
marker.id = 'cursor-marker';
|
|
205
|
+
marker.style.display = 'inline-block';
|
|
206
|
+
marker.style.width = '0';
|
|
207
|
+
marker.style.height = '0';
|
|
208
|
+
range.insertNode(marker);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
exports.insertPseudoMarker = insertPseudoMarker;
|
|
212
|
+
const insertCursorAtMarker = ref => {
|
|
213
|
+
var _ref$current;
|
|
214
|
+
const marker = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector('#cursor-marker');
|
|
215
|
+
if (marker) {
|
|
216
|
+
const selection = window.getSelection();
|
|
217
|
+
const range = document.createRange();
|
|
218
|
+
range.setStartAfter(marker);
|
|
219
|
+
range.setEndAfter(marker);
|
|
220
|
+
selection === null || selection === void 0 || selection.removeAllRanges();
|
|
221
|
+
selection === null || selection === void 0 || selection.addRange(range);
|
|
222
|
+
marker.remove();
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
exports.insertCursorAtMarker = insertCursorAtMarker;
|
|
226
|
+
const moveSelectionOffset = distance => {
|
|
227
|
+
endOffset += distance;
|
|
228
|
+
startOffset += distance;
|
|
229
|
+
};
|
|
230
|
+
exports.moveSelectionOffset = moveSelectionOffset;
|
|
231
|
+
const setChildIndex = index => {
|
|
232
|
+
childIndex = index;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* This function returns the code of the character that will be removed by the KeyDown event in the
|
|
237
|
+
* next step, if the "Backspace" or "Delete" key was pressed and there is no selection of multiple
|
|
238
|
+
* characters.
|
|
239
|
+
*
|
|
240
|
+
* @param event - Keyboard event from "onKeyDown"
|
|
241
|
+
*/
|
|
242
|
+
exports.setChildIndex = setChildIndex;
|
|
243
|
+
const getCharCodeThatWillBeDeleted = event => {
|
|
244
|
+
var _window$getSelection, _nextSibling$nodeValu;
|
|
245
|
+
const range = (_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.getRangeAt(0);
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* At this point the function is aborted if there is no selection range, several characters have
|
|
249
|
+
* been selected and therefore no single letter is removed or neither the "Backspace" nor the
|
|
250
|
+
* "Delete" key has been pressed.
|
|
251
|
+
*/
|
|
252
|
+
if (!range || range.endOffset !== range.startOffset || event.key !== 'Backspace' && event.key !== 'Delete' && event.key !== 'Unidentified') {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
if (event.key === 'Backspace' || event.key === 'Unidentified') {
|
|
256
|
+
var _previousSibling$node;
|
|
257
|
+
const {
|
|
258
|
+
nodeValue,
|
|
259
|
+
previousSibling
|
|
260
|
+
} = range.startContainer;
|
|
261
|
+
if (range.startOffset > 0) {
|
|
262
|
+
return nodeValue === null || nodeValue === void 0 ? void 0 : nodeValue.charCodeAt(range.startOffset - 1);
|
|
263
|
+
}
|
|
264
|
+
return previousSibling === null || previousSibling === void 0 || (_previousSibling$node = previousSibling.nodeValue) === null || _previousSibling$node === void 0 ? void 0 : _previousSibling$node.charCodeAt(previousSibling.nodeValue.length - 1);
|
|
265
|
+
}
|
|
266
|
+
const {
|
|
267
|
+
nextSibling,
|
|
268
|
+
nodeValue
|
|
269
|
+
} = range.endContainer;
|
|
270
|
+
if (range.endOffset < ((nodeValue === null || nodeValue === void 0 ? void 0 : nodeValue.length) ?? 0)) {
|
|
271
|
+
return nodeValue === null || nodeValue === void 0 ? void 0 : nodeValue.charCodeAt(range.endOffset);
|
|
272
|
+
}
|
|
273
|
+
return nextSibling === null || nextSibling === void 0 || (_nextSibling$nodeValu = nextSibling.nodeValue) === null || _nextSibling$nodeValu === void 0 ? void 0 : _nextSibling$nodeValu.charCodeAt(0);
|
|
274
|
+
};
|
|
275
|
+
exports.getCharCodeThatWillBeDeleted = getCharCodeThatWillBeDeleted;
|
|
276
|
+
const findAndSelectText = ({
|
|
277
|
+
editorElement,
|
|
278
|
+
searchText,
|
|
279
|
+
options = {
|
|
280
|
+
shouldReplaceNearCursor: true
|
|
281
|
+
}
|
|
282
|
+
}) => {
|
|
283
|
+
var _editorElement$textCo;
|
|
284
|
+
if (!((_editorElement$textCo = editorElement.textContent) !== null && _editorElement$textCo !== void 0 && _editorElement$textCo.includes(searchText))) {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
const range = document.createRange();
|
|
288
|
+
const cursorPos = getCurrentCursorPosition(editorElement);
|
|
289
|
+
const matches = [];
|
|
290
|
+
let absCounter = 0;
|
|
291
|
+
const searchNodesForText = node => {
|
|
292
|
+
if (node.nodeType === Node.TEXT_NODE && node.textContent) {
|
|
293
|
+
let index = node.textContent.indexOf(searchText);
|
|
294
|
+
while (index !== -1) {
|
|
295
|
+
matches.push({
|
|
296
|
+
node,
|
|
297
|
+
offset: index,
|
|
298
|
+
absIndex: absCounter + index
|
|
299
|
+
});
|
|
300
|
+
index = node.textContent.indexOf(searchText, index + 1);
|
|
301
|
+
}
|
|
302
|
+
absCounter += node.textContent.length;
|
|
303
|
+
} else if (node.nodeName !== 'LC_MENTION') {
|
|
304
|
+
Array.from(node.childNodes).forEach(searchNodesForText);
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
searchNodesForText(editorElement);
|
|
308
|
+
if (matches.length === 0) {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
let match = matches[0];
|
|
312
|
+
if (options !== null && options !== void 0 && options.shouldReplaceNearCursor && cursorPos !== null) {
|
|
313
|
+
match = matches.reduce((prev, curr) => Math.abs(curr.absIndex - cursorPos) < Math.abs(prev.absIndex - cursorPos) ? curr : prev);
|
|
314
|
+
}
|
|
315
|
+
if (!match) {
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
range.setStart(match.node, match.offset);
|
|
319
|
+
range.setEnd(match.node, match.offset + searchText.length);
|
|
320
|
+
return range;
|
|
321
|
+
};
|
|
322
|
+
exports.findAndSelectText = findAndSelectText;
|
|
323
|
+
const getCurrentCursorPosition = editorElement => {
|
|
324
|
+
var _window$getSelection2, _window;
|
|
325
|
+
if (!editorElement) {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
const sel = (_window$getSelection2 = (_window = window).getSelection) === null || _window$getSelection2 === void 0 ? void 0 : _window$getSelection2.call(_window);
|
|
329
|
+
if (!sel || sel.rangeCount === 0) {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
const range = sel.getRangeAt(0);
|
|
333
|
+
if (!editorElement.contains(range.commonAncestorContainer)) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
const pre = document.createRange();
|
|
337
|
+
pre.selectNodeContents(editorElement);
|
|
338
|
+
try {
|
|
339
|
+
pre.setEnd(range.startContainer, range.startOffset);
|
|
340
|
+
const container = document.createElement('div');
|
|
341
|
+
container.appendChild(pre.cloneContents());
|
|
342
|
+
const bbCodeUntilCursor = (0, _text.convertHTMLToText)(container.innerHTML, {
|
|
343
|
+
preserveSpaces: true
|
|
344
|
+
});
|
|
345
|
+
return bbCodeUntilCursor.length;
|
|
346
|
+
} catch {
|
|
347
|
+
return (0, _text.convertHTMLToText)(editorElement.innerHTML).length;
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
exports.getCurrentCursorPosition = getCurrentCursorPosition;
|
|
351
|
+
//# sourceMappingURL=selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.js","names":["_number","require","_text","childIndex","endOffset","startOffset","saveSelection","element","shouldIgnoreEmptyTextNodes","selection","window","getSelection","anchorNode","range","getRangeAt","childNodesArray","Array","from","childNodes","filter","nodeType","nodeValue","Node","TEXT_NODE","indexOf","exports","restoreSelection","hasFoundNoJoiner","forEach","node","noJoinerIndex","replace","childNode","elementTextLength","getElementTextLength","nextSibling","charCodeAt","_childNode$parentNode","textNode","document","createTextNode","parentNode","insertBefore","length","_childNode$parentNode2","_childNode$nextSiblin","_childNode$nextSiblin2","_childNode$parentNode3","_childNode$parentNode4","createRange","clamp","setStart","setEnd","error","removeAllRanges","addRange","collapse","insertInvisibleCursorMarker","rangeCount","startContainer","offset","execCommand","span","createElement","style","display","width","height","className","parent","textContent","beforeText","slice","afterText","afterTextNode","setTimeout","newRange","setStartAfter","setEndAfter","remove","insertPseudoMarker","marker","id","insertNode","insertCursorAtMarker","ref","_ref$current","current","querySelector","moveSelectionOffset","distance","setChildIndex","index","getCharCodeThatWillBeDeleted","event","_window$getSelection","_nextSibling$nodeValu","key","_previousSibling$node","previousSibling","endContainer","findAndSelectText","editorElement","searchText","options","shouldReplaceNearCursor","_editorElement$textCo","includes","cursorPos","getCurrentCursorPosition","matches","absCounter","searchNodesForText","push","absIndex","nodeName","match","reduce","prev","curr","Math","abs","_window$getSelection2","_window","sel","call","contains","commonAncestorContainer","pre","selectNodeContents","container","appendChild","cloneContents","bbCodeUntilCursor","convertHTMLToText","innerHTML","preserveSpaces"],"sources":["../../../src/utils/selection.ts"],"sourcesContent":["import type { KeyboardEvent, RefObject } from 'react';\nimport { clamp } from './number';\nimport { convertHTMLToText, getElementTextLength } from './text';\n\nlet childIndex = -1;\nlet endOffset = -1;\nlet startOffset = -1;\n\ninterface SaveSelectionOptions {\n shouldIgnoreEmptyTextNodes?: boolean;\n}\n\nexport const saveSelection = (\n element: HTMLDivElement,\n { shouldIgnoreEmptyTextNodes }: SaveSelectionOptions = {},\n) => {\n const selection = window.getSelection();\n\n if (!selection) {\n return;\n }\n\n const { anchorNode } = selection;\n\n if (!anchorNode) {\n return;\n }\n\n const range = selection.getRangeAt(0);\n\n let childNodesArray = Array.from(element.childNodes);\n\n if (shouldIgnoreEmptyTextNodes) {\n childNodesArray = childNodesArray.filter(\n ({ nodeType, nodeValue }) =>\n nodeType !== Node.TEXT_NODE || (nodeValue !== '' && nodeValue !== '\\u200B'),\n );\n }\n\n childIndex = childNodesArray.indexOf(anchorNode as ChildNode);\n\n endOffset = range.endOffset;\n startOffset = range.startOffset;\n};\n\nexport const restoreSelection = (element: HTMLDivElement) => {\n // Search for \\u200C in child nodes. If found, set the childIndex, startOffset, and endOffset to the\n // position of the \\u200C character. Also remove the \\u200C character from the child node. If not found,\n // the childIndex, startOffset, and endOffset will be like before.\n const childNodesArray = Array.from(element.childNodes);\n\n let hasFoundNoJoiner = false;\n\n childNodesArray.forEach((node) => {\n if (\n !hasFoundNoJoiner &&\n node.nodeType === Node.TEXT_NODE &&\n typeof node.nodeValue === 'string'\n ) {\n const noJoinerIndex = node.nodeValue.indexOf('\\u200C');\n\n if (noJoinerIndex !== -1) {\n hasFoundNoJoiner = true;\n\n childIndex = childNodesArray.indexOf(node);\n startOffset = noJoinerIndex;\n endOffset = noJoinerIndex;\n }\n }\n });\n\n // Remove all no joiner characters from the child nodes if no joiner was found\n if (hasFoundNoJoiner) {\n childNodesArray.forEach((node) => {\n if (node.nodeType === Node.TEXT_NODE && typeof node.nodeValue === 'string') {\n // eslint-disable-next-line no-param-reassign\n node.nodeValue = node.nodeValue.replace(/\\u200C/g, '');\n }\n });\n }\n\n let childNode = element.childNodes[childIndex];\n\n const selection = window.getSelection();\n\n if (!childNode || !element || !selection) {\n return;\n }\n\n // noinspection SuspiciousTypeOfGuard\n if (typeof childNode.nodeValue !== 'string') {\n const elementTextLength = getElementTextLength(childNode as Element);\n\n if (childNode.nextSibling) {\n childNode = childNode.nextSibling;\n\n if (childNode.nodeType === Node.TEXT_NODE && childNode.nodeValue) {\n endOffset -= elementTextLength;\n startOffset -= elementTextLength;\n\n if (childNode.nodeValue.charCodeAt(endOffset) === 8203) {\n endOffset += 1;\n startOffset += 1;\n }\n } else {\n const textNode = document.createTextNode('\\u200B');\n\n childNode.parentNode?.insertBefore(textNode, childNode.nextSibling);\n\n childNode = textNode;\n\n endOffset = textNode.length;\n startOffset = textNode.length;\n }\n } else {\n const textNode = document.createTextNode('\\u200B');\n\n childNode.parentNode?.insertBefore(textNode, childNode.nextSibling);\n\n childNode = textNode;\n\n endOffset = textNode.length;\n startOffset = textNode.length;\n }\n } else if (childNode.nodeValue && endOffset > childNode.nodeValue.length) {\n if (childNode.nextSibling?.nodeValue) {\n let elementTextLength = childNode.nodeValue.length;\n\n childNode = childNode.nextSibling;\n\n // noinspection SuspiciousTypeOfGuard\n if (typeof childNode.nodeValue !== 'string') {\n elementTextLength += getElementTextLength(childNode as Element);\n\n if (childNode.nextSibling?.nodeValue) {\n childNode = childNode.nextSibling;\n\n if (childNode.nodeType === Node.TEXT_NODE && childNode.nodeValue) {\n endOffset -= elementTextLength;\n startOffset -= elementTextLength;\n\n if (childNode.nodeValue.charCodeAt(endOffset) === 8203) {\n endOffset += 1;\n startOffset += 1;\n }\n } else {\n const textNode = document.createTextNode('\\u200B');\n\n childNode.parentNode?.insertBefore(textNode, childNode.nextSibling);\n\n childNode = textNode;\n\n endOffset = textNode.length;\n startOffset = textNode.length;\n }\n } else {\n const textNode = document.createTextNode('\\u200B');\n\n childNode.parentNode?.insertBefore(textNode, childNode.nextSibling);\n\n childNode = textNode;\n\n endOffset = textNode.length;\n startOffset = textNode.length;\n }\n }\n } else {\n endOffset = childNode.nodeValue.length;\n startOffset = childNode.nodeValue.length;\n }\n }\n\n const range = document.createRange();\n\n // noinspection SuspiciousTypeOfGuard\n if (typeof childNode.nodeValue === 'string') {\n startOffset = clamp(startOffset, 0, childNode.nodeValue.length);\n endOffset = clamp(endOffset, 0, childNode.nodeValue.length);\n }\n\n try {\n range.setStart(childNode, startOffset);\n range.setEnd(childNode, endOffset);\n } catch (error) {\n // Do nothing\n }\n\n selection.removeAllRanges();\n selection.addRange(range);\n\n range.collapse(true);\n};\n\nexport const insertInvisibleCursorMarker = (): void => {\n const selection = window.getSelection();\n\n if (!selection || selection.rangeCount === 0) {\n return;\n }\n\n const range = selection.getRangeAt(0);\n const textNode = range.startContainer;\n const offset = range.startOffset;\n\n // noinspection JSDeprecatedSymbols\n document.execCommand('delete', false);\n\n const span = document.createElement('span');\n span.style.display = 'inline-block';\n span.style.width = '0';\n span.style.height = '0';\n span.className = 'invisible-cursor-marker';\n\n const parent = textNode.parentNode;\n\n if (parent) {\n if (textNode.nodeType === Node.TEXT_NODE) {\n const textContent = textNode.textContent || '';\n const beforeText = textContent.slice(0, offset);\n const afterText = textContent.slice(offset);\n\n textNode.textContent = beforeText;\n\n parent.insertBefore(span, textNode.nextSibling);\n const afterTextNode = document.createTextNode(afterText);\n parent.insertBefore(afterTextNode, span.nextSibling);\n\n setTimeout(() => {\n // Set cursor to cursor element\n const newRange = document.createRange();\n newRange.setStartAfter(span);\n newRange.setEndAfter(span);\n selection.removeAllRanges();\n selection.addRange(newRange);\n\n // Remove cursor element\n span.remove();\n }, 10);\n }\n }\n};\n\nexport const insertPseudoMarker = () => {\n const selection = window.getSelection();\n\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n const marker = document.createElement('span');\n marker.id = 'cursor-marker';\n marker.style.display = 'inline-block';\n marker.style.width = '0';\n marker.style.height = '0';\n range.insertNode(marker);\n }\n};\n\nexport const insertCursorAtMarker = (ref: RefObject<HTMLDivElement>) => {\n const marker = ref.current?.querySelector('#cursor-marker');\n\n if (marker) {\n const selection = window.getSelection();\n const range = document.createRange();\n range.setStartAfter(marker);\n range.setEndAfter(marker);\n selection?.removeAllRanges();\n selection?.addRange(range);\n marker.remove();\n }\n};\n\nexport const moveSelectionOffset = (distance: number) => {\n endOffset += distance;\n startOffset += distance;\n};\n\nexport const setChildIndex = (index: number) => {\n childIndex = index;\n};\n\n/**\n * This function returns the code of the character that will be removed by the KeyDown event in the\n * next step, if the \"Backspace\" or \"Delete\" key was pressed and there is no selection of multiple\n * characters.\n *\n * @param event - Keyboard event from \"onKeyDown\"\n */\nexport const getCharCodeThatWillBeDeleted = (event: KeyboardEvent<HTMLDivElement>) => {\n const range = window.getSelection()?.getRangeAt(0);\n\n /**\n * At this point the function is aborted if there is no selection range, several characters have\n * been selected and therefore no single letter is removed or neither the \"Backspace\" nor the\n * \"Delete\" key has been pressed.\n */\n if (\n !range ||\n range.endOffset !== range.startOffset ||\n (event.key !== 'Backspace' && event.key !== 'Delete' && event.key !== 'Unidentified')\n ) {\n return null;\n }\n\n if (event.key === 'Backspace' || event.key === 'Unidentified') {\n const { nodeValue, previousSibling } = range.startContainer;\n\n if (range.startOffset > 0) {\n return nodeValue?.charCodeAt(range.startOffset - 1);\n }\n\n return previousSibling?.nodeValue?.charCodeAt(previousSibling.nodeValue.length - 1);\n }\n\n const { nextSibling, nodeValue } = range.endContainer;\n\n if (range.endOffset < (nodeValue?.length ?? 0)) {\n return nodeValue?.charCodeAt(range.endOffset);\n }\n\n return nextSibling?.nodeValue?.charCodeAt(0);\n};\n\nexport type ReplaceTextOptions = { shouldReplaceNearCursor?: boolean };\n\ninterface FindAndSelectTextOptions {\n editorElement: HTMLDivElement;\n searchText: string;\n options?: ReplaceTextOptions;\n}\n\ntype Match = { node: Node; offset: number; absIndex: number };\n\nexport const findAndSelectText = ({\n editorElement,\n searchText,\n options = { shouldReplaceNearCursor: true },\n}: FindAndSelectTextOptions): Range | null => {\n if (!editorElement.textContent?.includes(searchText)) {\n return null;\n }\n\n const range = document.createRange();\n\n const cursorPos = getCurrentCursorPosition(editorElement);\n\n const matches: Match[] = [];\n let absCounter = 0;\n\n const searchNodesForText = (node: Node) => {\n if (node.nodeType === Node.TEXT_NODE && node.textContent) {\n let index = node.textContent.indexOf(searchText);\n while (index !== -1) {\n matches.push({\n node,\n offset: index,\n absIndex: absCounter + index,\n });\n index = node.textContent.indexOf(searchText, index + 1);\n }\n absCounter += node.textContent.length;\n } else if (node.nodeName !== 'LC_MENTION') {\n Array.from(node.childNodes).forEach(searchNodesForText);\n }\n };\n\n searchNodesForText(editorElement);\n\n if (matches.length === 0) {\n return null;\n }\n\n let match = matches[0];\n\n if (options?.shouldReplaceNearCursor && cursorPos !== null) {\n match = matches.reduce((prev, curr) =>\n Math.abs(curr.absIndex - cursorPos) < Math.abs(prev.absIndex - cursorPos) ? curr : prev,\n );\n }\n\n if (!match) {\n return null;\n }\n\n range.setStart(match.node, match.offset);\n range.setEnd(match.node, match.offset + searchText.length);\n\n return range;\n};\n\nexport const getCurrentCursorPosition = (editorElement: HTMLDivElement | null): number | null => {\n if (!editorElement) {\n return null;\n }\n\n const sel = window.getSelection?.();\n if (!sel || sel.rangeCount === 0) {\n return null;\n }\n\n const range = sel.getRangeAt(0);\n\n if (!editorElement.contains(range.commonAncestorContainer)) {\n return null;\n }\n\n const pre = document.createRange();\n pre.selectNodeContents(editorElement);\n\n try {\n pre.setEnd(range.startContainer, range.startOffset);\n\n const container = document.createElement('div');\n container.appendChild(pre.cloneContents());\n\n const bbCodeUntilCursor = convertHTMLToText(container.innerHTML, { preserveSpaces: true });\n\n return bbCodeUntilCursor.length;\n } catch {\n return convertHTMLToText(editorElement.innerHTML).length;\n }\n};\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAIE,UAAU,GAAG,CAAC,CAAC;AACnB,IAAIC,SAAS,GAAG,CAAC,CAAC;AAClB,IAAIC,WAAW,GAAG,CAAC,CAAC;AAMb,MAAMC,aAAa,GAAGA,CACzBC,OAAuB,EACvB;EAAEC;AAAiD,CAAC,GAAG,CAAC,CAAC,KACxD;EACD,MAAMC,SAAS,GAAGC,MAAM,CAACC,YAAY,CAAC,CAAC;EAEvC,IAAI,CAACF,SAAS,EAAE;IACZ;EACJ;EAEA,MAAM;IAAEG;EAAW,CAAC,GAAGH,SAAS;EAEhC,IAAI,CAACG,UAAU,EAAE;IACb;EACJ;EAEA,MAAMC,KAAK,GAAGJ,SAAS,CAACK,UAAU,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