Skip to content

Commit b893c20

Browse files
committed
feat: use MonacoEditor
1 parent 30977f4 commit b893c20

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

app/pages/index.vue

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import type { OutputModes } from '@vue/repl'
33
import type { ShallowRef } from 'vue'
44
import { mergeImportMap, Repl, useStore, useVueImportMap } from '@vue/repl'
5-
import CodeMirror from '@vue/repl/codemirror-editor'
5+
import MonacoEditor from '@vue/repl/monaco-editor'
66
77
const showOutput = useRouteQuery<string, boolean>('showOutput', 'false', { transform: {
88
get(value) {
@@ -79,8 +79,17 @@ productionMode.value = true
7979
watch(() => injectedVueVersion.value, (newVersion) => {
8080
vueVersion.value = newVersion
8181
})
82+
83+
const colorMode = useColorMode()
84+
85+
const theme = computed(() => {
86+
if (colorMode.value === 'dark')
87+
return 'dark'
88+
else
89+
return 'light'
90+
})
8291
</script>
8392

8493
<template>
85-
<Repl :store="store" :editor="CodeMirror" :show-compile-output="true" />
94+
<Repl :store="store" :editor="MonacoEditor" :show-compile-output="true" :theme="theme" :preview-theme="true" />
8695
</template>

app/template/App.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const timeago = useTimeAgo(ms)
1010
<template>
1111
<div>
1212
<input v-model="input" type="text" placeholder="Type anything...">
13-
<div>Last changed: <span class="text-primary">{{ timeago }}</span> <span class="opacity-50 font-mono">({{ ms }})</span></div>
13+
<div>
14+
Last changed: <span class="text-primary">{{ timeago }}</span>
15+
<span class="opacity-50 font-mono">({{ ms }})</span>
16+
</div>
1417
</div>
1518
</template>

nuxt.config.ts

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ export default defineNuxtConfig({
1616
optimizeDeps: {
1717
exclude: ['@vue/repl'],
1818
},
19+
build: {
20+
rollupOptions: {
21+
external: ['typescript'],
22+
},
23+
},
1924
},
2025
css: ['~/assets/css/main.css'],
2126
})

0 commit comments

Comments
 (0)