prevent error in bubble menu, fix #386

This commit is contained in:
Philipp Kühn 2019-07-19 23:46:44 +02:00
parent 81d4333bec
commit 3fee68b692
2 changed files with 16 additions and 2 deletions

View File

@ -66,7 +66,14 @@ class Menu {
return
}
const editorBoundings = this.options.element.offsetParent.getBoundingClientRect()
const parent = this.options.element.offsetParent
if (!parent) {
this.hide()
return
}
const editorBoundings = parent.getBoundingClientRect()
const cursorBoundings = view.coordsAtPos(state.selection.anchor)
const top = cursorBoundings.top - editorBoundings.top

View File

@ -111,7 +111,14 @@ class Menu {
const end = coordsAtPos(view, to, true)
// The box in which the tooltip is positioned, to use as base
const box = this.options.element.offsetParent.getBoundingClientRect()
const parent = this.options.element.offsetParent
if (!parent) {
this.hide()
return
}
const box = parent.getBoundingClientRect()
const el = this.options.element.getBoundingClientRect()
// Find a center-ish x position from the selection endpoints (when