wujingjing
2024-08-29 4739692ba84e946660d83c386e750d70e1e37f82
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<template>
    <div class="h-full flex flex-col">
        <div class="grid grid-cols-2 gap-2 h-2/3 flex-0">
            <div class="h-full overflow-auto">
                <!-- <codemirror
                    v-model="dockCode"
                    :style="{ height: '100%' }"
                    :autofocus="true"
                    :indent-with-tab="true"
                    :tab-size="2"
                    :extensions="dockEditorExtensions"
                    @change="log('change', $event)"
                    @focus="log('focus', $event)"
                    @blur="log('blur', $event)"
                /> -->
                
            </div>
            <div class="h-full overflow-auto">
                <codemirror
                    class="h-full overflow-auto"
                    v-model="sqlCode"
                    :style="{ height: '100%' }"
                    :autofocus="true"
                    :indent-with-tab="true"
                    :tab-size="2"
                    :extensions="sqlEditorExtensions"
                    @change="log('change', $event)"
                    @focus="log('focus', $event)"
                    @blur="log('blur', $event)"
                />
            </div>
        </div>
        <div class="flex-auto overflow-auto mt-3">
            <codemirror
                disabled
                class="h-full overflow-auto"
                v-model="jsonCode"
                :style="{ height: '100%' }"
                :autofocus="true"
                :indent-with-tab="true"
                :tab-size="2"
                :extensions="jsonEditorExtensions"
                @change="log('change', $event)"
                @focus="log('focus', $event)"
                @blur="log('blur', $event)"
            />
        </div>
    </div>
</template>
 
<script setup lang="ts">
import { defineComponent, ref, shallowRef } from 'vue';
import { Codemirror } from 'vue-codemirror';
import { json } from '@codemirror/lang-json';
import { vscodeDark, vscodeLight, vscodeLightInit } from '@uiw/codemirror-theme-vscode';
import * as codeExample from './testData';
import { sql } from '@codemirror/lang-sql';
import { xml } from '@codemirror/lang-xml';
const log = console.log;
const jsonCode = ref(codeExample.jsonCode);
const dockCode = ref(codeExample.dockCode);
const sqlCode = ref(codeExample.sqlCode);
 
const jsonEditorExtensions = [json(), vscodeDark];
const sqlEditorExtensions = [sql(), vscodeDark];
const dockEditorExtensions = [xml(), vscodeDark];
</script>