paricafe/packages/client/src/pages/page-editor/els/page-editor.el.note.vue

53 lines
1.7 KiB
Vue
Raw Normal View History

2020-11-14 22:42:04 -06:00
<template>
<!-- eslint-disable vue/no-mutating-props -->
2021-11-19 04:36:12 -06:00
<XContainer :draggable="true" @remove="() => $emit('remove')">
<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" setup>
/* eslint-disable vue/no-mutating-props */
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';
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
const props = withDefaults(defineProps<{
value: any
}>(), {
value: {
note: null,
detailed: false
}
});
2020-11-14 22:42:04 -06:00
let id: any = $ref(props.value.note);
let note: any = $ref(null);
2020-11-14 22:42:04 -06: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
note = await os.api('notes/show', { noteId: props.value.note });
}, {
immediate: true
2020-11-14 22:42:04 -06:00
});
</script>