image icon indicating copy to clipboard operation
image copied to clipboard

feat: add `onSelectFile` config option to `ImageConfig`

Open mernxl opened this issue 5 years ago • 3 comments

This config option, if passed will be invoked on clicking "select an image". This callback receive the current imageTool as parameter, in order to permit user carry call methods like onUpload with the response object ({ success: true, file: ... })

This should close #56

mernxl avatar Jul 23 '20 09:07 mernxl

I use this on my website, and it works perfectly.

const imageToolConfig = {
  class: EditorJSImage,
  config: {
    onSelectFile: tool => {
      toggleLibrary(img => {
        const data = tool.data;

        data.file = img; // set image
        data.caption = data.caption || img.meta;

        tool.data = data;
        toggleLibrary(undefined);
      });
      },
    uploader: {
       uploadByFile: ...
       uploadByUrl: ...
    }
  }
}

mernxl avatar Jul 23 '20 09:07 mernxl

Would be great to have it merged, very useful feature to have. Right it's impossible to integrate image uploading with CMS, Strapi for example.

O4epegb avatar Oct 13 '20 09:10 O4epegb

in order to permit user carry call methods like onUpload

Please, clarify. Why not use a custom uploader?

neSpecc avatar Dec 07 '22 11:12 neSpecc