Skip to content

Commit 2587d28

Browse files
committed
fix: undo needs v-model
1 parent c01ad3e commit 2587d28

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/VueLive.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<component :is="layout ? layout : VueLiveDefaultLayout">
33
<template v-slot:editor>
4-
<PrismEditor :code="stableCode" @change="updatePreview" :language="prismLang"/>
4+
<PrismEditor v-model="stableCode" @change="updatePreview" :language="prismLang"/>
55
</template>
66
<template v-slot:preview>
77
<Preview
@@ -31,6 +31,8 @@ const LANG_TO_PRISM = {
3131
js: "jsx"
3232
};
3333
34+
const UPDATE_DELAY = 300;
35+
3436
export default {
3537
name: "VueLivePreview",
3638
components: { PrismEditor, Preview },
@@ -74,6 +76,11 @@ export default {
7476
model: this.code,
7577
prismLang: "html",
7678
VueLiveDefaultLayout,
79+
/**
80+
* this data only gets changed when changing language.
81+
* it allows for copy and pasting without having the code
82+
* editor repainted every keystroke
83+
*/
7784
stableCode: this.code
7885
};
7986
},
@@ -92,7 +99,7 @@ export default {
9299
},
93100
updatePreview: debounce(function(value) {
94101
this.model = value;
95-
}, 300)
102+
}, UPDATE_DELAY)
96103
}
97104
};
98105
</script>

0 commit comments

Comments
 (0)