-
-
Notifications
You must be signed in to change notification settings - Fork 583
/
Copy pathStatusBody.vue
59 lines (53 loc) · 1.65 KB
/
StatusBody.vue
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<script setup lang="ts">
import type { mastodon } from 'masto'
const {
status,
newer,
withAction = true,
} = defineProps<{
status: mastodon.v1.Status | mastodon.v1.StatusEdit
newer?: mastodon.v1.Status
withAction?: boolean
}>()
const { translation } = useTranslation(status, getLanguageCode())
const emojisObject = useEmojisFallback(() => status.emojis)
const vnode = computed(() => {
if (!status.content)
return null
return contentToVNode(status.content, {
emojis: emojisObject.value,
mentions: 'mentions' in status ? status.mentions : undefined,
markdown: true,
collapseMentionLink: !!('inReplyToId' in status && status.inReplyToId),
status: 'id' in status ? status : undefined,
inReplyToStatus: newer,
})
})
const userSettings = useUserSettings()
const lineHeight = userSettings.value.lineHeight
</script>
<template>
<div class="status-body" whitespace-pre-wrap break-words :class="{ 'with-action': withAction }" relative>
<span
v-if="status.content"
class="content-rich" :class="[`line-height-${lineHeight}`]"
dir="auto"
:lang="('language' in status && status.language) || undefined"
>
<component :is="vnode" v-if="vnode" />
</span>
<div v-else />
<template v-if="translation.visible">
<div my2 h-px border="b base" bg-base />
<ContentRich v-if="translation.success" class="content-rich" :class="[`line-height-${lineHeight}`]" :content="translation.text" :emojis="status.emojis" />
<div v-else text-red-4>
Error: {{ translation.error }}
</div>
</template>
</div>
</template>
<style>
.status-body.with-action p {
cursor: pointer;
}
</style>