Skip to content

Commit 631b134

Browse files
committed
feat: intergrate chii into playground
1 parent 58feb85 commit 631b134

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<script>
2+
const { iframe } = $props();
3+
4+
let devtools_iframe;
5+
6+
7+
$effect(() => {
8+
if (iframe) {
9+
const iframe_window = iframe.contentWindow;
10+
iframe_window.addEventListener('preview_ready', () => {
11+
iframe_window.ChiiDevtoolsIframe = devtools_iframe;
12+
iframe_window.initialize();
13+
})
14+
15+
window.addEventListener('message', event => {
16+
if (typeof event.data === 'string') {
17+
iframe_window.postMessage(event.data, event.origin);
18+
}
19+
});
20+
}
21+
})
22+
23+
</script>
24+
25+
<iframe title="Svelte Playground" bind:this={devtools_iframe}></iframe>
26+
27+
<style>
28+
iframe {
29+
border: 0;
30+
}
31+
</style>

0 commit comments

Comments
 (0)