WYSIWYG: Treat ajax call to upload files as async #5273

pull/5293/head
Angel Fernando Quiroz Campos 2 years ago
parent e8fd9fcdd4
commit 981eabaaef
  1. 10
      assets/vue/components/basecomponents/BaseTinyEditor.vue

@ -218,7 +218,7 @@ async function filePickerCallback(callback, value, meta) {
}
function inputFileHandler(callback, input) {
return () => {
return async () => {
const file = input.files[0]
const title = file.name
const comment = ""
@ -234,13 +234,13 @@ function inputFileHandler(callback, input) {
formData.append("resourceLinkList", resourceLinkList)
try {
let response = fetch("/file-manager/upload-image", {
let response = await fetch("/file-manager/upload-image", {
method: "POST",
body: formData,
})
let data = response.json()
if (data.location) {
callback(data.location)
const { data, location } = await response.json()
if (location) {
callback(location, { alt: data.title })
} else {
console.error("Failed to upload file")
}

Loading…
Cancel
Save