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

In Legacy Templates mode, design:updated doesn't work when editor content changes

Open Lmangoxx opened this issue 3 years ago • 2 comments

unlayer.init({
  id: 'editor-container',
})

unlayer.loadDesign({
  classic: true,
  html: '<html><body><div>This is a legacy HTML template.</div></body></html>',
})

unlayer.addEventListener('design:updated', function(data) {
  console.log(data);
})

design:updated doesn't work when editor content changes

Lmangoxx avatar Apr 28 '22 07:04 Lmangoxx

hi! I am usingreact, where do i run the init method. Do i have to get reference to the ref?

brennanleez-coder avatar Mar 02 '24 10:03 brennanleez-coder

@brennanleez-coder you can register event listener in the onReady callback like this:

const onReady = (editor: Editor) => {
    if (value) {
      editor.loadDesign(value.design);
    }

 
    editorRef.current = editor;
    editor.addEventListener("design:updated", exportHtml);   <------------- here
    exportHtml();
  };

ahsansher avatar May 02 '24 21:05 ahsansher