Skip to content

Commit

Permalink
Fix retention of formats between lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
willrowe committed Jun 25, 2015
1 parent 564848e commit 7be4d29
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 7be4d29

Please sign in to comment.