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')">
|
2023-02-13 22:17:00 -06:00
|
|
|
<template #header><i class="ti ti-photo"></i> {{ $ts._pages.blocks.image }}</template>
|
2019-04-28 19:11:57 -05:00
|
|
|
<template #func>
|
|
|
|
<button @click="choose()">
|
2023-02-13 22:17:00 -06:00
|
|
|
<i class="ti ti-folder"></i>
|
2019-04-28 19:11:57 -05:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<section class="oyyftmcf">
|
2021-11-19 04:36:12 -06:00
|
|
|
<MkDriveFileThumbnail v-if="file" class="preview" :file="file" fit="contain" @click="choose()"/>
|
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 { onMounted } from 'vue';
|
2019-04-29 16:40:02 -05:00
|
|
|
import XContainer from '../page-editor.container.vue';
|
2022-08-30 10:24:33 -05:00
|
|
|
import MkDriveFileThumbnail from '@/components/MkDriveFileThumbnail.vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import * as os from '@/os';
|
2019-04-28 19:11:57 -05:00
|
|
|
|
2022-12-23 20:57:06 -06:00
|
|
|
const props = defineProps<{
|
|
|
|
modelValue: any
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
(ev: 'update:modelValue', value: any): void;
|
|
|
|
}>();
|
2019-04-28 19:11:57 -05:00
|
|
|
|
2022-06-18 04:39:04 -05:00
|
|
|
let file: any = $ref(null);
|
2019-04-28 19:11:57 -05:00
|
|
|
|
2022-06-18 04:39:04 -05:00
|
|
|
async function choose() {
|
|
|
|
os.selectDriveFile(false).then((fileResponse: any) => {
|
|
|
|
file = fileResponse;
|
2022-12-23 20:57:06 -06:00
|
|
|
emit('update:modelValue', {
|
|
|
|
...props.modelValue,
|
|
|
|
fileId: fileResponse.id,
|
|
|
|
});
|
2022-06-18 04:39:04 -05:00
|
|
|
});
|
|
|
|
}
|
2019-04-28 19:11:57 -05:00
|
|
|
|
2022-06-18 04:39:04 -05:00
|
|
|
onMounted(async () => {
|
2022-12-23 20:57:06 -06:00
|
|
|
if (props.modelValue.fileId == null) {
|
2022-06-18 04:39:04 -05:00
|
|
|
await choose();
|
|
|
|
} else {
|
|
|
|
os.api('drive/files/show', {
|
2022-12-23 20:57:06 -06:00
|
|
|
fileId: props.modelValue.fileId,
|
2022-06-18 04:39:04 -05:00
|
|
|
}).then(fileResponse => {
|
|
|
|
file = fileResponse;
|
|
|
|
});
|
2019-04-28 19:11:57 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2022-12-27 03:29:39 -06:00
|
|
|
<style lang="scss" scoped>
|
2020-01-29 13:37:25 -06:00
|
|
|
.oyyftmcf {
|
|
|
|
> .preview {
|
|
|
|
height: 150px;
|
|
|
|
}
|
|
|
|
}
|
2019-04-28 19:11:57 -05:00
|
|
|
</style>
|