Skip to content

Commit

Permalink
Fix pasting in checklist does not preserve indentation (#3064)
Browse files Browse the repository at this point in the history
  • Loading branch information
luin authored Jun 14, 2020
1 parent 125bc3c commit a201e1d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {}) });
Expand Down
14 changes: 14 additions & 0 deletions test/unit/modules/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,20 @@ describe('Clipboard', function() {
);
});

it('html nested checklist', function() {
const delta = this.clipboard.convert({
html:
'<ul><li data-list="checked">One<ul><li data-list="checked">Alpha</li><li data-list="checked">Beta' +
'<ul><li data-list="checked">I</li></ul></li></ul></li></ul>',
});
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:
Expand Down

0 comments on commit a201e1d

Please sign in to comment.