@@ -9,13 +9,13 @@ function keydown(fn: KeyboardEventHandler): KeyboardEventHandler {
9
9
}
10
10
if ( key === 'ArrowRight' || key === 'ArrowLeft' || key === 'Home' || key === 'End' ) {
11
11
const target = event . currentTarget
12
- if ( ! ( target instanceof MarkdownButtonElement ) ) return
12
+ if ( ! ( target instanceof HTMLElement ) ) return
13
+ if ( ! target . hasAttribute ( 'data-md-button' ) ) return
13
14
const toolbar = target . closest ( 'markdown-toolbar' )
14
15
if ( ! ( toolbar instanceof MarkdownToolbarElement ) ) return
15
16
16
17
const buttons = [ ]
17
- for ( const button of toolbar . children ) {
18
- if ( ! ( button instanceof MarkdownButtonElement ) ) continue
18
+ for ( const button of toolbar . querySelectorAll ( '[data-md-button]' ) ) {
19
19
button . setAttribute ( 'tabindex' , '-1' )
20
20
buttons . push ( button )
21
21
}
@@ -54,6 +54,7 @@ class MarkdownButtonElement extends HTMLElement {
54
54
if ( ! this . hasAttribute ( 'role' ) ) {
55
55
this . setAttribute ( 'role' , 'button' )
56
56
}
57
+ this . setAttribute ( 'data-md-button' , '' )
57
58
}
58
59
59
60
click ( ) {
@@ -252,7 +253,7 @@ class MarkdownToolbarElement extends HTMLElement {
252
253
this . field . addEventListener ( 'keydown' , fn )
253
254
shortcutListeners . set ( this , fn )
254
255
}
255
- const firstTabIndex = document . querySelector ( '[role=" button"][tabindex ]' )
256
+ const firstTabIndex = document . querySelector ( '[data-md- button]' )
256
257
if ( firstTabIndex ) firstTabIndex . setAttribute ( 'tabindex' , '0' )
257
258
}
258
259
0 commit comments