Skip to content

Commit

Permalink
fix list/button toolbar buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Oct 29, 2015
1 parent 5d58315 commit cc52d65
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"devDependencies": {
"async": "^1.5.0",
"babel-core": "^5.8.25",
"babel-core": "^5.8.30",
"babel-loader": "^5.3.2",
"babel-runtime": "^5.8.25",
"css-loader": "~0.20.2",
Expand Down
6 changes: 4 additions & 2 deletions src/modules/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,20 @@ class Keyboard {
_onTab(range, binding) {
let pos = this.quill.editor.findLine(range.start);
if (pos == null) return false;
let formats = this.quill.getFormat();
let formats = this.quill.getFormat(range.start);
if (typeof formats['list'] === 'number' || typeof formats['bullet'] === 'number') {
let format = formats['list'] ? 'list' : 'bullet';
// We are in a list or bullet
if (!range.isCollapsed() || pos.offset === 0) {
let value = formats[format] + (binding.shiftKey ? 1 : -1);
this.quill.formatLine(range, format, value, Quill.sources.USER);
this.quill.setSelection(range, Quill.sources.SILENT);
return false;
}
}
let delta = new Delta().retain(range.start).delete(range.end - range.start).insert('\t');
let delta = new Delta().retain(range.start).insert('\t').delete(range.end - range.start);
this.quill.updateContents(delta, Quill.sources.USER);
this.quill.setSelection(range.start + 1, Quill.sources.SILENT);
return false
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/modules/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ class Toolbar {
};
handler.call(this, input, range, (value) => {
let match = Parchment.match(format);
if ((match.prototype instanceof Parchment.Block) || (match instanceof BlockAttributor)) {
if ((match.prototype instanceof Parchment.Block) ||
(match.prototype instanceof Parchment.Container) ||
(match instanceof BlockAttributor)) {
this.quill.formatLine(range.start, range.end + 1, format, value, Quill.sources.USER);
this.quill.setSelection(range, Quill.sources.USER);
} else if (range.isCollapsed()) {
Expand Down

0 comments on commit cc52d65

Please sign in to comment.