summaryrefslogtreecommitdiff
path: root/packages/client/src/components/global
diff options
context:
space:
mode:
authorKagami Sascha Rosylight <saschanaz@outlook.com>2022-12-25 15:52:52 +0900
committerGitHub <noreply@github.com>2022-12-25 15:52:52 +0900
commitdecde50c865afb287d8c0d67e2dba0af65b1d69e (patch)
tree51d83931ca6f836613e5c6b7d6b2c61414816bd8 /packages/client/src/components/global
parentrefactor(client): fix TypeScript errors from MkPageHeader (#9400) (diff)
downloadmisskey-decde50c865afb287d8c0d67e2dba0af65b1d69e.tar.gz
misskey-decde50c865afb287d8c0d67e2dba0af65b1d69e.tar.bz2
misskey-decde50c865afb287d8c0d67e2dba0af65b1d69e.zip
enhance(client): show Unicode emoji tooltip with its name (#9399)
* enhance(client): show Unicode emoji tooltip with its name * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: tamaina <tamaina@hotmail.co.jp> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
Diffstat (limited to 'packages/client/src/components/global')
-rw-r--r--packages/client/src/components/global/MkEmoji.vue23
1 files changed, 16 insertions, 7 deletions
diff --git a/packages/client/src/components/global/MkEmoji.vue b/packages/client/src/components/global/MkEmoji.vue
index 106778aee2..440ef6220d 100644
--- a/packages/client/src/components/global/MkEmoji.vue
+++ b/packages/client/src/components/global/MkEmoji.vue
@@ -1,17 +1,18 @@
<template>
<img v-if="customEmoji" class="mk-emoji custom" :class="{ normal, noStyle }" :src="url" :alt="alt" :title="alt" decoding="async"/>
-<img v-else-if="char && !useOsNativeEmojis" class="mk-emoji" :src="url" :alt="alt" :title="alt" decoding="async"/>
-<span v-else-if="char && useOsNativeEmojis">{{ char }}</span>
+<img v-else-if="char && !useOsNativeEmojis" class="mk-emoji" :src="url" decoding="async" @pointerenter="computeTitle"/>
+<span v-else-if="char && useOsNativeEmojis" :alt="alt" @pointerenter="computeTitle">{{ char }}</span>
<span v-else>{{ emoji }}</span>
</template>
<script lang="ts" setup>
-import { computed, ref, watch } from 'vue';
+import { computed } from 'vue';
import { CustomEmoji } from 'misskey-js/built/entities';
import { getStaticImageUrl } from '@/scripts/get-static-image-url';
import { char2filePath } from '@/scripts/twemoji-base';
import { defaultStore } from '@/store';
import { instance } from '@/instance';
+import { getEmojiName } from '@/scripts/emojilist';
const props = defineProps<{
emoji: string;
@@ -22,20 +23,28 @@ const props = defineProps<{
}>();
const isCustom = computed(() => props.emoji.startsWith(':'));
-const char = computed(() => isCustom.value ? null : props.emoji);
+const char = computed(() => isCustom.value ? undefined : props.emoji);
const useOsNativeEmojis = computed(() => defaultStore.state.useOsNativeEmojis && !props.isReaction);
const ce = computed(() => props.customEmojis ?? instance.emojis ?? []);
-const customEmoji = computed(() => isCustom.value ? ce.value.find(x => x.name === props.emoji.substr(1, props.emoji.length - 2)) : null);
+const customEmoji = computed(() => isCustom.value ? ce.value.find(x => x.name === props.emoji.substr(1, props.emoji.length - 2)) : undefined);
const url = computed(() => {
if (char.value) {
return char2filePath(char.value);
} else {
+ const rawUrl = (customEmoji.value as CustomEmoji).url;
return defaultStore.state.disableShowingAnimatedImages
- ? getStaticImageUrl(customEmoji.value.url)
- : customEmoji.value.url;
+ ? getStaticImageUrl(rawUrl)
+ : rawUrl;
}
});
const alt = computed(() => customEmoji.value ? `:${customEmoji.value.name}:` : char.value);
+
+function computeTitle(event: PointerEvent): void {
+ const title = customEmoji.value
+ ? `:${customEmoji.value.name}:`
+ : (getEmojiName(char.value as string) ?? char.value as string);
+ (event.target as HTMLElement).title = title;
+}
</script>
<style lang="scss" scoped>