summaryrefslogtreecommitdiffstats
path: root/src/components/Emoji.vue
blob: 00257f348a3a1ba0dba7922456d06d7ad5396636 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<template>
	<img class="emoji" draggable="false" :alt="emoji"
		:src="emojiUrl">
</template>

<script>
import { generateFilePath } from '@nextcloud/router'
import twemoji from 'twemoji'

// avoid using a string literal like '\u200D' here because minifiers expand it inline
const U200D = String.fromCharCode(0x200D)
const UFE0Fg = /\uFE0F/g

export default {
	name: 'Emoji',
	props: {
		emoji: { type: String, default: '' }
	},
	data: function() {
		return {}
	},
	computed: {
		icon() {
			return twemoji.convert.toCodePoint(this.emoji.indexOf(U200D) < 0
				? this.emoji.replace(UFE0Fg, '')
				: this.emoji
			)
		},
		emojiUrl() {
			return generateFilePath('social', 'img', 'twemoji/' + this.icon + '.svg')
		}
	}
}
</script>
<style scoped>

</style>