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