Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registerCallback not made available #21

Closed
HyperMaxime opened this issue Jun 6, 2018 · 2 comments
Closed

registerCallback not made available #21

HyperMaxime opened this issue Jun 6, 2018 · 2 comments

Comments

@HyperMaxime
Copy link

When setting up custom file storage one needs to register a callback, however the react wrapper does not expose this method, unlike others (addEventListener, loadDesign, ...).

It seems to be just a matter of adding:

registerCallback = (type, callback) => {
    unlayer.registerCallback(type, callback)
}
@umairsiddique
Copy link
Contributor

@HyperMaxime kindly upgrade to 0.8.2.

@JoezerSmaniotto
Copy link

JoezerSmaniotto commented Dec 1, 2021

registerCallback needs to be called inside the onReady function:

exemplo:

const onReady = () => {
emailEditorRef.current.editor.registerCallback('image', function(file, done) {

  let files = file.attachments[0]
  let reader  = new FileReader();
  let imageBase64;
  console.log("onReady=> emailEditorRef")
  console.log("File: ", file)
  console.log("FileS: ", files)
  

  reader.onloadend = function () {
    imageBase64 = reader.result;
    console.log("64 =>", imageBase64)
  }

  if (file) {
    reader.readAsDataURL(files);
  }  

};
}

remembering that onReady must be inside the EmailEditor component as well as the other props you need.

<EmailEditor ref={emailEditorRef} onLoad={onLoad} onReady={onReady} saveDesign={saveDesign} options={{locale: 'pt-BR'}} />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants