From 9e11effe04cb5a113b8c1fdea379d9f2cb3b1c8a 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 | 9 +++++++++ 2 files changed, 10 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..94f6d95139 100644 --- a/test/unit/modules/keyboard.coffee +++ b/test/unit/modules/keyboard.coffee @@ -66,5 +66,14 @@ describe('Keyboard', -> dom(@quill.root).trigger('keydown', Quill.Module.Keyboard.hotkeys.OUTDENT) expect(@quill.root).toEqualHTML('
0123
', true) ) + + it('retain formatting', -> + @quill.setHTML('
foo bar baz
') + @quill.setSelection(@quill.getLength(), @quill.getLength()) + dom(@quill.root).trigger('keydown', { key: dom.KEYS.ENTER }) + document.execCommand('insertText', false, 'foo') + @quill.editor.checkUpdate() + expect(@quill.getHTML()).toEqual('
foo bar baz
foo
') + ) ) )