How to convert the selectionRect
of the context-menu
params to a Range?
https://www.electronjs.org/docs/latest/api/web-contents#event-context-menu
https://developer.mozilla.org/en-US/docs/Web/API/Range
I've found this explanation: How to create a Range Object from a point (X and Y Coordinates)?
https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint
but with:
let range: Range = document.caretRangeFromPoint(selectionRect.x, selectionRect.y)
console.log("App_S-range: ", range)
I get :
selectionRect{
"x": 675,
"y": 205,
"width": 69,
"height": 92
}
App_S-range:
Range
collapsed: true
commonAncestorContainer: div.ant-space.css-dev-only-do-not-override-diro6f.ant-space-
horizontal.ant-space-align-center
endContainer: div.ant-space.css-dev-only-do-not-override-diro6f.ant-space-
horizontal.ant-space-align-center
endOffset: 0
startContainer: div.ant-space.css-dev-only-do-not-override-diro6f.ant-space-
horizontal.ant-space-align-center
startOffset: 0
And it shouldn't be collapsed