GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.4k stars 4.06k forks source link

uploadFile being called twice on drop file? #507

Closed roytang closed 6 years ago

roytang commented 6 years ago

I have an editor initialized as so:

    var editor = grapesjs.init({
      height: '100%',
      container : '#gjs',
      components: '',
      fromElement: true,
      clearOnRender: true,
      style: '.txt-red{color: red}',
      noticeOnUnload: false,
      plugins: ['gjs-blocks-basic'],
      assetManager: {
        upload: "",
        uploadFile: function(e) { console.log("uploadFile"); },
        embedAsBase64: false,
        disableUpload: false
      }    
    });

If I add an image to the canvas and try to upload a new image by dragging it into the drop area in the modal, the uploadFile function is called twice. Uploading by clicking on the upload area and selecting a file from the windows dialog works fine, it only calls the function once.

artf commented 6 years ago

@roytang I can't reproduce it with the current version https://codesandbox.io/s/p554z8yv7j

duskhacker commented 6 years ago

@roytang Explicitly disabling the full-width editor dropzone (dropzone: 0) fixed this for me. Using version 0.12.30

kickbk commented 6 years ago

Got the same and @roytang's comment is true, disabling dropzone takes care of it. always using the latest version of course.

artf commented 6 years ago

Are you dropping files inside the AssetManager's dropzone or just on canvas?

duskhacker commented 6 years ago

@artf For me it was dropping on the dropzone in the assets manager.

artf commented 6 years ago

@duskhacker ok, in this case, what happens is that dropzone is active by default and is showing when someone drags elements inside the editor, so when you drop an image in assets modal, you're also dropping it inside the dropzone I will set it to false by default

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.