mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-08-06 13:38:49 +08:00
fix: check for NodeSelection within posToDOMRect
This commit is contained in:
parent
9e83413967
commit
a4ec4ffcfd
@ -1,7 +1,16 @@
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user