mirror of
https://github.com/docmost/docmost.git
synced 2026-05-20 08:34:04 +08:00
fix menu positioning
This commit is contained in:
@@ -52,16 +52,34 @@ const EditorAiMenu = ({ editor }: EditorAiMenuProps): JSX.Element | null => {
|
|||||||
if (!editor || !showAiMenu) return;
|
if (!editor || !showAiMenu) return;
|
||||||
|
|
||||||
const { view } = editor;
|
const { view } = editor;
|
||||||
const { to } = editor.state.selection;
|
const { from, to } = editor.state.selection;
|
||||||
const editorRect = view.dom.getBoundingClientRect();
|
const editorRect = view.dom.getBoundingClientRect();
|
||||||
const cursorCoords = view.coordsAtPos(to);
|
const fromCoords = view.coordsAtPos(from);
|
||||||
|
const toCoords = view.coordsAtPos(to);
|
||||||
const topOffset = 8;
|
const topOffset = 8;
|
||||||
const editorPadding = isSmBreakpoint ? 16 : 48;
|
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({
|
setMenuPlacement({
|
||||||
top: cursorCoords.bottom + topOffset + window.scrollY,
|
top: anchorBottom + topOffset + window.scrollY,
|
||||||
left: editorRect.left + editorPadding + window.scrollX,
|
left: menuLeft + window.scrollX,
|
||||||
width: editorRect.width - editorPadding * 2,
|
width: menuWidth,
|
||||||
});
|
});
|
||||||
}, [editor, showAiMenu, isSmBreakpoint]);
|
}, [editor, showAiMenu, isSmBreakpoint]);
|
||||||
const resetMenu = useCallback(() => {
|
const resetMenu = useCallback(() => {
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ import { IconCheck } from "@tabler/icons-react";
|
|||||||
|
|
||||||
const enterpriseFeatures = [
|
const enterpriseFeatures = [
|
||||||
"SSO (SAML, OIDC, LDAP)",
|
"SSO (SAML, OIDC, LDAP)",
|
||||||
"Multi-factor Authentication",
|
"AI Integration (Search & Assistant)",
|
||||||
"Page-level Permissions",
|
"Page-level Permissions",
|
||||||
"Audit Logs",
|
"Audit Logs",
|
||||||
"API Keys",
|
"API Keys",
|
||||||
"AI Integration",
|
|
||||||
"MCP Support",
|
"MCP Support",
|
||||||
|
"Multi-factor Authentication (2FA)",
|
||||||
|
"Enterprise Controls",
|
||||||
"Advanced Search Engine Support",
|
"Advanced Search Engine Support",
|
||||||
"Full-text Search in Attachments (PDF, DOCX)",
|
"Full-text Search in Attachments (PDF, DOCX)",
|
||||||
"Resolve Comments",
|
"Resolve Comments",
|
||||||
@@ -67,8 +68,7 @@ export default function OssDetails() {
|
|||||||
</List>
|
</List>
|
||||||
|
|
||||||
<Text size="sm" c="dimmed">
|
<Text size="sm" c="dimmed">
|
||||||
Contact <a href="mailto:sales@docmost.com">sales@docmost.com </a> for
|
Contact <a href="mailto:sales@docmost.com?subject=Enterprise%20License%20Inquiry">sales@docmost.com </a> to purchase an enterprise license.
|
||||||
enquiries.
|
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
Reference in New Issue
Block a user