fix: hide bubble menu on drag, fix #1443
This commit is contained in:
@@ -34,6 +34,7 @@ export class BubbleMenuView {
|
|||||||
this.element = element
|
this.element = element
|
||||||
this.view = view
|
this.view = view
|
||||||
this.element.addEventListener('mousedown', this.mousedownHandler, { capture: true })
|
this.element.addEventListener('mousedown', this.mousedownHandler, { capture: true })
|
||||||
|
this.view.dom.addEventListener('dragstart', this.dragstartHandler)
|
||||||
this.editor.on('focus', this.focusHandler)
|
this.editor.on('focus', this.focusHandler)
|
||||||
this.editor.on('blur', this.blurHandler)
|
this.editor.on('blur', this.blurHandler)
|
||||||
this.createTooltip(tippyOptions)
|
this.createTooltip(tippyOptions)
|
||||||
@@ -44,6 +45,10 @@ export class BubbleMenuView {
|
|||||||
this.preventHide = true
|
this.preventHide = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dragstartHandler = () => {
|
||||||
|
this.hide()
|
||||||
|
}
|
||||||
|
|
||||||
focusHandler = () => {
|
focusHandler = () => {
|
||||||
// we use `setTimeout` to make sure `selection` is already updated
|
// we use `setTimeout` to make sure `selection` is already updated
|
||||||
setTimeout(() => this.update(this.editor.view))
|
setTimeout(() => this.update(this.editor.view))
|
||||||
@@ -131,6 +136,7 @@ export class BubbleMenuView {
|
|||||||
destroy() {
|
destroy() {
|
||||||
this.tippy.destroy()
|
this.tippy.destroy()
|
||||||
this.element.removeEventListener('mousedown', this.mousedownHandler)
|
this.element.removeEventListener('mousedown', this.mousedownHandler)
|
||||||
|
this.view.dom.removeEventListener('dragstart', this.dragstartHandler)
|
||||||
this.editor.off('focus', this.focusHandler)
|
this.editor.off('focus', this.focusHandler)
|
||||||
this.editor.off('blur', this.blurHandler)
|
this.editor.off('blur', this.blurHandler)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user