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>
|
|
|
|
|
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 */
|
2022-06-18 04:39:04 -05:00
|
|
|
import { watch } from 'vue';
|
2020-11-14 22:42:04 -06:00
|
|
|
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';
|
2022-08-30 10:24:33 -05:00
|
|
|
import XNote from '@/components/MkNote.vue';
|
|
|
|
import XNoteDetailed from '@/components/MkNoteDetailed.vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import * as os from '@/os';
|
2020-11-14 22:42:04 -06:00
|
|
|
|
2022-06-18 04:39:04 -05:00
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
value: any
|
|
|
|
}>(), {
|
|
|
|
value: {
|
|
|
|
note: null,
|
|
|
|
detailed: false
|
|
|
|
}
|
|
|
|
});
|
2020-11-14 22:42:04 -06:00
|
|
|
|
2022-06-18 04:39:04 -05:00
|
|
|
let id: any = $ref(props.value.note);
|
|
|
|
let note: any = $ref(null);
|
2020-11-14 22:42:04 -06:00
|
|
|
|
2022-06-18 04:39:04 -05:00
|
|
|
watch(id, async () => {
|
|
|
|
if (id && (id.startsWith('http://') || id.startsWith('https://'))) {
|
|
|
|
props.value.note = (id.endsWith('/') ? id.slice(0, -1) : id).split('/').pop();
|
|
|
|
} else {
|
|
|
|
props.value.note = id;
|
|
|
|
}
|
2020-11-14 22:42:04 -06:00
|
|
|
|
2022-06-18 04:39:04 -05:00
|
|
|
note = await os.api('notes/show', { noteId: props.value.note });
|
|
|
|
}, {
|
|
|
|
immediate: true
|
2020-11-14 22:42:04 -06:00
|
|
|
});
|
|
|
|
</script>
|