1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Resolves #9980: Support Ctrl+Enter keyboard shortcut (Cmd+Enter on MacOS) (#10003)

This commit is contained in:
cagnusmarlsen 2024-03-02 21:22:55 +05:30 committed by GitHub
parent ff1f1b190e
commit c409160ad7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -145,6 +145,7 @@ export default function useKeymap(CodeMirror: any) {
'Alt-Right': 'goLineEnd', 'Alt-Right': 'goLineEnd',
'Ctrl-Backspace': 'delGroupBefore', 'Ctrl-Backspace': 'delGroupBefore',
'Ctrl-Delete': 'delGroupAfter', 'Ctrl-Delete': 'delGroupAfter',
'Ctrl-Enter': 'insertLineAfter',
'fallthrough': 'basic', 'fallthrough': 'basic',
}; };
@ -167,6 +168,7 @@ export default function useKeymap(CodeMirror: any) {
'Alt-Backspace': 'delGroupBefore', 'Alt-Backspace': 'delGroupBefore',
'Alt-Delete': 'delGroupAfter', 'Alt-Delete': 'delGroupAfter',
'Cmd-Backspace': 'delWrappedLineLeft', 'Cmd-Backspace': 'delWrappedLineLeft',
'Cmd-Enter': 'insertLineAfter',
'fallthrough': 'basic', 'fallthrough': 'basic',
}; };

View File

@ -29,6 +29,7 @@ import { selectionFormattingEqual } from '../SelectionFormatting';
import configFromSettings from './configFromSettings'; import configFromSettings from './configFromSettings';
import getScrollFraction from './getScrollFraction'; import getScrollFraction from './getScrollFraction';
import CodeMirrorControl from './CodeMirrorControl'; import CodeMirrorControl from './CodeMirrorControl';
import insertLineAfter from './editorCommands/insertLineAfter';
const createEditor = ( const createEditor = (
parentElement: HTMLElement, props: EditorProps, parentElement: HTMLElement, props: EditorProps,
@ -261,6 +262,10 @@ const createEditor = (
}), }),
keyCommand('Tab', insertOrIncreaseIndent, true), keyCommand('Tab', insertOrIncreaseIndent, true),
keyCommand('Shift-Tab', decreaseIndent, true), keyCommand('Shift-Tab', decreaseIndent, true),
keyCommand('Mod-Enter', (_: EditorView) => {
insertLineAfter(_);
return true;
}, true),
...standardKeymap, ...historyKeymap, ...searchKeymap, ...standardKeymap, ...historyKeymap, ...searchKeymap,
]), ]),