Permalink
Browse files

selection needs to be restored on api changes

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...
1 parent c55149a commit 51c03ba60d4c27d66ade7b7ff505c24ebd943fff @jhchen jhchen committed Jan 9, 2017
Showing with 4 additions and 2 deletions.
  1. +4 −2 core/quill.js
View
@@ -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) {
@@ -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);

0 comments on commit 51c03ba

Please sign in to comment.