Skip to content

Commit

Permalink
ignore top level whitespace, fixes #1244
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Apr 17, 2017
1 parent 6c32a39 commit c565ad1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions modules/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/modules/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('Clipboard', function() {
});

it('intentional whitespace', function() {
let html = '0&nbsp;<strong>1</strong>&nbsp;2';
let html = '<span>0&nbsp;<strong>1</strong>&nbsp;2</span>';
let delta = this.clipboard.convert(html);
expect(delta).toEqual(new Delta().insert('0\u00a0').insert('1', { bold: true }).insert('\u00a02'));
});
Expand Down

0 comments on commit c565ad1

Please sign in to comment.