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

Loading…
Cancel
Save