| 58 | * @returns {{left:number, top:number}} |
| 59 | */ |
| 60 | export function clampMenuPosition(menuRect, containerRect) { |
| 61 | const maxLeft = Math.max( |
| 62 | containerRect.left + MENU_MARGIN, |
| 63 | containerRect.left + containerRect.width - menuRect.width - MENU_MARGIN, |
| 64 | ); |
| 65 | const maxTop = Math.max( |
| 66 | containerRect.top + MENU_MARGIN, |
| 67 | containerRect.top + containerRect.height - menuRect.height - MENU_MARGIN, |
| 68 | ); |
| 69 | |
| 70 | return { |
| 71 | left: clamp(menuRect.left, containerRect.left + MENU_MARGIN, maxLeft), |
| 72 | top: clamp(menuRect.top, containerRect.top + MENU_MARGIN, maxTop), |
| 73 | }; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Filter menu items using Ace-compatible rules. |