mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Koenig - Prevent "Enter" being inserted into captions
refs https://github.com/TryGhost/Ghost/issues/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`)
This commit is contained in:
parent
6943e1d27a
commit
c33a0c23bc
1 changed files with 2 additions and 2 deletions
|
@ -90,10 +90,10 @@ export default Component.extend({
|
||||||
let key = new Key(event);
|
let key = new Key(event);
|
||||||
let {editor} = this;
|
let {editor} = this;
|
||||||
|
|
||||||
if (event.target.matches('[data-kg="editor"]') && editor && !editor._hasFocus() && key.isPrintableKey()) {
|
if (event.target.matches('[data-kg="editor"]') && editor && !editor._hasFocus() && key.isPrintableKey() && !key.isEnter()) {
|
||||||
editor.focus();
|
editor.focus();
|
||||||
editor.run((postEditor) => {
|
editor.run((postEditor) => {
|
||||||
postEditor.insertText(editor.post.tailPosition(), event.key);
|
postEditor.insertText(editor.post.tailPosition(), key.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
Loading…
Add table
Reference in a new issue