vue-codemirror icon indicating copy to clipboard operation
vue-codemirror copied to clipboard

Initial content is open for undoing (getting empty on undo)

Open vintprox opened this issue 5 years ago • 2 comments

Vue.js version and component version

  • vue version 2.6.11
  • vue-codemirror version 4.0.6

Steps to reproduce

  1. Make editor with model set: <codemirror v-model="draft" />
  2. Initially set model: draft: 'TO WHATEVER TEXT'.
  3. 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.

vintprox avatar Apr 11 '20 09:04 vintprox

Just have found a workaround! Issue can be negotiated with clearing history on load.

  1. Bind event listener <codemirror @ready="onCmReady"... />.
  2. Add method that clears history:
onCmReady(cm) {
  cm.doc.clearHistory();
  cm.refresh();
}

vintprox avatar Apr 11 '20 09:04 vintprox