frontend(apps): html component uses iframe for security

This commit is contained in:
Ruben Fiszel
2023-01-17 17:28:55 +01:00
parent 87e07be1c2
commit c3ffb49775
@@ -12,17 +12,29 @@
export const staticOutputs: string[] = ['result', 'loading']
let result: string | undefined = undefined
let h: number | undefined = undefined
let w: number | undefined = undefined
</script>
<RunnableWrapper flexWrap bind:componentInput {id} bind:result>
<AlignWrapper {horizontalAlignment} {verticalAlignment}>
<div
on:pointerdown={(e) => {
e?.preventDefault()
}}
class="h-full relative w-full overflow-hidden"
<div
on:pointerdown={(e) => {
e?.preventDefault()
}}
class="h-full w-full"
bind:clientHeight={h}
bind:clientWidth={w}
>
<RunnableWrapper flexWrap bind:componentInput {id} bind:result>
<AlignWrapper {horizontalAlignment} {verticalAlignment}>
<iframe
frameborder="0"
style="height: {h}px; width: {w}px"
class="p-0"
title="sandbox"
srcdoc={result
? '<scr' + `ipt src="https://cdn.tailwindcss.com"></script>` + result
: 'No html'}
/></AlignWrapper
>
{@html result ?? 'No html'}
</div>
</AlignWrapper>
</RunnableWrapper>
</RunnableWrapper>
</div>