2018-11-05 04:19:40 +02:00
|
|
|
<template>
|
2018-12-06 03:02:04 +02:00
|
|
|
<img v-if="customEmoji" class="fvgwvorwhxigeolkkrcderjzcawqrscl custom" :class="{ normal: normal }" :src="url" :alt="alt" :title="alt"/>
|
2018-11-05 12:20:35 +02:00
|
|
|
<img v-else-if="char && !useOsDefaultEmojis" class="fvgwvorwhxigeolkkrcderjzcawqrscl" :src="url" :alt="alt" :title="alt"/>
|
|
|
|
<span v-else-if="char && useOsDefaultEmojis">{{ char }}</span>
|
|
|
|
<span v-else>:{{ name }}:</span>
|
2018-11-05 04:19:40 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-11 21:09:02 +02:00
|
|
|
// スクリプトサイズがデカい
|
|
|
|
//import { lib } from 'emojilib';
|
2019-02-04 20:51:54 +02:00
|
|
|
import { getStaticImageUrl } from '../../../common/scripts/get-static-image-url';
|
2019-03-18 15:02:45 +02:00
|
|
|
import { twemojiBase } from '../../../../../misc/twemoji-base';
|
2018-11-05 09:19:10 +02:00
|
|
|
|
2018-11-05 04:19:40 +02:00
|
|
|
export default Vue.extend({
|
2018-11-05 06:23:26 +02:00
|
|
|
props: {
|
2018-11-05 12:20:35 +02:00
|
|
|
name: {
|
2018-11-05 06:23:26 +02:00
|
|
|
type: String,
|
2018-11-05 08:15:30 +02:00
|
|
|
required: false
|
|
|
|
},
|
2018-11-05 12:20:35 +02:00
|
|
|
emoji: {
|
2018-11-05 08:15:30 +02:00
|
|
|
type: String,
|
|
|
|
required: false
|
2018-11-05 06:23:26 +02:00
|
|
|
},
|
2018-12-06 03:02:04 +02:00
|
|
|
normal: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
2018-11-05 06:23:26 +02:00
|
|
|
customEmojis: {
|
2018-11-05 12:20:35 +02:00
|
|
|
required: false,
|
2018-11-12 17:12:55 +02:00
|
|
|
default: () => []
|
2019-03-17 17:03:57 +02:00
|
|
|
},
|
|
|
|
isReaction: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
},
|
2018-11-05 06:23:26 +02:00
|
|
|
},
|
2018-11-05 12:20:35 +02:00
|
|
|
|
2018-11-05 04:19:40 +02:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
url: null,
|
2018-11-05 12:20:35 +02:00
|
|
|
char: null,
|
|
|
|
customEmoji: null
|
2018-11-05 04:19:40 +02:00
|
|
|
}
|
|
|
|
},
|
2018-11-05 12:20:35 +02:00
|
|
|
|
|
|
|
computed: {
|
|
|
|
alt(): string {
|
2018-11-05 12:33:28 +02:00
|
|
|
return this.customEmoji ? `:${this.customEmoji.name}:` : this.char;
|
2018-11-05 12:20:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
useOsDefaultEmojis(): boolean {
|
2019-03-17 17:03:57 +02:00
|
|
|
return this.$store.state.device.useOsDefaultEmojis && !this.isReaction;
|
2018-11-05 12:20:35 +02:00
|
|
|
}
|
2018-11-05 04:19:40 +02:00
|
|
|
},
|
2018-11-05 12:20:35 +02:00
|
|
|
|
2019-07-05 11:58:54 +03:00
|
|
|
watch: {
|
|
|
|
customEmojis() {
|
|
|
|
if (this.name) {
|
|
|
|
const customEmoji = this.customEmojis.find(x => x.name == this.name);
|
|
|
|
if (customEmoji) {
|
|
|
|
this.customEmoji = customEmoji;
|
|
|
|
this.url = this.$store.state.device.disableShowingAnimatedImages
|
|
|
|
? getStaticImageUrl(customEmoji.url)
|
|
|
|
: customEmoji.url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2018-11-05 12:20:35 +02:00
|
|
|
created() {
|
|
|
|
if (this.name) {
|
|
|
|
const customEmoji = this.customEmojis.find(x => x.name == this.name);
|
|
|
|
if (customEmoji) {
|
|
|
|
this.customEmoji = customEmoji;
|
2019-02-04 21:09:44 +02:00
|
|
|
this.url = this.$store.state.device.disableShowingAnimatedImages
|
2019-02-04 20:51:54 +02:00
|
|
|
? getStaticImageUrl(customEmoji.url)
|
|
|
|
: customEmoji.url;
|
2018-11-05 12:20:35 +02:00
|
|
|
} else {
|
2018-11-11 21:09:02 +02:00
|
|
|
//const emoji = lib[this.name];
|
|
|
|
//if (emoji) {
|
|
|
|
// this.char = emoji.char;
|
|
|
|
//}
|
2018-11-05 04:19:40 +02:00
|
|
|
}
|
2018-11-05 12:20:35 +02:00
|
|
|
} else {
|
|
|
|
this.char = this.emoji;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.char) {
|
2018-12-07 10:21:34 +02:00
|
|
|
let codes = Array.from(this.char).map(x => x.codePointAt(0).toString(16));
|
2018-11-06 07:09:40 +02:00
|
|
|
if (!codes.includes('200d')) codes = codes.filter(x => x != 'fe0f');
|
2018-12-07 10:21:34 +02:00
|
|
|
codes = codes.filter(x => x && x.length);
|
2018-11-06 07:09:40 +02:00
|
|
|
|
2019-03-18 15:02:45 +02:00
|
|
|
this.url = `${twemojiBase}/2/svg/${codes.join('-')}.svg`;
|
2018-11-05 04:19:40 +02:00
|
|
|
}
|
2019-07-05 11:58:54 +03:00
|
|
|
},
|
2018-11-05 04:19:40 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-11-05 12:20:35 +02:00
|
|
|
.fvgwvorwhxigeolkkrcderjzcawqrscl
|
2018-11-05 18:48:33 +02:00
|
|
|
height 1.25em
|
|
|
|
vertical-align -0.25em
|
2018-11-05 12:20:35 +02:00
|
|
|
|
|
|
|
&.custom
|
|
|
|
height 2.5em
|
|
|
|
vertical-align middle
|
2018-11-05 14:04:19 +02:00
|
|
|
transition transform 0.2s ease
|
|
|
|
|
|
|
|
&:hover
|
|
|
|
transform scale(1.2)
|
2018-11-05 12:20:35 +02:00
|
|
|
|
2018-12-06 03:02:04 +02:00
|
|
|
&.normal
|
|
|
|
height 1.25em
|
|
|
|
vertical-align -0.25em
|
|
|
|
|
|
|
|
&:hover
|
|
|
|
transform none
|
|
|
|
|
2018-11-05 04:19:40 +02:00
|
|
|
</style>
|