2019-04-29 00:11:57 +00:00
|
|
|
<template>
|
2021-11-18 14:32:43 +00:00
|
|
|
<!-- eslint-disable vue/no-mutating-props -->
|
2021-11-19 10:36:12 +00:00
|
|
|
<XContainer :draggable="true" @remove="() => $emit('remove')">
|
2021-04-20 14:22:59 +00:00
|
|
|
<template #header><i class="fas fa-image"></i> {{ $ts._pages.blocks.image }}</template>
|
2019-04-29 00:11:57 +00:00
|
|
|
<template #func>
|
|
|
|
<button @click="choose()">
|
2021-04-20 14:22:59 +00:00
|
|
|
<i class="fas fa-folder-open"></i>
|
2019-04-29 00:11:57 +00:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<section class="oyyftmcf">
|
2021-11-19 10:36:12 +00:00
|
|
|
<MkDriveFileThumbnail v-if="file" class="preview" :file="file" fit="contain" @click="choose()"/>
|
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>
|
|
|
|
|
2022-06-18 09:39:04 +00:00
|
|
|
<script lang="ts" setup>
|
2021-11-18 14:32:43 +00:00
|
|
|
/* eslint-disable vue/no-mutating-props */
|
2022-06-18 09:39:04 +00:00
|
|
|
import { onMounted } from 'vue';
|
2019-04-29 21:40:02 +00:00
|
|
|
import XContainer from '../page-editor.container.vue';
|
2021-11-11 17:02:25 +00:00
|
|
|
import MkDriveFileThumbnail from '@/components/drive-file-thumbnail.vue';
|
|
|
|
import * as os from '@/os';
|
2019-04-29 00:11:57 +00:00
|
|
|
|
2022-06-18 09:39:04 +00:00
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
value: any
|
|
|
|
}>(), {
|
|
|
|
value: {
|
|
|
|
fileId: null
|
|
|
|
}
|
|
|
|
});
|
2019-04-29 00:11:57 +00:00
|
|
|
|
2022-06-18 09:39:04 +00:00
|
|
|
let file: any = $ref(null);
|
2019-04-29 00:11:57 +00:00
|
|
|
|
2022-06-18 09:39:04 +00:00
|
|
|
async function choose() {
|
|
|
|
os.selectDriveFile(false).then((fileResponse: any) => {
|
|
|
|
file = fileResponse;
|
|
|
|
props.value.fileId = fileResponse.id;
|
|
|
|
});
|
|
|
|
}
|
2019-04-29 00:11:57 +00:00
|
|
|
|
2022-06-18 09:39:04 +00:00
|
|
|
onMounted(async () => {
|
|
|
|
if (props.value.fileId == null) {
|
|
|
|
await choose();
|
|
|
|
} else {
|
|
|
|
os.api('drive/files/show', {
|
|
|
|
fileId: props.value.fileId
|
|
|
|
}).then(fileResponse => {
|
|
|
|
file = fileResponse;
|
|
|
|
});
|
2019-04-29 00:11:57 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.oyyftmcf {
|
|
|
|
> .preview {
|
|
|
|
height: 150px;
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 00:11:57 +00:00
|
|
|
</style>
|