mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Map Cmd-[] to change list level when in list
These shortcuts alter the indentation level of blockquotes. When inside a list this is probably not the behaviour the user would expect. This change alters the functionality to increase/decrease the list indentation level instead of wrapping the list item in a blockquote when inside a list. Co-authored-by: Neil Jenkins <neil@nmjenkins.com>
This commit is contained in:
parent
6b3ce94406
commit
85e39333dc
3 changed files with 36 additions and 5 deletions
|
@ -1824,6 +1824,19 @@ if ( !isMac ) {
|
|||
};
|
||||
}
|
||||
|
||||
const changeIndentationLevel = function ( methodIfInQuote, methodIfInList ) {
|
||||
return function ( self, event ) {
|
||||
event.preventDefault();
|
||||
var path = self.getPath();
|
||||
if ( /(?:^|>)BLOCKQUOTE/.test( path ) ||
|
||||
!/(?:^|>)[OU]L/.test( path ) ) {
|
||||
self[ methodIfInQuote ]();
|
||||
} else {
|
||||
self[ methodIfInList ]();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
keyHandlers[ ctrlKey + 'b' ] = mapKeyToFormat( 'B' );
|
||||
keyHandlers[ ctrlKey + 'i' ] = mapKeyToFormat( 'I' );
|
||||
keyHandlers[ ctrlKey + 'u' ] = mapKeyToFormat( 'U' );
|
||||
|
@ -1832,8 +1845,10 @@ keyHandlers[ ctrlKey + 'shift-5' ] = mapKeyToFormat( 'SUB', { tag: 'SUP' } );
|
|||
keyHandlers[ ctrlKey + 'shift-6' ] = mapKeyToFormat( 'SUP', { tag: 'SUB' } );
|
||||
keyHandlers[ ctrlKey + 'shift-8' ] = mapKeyTo( 'makeUnorderedList' );
|
||||
keyHandlers[ ctrlKey + 'shift-9' ] = mapKeyTo( 'makeOrderedList' );
|
||||
keyHandlers[ ctrlKey + '[' ] = mapKeyTo( 'decreaseQuoteLevel' );
|
||||
keyHandlers[ ctrlKey + ']' ] = mapKeyTo( 'increaseQuoteLevel' );
|
||||
keyHandlers[ ctrlKey + '[' ] =
|
||||
changeIndentationLevel( 'decreaseQuoteLevel', 'decreaseListLevel' );
|
||||
keyHandlers[ ctrlKey + ']' ] =
|
||||
changeIndentationLevel( 'increaseQuoteLevel', 'increaseListLevel' );
|
||||
keyHandlers[ ctrlKey + 'd' ] = mapKeyTo( 'toggleCode' );
|
||||
keyHandlers[ ctrlKey + 'y' ] = mapKeyTo( 'redo' );
|
||||
keyHandlers[ ctrlKey + 'z' ] = mapKeyTo( 'undo' );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -583,6 +583,19 @@ if ( !isMac ) {
|
|||
};
|
||||
}
|
||||
|
||||
const changeIndentationLevel = function ( methodIfInQuote, methodIfInList ) {
|
||||
return function ( self, event ) {
|
||||
event.preventDefault();
|
||||
var path = self.getPath();
|
||||
if ( /(?:^|>)BLOCKQUOTE/.test( path ) ||
|
||||
!/(?:^|>)[OU]L/.test( path ) ) {
|
||||
self[ methodIfInQuote ]();
|
||||
} else {
|
||||
self[ methodIfInList ]();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
keyHandlers[ ctrlKey + 'b' ] = mapKeyToFormat( 'B' );
|
||||
keyHandlers[ ctrlKey + 'i' ] = mapKeyToFormat( 'I' );
|
||||
keyHandlers[ ctrlKey + 'u' ] = mapKeyToFormat( 'U' );
|
||||
|
@ -591,8 +604,10 @@ keyHandlers[ ctrlKey + 'shift-5' ] = mapKeyToFormat( 'SUB', { tag: 'SUP' } );
|
|||
keyHandlers[ ctrlKey + 'shift-6' ] = mapKeyToFormat( 'SUP', { tag: 'SUB' } );
|
||||
keyHandlers[ ctrlKey + 'shift-8' ] = mapKeyTo( 'makeUnorderedList' );
|
||||
keyHandlers[ ctrlKey + 'shift-9' ] = mapKeyTo( 'makeOrderedList' );
|
||||
keyHandlers[ ctrlKey + '[' ] = mapKeyTo( 'decreaseQuoteLevel' );
|
||||
keyHandlers[ ctrlKey + ']' ] = mapKeyTo( 'increaseQuoteLevel' );
|
||||
keyHandlers[ ctrlKey + '[' ] =
|
||||
changeIndentationLevel( 'decreaseQuoteLevel', 'decreaseListLevel' );
|
||||
keyHandlers[ ctrlKey + ']' ] =
|
||||
changeIndentationLevel( 'increaseQuoteLevel', 'increaseListLevel' );
|
||||
keyHandlers[ ctrlKey + 'd' ] = mapKeyTo( 'toggleCode' );
|
||||
keyHandlers[ ctrlKey + 'y' ] = mapKeyTo( 'redo' );
|
||||
keyHandlers[ ctrlKey + 'z' ] = mapKeyTo( 'undo' );
|
||||
|
|
Loading…
Reference in a new issue