Commit 6901088 1 parent 420e779 commit 6901088 Copy full SHA for 6901088
File tree 1 file changed +11
-13
lines changed
src/components/EditorWidgets/Markdown/MarkdownControl/VisualEditor
1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change 1
1
import { Block , Text } from 'slate' ;
2
- import { isHotkey } from 'is-hotkey' ;
2
+ import isHotkey from 'is-hotkey' ;
3
3
4
4
export default onKeyDown ;
5
5
@@ -38,19 +38,17 @@ function onKeyDown(event, change) {
38
38
. collapseToStartOf ( newBlock ) ;
39
39
}
40
40
41
- if ( isHotkey ( `mod+${ event . key } ` , event ) ) {
42
- const marks = {
43
- b : 'bold' ,
44
- i : 'italic' ,
45
- s : 'strikethrough' ,
46
- '`' : 'code' ,
47
- } ;
41
+ const marks = [
42
+ [ 'b' , 'bold' ] ,
43
+ [ 'i' , 'italic' ] ,
44
+ [ 's' , 'strikethrough' ] ,
45
+ [ '`' , 'code' ] ,
46
+ ] ;
48
47
49
- const mark = marks [ event . key ] ;
48
+ const [ markKey , markName ] = marks . find ( ( [ key ] ) => isHotkey ( `mod+ ${ key } ` , event ) ) || [ ] ;
50
49
51
- if ( mark ) {
52
- event . preventDefault ( ) ;
53
- return change . toggleMark ( mark ) ;
54
- }
50
+ if ( markName ) {
51
+ event . preventDefault ( ) ;
52
+ return change . toggleMark ( markName ) ;
55
53
}
56
54
} ;
You can’t perform that action at this time.
0 commit comments