mirror of
https://github.com/paricafe/misskey.git
synced 2024-12-01 20:36:44 -06:00
63 lines
1.5 KiB
Vue
63 lines
1.5 KiB
Vue
|
<template>
|
||
|
<XContainer @remove="() => $emit('remove')" :draggable="true">
|
||
|
<template #header><Fa :icon="faStickyNote"/> {{ $t('_pages.blocks.note') }}</template>
|
||
|
|
||
|
<section style="padding: 0 16px 0 16px;">
|
||
|
<MkInput v-model:value="id">
|
||
|
<span>{{ $t('_pages.blocks._note.id') }}</span>
|
||
|
<template #desc>{{ $t('_pages.blocks._note.idDescription') }}</template>
|
||
|
</MkInput>
|
||
|
|
||
|
<XNote v-if="note" v-model:note="note" :key="note.id" style="margin-bottom: 16px;"/>
|
||
|
</section>
|
||
|
</XContainer>
|
||
|
</template>
|
||
|
|
||
|
<script lang="ts">
|
||
|
import { defineComponent } from 'vue';
|
||
|
import { faStickyNote } from '@fortawesome/free-solid-svg-icons';
|
||
|
import XContainer from '../page-editor.container.vue';
|
||
|
import MkInput from '@/components/ui/input.vue';
|
||
|
import XNote from '@/components/note.vue';
|
||
|
import * as os from '@/os';
|
||
|
|
||
|
export default defineComponent({
|
||
|
components: {
|
||
|
XContainer, MkInput, XNote
|
||
|
},
|
||
|
|
||
|
props: {
|
||
|
value: {
|
||
|
required: true
|
||
|
},
|
||
|
},
|
||
|
|
||
|
data() {
|
||
|
return {
|
||
|
id: this.value.note,
|
||
|
note: null,
|
||
|
faStickyNote
|
||
|
};
|
||
|
},
|
||
|
|
||
|
watch: {
|
||
|
id: {
|
||
|
async handler() {
|
||
|
if (this.id && (this.id.startsWith('http://') || this.id.startsWith('https://'))) {
|
||
|
this.value.note = this.id.endsWith('/') ? this.id.substr(0, this.id.length - 1).split('/').pop() : this.id.split('/').pop();
|
||
|
} else {
|
||
|
this.value.note = this.id;
|
||
|
}
|
||
|
|
||
|
this.note = await os.api('notes/show', { noteId: this.value.note });
|
||
|
},
|
||
|
immediate: true
|
||
|
},
|
||
|
},
|
||
|
|
||
|
created() {
|
||
|
if (this.value.note == null) this.value.note = null;
|
||
|
},
|
||
|
});
|
||
|
</script>
|