File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ const props = defineProps<{ show: boolean; ssr: boolean }>()
2020
2121const store = inject (' store' ) as Store
2222const clearConsole = inject (' clear-console' ) as Ref <boolean >
23+ const theme = inject (' theme' ) as Ref <' dark' | ' light' >
2324
2425const previewOptions = inject (' preview-options' ) as Props [' previewOptions' ]
2526
@@ -85,6 +86,7 @@ function createSandbox() {
8586 importMap .imports .vue = store .state .vueRuntimeURL
8687 }
8788 const sandboxSrc = srcdoc
89+ .replace (/ <html>/ , ` <html class="${theme .value }"> ` )
8890 .replace (/ <!--IMPORT_MAP-->/ , JSON .stringify (importMap ))
8991 .replace (
9092 / <!-- PREVIEW-OPTIONS-HEAD-HTML -->/ ,
@@ -277,7 +279,12 @@ defineExpose({ reload })
277279 </script >
278280
279281<template >
280- <div class =" iframe-container" v-show =" show" ref =" container" ></div >
282+ <div
283+ class =" iframe-container"
284+ :class =" theme"
285+ v-show =" show"
286+ ref =" container"
287+ ></div >
281288 <Message :err =" runtimeError" />
282289 <Message v-if =" !runtimeError" :warn =" runtimeWarning" />
283290</template >
@@ -290,4 +297,7 @@ defineExpose({ reload })
290297 border : none ;
291298 background-color : #fff ;
292299}
300+ .iframe-container.dark :deep(iframe ) {
301+ background-color : #1e1e1e ;
302+ }
293303 </style >
You can’t perform that action at this time.
0 commit comments