diff --git a/src/y-codemirror.js b/src/y-codemirror.js index 9361cfd..c2071a8 100644 --- a/src/y-codemirror.js +++ b/src/y-codemirror.js @@ -81,6 +81,11 @@ const typeObserver = (binding, event) => { const targetObserver = (binding, changes) => { binding._mux(() => { binding.doc.transact(() => { + const hasPaste = binding.yUndoManager && changes.some(change => change.origin === 'paste'); + if (hasPaste) { + binding.yUndoManager.stopCapturing(); + } + if (changes.length > 1) { // If there are several consecutive changes, we can't reliably compute the positions anymore. See y-codemirror#11 // Instead, we will compute the diff and apply the changes @@ -98,6 +103,10 @@ const targetObserver = (binding, changes) => { binding.type.insert(start, change.text.join('\n')) } } + + if (hasPaste) { + binding.yUndoManager.stopCapturing(); + } }, binding) }) }