From 9c64c5d5a58f1f5f9057bb4574841a72f303592b Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Thu, 15 Sep 2016 16:01:03 -0700 Subject: [PATCH] fix #974 --- modules/clipboard.js | 1 + test/unit/modules/clipboard.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/modules/clipboard.js b/modules/clipboard.js index 2dc6c77f8f..8404958cd1 100644 --- a/modules/clipboard.js +++ b/modules/clipboard.js @@ -127,6 +127,7 @@ class Clipboard extends Module { let bodyTop = document.body.scrollTop; this.container.focus(); setTimeout(() => { + this.quill.selection.update(Quill.sources.SILENT); delta = delta.concat(this.convert()); this.quill.updateContents(delta, Quill.sources.USER); // range.length contributes to delta.length() diff --git a/test/unit/modules/clipboard.js b/test/unit/modules/clipboard.js index 5ab0e1c6d1..9e092f16f9 100644 --- a/test/unit/modules/clipboard.js +++ b/test/unit/modules/clipboard.js @@ -19,6 +19,20 @@ describe('Clipboard', function() { done(); }, 2); }); + + it('selection-change', function(done) { + let handler = { + change: function() {} + }; + spyOn(handler, 'change') + this.quill.on('selection-change', handler.change); + this.quill.clipboard.container.innerHTML = '0'; + this.quill.clipboard.onPaste({}); + setTimeout(function() { + expect(handler.change).not.toHaveBeenCalled(); + done(); + }, 2); + }); }); describe('convert', function() {