Skip to content

Commit

Permalink
selection needs to be restored on api changes
Browse files Browse the repository at this point in the history
It may be the case the user's cursor is on a bold (or any other) blot
and an api call removes the format which would lose the selection.

Related #1152
  • Loading branch information
jhchen committed Jan 9, 2017
1 parent c55149a commit 51c03ba
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ class Quill {
[index, length, , source] = overload(index, length, source);
this.selection.setRange(new Range(index, length), source);
}
this.selection.scrollIntoView();
if (source !== Emitter.sources.SILENT) {
this.selection.scrollIntoView();
}
}

setText(text, source = Emitter.sources.API) {
Expand Down Expand Up @@ -394,7 +396,7 @@ function modify(modifier, source, index, shift) {
let range = index == null ? null : this.getSelection();
let oldDelta = this.editor.delta;
let change = modifier();
if (range != null && source === Emitter.sources.USER) {
if (range != null) {
if (index === true) index = range.index;
if (shift == null) {
range = shiftRange(range, change, source);
Expand Down

0 comments on commit 51c03ba

Please sign in to comment.