Skip to content

Commit 081f961

Browse files
committed
fix: allow for cpy-paste in examples
1 parent db50daa commit 081f961

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/VueLive.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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;

0 commit comments

Comments
 (0)