2023-07-27 00:31:52 -05:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-11-14 22:42:04 -06:00
|
|
|
<template>
|
2021-11-18 08:32:43 -06:00
|
|
|
<!-- eslint-disable vue/no-mutating-props -->
|
2021-11-19 04:36:12 -06:00
|
|
|
<XContainer :draggable="true" @remove="() => $emit('remove')">
|
2023-04-01 00:01:57 -05:00
|
|
|
<template #header><i class="ti ti-note"></i> {{ i18n.ts._pages.blocks.note }}</template>
|
2020-11-14 22:42:04 -06:00
|
|
|
|
|
|
|
<section style="padding: 0 16px 0 16px;">
|
2021-08-06 08:29:19 -05:00
|
|
|
<MkInput v-model="id">
|
2023-04-01 00:01:57 -05:00
|
|
|
<template #label>{{ i18n.ts._pages.blocks._note.id }}</template>
|
|
|
|
<template #caption>{{ i18n.ts._pages.blocks._note.idDescription }}</template>
|
2020-11-14 22:42:04 -06:00
|
|
|
</MkInput>
|
2023-04-01 00:01:57 -05:00
|
|
|
<MkSwitch v-model="props.modelValue.detailed"><span>{{ i18n.ts._pages.blocks._note.detailed }}</span></MkSwitch>
|
2020-11-14 22:42:04 -06:00
|
|
|
|
2023-03-31 00:14:30 -05:00
|
|
|
<MkNote v-if="note && !props.modelValue.detailed" :key="note.id + ':normal'" v-model:note="note" style="margin-bottom: 16px;"/>
|
|
|
|
<MkNoteDetailed v-if="note && props.modelValue.detailed" :key="note.id + ':detail'" v-model:note="note" style="margin-bottom: 16px;"/>
|
2020-11-14 22:42:04 -06:00
|
|
|
</section>
|
|
|
|
</XContainer>
|
|
|
|
</template>
|
|
|
|
|
2022-06-18 04:39:04 -05:00
|
|
|
<script lang="ts" setup>
|
2021-11-18 08:32:43 -06:00
|
|
|
/* eslint-disable vue/no-mutating-props */
|
2023-12-06 23:42:09 -06:00
|
|
|
import { watch, ref } from 'vue';
|
2023-12-25 23:19:35 -06:00
|
|
|
import * as Misskey from 'misskey-js';
|
2020-11-14 22:42:04 -06:00
|
|
|
import XContainer from '../page-editor.container.vue';
|
2023-01-07 00:09:46 -06:00
|
|
|
import MkInput from '@/components/MkInput.vue';
|
2023-01-06 23:59:54 -06:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
2023-03-31 00:14:30 -05:00
|
|
|
import MkNote from '@/components/MkNote.vue';
|
|
|
|
import MkNoteDetailed from '@/components/MkNoteDetailed.vue';
|
2024-01-04 03:32:46 -06:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 02:37:43 -05:00
|
|
|
import { i18n } from '@/i18n.js';
|
2020-11-14 22:42:04 -06:00
|
|
|
|
2022-12-23 20:57:06 -06:00
|
|
|
const props = defineProps<{
|
|
|
|
modelValue: any
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
(ev: 'update:modelValue', value: any): void;
|
|
|
|
}>();
|
2020-11-14 22:42:04 -06:00
|
|
|
|
2023-12-06 23:42:09 -06:00
|
|
|
const id = ref<any>(props.modelValue.note);
|
2023-12-25 23:19:35 -06:00
|
|
|
const note = ref<Misskey.entities.Note | null>(null);
|
2020-11-14 22:42:04 -06:00
|
|
|
|
2023-12-06 23:42:09 -06:00
|
|
|
watch(id, async () => {
|
|
|
|
if (id.value && (id.value.startsWith('http://') || id.value.startsWith('https://'))) {
|
|
|
|
id.value = (id.value.endsWith('/') ? id.value.slice(0, -1) : id.value).split('/').pop();
|
2022-06-18 04:39:04 -05:00
|
|
|
}
|
2020-11-14 22:42:04 -06:00
|
|
|
|
2023-01-15 08:47:04 -06:00
|
|
|
emit('update:modelValue', {
|
|
|
|
...props.modelValue,
|
2023-12-06 23:42:09 -06:00
|
|
|
note: id.value,
|
2023-01-15 08:47:04 -06:00
|
|
|
});
|
2024-01-04 03:32:46 -06:00
|
|
|
note.value = await misskeyApi('notes/show', { noteId: id.value });
|
2022-06-18 04:39:04 -05:00
|
|
|
}, {
|
2022-12-22 01:01:59 -06:00
|
|
|
immediate: true,
|
2020-11-14 22:42:04 -06:00
|
|
|
});
|
|
|
|
</script>
|