How can I set the caret position (text cursor) to the nearest possible position based on an x and y coordinate? The whole html document has document.designMode = "on"
set.
I found something to get the current X and Y coordinate, but how can I reverse the scenario?
let sel = window.getSelection();
let range = sel.getRangeAt(0);
console.log(range.getClientRects());
I'm looking for vanilla javascript that has to work in Microsoft WebView2/Edge. When dragging files onto this html document the caret position is changed exactly as I'm looking for (but I cannot use this drag operation).