File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 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+
3436export 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 >
You can’t perform that action at this time.
0 commit comments