fix menu positioning

This commit is contained in:
Philipinho
2026-03-03 18:28:55 +00:00
parent f5d794220e
commit f12bfc1ff7
2 changed files with 27 additions and 9 deletions
@@ -52,16 +52,34 @@ const EditorAiMenu = ({ editor }: EditorAiMenuProps): JSX.Element | null => {
if (!editor || !showAiMenu) return;
const { view } = editor;
const { to } = editor.state.selection;
const { from, to } = editor.state.selection;
const editorRect = view.dom.getBoundingClientRect();
const cursorCoords = view.coordsAtPos(to);
const fromCoords = view.coordsAtPos(from);
const toCoords = view.coordsAtPos(to);
const topOffset = 8;
const editorPadding = isSmBreakpoint ? 16 : 48;
const anchorBottom =
toCoords.bottom > 0 && toCoords.bottom < window.innerHeight
? toCoords.bottom
: fromCoords.bottom;
const menuMaxWidth = 600;
const editorLeft = editorRect.left + editorPadding;
const editorRight = editorRect.right - editorPadding;
const availableWidth = editorRight - editorLeft;
const menuWidth = Math.min(menuMaxWidth, availableWidth);
let menuLeft = Math.max(editorLeft, fromCoords.left);
if (menuLeft + menuWidth > editorRight) {
menuLeft = editorRight - menuWidth;
}
menuLeft = Math.max(editorLeft, menuLeft);
setMenuPlacement({
top: cursorCoords.bottom + topOffset + window.scrollY,
left: editorRect.left + editorPadding + window.scrollX,
width: editorRect.width - editorPadding * 2,
top: anchorBottom + topOffset + window.scrollY,
left: menuLeft + window.scrollX,
width: menuWidth,
});
}, [editor, showAiMenu, isSmBreakpoint]);
const resetMenu = useCallback(() => {
@@ -3,12 +3,13 @@ import { IconCheck } from "@tabler/icons-react";
const enterpriseFeatures = [
"SSO (SAML, OIDC, LDAP)",
"Multi-factor Authentication",
"AI Integration (Search & Assistant)",
"Page-level Permissions",
"Audit Logs",
"API Keys",
"AI Integration",
"MCP Support",
"Multi-factor Authentication (2FA)",
"Enterprise Controls",
"Advanced Search Engine Support",
"Full-text Search in Attachments (PDF, DOCX)",
"Resolve Comments",
@@ -67,8 +68,7 @@ export default function OssDetails() {
</List>
<Text size="sm" c="dimmed">
Contact <a href="mailto:sales@docmost.com">sales@docmost.com </a> for
enquiries.
Contact <a href="mailto:sales@docmost.com?subject=Enterprise%20License%20Inquiry">sales@docmost.com </a> to purchase an enterprise license.
</Text>
</Stack>
</Stack>