@@ -232,6 +232,11 @@ class MarkdownUnorderedListButtonElement extends MarkdownButtonElement {
232
232
super ( )
233
233
styles . set ( this , { prefix : '- ' , multiline : true , surroundWithNewlines : true } )
234
234
}
235
+ connectedCallback ( ) {
236
+ super . connectedCallback ( )
237
+ this . setAttribute ( 'hotkey' , '8' )
238
+ this . setAttribute ( 'hotkey-requires-shift' , 'true' )
239
+ }
235
240
}
236
241
237
242
if ( ! window . customElements . get ( 'md-unordered-list' ) ) {
@@ -387,10 +392,13 @@ function focusKeydown(event: KeyboardEvent) {
387
392
}
388
393
389
394
const shortcutListeners = new WeakMap ( )
395
+ function elementHotkeyRequiresShift ( element : Element ) : boolean {
396
+ return element . hasAttribute ( 'hotkey-requires-shift' ) && element . getAttribute ( 'hotkey-requires-shift' ) !== 'false'
397
+ }
390
398
391
- function findHotkey ( toolbar : Element , key : string ) : HTMLElement | null {
399
+ function findHotkey ( toolbar : Element , key : string , shiftPressed : boolean ) : HTMLElement | null {
392
400
for ( const el of toolbar . querySelectorAll < HTMLElement > ( '[hotkey]' ) ) {
393
- if ( el . getAttribute ( 'hotkey' ) === key ) {
401
+ if ( el . getAttribute ( 'hotkey' ) === key && ( ! elementHotkeyRequiresShift ( el ) || shiftPressed ) ) {
394
402
return el
395
403
}
396
404
}
@@ -400,7 +408,7 @@ function findHotkey(toolbar: Element, key: string): HTMLElement | null {
400
408
function shortcut ( toolbar : Element , event : KeyboardEvent ) {
401
409
if ( ( event . metaKey && modifierKey === 'Meta' ) || ( event . ctrlKey && modifierKey === 'Control' ) ) {
402
410
const key = event . shiftKey ? event . key . toUpperCase ( ) : event . key
403
- const button = findHotkey ( toolbar , key )
411
+ const button = findHotkey ( toolbar , key , event . shiftKey )
404
412
if ( button ) {
405
413
button . click ( )
406
414
event . preventDefault ( )
0 commit comments