mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-08-06 13:38:49 +08:00
fix: do not check for node selection within posToDOMRect
This commit is contained in:
parent
3bb99b8e1e
commit
c0e68d5a25
@ -1,16 +1,7 @@
|
||||
import isNodeSelection from './isNodeSelection'
|
||||
import { EditorView } from 'prosemirror-view'
|
||||
import coordsAtPos from './coordsAtPos'
|
||||
|
||||
export default function posToDOMRect(view: EditorView, from: number, to: number): DOMRect {
|
||||
if (isNodeSelection(view.state.selection)) {
|
||||
const node = view.nodeDOM(from) as HTMLElement
|
||||
|
||||
if (node && node.getBoundingClientRect) {
|
||||
return node.getBoundingClientRect()
|
||||
}
|
||||
}
|
||||
|
||||
const start = coordsAtPos(view, from)
|
||||
const end = coordsAtPos(view, to, true)
|
||||
const top = Math.min(start.top, end.top)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Editor, posToDOMRect } from '@tiptap/core'
|
||||
import { Editor, posToDOMRect, isNodeSelection } from '@tiptap/core'
|
||||
import { EditorState, Plugin, PluginKey } from 'prosemirror-state'
|
||||
import { EditorView } from 'prosemirror-view'
|
||||
import tippy, { Instance, Props } from 'tippy.js'
|
||||
@ -104,7 +104,17 @@ export class BubbleMenuView {
|
||||
}
|
||||
|
||||
this.tippy.setProps({
|
||||
getReferenceClientRect: () => posToDOMRect(view, from, to),
|
||||
getReferenceClientRect: () => {
|
||||
if (isNodeSelection(view.state.selection)) {
|
||||
const node = view.nodeDOM(from) as HTMLElement
|
||||
|
||||
if (node) {
|
||||
return node.getBoundingClientRect()
|
||||
}
|
||||
}
|
||||
|
||||
return posToDOMRect(view, from, to)
|
||||
},
|
||||
})
|
||||
|
||||
this.show()
|
||||
|
Loading…
Reference in New Issue
Block a user