2018-08-20 00:23:40 +02:00
|
|
|
<span class="account-display-name">{@html massagedAccountName }</span>
|
|
|
|
<style>
|
|
|
|
.account-display-name {
|
|
|
|
pointer-events: none; /* allows focus to work correctly, focus on the parent only */
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script>
|
2018-08-20 03:03:26 +02:00
|
|
|
import { emojifyText, removeEmoji } from '../../_utils/emojifyText'
|
2018-08-20 00:23:40 +02:00
|
|
|
import { store } from '../../_store/store'
|
|
|
|
import escapeHtml from 'escape-html'
|
2018-08-20 03:03:26 +02:00
|
|
|
import emojiRegex from 'emoji-regex'
|
|
|
|
|
|
|
|
let theEmojiRegex
|
2018-08-20 00:23:40 +02:00
|
|
|
|
|
|
|
export default {
|
|
|
|
store: () => store,
|
|
|
|
computed: {
|
|
|
|
emojis: ({ account }) => (account.emojis || []),
|
|
|
|
accountName: ({ account }) => (account.display_name || account.username),
|
2018-08-20 03:03:26 +02:00
|
|
|
massagedAccountName: ({ accountName, emojis, $autoplayGifs, $omitEmojiInDisplayNames }) => {
|
2018-08-20 00:23:40 +02:00
|
|
|
accountName = escapeHtml(accountName)
|
2018-08-20 03:03:26 +02:00
|
|
|
|
|
|
|
if ($omitEmojiInDisplayNames) { // display name emoji are annoying to some screenreader users
|
|
|
|
theEmojiRegex = theEmojiRegex || emojiRegex() // only init when needed
|
|
|
|
let emojiFreeAccountName = removeEmoji(accountName.replace(theEmojiRegex, ''), emojis).trim()
|
|
|
|
if (emojiFreeAccountName) {
|
|
|
|
return emojiFreeAccountName // only remove emoji if the resulting username is non-empty
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-20 00:23:40 +02:00
|
|
|
return emojifyText(accountName, emojis, $autoplayGifs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|