merge: upstream

This commit is contained in:
Marie 2024-02-03 20:19:44 +01:00
commit 11628e4b6a
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
285 changed files with 3413 additions and 1913 deletions

View file

@ -1,34 +0,0 @@
/*
* SPDX-FileCopyrightText: syuilo and other misskey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
export type BlockBase = {
id: string;
type: string;
};
export type TextBlock = BlockBase & {
type: 'text';
text: string;
};
export type SectionBlock = BlockBase & {
type: 'section';
title: string;
children: Block[];
};
export type ImageBlock = BlockBase & {
type: 'image';
fileId: string | null;
};
export type NoteBlock = BlockBase & {
type: 'note';
detailed: boolean;
note: string | null;
};
export type Block =
TextBlock | SectionBlock | ImageBlock | NoteBlock;

View file

@ -14,7 +14,6 @@ import XText from './page.text.vue';
import XSection from './page.section.vue';
import XImage from './page.image.vue';
import XNote from './page.note.vue';
import { Block } from './block.type.js';
function getComponent(type: string) {
switch (type) {
@ -27,7 +26,7 @@ function getComponent(type: string) {
}
defineProps<{
block: Block,
block: Misskey.entities.PageBlock,
h: number,
page: Misskey.entities.Page,
}>();

View file

@ -14,15 +14,19 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { onMounted, ref } from 'vue';
import * as Misskey from 'misskey-js';
import { ImageBlock } from './block.type.js';
import MediaImage from '@/components/MkMediaImage.vue';
const props = defineProps<{
block: ImageBlock,
block: Misskey.entities.PageBlock,
page: Misskey.entities.Page,
}>();
const image = ref<Misskey.entities.DriveFile>(props.page.attachedFiles.find(x => x.id === props.block.fileId));
const image = ref<Misskey.entities.DriveFile | null>(null);
onMounted(() => {
image.value = props.page.attachedFiles.find(x => x.id === props.block.fileId) ?? null;
});
</script>

View file

@ -13,19 +13,19 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import * as Misskey from 'misskey-js';
import { NoteBlock } from './block.type.js';
import MkNote from '@/components/MkNote.vue';
import MkNoteDetailed from '@/components/MkNoteDetailed.vue';
import { misskeyApi } from '@/scripts/misskey-api.js';
const props = defineProps<{
block: NoteBlock,
block: Misskey.entities.PageBlock,
page: Misskey.entities.Page,
}>();
const note = ref<Misskey.entities.Note | null>(null);
onMounted(() => {
if (props.block.note == null) return;
misskeyApi('notes/show', { noteId: props.block.note })
.then(result => {
note.value = result;

View file

@ -25,12 +25,11 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { defineAsyncComponent } from 'vue';
import * as Misskey from 'misskey-js';
import { SectionBlock } from './block.type.js';
const XBlock = defineAsyncComponent(() => import('./page.block.vue'));
defineProps<{
block: SectionBlock,
block: Misskey.entities.PageBlock,
h: number,
page: Misskey.entities.Page,
}>();

View file

@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<div class="_gaps">
<Mfm :text="block.text" :isNote="false"/>
<Mfm :text="block.text ?? ''" :isNote="false"/>
<MkUrlPreview v-for="url in urls" :key="url" :url="url"/>
</div>
</template>
@ -14,13 +14,12 @@ SPDX-License-Identifier: AGPL-3.0-only
import { defineAsyncComponent } from 'vue';
import * as mfm from '@transfem-org/sfm-js';
import * as Misskey from 'misskey-js';
import { TextBlock } from './block.type.js';
import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm.js';
const MkUrlPreview = defineAsyncComponent(() => import('@/components/MkUrlPreview.vue'));
const props = defineProps<{
block: TextBlock,
block: Misskey.entities.PageBlock,
page: Misskey.entities.Page,
}>();