index.vue
1.67 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<style lang="scss">
.eagle-code {
border: 1px solid #DCDFE6;
border-radius: 4px;
.height-100 {
.CodeMirror {
font-size: 16px;
height: 100px !important;
}
}
.height-200 {
.CodeMirror {
font-size: 16px;
height: 200px !important;
}
}
.height-300 {
.CodeMirror {
font-size: 16px;
height: 300px !important;
}
}
.height-400 {
.CodeMirror {
font-size: 16px;
height: 400px !important;
}
}
.height-500 {
.CodeMirror {
font-size: 16px;
height: 500px !important;
}
}
.height-600 {
.CodeMirror {
font-size: 16px;
height: 600px !important;
}
}
.div.CodeMirror-cursors {
padding: 12px 0px !important;
}
}
</style>
<template>
<div class="codemirror eagle-code">
<codemirror :class="`height-${height}`" v-model="code" :options="opt"></codemirror>
</div>
</template>
<script>
export default {
name: 'Code',
props: {
disabled: {
type: Boolean,
default: false,
},
options: Object,
value: {
type: String,
default: '',
},
height: {
type: Number,
default: 300
}
},
data () {
const propsOpt = this.options || {};
return {
opt: {
tabSize: 4,
styleActiveLine: true,
lineNumbers: true,
line: true,
mode: 'text/x-mysql',
...propsOpt,
},
code: '',
}
},
watch: {
value(val) {
this.code = val !== undefined ? val : '';
},
code(val) {
this.$emit('input', val);
}
},
methods: {
}
};
</script>