2022-11-25 07:12:49 +00:00
|
|
|
import type { Emoji } from 'masto'
|
|
|
|
import { emojisArrayToObject } from '~/composables/utils'
|
2022-12-27 18:38:57 +00:00
|
|
|
import { currentCustomEmojis } from '~/composables/emojis'
|
2022-11-25 07:12:49 +00:00
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
name: 'ContentRich',
|
|
|
|
})
|
|
|
|
|
2022-12-17 21:01:20 +00:00
|
|
|
const { content, emojis, markdown = true } = defineProps<{
|
2022-11-25 07:12:49 +00:00
|
|
|
content: string
|
2022-12-17 21:01:20 +00:00
|
|
|
markdown?: boolean
|
2022-11-25 07:57:39 +00:00
|
|
|
emojis?: Emoji[]
|
2022-11-25 07:12:49 +00:00
|
|
|
}>()
|
|
|
|
|
2022-12-27 18:38:57 +00:00
|
|
|
const useEmojis = computed(() => {
|
|
|
|
const result: Emoji[] = []
|
|
|
|
if (emojis)
|
|
|
|
result.push(...emojis)
|
|
|
|
|
|
|
|
result.push(...currentCustomEmojis.value.emojis)
|
|
|
|
|
|
|
|
return emojisArrayToObject(result)
|
|
|
|
})
|
|
|
|
|
2022-11-25 07:12:49 +00:00
|
|
|
export default () => h(
|
2022-11-27 00:19:45 +00:00
|
|
|
'span',
|
2022-11-25 13:21:02 +00:00
|
|
|
{ class: 'content-rich' },
|
2022-12-17 21:01:20 +00:00
|
|
|
contentToVNode(content, {
|
2022-12-27 18:38:57 +00:00
|
|
|
emojis: useEmojis.value,
|
2022-12-17 21:01:20 +00:00
|
|
|
markdown,
|
|
|
|
}),
|
2022-11-25 07:12:49 +00:00
|
|
|
)
|