forked from devlive-community/codeforge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeEditor.vue
More file actions
41 lines (35 loc) · 964 Bytes
/
CodeEditor.vue
File metadata and controls
41 lines (35 loc) · 964 Bytes
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
<template>
<div class="flex bg-white h-full relative">
<Codemirror v-if="isReady"
style="width: 100%; height: 100%"
:model-value="modelValue"
:extensions="extensions"
:indent-with-tab="editorConfig?.indent_with_tab"
:tab-size="editorConfig?.tab_size"
@change="handleInput"/>
</div>
</template>
<script setup lang="ts">
import { onMounted } from 'vue'
import { Codemirror } from 'vue-codemirror'
import { useCodeMirrorEditor } from '../composables/useCodeMirrorEditor'
const props = defineProps<{
modelValue: string
language?: string
}>()
const emit = defineEmits<{
'update:modelValue': [value: string]
}>()
const {
isReady,
extensions,
editorConfig,
initializeEditor
} = useCodeMirrorEditor(props)
const handleInput = (value: string) => {
emit('update:modelValue', value)
}
onMounted(async () => {
await initializeEditor()
})
</script>