Skip to content

Commit

Permalink
Changing code theme when the main theme is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
GusevPM committed Aug 5, 2023
1 parent d279ac4 commit b1685e5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/components/Michelson.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<template>
<codemirror ref="editor" v-model="value" :options="cmOptions"></codemirror>
<codemirror
ref="editor"
v-model="value"
:options="cmOptions"
:key="codeMirrorTheme"
></codemirror>
</template>

<script>
Expand Down Expand Up @@ -27,6 +32,9 @@ export default {
editor() {
return this.$refs.editor.editor;
},
codeMirrorTheme() {
return this.$vuetify.theme.dark ? "darcula" : "neo";
},
},
data: () => ({
value: "",
Expand All @@ -41,11 +49,10 @@ export default {
},
}),
created() {
if (this.firstLineNumber)
this.cmOptions.firstLineNumber = this.firstLineNumber;
if (this.$vuetify.theme.dark) this.cmOptions.theme = "darcula";
if (this.firstLineNumber) this.cmOptions.firstLineNumber = this.firstLineNumber;
if (this.code !== null) this.value = this.code;
if (this.mutable) this.cmOptions.readOnly = false;
this.cmOptions.theme = this.codeMirrorTheme;
create();
},
Expand All @@ -69,6 +76,9 @@ export default {
this.value = newValue;
}
},
codeMirrorTheme(theme) {
this.cmOptions.theme = theme;
},
},
};
</script>
Expand Down

0 comments on commit b1685e5

Please sign in to comment.