craft.js
craft.js copied to clipboard
How do i get my html markup
I am struggling to understand how to retrieve my HTML markup. Could you help me with this? Perhaps this information should be added to the documentation as well
export default function renderToHTMLString (designerContent: string, title: string): Promise<string> {
const data = getPreviewData(designerContent);
const div = document.createElement('div');
div.style.display = 'none';
document.body.appendChild(div);
const root = createRoot(div);
flushSync(() => {
root.render(<PreviewContent data={data}
isRenderMode />);
});
return new Promise((resolve) => {
setTimeout(() => {
const html = div.innerHTML ?? '';
div.remove();
const embededHtml = getEmbededHtml(title, html);
resolve(embededHtml);
}, 250);
});
}
See my sample code
https://github.com/prevwong/craft.js/issues/42#issuecomment-796409445