From e62221074e63f6cc99a74c408136614799ece508 Mon Sep 17 00:00:00 2001 From: James Johnson Date: Mon, 10 Jul 2017 14:35:01 +1000 Subject: [PATCH] Add shortcut keys for indenting and outdenting lists --- blocks/library/list/index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/blocks/library/list/index.js b/blocks/library/list/index.js index f98de710f6458..eb80484c52950 100644 --- a/blocks/library/list/index.js +++ b/blocks/library/list/index.js @@ -165,6 +165,19 @@ registerBlockType( 'core/list', { } ); } ); + // this checks for languages that do not typically have square brackets on their keyboards + const lang = window.navigator.browserLanguage || window.navigator.language; + const keyboardHasSqBracket = ! /^(?:fr|nl|sv|ru|de|es|it)/.test( lang ); + + if ( keyboardHasSqBracket ) { + // keycode 219 = '[' and keycode 221 = ']' + editor.shortcuts.add( 'meta+219', 'Decrease indent', 'Outdent' ); + editor.shortcuts.add( 'meta+221', 'Increase indent', 'Indent' ); + } else { + editor.shortcuts.add( 'meta+shift+m', 'Decrease indent', 'Outdent' ); + editor.shortcuts.add( 'meta+m', 'Increase indent', 'Indent' ); + } + this.editor = editor; }