mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-15 11:09:01 +08:00
prevent blur event in menus, fix #353
This commit is contained in:
parent
134c4c0132
commit
2189151903
@ -14,6 +14,9 @@ class Menu {
|
|||||||
this.isActive = false
|
this.isActive = false
|
||||||
this.top = 0
|
this.top = 0
|
||||||
|
|
||||||
|
// the mousedown event is fired before blur so we can prevent it
|
||||||
|
this.options.element.addEventListener('mousedown', this.handleClick)
|
||||||
|
|
||||||
this.options.editor.on('focus', ({ view }) => {
|
this.options.editor.on('focus', ({ view }) => {
|
||||||
this.update(view)
|
this.update(view)
|
||||||
})
|
})
|
||||||
@ -22,6 +25,10 @@ class Menu {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleClick(event) {
|
||||||
|
event.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
update(view, lastState) {
|
update(view, lastState) {
|
||||||
const { state } = view
|
const { state } = view
|
||||||
|
|
||||||
@ -72,6 +79,10 @@ class Menu {
|
|||||||
this.sendUpdate()
|
this.sendUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destroy() {
|
||||||
|
this.options.element.removeEventListener('mousedown', this.handleClick)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function (options) {
|
export default function (options) {
|
||||||
|
@ -67,6 +67,9 @@ class Menu {
|
|||||||
this.left = 0
|
this.left = 0
|
||||||
this.bottom = 0
|
this.bottom = 0
|
||||||
|
|
||||||
|
// the mousedown event is fired before blur so we can prevent it
|
||||||
|
this.options.element.addEventListener('mousedown', this.handleClick)
|
||||||
|
|
||||||
this.options.editor.on('focus', ({ view }) => {
|
this.options.editor.on('focus', ({ view }) => {
|
||||||
this.update(view)
|
this.update(view)
|
||||||
})
|
})
|
||||||
@ -75,6 +78,10 @@ class Menu {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleClick(event) {
|
||||||
|
event.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
update(view, lastState) {
|
update(view, lastState) {
|
||||||
const { state } = view
|
const { state } = view
|
||||||
|
|
||||||
@ -132,6 +139,10 @@ class Menu {
|
|||||||
this.sendUpdate()
|
this.sendUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destroy() {
|
||||||
|
this.options.element.removeEventListener('mousedown', this.handleClick)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function (options) {
|
export default function (options) {
|
||||||
|
Loading…
Reference in New Issue
Block a user