From e140193fa5f0e85a1d10825f81b9cbb763ad12c4 Mon Sep 17 00:00:00 2001 From: luin Date: Sat, 13 Jun 2020 13:51:26 +0800 Subject: [PATCH] Fix pasting in checklist does not preserve indentation --- modules/clipboard.js | 2 +- test/unit/modules/clipboard.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/clipboard.js b/modules/clipboard.js index 0b870ae370..f8d409fe62 100644 --- a/modules/clipboard.js +++ b/modules/clipboard.js @@ -414,7 +414,7 @@ function matchIndent(node, delta, scroll) { } if (indent <= 0) return delta; return delta.reduce((composed, op) => { - if (op.attributes && op.attributes.list) { + if (op.attributes && typeof op.attributes.indent === 'number') { return composed.push(op); } return composed.insert(op.insert, { indent, ...(op.attributes || {}) }); diff --git a/test/unit/modules/clipboard.js b/test/unit/modules/clipboard.js index 7ad5328be5..d542fc9fcd 100644 --- a/test/unit/modules/clipboard.js +++ b/test/unit/modules/clipboard.js @@ -203,6 +203,20 @@ describe('Clipboard', function() { ); }); + it('html nested checklist', function() { + const delta = this.clipboard.convert({ + html: + '', + }); + expect(delta).toEqual( + new Delta() + .insert('One\n', { list: 'checked' }) + .insert('Alpha\nBeta\n', { list: 'checked', indent: 1 }) + .insert('I\n', { list: 'checked', indent: 2 }), + ); + }); + it('html partial list', function() { const delta = this.clipboard.convert({ html: