2023-10-04 19:38:50 -04:00
|
|
|
<script lang="ts" setup>
|
2023-12-29 20:11:07 -05:00
|
|
|
import { useField } from "vee-validate";
|
2023-12-20 17:23:31 -05:00
|
|
|
import { story } from "@client/editorConfig";
|
2023-10-04 19:38:50 -04:00
|
|
|
import icon from "~/components/icon.vue";
|
|
|
|
import baseEditor from "../../baseEditor.vue";
|
|
|
|
const fname = inject<string>("curName");
|
|
|
|
const fileList = ref([]);
|
|
|
|
const potField = useField(fname + "pot");
|
|
|
|
const fileField = useField(fname + "file");
|
|
|
|
const { value: pvalue } = potField;
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<a-radio-group v-model:value="pvalue">
|
|
|
|
<a-radio value="pasteOrType">Paste or type content</a-radio>
|
|
|
|
<a-radio value="upload">Upload a file</a-radio>
|
|
|
|
</a-radio-group>
|
|
|
|
<br />
|
|
|
|
<br />
|
2023-12-29 20:11:07 -05:00
|
|
|
<base-editor label="" v-if="pvalue === 'pasteOrType'" :init="story" :name="fname + 'content'" />
|
2023-10-04 19:38:50 -04:00
|
|
|
<a-upload
|
|
|
|
v-model:file-list="fileList"
|
|
|
|
v-else-if="pvalue === 'upload'"
|
|
|
|
:name="fname + 'file'"
|
|
|
|
accept=".doc,.docx,.md,.markdown"
|
|
|
|
:max-count="1"
|
2023-10-12 22:57:39 -04:00
|
|
|
action="/api/upload/content"
|
|
|
|
method="post"
|
|
|
|
@reject="(a) => console.error(a)"
|
2023-10-04 19:38:50 -04:00
|
|
|
@change="
|
2023-10-12 22:57:39 -04:00
|
|
|
(bap) => {
|
|
|
|
console.log(bap);
|
|
|
|
let resp;
|
|
|
|
try {
|
|
|
|
resp = bap.file.response;
|
|
|
|
if (resp.success) {
|
|
|
|
fileField.setValue(resp.fileName);
|
|
|
|
console.log(fileField.value);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.error('not yet');
|
2023-10-04 19:38:50 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
"
|
|
|
|
>
|
2023-12-29 20:11:07 -05:00
|
|
|
<a-button type="primary"> <icon istyle="regular" name="upload" /><span style="margin-left: 0.5em"> Upload a file</span> </a-button>
|
2023-10-04 19:38:50 -04:00
|
|
|
</a-upload>
|
|
|
|
</template>
|