update menus on resize

This commit is contained in:
Philipp Kühn
2021-04-01 16:22:02 +02:00
parent c68fa74ad1
commit e25e1ddd27
2 changed files with 16 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ export class BubbleMenuView {
this.element.addEventListener('mousedown', this.mousedownHandler, { capture: true })
this.editor.on('focus', this.focusHandler)
this.editor.on('blur', this.blurHandler)
this.editor.on('resize', this.resizeHandler)
this.render()
}
@@ -57,6 +58,12 @@ export class BubbleMenuView {
setTimeout(() => this.update(this.editor.view))
}
resizeHandler = () => {
if (this.isActive) {
this.update(this.editor.view)
}
}
blurHandler = ({ event }: { event: FocusEvent }) => {
if (this.preventHide) {
this.preventHide = false
@@ -137,6 +144,7 @@ export class BubbleMenuView {
this.element.removeEventListener('mousedown', this.mousedownHandler)
this.editor.off('focus', this.focusHandler)
this.editor.off('blur', this.blurHandler)
this.editor.off('resize', this.resizeHandler)
}
}