Skip to content

Commit

Permalink
chore(playground): use CodeMirror during local dev
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Nov 30, 2023
1 parent 4d94ebf commit dd26e98
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/sfc-playground/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
<script setup lang="ts">
import Header from './Header.vue'
import { Repl, ReplStore, SFCOptions } from '@vue/repl'
import Monaco from '@vue/repl/monaco-editor'
import type Monaco from '@vue/repl/monaco-editor'
import type CodeMirror from '@vue/repl/codemirror-editor'
import { ref, watchEffect, onMounted } from 'vue'
import { shallowRef } from 'vue'
const EditorComponent = shallowRef<typeof Monaco | typeof CodeMirror>()
if (import.meta.env.DEV) {
import('@vue/repl/codemirror-editor').then(
mod => (EditorComponent.value = mod.default)
)
} else {
import('@vue/repl/monaco-editor').then(
mod => (EditorComponent.value = mod.default)
)
}
const setVH = () => {
document.documentElement.style.setProperty('--vh', window.innerHeight + `px`)
Expand Down Expand Up @@ -97,8 +111,9 @@ onMounted(() => {
@toggle-ssr="toggleSSR"
/>
<Repl
v-if="EditorComponent"
:theme="theme"
:editor="Monaco"
:editor="EditorComponent"
@keydown.ctrl.s.prevent
@keydown.meta.s.prevent
:ssr="useSSRMode"
Expand Down

0 comments on commit dd26e98

Please sign in to comment.