Skip to content

Commit

Permalink
Fix a bug in the codemirror demo
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Jul 20, 2022
1 parent c6a603c commit a7a91cc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions example/codemirror/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ class CodeBlockView {
if (update.docChanged || !this.view.state.selection.eq(selection)) {
let tr = this.view.state.tr.setSelection(selection)
update.changes.iterChanges((fromA, toA, fromB, toB, text) => {
tr.replaceWith(offset + fromA, offset + toA,
schema.text(text.toString()))
if (text.length)
tr.replaceWith(offset + fromA, offset + toA,
schema.text(text.toString()))
else
tr.delete(offset + fromA, offset + toA)
offset += (toB - fromB) - (toA - fromA)
})
this.view.dispatch(tr)
Expand Down

0 comments on commit a7a91cc

Please sign in to comment.