substance
Version:
Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing system. It is developed to power our online editing platform [Substance](http://substance.io).
13 lines (12 loc) • 433 B
JavaScript
export default function isMouseInsideDOMSelection (event) {
const wsel = window.getSelection()
if (wsel.rangeCount === 0) {
return false
}
const wrange = wsel.getRangeAt(0)
const selectionRect = wrange.getBoundingClientRect()
return event.clientX >= selectionRect.left &&
event.clientX <= selectionRect.right &&
event.clientY >= selectionRect.top &&
event.clientY <= selectionRect.bottom
}