Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit 482188b

Browse files
committed
Koenig - Prevent "Enter" being inserted into captions
refs TryGhost/Ghost#9724 - mobiledoc-kit's `key.isPrintable()` returns true for <kbd>Enter</kbd> but in this instance we don't want to capture newlines as printable chars - swapped insertion of `event.key` for `key.toString()` for better handling of named keys that output characters (eg. when `event.key` === `Enter` which prints `\n`)
1 parent fcc943f commit 482188b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/koenig-editor/addon/components/koenig-caption-input.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ export default Component.extend({
9090
let key = new Key(event);
9191
let {editor} = this;
9292

93-
if (event.target.matches('[data-kg="editor"]') && editor && !editor._hasFocus() && key.isPrintableKey()) {
93+
if (event.target.matches('[data-kg="editor"]') && editor && !editor._hasFocus() && key.isPrintableKey() && !key.isEnter()) {
9494
editor.focus();
9595
editor.run((postEditor) => {
96-
postEditor.insertText(editor.post.tailPosition(), event.key);
96+
postEditor.insertText(editor.post.tailPosition(), key.toString());
9797
});
9898

9999
event.preventDefault();

0 commit comments

Comments
 (0)