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