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

Mac: Fixes #10921: Markdown editor: Fix custom arrow-key shortcuts fail to register (#10922)

This commit is contained in:
Henry Heino 2024-08-23 03:49:30 -07:00 committed by GitHub
parent 12a26023dd
commit c691fedc12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 6 deletions

View File

@ -6,7 +6,7 @@ describe('normalizeAccelerator', () => {
['Z', { v6: 'z', v5: 'Z' }], ['Z', { v6: 'z', v5: 'Z' }],
['Alt+A', { v6: 'Alt-a', v5: 'Alt-A' }], ['Alt+A', { v6: 'Alt-a', v5: 'Alt-A' }],
['Shift+A', { v6: 'Shift-a', v5: 'Shift-A' }], ['Shift+A', { v6: 'Shift-a', v5: 'Shift-A' }],
['Shift+Up', { v6: 'Shift-Up', v5: 'Shift-Up' }], ['Shift+Up', { v6: 'Shift-ArrowUp', v5: 'Shift-Up' }],
])( ])(
'should convert single-letter key names to lowercase for CM6, keep case unchanged for CM5 (%j)', 'should convert single-letter key names to lowercase for CM6, keep case unchanged for CM5 (%j)',
(original, expected) => { (original, expected) => {

View File

@ -12,11 +12,17 @@ const normalizeAccelerator = (accelerator: string, editorVersion: CodeMirrorVers
const parts = command.split(/-(?!$)/); const parts = command.split(/-(?!$)/);
let name = parts[parts.length - 1]; let name = parts[parts.length - 1];
// In CodeMirror 6, an uppercase single-letter key name makes the editor if (editorVersion === CodeMirrorVersion.CodeMirror6) {
// require the shift key to activate the shortcut. If a key name like `Up`, // In CodeMirror 6, an uppercase single-letter key name makes the editor
// however, `.toLowerCase` breaks the shortcut. // require the shift key to activate the shortcut. If a key name like `Up`,
if (editorVersion === CodeMirrorVersion.CodeMirror6 && name.length === 1) { // however, `.toLowerCase` breaks the shortcut.
name = name.toLowerCase(); if (name.length === 1) {
name = name.toLowerCase();
}
if (['Up', 'Down', 'Left', 'Right'].includes(name)) {
name = `Arrow${name}`;
}
} }
let alt, ctrl, shift, cmd; let alt, ctrl, shift, cmd;