summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-11-05 18:01:51 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-11-05 18:01:51 +0900
commitbb76ee2c0ec20cc465ee2647cf9412db379db5fb (patch)
tree5194f93756e9be75dc99d2dd8e5f7ca1087a5ace /packages
parentenhance(build): フォールバック効かすためにlocaleの空文字は... (diff)
downloadsharkey-bb76ee2c0ec20cc465ee2647cf9412db379db5fb.tar.gz
sharkey-bb76ee2c0ec20cc465ee2647cf9412db379db5fb.tar.bz2
sharkey-bb76ee2c0ec20cc465ee2647cf9412db379db5fb.zip
enhance(frontend): 投稿内のunicode絵文字もメニューを出せるように
Diffstat (limited to 'packages')
-rw-r--r--packages/frontend/src/components/global/MkEmoji.vue35
-rw-r--r--packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts2
2 files changed, 34 insertions, 3 deletions
diff --git a/packages/frontend/src/components/global/MkEmoji.vue b/packages/frontend/src/components/global/MkEmoji.vue
index e06549a891..0855f20b8d 100644
--- a/packages/frontend/src/components/global/MkEmoji.vue
+++ b/packages/frontend/src/components/global/MkEmoji.vue
@@ -4,21 +4,28 @@ SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
-<img v-if="!useOsNativeEmojis" :class="$style.root" :src="url" :alt="props.emoji" decoding="async" @pointerenter="computeTitle"/>
-<span v-else-if="useOsNativeEmojis" :alt="props.emoji" @pointerenter="computeTitle">{{ props.emoji }}</span>
+<img v-if="!useOsNativeEmojis" :class="$style.root" :src="url" :alt="props.emoji" decoding="async" @pointerenter="computeTitle" @click="onClick"/>
+<span v-else-if="useOsNativeEmojis" :alt="props.emoji" @pointerenter="computeTitle" @click="onClick">{{ props.emoji }}</span>
<span v-else>{{ emoji }}</span>
</template>
<script lang="ts" setup>
-import { computed } from 'vue';
+import { computed, inject } from 'vue';
import { char2twemojiFilePath, char2fluentEmojiFilePath } from '@/scripts/emoji-base.js';
import { defaultStore } from '@/store.js';
import { getEmojiName } from '@/scripts/emojilist.js';
+import * as os from '@/os.js';
+import copyToClipboard from '@/scripts/copy-to-clipboard.js';
+import { i18n } from '@/i18n.js';
const props = defineProps<{
emoji: string;
+ menu?: boolean;
+ menuReaction?: boolean;
}>();
+const react = inject<((name: string) => void) | null>('react', null);
+
const char2path = defaultStore.state.emojiStyle === 'twemoji' ? char2twemojiFilePath : char2fluentEmojiFilePath;
const useOsNativeEmojis = computed(() => defaultStore.state.emojiStyle === 'native');
@@ -31,6 +38,28 @@ function computeTitle(event: PointerEvent): void {
const title = getEmojiName(props.emoji as string) ?? props.emoji as string;
(event.target as HTMLElement).title = title;
}
+
+function onClick(ev: MouseEvent) {
+ if (props.menu) {
+ os.popupMenu([{
+ type: 'label',
+ text: props.emoji,
+ }, {
+ text: i18n.ts.copy,
+ icon: 'ti ti-copy',
+ action: () => {
+ copyToClipboard(props.emoji);
+ os.success();
+ },
+ }, ...(props.menuReaction && react ? [{
+ text: i18n.ts.doReaction,
+ icon: 'ti ti-plus',
+ action: () => {
+ react(props.emoji);
+ },
+ }] : [])], ev.currentTarget ?? ev.target);
+ }
+}
</script>
<style lang="scss" module>
diff --git a/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts b/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts
index d7e1490502..441731d7ca 100644
--- a/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts
+++ b/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts
@@ -354,6 +354,8 @@ export default function(props: MfmProps) {
return [h(MkEmoji, {
key: Math.random(),
emoji: token.props.emoji,
+ menu: props.enableEmojiMenu,
+ menuReaction: props.enableEmojiMenuReaction,
})];
}