2019-04-29 00:11:57 +00:00
|
|
|
<template>
|
2020-10-17 11:12:00 +00:00
|
|
|
<XContainer @remove="() => $emit('remove')" :draggable="true">
|
|
|
|
<template #header><Fa :icon="faStickyNote"/> {{ value.title }}</template>
|
2019-04-29 00:11:57 +00:00
|
|
|
<template #func>
|
2020-04-16 14:13:33 +00:00
|
|
|
<button @click="rename()" class="_button">
|
2020-10-17 11:12:00 +00:00
|
|
|
<Fa :icon="faPencilAlt"/>
|
2019-04-29 00:11:57 +00:00
|
|
|
</button>
|
2020-04-16 14:13:33 +00:00
|
|
|
<button @click="add()" class="_button">
|
2020-10-17 11:12:00 +00:00
|
|
|
<Fa :icon="faPlus"/>
|
2019-04-29 00:11:57 +00:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<section class="ilrvjyvi">
|
2020-10-17 11:12:00 +00:00
|
|
|
<XBlocks class="children" v-model:value="value.children" :hpml="hpml"/>
|
2019-04-29 00:11:57 +00:00
|
|
|
</section>
|
2020-10-17 11:12:00 +00:00
|
|
|
</XContainer>
|
2019-04-29 00:11:57 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-19 00:30:21 +00:00
|
|
|
import { defineComponent, defineAsyncComponent } from 'vue';
|
2019-08-18 03:42:58 +00:00
|
|
|
import { v4 as uuid } from 'uuid';
|
2019-04-29 00:11:57 +00:00
|
|
|
import { faPlus, faPencilAlt } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { faStickyNote } from '@fortawesome/free-regular-svg-icons';
|
2019-04-29 21:40:02 +00:00
|
|
|
import XContainer from '../page-editor.container.vue';
|
2020-10-17 11:12:00 +00:00
|
|
|
import * as os from '@/os';
|
2019-04-29 00:11:57 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2019-04-29 00:11:57 +00:00
|
|
|
components: {
|
2020-10-19 00:30:21 +00:00
|
|
|
XContainer,
|
|
|
|
XBlocks: defineAsyncComponent(() => import('../page-editor.blocks.vue')),
|
2019-04-29 00:11:57 +00:00
|
|
|
},
|
|
|
|
|
2019-04-29 21:40:02 +00:00
|
|
|
inject: ['getPageBlockList'],
|
|
|
|
|
2019-04-29 00:11:57 +00:00
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
required: true
|
|
|
|
},
|
2020-04-20 12:35:27 +00:00
|
|
|
hpml: {
|
2019-04-29 21:40:02 +00:00
|
|
|
required: true,
|
|
|
|
},
|
2019-04-29 00:11:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
faStickyNote, faPlus, faPencilAlt
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-10-17 11:12:00 +00:00
|
|
|
if (this.value.title == null) this.value.title = null;
|
|
|
|
if (this.value.children == null) this.value.children = [];
|
2019-04-29 00:11:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
if (this.value.title == null) {
|
|
|
|
this.rename();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async rename() {
|
2020-10-17 11:12:00 +00:00
|
|
|
const { canceled, result: title } = await os.dialog({
|
2019-04-29 00:11:57 +00:00
|
|
|
title: 'Enter title',
|
|
|
|
input: {
|
|
|
|
type: 'text',
|
|
|
|
default: this.value.title
|
|
|
|
},
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
this.value.title = title;
|
|
|
|
},
|
|
|
|
|
|
|
|
async add() {
|
2020-10-17 11:12:00 +00:00
|
|
|
const { canceled, result: type } = await os.dialog({
|
2019-04-29 00:11:57 +00:00
|
|
|
type: null,
|
2020-12-26 01:47:36 +00:00
|
|
|
title: this.$ts._pages.chooseBlock,
|
2019-04-29 00:11:57 +00:00
|
|
|
select: {
|
2019-04-30 03:15:41 +00:00
|
|
|
groupedItems: this.getPageBlockList()
|
2019-04-29 00:11:57 +00:00
|
|
|
},
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2019-08-18 03:42:58 +00:00
|
|
|
const id = uuid();
|
2019-04-29 00:11:57 +00:00
|
|
|
this.value.children.push({ id, type });
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.ilrvjyvi {
|
|
|
|
> .children {
|
|
|
|
padding: 16px;
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 00:11:57 +00:00
|
|
|
</style>
|