fix: super editor popover menus (#2041)
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user