fix: shadow rendering inside preview after api change

This commit is contained in:
Michal Szczepanski 2023-09-03 06:09:05 +02:00
parent eed0f4f06b
commit de8a176dae

@ -249,6 +249,10 @@ export const HtmlPreviewComponent: FunctionComponent<Props> = (props) => {
fnConsoleLog('htmlPreview->renderAssetList->ERROR', e, hash);
}
}
const elList = Array.from(doc.querySelectorAll(`[data-pmn-shadow]`));
for (const el of elList) {
renderTemplate(el);
}
};
const renderAsset = async (hash: string, el: Element): Promise<void> => {
@ -273,11 +277,6 @@ export const HtmlPreviewComponent: FunctionComponent<Props> = (props) => {
approximatePictureSize(img);
break;
}
case SegmentType.SHADOW: {
const content = dto.content as SegmentShadow;
renderShadow(el, content);
break;
}
default:
fnConsoleLog('UNSUPPORTED TYPE', dto.type, dto);
break;
@ -294,11 +293,6 @@ export const HtmlPreviewComponent: FunctionComponent<Props> = (props) => {
if (rect.width > window.innerWidth) img.style.width = '100%';
};
const renderShadow = (el: Element, content: SegmentShadow) => {
el.innerHTML = content.html + el.innerHTML;
renderTemplate(el);
};
const renderTemplate = (el: Element) => {
const templates = Array.from(el.querySelectorAll('template'));
for (const template of templates) {