vue-codemirror
vue-codemirror copied to clipboard
Initial content is open for undoing (getting empty on undo)
Vue.js version and component version
vueversion2.6.11vue-codemirrorversion4.0.6
Steps to reproduce
- Make editor with model set:
<codemirror v-model="draft" /> - Initially set model:
draft: 'TO WHATEVER TEXT'. - Open editor, press Ctrl + Z.
What is Expected?
Nothing must happen.
What is actually happening?
Content is cleared completely, and as I suspect because of behavior described here.
Would be plesant if first content was fed to editor at initialization call rather than at runtime.
Just have found a workaround! Issue can be negotiated with clearing history on load.
- Bind event listener
<codemirror @ready="onCmReady"... />. - Add method that clears history:
onCmReady(cm) {
cm.doc.clearHistory();
cm.refresh();
}