add code generation
This commit is contained in:
1 parent
7b8ac91183
commit
8f8e291188
14 files changed
+362
-35
No files matched your search
@@ -5,13 +5,12 @@
|
||||
<script lang="ts">
|
||||
import { Codemirror } from 'vue-codemirror';
|
||||
import { json } from '@codemirror/lang-json';
|
||||
import { python } from '@codemirror/lang-python';
|
||||
import { javascript } from '@codemirror/lang-javascript';
|
||||
import { php } from '@codemirror/lang-php';
|
||||
import { java } from '@codemirror/lang-java';
|
||||
import { oneDark } from '@codemirror/theme-one-dark';
|
||||
import { defineComponent } from 'vue';
|
||||
import { Extension } from '@codemirror/state';
|
||||
|
||||
interface IData {
|
||||
extensions: Extension[];
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CodeSnippet',
|
||||
@@ -26,12 +25,34 @@ export default defineComponent({
|
||||
editable: {
|
||||
type: Boolean,
|
||||
required: false
|
||||
},
|
||||
lang: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'JSON'
|
||||
}
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
extensions: [json(), oneDark]
|
||||
};
|
||||
computed: {
|
||||
extensions() {
|
||||
let result = [];
|
||||
result.push(oneDark);
|
||||
if (this.lang === 'JSON') {
|
||||
result.push(json());
|
||||
}
|
||||
if (this.lang === 'Python') {
|
||||
result.push(python());
|
||||
}
|
||||
if (this.lang === 'Java') {
|
||||
result.push(java());
|
||||
}
|
||||
if (this.lang === 'JavaScript') {
|
||||
result.push(javascript());
|
||||
}
|
||||
if (this.lang === 'PHP') {
|
||||
result.push(php());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in new issue
Block a user