2
2
import SplitPane from ' ./SplitPane.vue'
3
3
import Output from ' ./output/Output.vue'
4
4
import { Store , ReplStore , SFCOptions } from ' ./store'
5
- import { provide , toRef } from ' vue'
5
+ import { provide , ref , toRef } from ' vue'
6
6
import type { EditorComponentType } from ' ./editor/types'
7
7
import EditorContainer from ' ./editor/EditorContainer.vue'
8
8
@@ -49,6 +49,7 @@ if (!props.editor) {
49
49
throw new Error (' The "editor" prop is now required.' )
50
50
}
51
51
52
+ const outputRef = ref <InstanceType <typeof Output >>()
52
53
const { store } = props
53
54
const sfcOptions = (store .options = props .sfcOptions || {})
54
55
if (! sfcOptions .script ) {
@@ -74,6 +75,15 @@ provide('import-map', toRef(props, 'showImportMap'))
74
75
provide (' tsconfig' , toRef (props , ' showTsConfig' ))
75
76
provide (' clear-console' , toRef (props , ' clearConsole' ))
76
77
provide (' preview-options' , props .previewOptions )
78
+
79
+ /**
80
+ * Reload the preview iframe
81
+ */
82
+ function reload() {
83
+ outputRef .value ?.reload ()
84
+ }
85
+
86
+ defineExpose ({ reload })
77
87
</script >
78
88
79
89
<template >
@@ -84,6 +94,7 @@ provide('preview-options', props.previewOptions)
84
94
</template >
85
95
<template #right >
86
96
<Output
97
+ ref =" outputRef"
87
98
:editorComponent =" editor"
88
99
:showCompileOutput =" props.showCompileOutput"
89
100
:ssr =" !!props.ssr"
0 commit comments