fix(bubble-menu): prevent null pointer exception in BubbleMenu (#5842)

This commit is contained in:
Felix Gabler 2024-11-19 03:27:06 +01:00 committed by GitHub
parent 2ea807d1db
commit 1959eb5920
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 7 deletions

View File

@ -0,0 +1,5 @@
---
"@tiptap/extension-bubble-menu": patch
---
Fix a potential null pointer exception

View File

@ -266,14 +266,16 @@ export class BubbleMenuView {
if (isNodeSelection(state.selection)) {
let node = view.nodeDOM(from) as HTMLElement
const nodeViewWrapper = node.dataset.nodeViewWrapper ? node : node.querySelector('[data-node-view-wrapper]')
if (nodeViewWrapper) {
node = nodeViewWrapper.firstChild as HTMLElement
}
if (node) {
return node.getBoundingClientRect()
const nodeViewWrapper = node.dataset.nodeViewWrapper ? node : node.querySelector('[data-node-view-wrapper]')
if (nodeViewWrapper) {
node = nodeViewWrapper.firstChild as HTMLElement
}
if (node) {
return node.getBoundingClientRect()
}
}
}