@@ -34,14 +34,14 @@ describe('markdown-toolbar-element', function () {
34
34
textarea . dispatchEvent ( event )
35
35
}
36
36
37
- function pressHotkey ( hotkey ) {
37
+ function pressHotkey ( hotkey , explicitShiftKey = false ) {
38
38
const textarea = document . querySelector ( 'textarea' )
39
39
const osx = navigator . userAgent . indexOf ( 'Macintosh' ) !== - 1
40
40
const event = document . createEvent ( 'Event' )
41
41
event . initEvent ( 'keydown' , true , true )
42
42
event . metaKey = osx
43
43
event . ctrlKey = ! osx
44
- event . shiftKey = hotkey === hotkey . toUpperCase ( )
44
+ event . shiftKey = ( hotkey === hotkey . toUpperCase ( ) && hotkey !== hotkey . toLowerCase ( ) ) || explicitShiftKey
45
45
46
46
// emulate existing osx browser bug
47
47
// https://bugs.webkit.org/show_bug.cgi?id=174782
@@ -556,6 +556,22 @@ describe('markdown-toolbar-element', function () {
556
556
assert . equal ( 'One\n\n|- Two\n- Three|\n' , visualValue ( ) )
557
557
} )
558
558
559
+ it ( 'turns multiple lines into unordered list via hotkey, requiring shift' , function ( ) {
560
+ setVisualValue ( 'One\n|Two\nThree|\n' )
561
+ pressHotkey ( '8' , false )
562
+ assert . equal ( 'One\n|Two\nThree|\n' , visualValue ( ) )
563
+ pressHotkey ( '8' , true )
564
+ assert . equal ( 'One\n\n|- Two\n- Three|\n' , visualValue ( ) )
565
+ } )
566
+
567
+ it ( 'turns multiple lines into ordered list via hotkey, requiring shift' , function ( ) {
568
+ setVisualValue ( 'One\n|Two\nThree|\n' )
569
+ pressHotkey ( '9' , false )
570
+ assert . equal ( 'One\n|Two\nThree|\n' , visualValue ( ) )
571
+ pressHotkey ( '9' , true )
572
+ assert . equal ( 'One\n\n|1. Two\n2. Three|\n' , visualValue ( ) )
573
+ } )
574
+
559
575
it ( 'prefixes newlines when a list is created on the last line' , function ( ) {
560
576
setVisualValue ( "Here's a list:|One|" )
561
577
clickToolbar ( 'md-unordered-list' )
0 commit comments