react-email-editor icon indicating copy to clipboard operation
react-email-editor copied to clipboard

registerCallback with selectImage stopped working

Open Arsenalist opened this issue 1 year ago • 15 comments

This is in react:

  import EmailEditor, { UnlayerOptions } from "react-email-editor";

  ...

  const internalOnReady = () => {
    emailEditorRef.current.editor.registerCallback("selectImage", (a, b) =>
      console.log("registering callback"),
    );
  };

  ...

<EmailEditor ref={emailEditorRef} onReady={internalOnReady} />

The selectImage callback is not called when clicking the Image upload button. This used to work fine a few days ago.

Arsenalist avatar Nov 19 '24 22:11 Arsenalist

If you're looking to upload an image , you can use the 'image' option instead of 'selectImage'. This allows you to handle image uploads. You can refer to the (https://docs.unlayer.com/docs/custom-file-storage) for detailed instructions.

realirfanashraf avatar Dec 05 '24 11:12 realirfanashraf

Thank you, I believe the code you posted is for changing the storage of the image, not replacing the picker.

I want to replace the image picker and uploader. The code I posted above was working perfectly fine until recently, but now selectImage event seems to have no effect. Keep in mind that I am on the free version but again this worked perfectly fine.

Arsenalist avatar Dec 05 '24 12:12 Arsenalist

You're very welcome!

realirfanashraf avatar Dec 05 '24 12:12 realirfanashraf

So is there a way to still replace the picker?

Arsenalist avatar Dec 05 '24 12:12 Arsenalist

I'm unsure about that; my requirement was to upload the images to my server instead of Unlayer's.

realirfanashraf avatar Dec 06 '24 05:12 realirfanashraf

@realirfanashraf I was facing the similar issue, Resolved this by adding a proper null check on loadDesign function. Calling loadDesign with empty data is throwing NPE internally.

pnp-os avatar Jan 24 '25 12:01 pnp-os

@pnp-os are you using a paid version? Seems like unlayer moved custom storage, and image library to paid version. My custom image storage was working previously, but recently stopped working. https://unlayer.com/pricing

Keshavdulal avatar Jan 29 '25 15:01 Keshavdulal

@Arsenalist @Keshavdulal Using version 1.157.0 seems to fix the issue. It will load this editor: https://editor.unlayer.com/1.157.0/editor.html instead of the latest version. Hopefully they don't remove this version :)

<EmailEditor ref={emailEditorRef} onLoad={onLoad} onReady={onReady} options={{version: '1.157.0'}} />

roy-rayyone avatar Feb 07 '25 07:02 roy-rayyone

@Arsenalist @Keshavdulal Using version 1.157.0 seems to fix the issue. It will load this editor: https://editor.unlayer.com/1.157.0/editor.html instead of the latest version. Hopefully they don't remove this version :)

<EmailEditor ref={emailEditorRef} onLoad={onLoad} onReady={onReady} options={{version: '1.157.0'}} />

Thanks a lot @roy-rayyone its working with this version change.

pnp-os avatar Feb 07 '25 08:02 pnp-os

@roy-rayyone Thanks a lot! It's working perfectly now.

realirfanashraf avatar Feb 07 '25 10:02 realirfanashraf

@Arsenalist @Keshavdulal Using version 1.157.0 seems to fix the issue. It will load this editor: https://editor.unlayer.com/1.157.0/editor.html instead of the latest version. Hopefully they don't remove this version :)

<EmailEditor ref={emailEditorRef} onLoad={onLoad} onReady={onReady} options={{version: '1.157.0'}} />

I can not get it to work with the solution. I used the codesandbox to create an example as the link below, would you be so kind as to have a look The exmaple

mark-gogoro avatar Feb 18 '25 07:02 mark-gogoro

@Arsenalist @Keshavdulal Using version 1.157.0 seems to fix the issue. It will load this editor: https://editor.unlayer.com/1.157.0/editor.html instead of the latest version. Hopefully they don't remove this version :)

<EmailEditor ref={emailEditorRef} onLoad={onLoad} onReady={onReady} options={{version: '1.157.0'}} />

I can not get it to work with the solution. I used the codesandbox to create an example as the link below, would you be so kind as to have a look The exmaple

Try this @mark-gogoro

emailEditorRef.current.editor.registerCallback(
      "image",
      selectImageCallback
    );

roy-rayyone avatar Feb 19 '25 04:02 roy-rayyone

Try this

emailEditorRef.current.editor.registerCallback(
      "image",
      selectImageCallback
    );

Hi @roy-rayyone thanks for your code, but I still could not make it work (Code Example)

when a user clicks the Upload Image Button or drops a new image to the drop zone that should trigger the selectImageCallback function.

mark-gogoro avatar Feb 19 '25 09:02 mark-gogoro

Try this

emailEditorRef.current.editor.registerCallback(
      "image",
      selectImageCallback
    );

Hi @roy-rayyone thanks for your code, but I still could not make it work (Code Example)

when a user clicks the Upload Image Button or drops a new image to the drop zone that should trigger the selectImageCallback function.

use onLoad over onReady it will work

realirfanashraf avatar Feb 22 '25 14:02 realirfanashraf

Try this

emailEditorRef.current.editor.registerCallback(
      "image",
      selectImageCallback
    );

Hi @roy-rayyone thanks for your code, but I still could not make it work (Code Example) when a user clicks the Upload Image Button or drops a new image to the drop zone that should trigger the selectImageCallback function.

use onLoad over onReady it will work

thanks for your reply

I use onLoad over onReady as below ` const onLoad = () => { const { current: { editor }, } = emailEditorRef;

// # selectImage // - for click the Upload Image button, and click the drop area editor.registerCallback("selectImage", selectImageCallback);

// # image // - For drag and drop an image // - This works when a user drags and drops an image editor.registerCallback("image", selectImageCallback); }; `

the selectImageCallback event can not be triggered when a user clicks the Upload Image button OR the Drop a new image

but the image with registerCallback did trigger the selectImageCallback event when a user drags and drops an image into the Drop a new image

mark-gogoro avatar Feb 24 '25 03:02 mark-gogoro