Skip to content

Commit

Permalink
fix #698
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed May 25, 2016
1 parent e2cd8e6 commit 762699c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions formats/indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class IdentAttributor extends Parchment.Attributor.Class {
}
}

value(node){
return parseInt(super.value(node));
value(node) {
return parseInt(super.value(node)) || undefined; // Don't return NaN
}
}

Expand Down
1 change: 1 addition & 0 deletions test/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import './unit/formats/script';
import './unit/formats/align';
import './unit/formats/code';
import './unit/formats/header';
import './unit/formats/indent';
import './unit/formats/list';

import './unit/modules/clipboard';
Expand Down
19 changes: 19 additions & 0 deletions test/unit/formats/indent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Delta from 'rich-text/lib/delta';
import Editor from '../../../core/editor';


describe('Indent', function() {
it('+1', function() {
let editor = this.initialize(Editor, '<ul><li>0123</li></ul>');
editor.formatText(4, 1, { 'indent': '+1' });
expect(editor.getDelta()).toEqual(new Delta().insert('0123').insert('\n', { list: 'bullet', indent: 1 }));
expect(editor.scroll.domNode).toEqualHTML('<ul><li class="ql-indent-1">0123</li></ul>');
});

it('-1', function() {
let editor = this.initialize(Editor, '<ul><li class="ql-indent-1">0123</li></ul>');
editor.formatText(4, 1, { 'indent': '-1' });
expect(editor.getDelta()).toEqual(new Delta().insert('0123').insert('\n', { list: 'bullet' }));
expect(editor.scroll.domNode).toEqualHTML('<ul><li>0123</li></ul>');
});
});

0 comments on commit 762699c

Please sign in to comment.