2019-04-29 02:11:57 +02:00
|
|
|
<template>
|
2021-11-18 15:32:43 +01:00
|
|
|
<!-- eslint-disable vue/no-mutating-props -->
|
2021-11-19 11:36:12 +01:00
|
|
|
<XContainer :draggable="true" @remove="() => $emit('remove')">
|
2021-04-20 16:22:59 +02:00
|
|
|
<template #header><i class="fas fa-sticky-note"></i> {{ value.title }}</template>
|
2019-04-29 02:11:57 +02:00
|
|
|
<template #func>
|
2021-11-19 11:36:12 +01:00
|
|
|
<button class="_button" @click="rename()">
|
2022-12-19 11:01:30 +01:00
|
|
|
<i class="ti ti-pencil"></i>
|
2019-04-29 02:11:57 +02:00
|
|
|
</button>
|
2021-11-19 11:36:12 +01:00
|
|
|
<button class="_button" @click="add()">
|
2022-12-19 11:01:30 +01:00
|
|
|
<i class="ti ti-plus"></i>
|
2019-04-29 02:11:57 +02:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<section class="ilrvjyvi">
|
2021-11-19 11:36:12 +01:00
|
|
|
<XBlocks v-model="value.children" class="children" :hpml="hpml"/>
|
2019-04-29 02:11:57 +02:00
|
|
|
</section>
|
2020-10-17 13:12:00 +02:00
|
|
|
</XContainer>
|
2019-04-29 02:11:57 +02:00
|
|
|
</template>
|
|
|
|
|
2022-06-18 11:39:04 +02:00
|
|
|
<script lang="ts" setup>
|
2021-11-18 15:32:43 +01:00
|
|
|
/* eslint-disable vue/no-mutating-props */
|
2022-06-18 11:39:04 +02:00
|
|
|
import { defineAsyncComponent, inject, onMounted } from 'vue';
|
2019-08-18 05:42:58 +02:00
|
|
|
import { v4 as uuid } from 'uuid';
|
2019-04-29 23:40:02 +02:00
|
|
|
import XContainer from '../page-editor.container.vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import * as os from '@/os';
|
2022-06-18 11:39:04 +02:00
|
|
|
import { i18n } from '@/i18n';
|
2019-04-29 02:11:57 +02:00
|
|
|
|
2022-06-18 11:39:04 +02:00
|
|
|
const XBlocks = defineAsyncComponent(() => import('../page-editor.blocks.vue'));
|
2019-04-29 02:11:57 +02:00
|
|
|
|
2022-06-18 11:39:04 +02:00
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
value: any,
|
|
|
|
hpml: any
|
|
|
|
}>(), {
|
|
|
|
value: {
|
|
|
|
title: null,
|
2022-12-22 08:01:59 +01:00
|
|
|
children: [],
|
|
|
|
},
|
2022-06-18 11:39:04 +02:00
|
|
|
});
|
2019-04-29 02:11:57 +02:00
|
|
|
|
2022-06-18 11:39:04 +02:00
|
|
|
const getPageBlockList = inject<(any) => any>('getPageBlockList');
|
2019-04-29 02:11:57 +02:00
|
|
|
|
2022-06-18 11:39:04 +02:00
|
|
|
async function rename() {
|
|
|
|
const { canceled, result: title } = await os.inputText({
|
|
|
|
title: 'Enter title',
|
2022-12-22 08:01:59 +01:00
|
|
|
default: props.value.title,
|
2022-06-18 11:39:04 +02:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
props.value.title = title;
|
|
|
|
}
|
2019-04-29 02:11:57 +02:00
|
|
|
|
2022-06-18 11:39:04 +02:00
|
|
|
async function add() {
|
|
|
|
const { canceled, result: type } = await os.select({
|
|
|
|
title: i18n.ts._pages.chooseBlock,
|
2022-12-22 08:01:59 +01:00
|
|
|
groupedItems: getPageBlockList(),
|
2022-06-18 11:39:04 +02:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
2019-04-29 02:11:57 +02:00
|
|
|
|
2022-06-18 11:39:04 +02:00
|
|
|
const id = uuid();
|
|
|
|
props.value.children.push({ id, type });
|
|
|
|
}
|
2019-04-29 02:11:57 +02:00
|
|
|
|
2022-06-18 11:39:04 +02:00
|
|
|
onMounted(() => {
|
|
|
|
if (props.value.title == null) {
|
|
|
|
rename();
|
2019-04-29 02:11:57 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.ilrvjyvi {
|
|
|
|
> .children {
|
|
|
|
padding: 16px;
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 02:11:57 +02:00
|
|
|
</style>
|