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

58 lines
1.8 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')">
2022-12-23 23:45:27 -06:00
<template #header><i class="ti ti-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>
2022-12-23 20:57:06 -06:00
<MkSwitch v-model="props.modelValue.detailed"><span>{{ $ts._pages.blocks._note.detailed }}</span></MkSwitch>
2020-11-14 22:42:04 -06:00
2022-12-23 20:57:06 -06:00
<XNote v-if="note && !props.modelValue.detailed" :key="note.id + ':normal'" v-model:note="note" style="margin-bottom: 16px;"/>
<XNoteDetailed v-if="note && props.modelValue.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
2022-12-23 20:57:06 -06:00
const props = defineProps<{
modelValue: any
}>();
const emit = defineEmits<{
(ev: 'update:modelValue', value: any): void;
}>();
2020-11-14 22:42:04 -06:00
2022-12-23 20:57:06 -06:00
let id: any = $ref(props.modelValue.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://'))) {
2022-12-23 20:57:06 -06:00
emit('update:modelValue', {
...props.modelValue,
note: (id.endsWith('/') ? id.slice(0, -1) : id).split('/').pop(),
});
} else {
2022-12-23 20:57:06 -06:00
emit('update:modelValue', {
...props.modelValue,
note: id,
});
}
2020-11-14 22:42:04 -06:00
2022-12-23 20:57:06 -06:00
note = await os.api('notes/show', { noteId: props.modelValue.note });
}, {
immediate: true,
2020-11-14 22:42:04 -06:00
});
</script>