Skip to content

Commit

Permalink
fixes #752
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Jun 19, 2016
1 parent e5ebf25 commit bd1358d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
13 changes: 6 additions & 7 deletions blots/cursor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Parchment from 'parchment';
import Embed from './embed';
import Emitter from '../core/emitter';


class Cursor extends Embed {
Expand Down Expand Up @@ -79,14 +80,12 @@ class Cursor extends Embed {
}
this.remove();
if (range != null && range.start.node === textNode && range.end.node === textNode) {
// optimize() might move the cursor after our restore
let [start, end] = [range.start.offset, range.end.offset].map(function(offset) {
return Math.max(0, Math.min(textNode.data.length, offset - 1));
});
setTimeout(() => {
// optimize() might move selection after us
this.selection.emitter.once(Emitter.events.SCROLL_OPTIMIZE, () => {
let [start, end] = [range.start.offset, range.end.offset].map(function(offset) {
return Math.max(0, Math.min(textNode.data.length, offset - 1));
});
this.selection.setNativeRange(textNode, start, textNode, end);
}, 1);
});
}
}

Expand Down
3 changes: 1 addition & 2 deletions test/functional/epic.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ describe('compose an epic', function(done) {
if (browser.desiredCapabilities.browserName === 'firefox') {
browser.click('.ql-editor .ql-cursor');
}
browser.keys('M').pause(200);
browser.keys('oby Dick');
browser.keys('Moby Dick');
expect(browser.getHTML('.ql-editor', false)).toEqual([
'<p><strong>Moby Dick</strong></p>',
'<p>' + CHAPTER + '</p>',
Expand Down

0 comments on commit bd1358d

Please sign in to comment.