Skip to content

Commit 432d70d

Browse files
authored
Merge pull request #74 from github/event_prevent_deafult_apply
Move preventDefault into apply functions
2 parents ce94934 + d933491 commit 432d70d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: src/index.ts

+3-2
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)