fix: 🐛 properly apply unicode for skin tone selector
This commit is contained in:
parent
e5315db92c
commit
41c65a4623
2 changed files with 15 additions and 14 deletions
|
@ -14,7 +14,7 @@
|
|||
<button
|
||||
v-for="skinTone in props.skinTones"
|
||||
class="_button"
|
||||
@click.prevent="
|
||||
@click.stop="
|
||||
applyUnicodeSkinTone(
|
||||
props.skinTones.indexOf(skinTone) + 1
|
||||
)
|
||||
|
@ -43,7 +43,6 @@
|
|||
<script lang="ts" setup>
|
||||
import { ref, watch, onMounted } from "vue";
|
||||
import { addSkinTone } from "@/scripts/emojilist";
|
||||
import emojiComponents from "unicode-emoji-json/data-emoji-components.json";
|
||||
|
||||
const props = defineProps<{
|
||||
emojis: string[];
|
||||
|
@ -56,17 +55,6 @@ const localEmojis = ref([...props.emojis]);
|
|||
|
||||
function applyUnicodeSkinTone(custom?: number) {
|
||||
for (let i = 0; i < localEmojis.value.length; i++) {
|
||||
if (
|
||||
[
|
||||
emojiComponents.light_skin_tone,
|
||||
emojiComponents.medium_light_skin_tone,
|
||||
emojiComponents.medium_skin_tone,
|
||||
emojiComponents.medium_dark_skin_tone,
|
||||
emojiComponents.dark_skin_tone,
|
||||
].some((v) => localEmojis.value[i].endsWith(v))
|
||||
) {
|
||||
localEmojis.value[i] = localEmojis.value[i].slice(0, -1);
|
||||
}
|
||||
localEmojis.value[i] = addSkinTone(localEmojis.value[i], custom);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ export const unicodeEmojiSkinTones = [
|
|||
];
|
||||
|
||||
export function addSkinTone(emoji: string, skinTone?: number) {
|
||||
const individualData = import("unicode-emoji-json/data-by-emoji.json");
|
||||
|
||||
const chosenSkinTone = skinTone || defaultStore.state.reactionPickerSkinTone;
|
||||
const skinToneModifiers = [
|
||||
"",
|
||||
|
@ -54,7 +56,18 @@ export function addSkinTone(emoji: string, skinTone?: number) {
|
|||
emojiComponents.medium_dark_skin_tone,
|
||||
emojiComponents.dark_skin_tone,
|
||||
];
|
||||
return emoji + (skinToneModifiers[chosenSkinTone - 1] || "");
|
||||
if (individualData[emoji]?.skin_tone_support === false) {
|
||||
return emoji;
|
||||
}
|
||||
return (
|
||||
emoji.replace(
|
||||
new RegExp(
|
||||
`(${skinToneModifiers.slice(1).join("|")})`,
|
||||
"gi",
|
||||
),
|
||||
"",
|
||||
) + (skinToneModifiers[chosenSkinTone - 1] || "")
|
||||
);
|
||||
}
|
||||
|
||||
const unicodeFifteenEmojis = [
|
||||
|
|
Loading…
Reference in a new issue