refactoring: rename posToClientRect to posToDOMRect
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { EditorView } from 'prosemirror-view'
|
||||
import coordsAtPos from './coordsAtPos'
|
||||
|
||||
export default function posToClientRect(view: EditorView, from: number, to: number): ClientRect {
|
||||
export default function posToDOMRect(view: EditorView, from: number, to: number): DOMRect {
|
||||
const start = coordsAtPos(view, from)
|
||||
const end = coordsAtPos(view, to, true)
|
||||
const top = Math.min(start.top, end.top)
|
||||
@@ -10,13 +10,21 @@ export default function posToClientRect(view: EditorView, from: number, to: numb
|
||||
const right = Math.max(start.right, end.right)
|
||||
const width = right - left
|
||||
const height = bottom - top
|
||||
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
const x = left
|
||||
const y = top
|
||||
const data = {
|
||||
top,
|
||||
bottom,
|
||||
left,
|
||||
right,
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y,
|
||||
}
|
||||
|
||||
return {
|
||||
...data,
|
||||
toJSON: () => data,
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ export { default as isNodeActive } from './helpers/isNodeActive'
|
||||
export { default as isNodeEmpty } from './helpers/isNodeEmpty'
|
||||
export { default as isNodeSelection } from './helpers/isNodeSelection'
|
||||
export { default as isTextSelection } from './helpers/isTextSelection'
|
||||
export { default as posToClientRect } from './helpers/posToClientRect'
|
||||
export { default as posToDOMRect } from './helpers/posToDOMRect'
|
||||
|
||||
export interface Commands {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user