fix: super editor popover menus (#2041)

This commit is contained in:
Aman Harwara
2022-11-22 19:16:59 +05:30
committed by GitHub
parent b3140f1623
commit 8c8f045b9a
12 changed files with 75 additions and 50 deletions

View File

@@ -8,6 +8,17 @@ export const OppositeSide: Record<PopoverSide, PopoverSide> = {
right: 'left',
}
export const getOverflows = (popoverRect: DOMRect, documentRect: DOMRect): Record<PopoverSide, number> => {
const overflows = {
top: documentRect.top - popoverRect.top,
bottom: popoverRect.height - (documentRect.bottom - popoverRect.top),
left: documentRect.left - popoverRect.left,
right: popoverRect.right - documentRect.right,
}
return overflows
}
export const checkCollisions = (popoverRect: DOMRect, containerRect: DOMRect): RectCollisions => {
const appRect = getAppRect(containerRect)

View File

@@ -49,15 +49,6 @@ export const getPopoverMaxHeight = (
return appRect.height - constraint - MarginFromAppBorderInPX
}
export const getMaxHeightAdjustedRect = (rect: DOMRect, maxHeight: number) => {
return DOMRect.fromRect({
width: rect.width,
height: rect.height < maxHeight ? rect.height : maxHeight,
x: rect.x,
y: rect.y,
})
}
export const getAppRect = (updatedDocumentRect?: DOMRect) => {
const footerRect = document.querySelector('footer')?.getBoundingClientRect()
const documentRect = updatedDocumentRect ? updatedDocumentRect : document.documentElement.getBoundingClientRect()