How to load HTML template instead of json using react-email-editor?

Viewed 319

I am using react-email-editor to edit email templates. Now I want to save template data in html format and also want to load html data in editor. As react-email-editor is loading data in json format(I have used onLoad function and passes json data in it), but now the question is how can I load editor data using html.

Is there any method to convert html to json format using this package?

Or if there is any other method to do this please suggest.

1 Answers

Details: https://github.com/unlayer/react-email-editor/blob/master/demo/src/example/index.js

Even though its been above 1 year, someone might find it useful later:

 const emailEditorRef = useRef(null);
 const saveDesign = () => {
     emailEditorRef.current.editor.saveDesign((design) => {
      console.log('saveDesign', design);
      alert('Design JSON has been logged in your developer console.');
   });
 };

 const exportHtml = () => {
     emailEditorRef.current.editor.exportHtml((data) => {
       const { design, html } = data;
       console.log('exportHtml', html);
       alert('Output HTML has been logged in your developer console.');
     });
 };


<button onClick={saveDesign}>Save Design</button>
<button onClick={exportHtml}>Export HTML</button>
Related