feat: CodemirrorCode组件

This commit is contained in:
wf 2024-06-04 13:05:42 +08:00
parent e3d4e0947e
commit a94a33b15c

View File

@ -1,11 +1,12 @@
<template> <template>
<div class="main"> <div class="main">
<code-mirror basic :lang="lang" v-model="codeVal" style="height: 400px" :theme="theme" /> <code-mirror basic :lang="lang" v-model="codeVal" style="height: 400px" :theme="theme" :extensions="extensions" />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import CodeMirror from "vue-codemirror6"; import CodeMirror from "vue-codemirror6";
import { oneDark } from '@codemirror/theme-one-dark'
import { json } from "@codemirror/lang-json"; import { json } from "@codemirror/lang-json";
defineOptions({ name: "CodemirrorCode" }); defineOptions({ name: "CodemirrorCode" });
@ -28,6 +29,8 @@ let codeVal = ref("");
codeVal.value = JSON.stringify(props.initJson, null, "\t"); codeVal.value = JSON.stringify(props.initJson, null, "\t");
// json // json
const lang = json(); const lang = json();
//
const extensions = [oneDark];
// //
const theme = { const theme = {
"&": { "&": {