2018-08-19 22:23:40 +00: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 01:03:26 +00:00
|
|
|
import { emojifyText, removeEmoji } from '../../_utils/emojifyText'
|
2018-08-19 22:23:40 +00:00
|
|
|
import { store } from '../../_store/store'
|
|
|
|
import escapeHtml from 'escape-html'
|
2018-08-20 01:03:26 +00:00
|
|
|
import emojiRegex from 'emoji-regex'
|
|
|
|
|
|
|
|
let theEmojiRegex
|
2018-08-19 22:23:40 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
store: () => store,
|
|
|
|
computed: {
|
|
|
|
emojis: ({ account }) => (account.emojis || []),
|
|
|
|
accountName: ({ account }) => (account.display_name || account.username),
|
2018-08-20 01:03:26 +00:00
|
|
|
massagedAccountName: ({ accountName, emojis, $autoplayGifs, $omitEmojiInDisplayNames }) => {
|
2018-08-19 22:23:40 +00:00
|
|
|
accountName = escapeHtml(accountName)
|
2018-08-20 01:03:26 +00: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-19 22:23:40 +00:00
|
|
|
return emojifyText(accountName, emojis, $autoplayGifs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|