This commit is contained in:
syuilo
2023-05-14 10:50:21 +09:00
parent a979fb9207
commit 238d0fa667
13 changed files with 92 additions and 1043 deletions

View File

@@ -1,56 +1,26 @@
<template>
<div class="mrdgzndn">
<Mfm :key="text" :text="text" :is-note="false" :i="$i"/>
<Mfm :text="block.text" :is-note="false" :i="$i"/>
<MkUrlPreview v-for="url in urls" :key="url" :url="url" class="url"/>
</div>
</template>
<script lang="ts">
import { defineAsyncComponent, defineComponent, PropType } from 'vue';
<script lang="ts" setup>
import { defineAsyncComponent } from 'vue';
import * as mfm from 'mfm-js';
import { TextBlock } from '@/scripts/hpml/block';
import { Hpml } from '@/scripts/hpml/evaluator';
import * as Misskey from 'misskey-js';
import { TextBlock } from './block.type';
import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm';
import { $i } from '@/account';
export default defineComponent({
components: {
MkUrlPreview: defineAsyncComponent(() => import('@/components/MkUrlPreview.vue')),
},
props: {
block: {
type: Object as PropType<TextBlock>,
required: true,
},
hpml: {
type: Object as PropType<Hpml>,
required: true,
},
},
data() {
return {
text: this.hpml.interpolate(this.block.text),
$i,
};
},
computed: {
urls(): string[] {
if (this.text) {
return extractUrlFromMfm(mfm.parse(this.text));
} else {
return [];
}
},
},
watch: {
'hpml.vars': {
handler() {
this.text = this.hpml.interpolate(this.block.text);
},
deep: true,
},
},
});
const MkUrlPreview = defineAsyncComponent(() => import('@/components/MkUrlPreview.vue'));
const props = defineProps<{
block: TextBlock,
page: Misskey.entities.Page,
}>();
const urls = props.block.text ? extractUrlFromMfm(mfm.parse(props.block.text)) : [];
</script>
<style lang="scss" scoped>