File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,12 @@ import { compileModulesForPreview } from './moduleCompiler'
1616import { Store , importMapFile } from ' ../store'
1717import { Props } from ' ../Repl.vue'
1818
19- const props = defineProps <{ show: boolean ; ssr: boolean }>()
19+ const props = defineProps <{
20+ show: boolean
21+ ssr: boolean
22+ bodyStyle? : CSSStyleDeclaration
23+ appStyle? : CSSStyleDeclaration
24+ }>()
2025export type UpdateFlag = ' UPDATING' | ' SUCCESS' | ' FAILURE'
2126const emits = defineEmits <{
2227 (e : ' update-preview' , flag : UpdateFlag ): UpdateFlag
@@ -270,6 +275,23 @@ async function updatePreview() {
270275 runtimeError .value = (e as Error ).message
271276 emits (' update-preview' , ' FAILURE' )
272277 }
278+
279+ if (sandbox .contentWindow ?.document .body && props .bodyStyle ) {
280+ for (const key in props .bodyStyle ) {
281+ sandbox .contentWindow .document .body .style [key ] = props .bodyStyle [key ]
282+ }
283+ }
284+
285+ if (props .appStyle ) {
286+ const appEl = sandbox .contentWindow ?.document .body .querySelector (
287+ ' #app'
288+ ) as HTMLElement
289+ if (appEl ) {
290+ for (const key in props .appStyle ) {
291+ appEl .style [key ] = props .appStyle [key ]
292+ }
293+ }
294+ }
273295}
274296 </script >
275297
You can’t perform that action at this time.
0 commit comments