Skip to content

Commit

Permalink
fix #841 and test
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Aug 3, 2016
1 parent 8192c0b commit 233b42d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions blots/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ class Cursor extends Embed {
return super.format(name, value);
}
let target = this, index = 0;
this._length = Cursor.CONTENTS.length;
while (target != null && target.statics.scope !== Parchment.Scope.BLOCK_BLOT) {
index += target.offset(target.parent);
target = target.parent;
}
if (target != null) {
this._length = Cursor.CONTENTS.length;
target.optimize();
target.formatAt(index, Cursor.CONTENTS.length, name, value);
this._length = 0;
}
this._length = 0;
}

index(node, offset) {
Expand Down
9 changes: 5 additions & 4 deletions test/functional/epic.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ describe('compose an epic', function(done) {

it('preformat', function() {
browser.click('.ql-toolbar .ql-bold');
browser.click('.ql-toolbar .ql-italic');
expect(browser.getHTML('.ql-editor', false)).toEqual([
'<p><strong><span class="ql-cursor">\uFEFF</span></strong></p>',
'<p><strong><em><span class="ql-cursor">\uFEFF</span></em></strong></p>',
'<p>' + CHAPTER + '</p>',
'<p><br></p>',
'<p>\t' + P1 + '</p>',
Expand All @@ -121,7 +122,7 @@ describe('compose an epic', function(done) {
}
browser.keys('Moby Dick');
expect(browser.getHTML('.ql-editor', false)).toEqual([
'<p><strong>Moby Dick</strong></p>',
'<p><strong><em>Moby Dick</em></strong></p>',
'<p>' + CHAPTER + '</p>',
'<p><br></p>',
'<p>\t' + P1 + '</p>',
Expand All @@ -142,7 +143,7 @@ describe('compose an epic', function(done) {
browser.keys([KEYS.Short, 'b', KEYS.Null]);
expect(browser.isExisting('.ql-toolbar .ql-bold.ql-active')).toBe(true);
expect(browser.getHTML('.ql-editor', false)).toEqual([
'<p><strong>Moby Dick</strong></p>',
'<p><strong><em>Moby Dick</em></strong></p>',
'<p><strong>' + CHAPTER + '</strong></p>',
'<p><br></p>',
'<p>\t' + P1 + '</p>',
Expand All @@ -155,7 +156,7 @@ describe('compose an epic', function(done) {
browser.keys([KEYS.Left, KEYS.Up])
.click('.ql-toolbar .ql-header[value="1"]');
expect(browser.getHTML('.ql-editor', false)).toEqual([
'<h1><strong>Moby Dick</strong></h1>',
'<h1><strong><em>Moby Dick</em></strong></h1>',
'<p><strong>' + CHAPTER + '</strong></p>',
'<p><br></p>',
'<p>\t' + P1 + '</p>',
Expand Down

0 comments on commit 233b42d

Please sign in to comment.