Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dom.computeCaretRect();
// $ExpectType boolean
dom.documentHasSelection();
// $ExpectType Element[]
dom.focus.focusable.find(element);
// $ExpectType Element[]
dom.focus.tabbable.find(element);
// $ExpectType boolean
dom.focus.tabbable.isTabbableIndex(element);
// $ExpectType Element | null
dom.getOffsetParent(node);
// $ExpectType DOMRect
dom.getRectangleFromRange(range);
// $ExpectType Element | undefined
dom.getScrollContainer(element);
// $ExpectType void
dom.insertAfter(node, node);
// $ExpectType boolean
dom.isEntirelySelected(element);
// $ExpectType boolean
dom.isHorizontalEdge(element, true);
function getCurrentCaretPositionStyle() {
const selection = window.getSelection();
// Unlikely, but in the case there is no selection, return empty styles so
// as to avoid a thrown error by `Selection#getRangeAt` on invalid index.
if ( selection.rangeCount === 0 ) {
return {};
}
// Get position relative viewport.
const rect = getRectangleFromRange( selection.getRangeAt( 0 ) );
let top = rect.top + rect.height;
let left = rect.left + ( rect.width / 2 );
// Offset by positioned parent, if one exists.
const offsetParent = getOffsetParent( selection.anchorNode );
if ( offsetParent ) {
const parentRect = offsetParent.getBoundingClientRect();
top -= parentRect.top;
left -= parentRect.left;
}
return { top, left };
}