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')">
|
2021-04-20 09:22:59 -05:00
|
|
|
<template #header><i class="fas fa-sticky-note"></i> {{ $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">
|
|
|
|
<template #label>{{ $ts._pages.blocks._note.id }}</template>
|
|
|
|
<template #caption>{{ $ts._pages.blocks._note.idDescription }}</template>
|
2020-11-14 22:42:04 -06:00
|
|
|
</MkInput>
|
2021-08-06 08:29:19 -05:00
|
|
|
<MkSwitch v-model="value.detailed"><span>{{ $ts._pages.blocks._note.detailed }}</span></MkSwitch>
|
2020-11-14 22:42:04 -06:00
|
|
|
|
2021-11-19 04:36:12 -06:00
|
|
|
<XNote v-if="note && !value.detailed" :key="note.id + ':normal'" v-model:note="note" style="margin-bottom: 16px;"/>
|
|
|
|
<XNoteDetailed v-if="note && value.detailed" :key="note.id + ':detail'" v-model:note="note" style="margin-bottom: 16px;"/>
|
2020-11-14 22:42:04 -06:00
|
|
|
</section>
|
|
|
|
</XContainer>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-11-18 08:32:43 -06:00
|
|
|
/* eslint-disable vue/no-mutating-props */
|
2020-11-14 22:42:04 -06:00
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
import XContainer from '../page-editor.container.vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import MkInput from '@/components/form/input.vue';
|
|
|
|
import MkSwitch from '@/components/form/switch.vue';
|
|
|
|
import XNote from '@/components/note.vue';
|
|
|
|
import XNoteDetailed from '@/components/note-detailed.vue';
|
|
|
|
import * as os from '@/os';
|
2020-11-14 22:42:04 -06:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2021-01-15 08:18:14 -06:00
|
|
|
XContainer, MkInput, MkSwitch, XNote, XNoteDetailed,
|
2020-11-14 22:42:04 -06:00
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
id: this.value.note,
|
|
|
|
note: null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
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;
|
2020-11-14 22:47:15 -06:00
|
|
|
if (this.value.detailed == null) this.value.detailed = false;
|
2020-11-14 22:42:04 -06:00
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|