commajs
Drag and Drop
Introduction
Utility to manage dragging and dropping files on a CommaJS document
Installation
npm install commajs-dragndrop
Configuration
new CommaDragNDrop('idEditorContainer', onUploadFunction);
onUploadFunction example:
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);
                });
            }
        });  
        */    
    }
 
© 2020 Plugg, Inc. All rights reserved. Various trademarks held by their respective owners.
Plugg, Inc. - San Francisco, CA 94114, United States