From 7be4d29e2517a6f8a663bb37fed8a766ecbbdb12 Mon Sep 17 00:00:00 2001 From: Will Rowe Date: Thu, 25 Jun 2015 04:35:32 -0400 Subject: [PATCH] Fix retention of formats between lines. --- src/modules/keyboard.coffee | 1 + test/unit/modules/keyboard.coffee | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/modules/keyboard.coffee b/src/modules/keyboard.coffee index 2b1b75d831..8118d80f99 100644 --- a/src/modules/keyboard.coffee +++ b/src/modules/keyboard.coffee @@ -58,6 +58,7 @@ class Keyboard _.each(leaf.formats, (value, format) => @quill.prepareFormat(format, value) @toolbar.setActive(format, value) if @toolbar? + return ) return false ) diff --git a/test/unit/modules/keyboard.coffee b/test/unit/modules/keyboard.coffee index 538bf6ff6c..460d361533 100644 --- a/test/unit/modules/keyboard.coffee +++ b/test/unit/modules/keyboard.coffee @@ -66,5 +66,19 @@ describe('Keyboard', -> dom(@quill.root).trigger('keydown', Quill.Module.Keyboard.hotkeys.OUTDENT) expect(@quill.root).toEqualHTML('
0123
', 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) + ) ) )