Skip to content

Commit d933491

Browse files
committed
Move preventDefault into apply functions
1 parent ce94934 commit d933491

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ function getButtons(toolbar: Element): HTMLElement[] {
6262
function keydown(fn: (event: KeyboardEvent) => void): (event: KeyboardEvent) => void {
6363
return function (event: KeyboardEvent) {
6464
if (event.key === ' ' || event.key === 'Enter') {
65-
event.preventDefault()
6665
fn(event)
6766
}
6867
}
@@ -121,9 +120,10 @@ const manualStyles = {
121120
class MarkdownButtonElement extends HTMLElement {
122121
constructor() {
123122
super()
124-
const apply = () => {
123+
const apply = (event: Event) => {
125124
const style = styles.get(this)
126125
if (!style) return
126+
event.preventDefault()
127127
applyStyle(this, style)
128128
}
129129
this.addEventListener('keydown', keydown(apply))
@@ -316,6 +316,7 @@ function applyFromToolbar(event: Event) {
316316
const mdButtonStyle = target.getAttribute('data-md-button')
317317
const style = manualStyles[mdButtonStyle as keyof typeof manualStyles]
318318
if (!style) return
319+
event.preventDefault()
319320
applyStyle(target, style)
320321
}
321322

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy