Skip to content

Commit

Permalink
Merge pull request #403 from willrowe/fix-format-retention
Browse files Browse the repository at this point in the history
Fix retention of formats between lines.
  • Loading branch information
jhchen committed Jun 26, 2015
2 parents 564848e + 7be4d29 commit 7243bf2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/modules/keyboard.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Keyboard
_.each(leaf.formats, (value, format) =>
@quill.prepareFormat(format, value)
@toolbar.setActive(format, value) if @toolbar?
return
)
return false
)
Expand Down
14 changes: 14 additions & 0 deletions test/unit/modules/keyboard.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,19 @@ describe('Keyboard', ->
dom(@quill.root).trigger('keydown', Quill.Module.Keyboard.hotkeys.OUTDENT)
expect(@quill.root).toEqualHTML('<div>0123</div>', true)
)

it('retain formatting', ->
@quill.addModule('toolbar', { container: $('#toolbar-container').get(0) })
size = '18px'

@quill.setText('foo bar baz')
@quill.formatText(0, @quill.getLength(), { 'bold': true, 'size': size })

@quill.setSelection(@quill.getLength(), @quill.getLength())
dom(@quill.root).trigger('keydown', { key: dom.KEYS.ENTER })

expect(dom($('.ql-bold').get(0)).hasClass('ql-active')).toBe(true)
expect(dom($('.ql-size').get(0)).value()).toBe(size)
)
)
)

0 comments on commit 7243bf2

Please sign in to comment.