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

68 lines
1.9 KiB
Vue
Raw Normal View History

2020-11-14 22:42:04 -06:00
<template>
<XContainer @remove="() => $emit('remove')" :draggable="true">
2020-12-25 19:47:36 -06:00
<template #header><Fa :icon="faStickyNote"/> {{ $ts._pages.blocks.note }}</template>
2020-11-14 22:42:04 -06:00
<section style="padding: 0 16px 0 16px;">
<MkInput v-model:value="id">
2020-12-25 19:47:36 -06:00
<span>{{ $ts._pages.blocks._note.id }}</span>
<template #desc>{{ $ts._pages.blocks._note.idDescription }}</template>
2020-11-14 22:42:04 -06:00
</MkInput>
2020-12-25 19:47:36 -06:00
<MkSwitch v-model:value="value.detailed"><span>{{ $ts._pages.blocks._note.detailed }}</span></MkSwitch>
2020-11-14 22:42:04 -06:00
<XNote v-if="note && !value.detailed" v-model:note="note" :key="note.id + ':normal'" style="margin-bottom: 16px;"/>
<XNoteDetailed v-if="note && value.detailed" v-model:note="note" :key="note.id + ':detail'" style="margin-bottom: 16px;"/>
2020-11-14 22:42:04 -06:00
</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 MkSwitch from '@/components/ui/switch.vue';
2020-11-14 22:42:04 -06:00
import XNote from '@/components/note.vue';
import XNoteDetailed from '@/components/note-detailed.vue';
2020-11-14 22:42:04 -06:00
import * as os from '@/os';
export default defineComponent({
components: {
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,
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;
if (this.value.detailed == null) this.value.detailed = false;
2020-11-14 22:42:04 -06:00
},
});
</script>