npm install commajs-dragndrop
new CommaDragNDrop('idEditorContainer', onUploadFunction);
const onUploadFunction = = (files) => {
//you will probably need to do something like:
/*
files.forEach(file => {
if(file.type!="directory") {
const formData = new FormData();
formData.append('myFile', file);
fetch('....../uploadFile', {
method: 'POST',
body: formData
})
.then(response => {
return response.json();
})
.then(data => {
let fileName = data.fileName;
....
if(GetFileType(fileName) == "image" ) {
commaEditor.InsertPluginAtSection(CommaJS.GetPluginImageName(), {link: "........../uploads/"+fileName});
} else if(GetFileType(fileName) == "video" ) {
commaEditor.InsertPluginAtSection(CommaJS.GetPluginVideoName(), {link: "........../uploads/"+fileName, mimeType: "video/"+fileExtension});
} else {
console.log("not supported");
}
})
.catch(error => {
console.error(error);
});
}
});
*/
}