-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReplEditor.vue
45 lines (40 loc) · 988 Bytes
/
ReplEditor.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<script setup lang="ts">
import type { Store } from '@vue/repl'
import { Repl } from '@vue/repl'
import MonacoEditor from '@vue/repl/monaco-editor'
const props = defineProps({
ssr: {
type: Boolean,
default: false,
},
store: {
type: Object as PropType<Store>,
required: true,
},
})
const colorMode = useColorMode()
const theme = computed(() => {
if (colorMode.value === 'dark')
return 'dark'
else
return 'light'
})
const previewOptions = {
headHTML: `
<script src="https://cdn.jsdelivr.net/npm/@unocss/runtime"><\/script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@unocss/reset/tailwind.min.css" />
<script>
window.__unocss = {
rules: [],
presets: [],
}
<\/script>
`,
}
</script>
<template>
<Repl
:store="props.store" :editor="MonacoEditor" :show-compile-output="true" :theme="theme" :preview-theme="true"
:preview-options="previewOptions" :ssr="props.ssr"
/>
</template>