File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 11<template >
22 <component :is =" this.layout ? this.layout : VueLiveDefaultLayout" >
33 <template v-slot :editor >
4- <PrismEditor :code =" code " @change =" updatePreview" :language =" prismLang" />
4+ <PrismEditor :code =" stableCode " @change =" updatePreview" :language =" prismLang" />
55 </template >
66 <template v-slot :preview >
77 <Preview
@@ -73,7 +73,8 @@ export default {
7373 return {
7474 model: this .code ,
7575 prismLang: " html" ,
76- VueLiveDefaultLayout
76+ VueLiveDefaultLayout,
77+ stableCode: this .code
7778 };
7879 },
7980 computed: {
@@ -83,7 +84,11 @@ export default {
8384 },
8485 methods: {
8586 switchLanguage (newLang ) {
86- this .prismLang = LANG_TO_PRISM [newLang];
87+ const newPrismLang = LANG_TO_PRISM [newLang];
88+ if (this .prismLang !== newPrismLang) {
89+ this .prismLang = newPrismLang;
90+ this .stableCode = this .model ;
91+ }
8792 },
8893 updatePreview: debounce (function (value ) {
8994 this .model = value;
You can’t perform that action at this time.
0 commit comments