Closed udayan46 closed 1 year ago
If you are trying to load an html string, you need to enable the legacy mode:
unlayer.loadDesign({
html: '<html><body><div>This is a legacy HTML template.</div></body></html>',
classic: true
});
See docs: https://docs.unlayer.com/docs/legacy-templates
If you have a normal unlayer template, you can obtain its json by calling unlayer.saveDesign(console.log)
or unlayer.exportHtml(console.log)
. The loadDesign(json)
methods require a proper design JSON as a parameter when not in the classic/legacy mode.
Hello , I need to render html while the editor is ready , but somehow i see that emailEditorRef.current.editor.loadDesign accepts json but the html even if JSON.parse is not a proper json , is there any way i can load my html here? Below is my onReady function , props.templateData.resource[0].welcome_contenthtml is my html getting these two errors 1.editor.js:2 TypeError: Cannot read properties of undefined (reading 'values') 2.editor.js:2 Uncaught TypeError: Cannot read properties of undefined (reading 'values') const onReady = () => { let html_data = JSON.parse( JSON.stringify(props.templateData.resource[0].welcome_contenthtml) ); const templateJson = { html_data }; console.log("templateJson", templateJson); emailEditorRef.current.editor.loadDesign(templateJson); };