From c565ad1f52f43f22e7f80c4f37cd726e302c1d9c Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Sun, 16 Apr 2017 20:57:06 -0700 Subject: [PATCH] ignore top level whitespace, fixes #1244 --- modules/clipboard.js | 3 +++ test/unit/modules/clipboard.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/clipboard.js b/modules/clipboard.js index a55321bd1e..4640d23303 100644 --- a/modules/clipboard.js +++ b/modules/clipboard.js @@ -281,6 +281,9 @@ function matchText(node, delta) { if (node.parentNode.tagName === 'O:P') { return delta.insert(text.trim()); } + if (text.trim().length === 0 && node.parentNode.classList.contains('ql-clipboard')) { + return delta; + } if (!computeStyle(node.parentNode).whiteSpace.startsWith('pre')) { // eslint-disable-next-line func-style let replacer = function(collapse, match) { diff --git a/test/unit/modules/clipboard.js b/test/unit/modules/clipboard.js index 8a96c48e40..5c3017f0a4 100644 --- a/test/unit/modules/clipboard.js +++ b/test/unit/modules/clipboard.js @@ -61,7 +61,7 @@ describe('Clipboard', function() { }); it('intentional whitespace', function() { - let html = '0 1 2'; + let html = '1 2'; let delta = this.clipboard.convert(html); expect(delta).toEqual(new Delta().insert('0\u00a0').insert('1', { bold: true }).insert('\u00a02')); });