diff --git a/client/src/components/Messages/Content/Mermaid.tsx b/client/src/components/Messages/Content/Mermaid.tsx index 33e88d4353..2e81f6c1d4 100644 --- a/client/src/components/Messages/Content/Mermaid.tsx +++ b/client/src/components/Messages/Content/Mermaid.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useMemo, useState, useRef, useCallback, memo } from 'react'; import copy from 'copy-to-clipboard'; import { + X, ZoomIn, Expand, ZoomOut, @@ -15,6 +16,7 @@ import { OGDialog, Clipboard, CheckMark, + OGDialogClose, OGDialogTitle, OGDialogContent, } from '@librechat/client'; @@ -149,11 +151,19 @@ const Mermaid: React.FC = memo(({ children, id, theme }) => { }, 3000); }, [children]); + const [isDialogCopied, setIsDialogCopied] = useState(false); const handleDialogCopy = useCallback(() => { copy(children.trim(), { format: 'text/plain' }); + setIsDialogCopied(true); requestAnimationFrame(() => { dialogCopyButtonRef.current?.focus(); }); + setTimeout(() => { + setIsDialogCopied(false); + requestAnimationFrame(() => { + dialogCopyButtonRef.current?.focus(); + }); + }, 3000); }, [children]); // Zoom controls copy with focus restoration @@ -345,7 +355,7 @@ const Mermaid: React.FC = memo(({ children, id, theme }) => { ref={showCodeButtonRef} variant="ghost" size="sm" - className="h-auto gap-1 rounded-sm px-1 py-0 text-xs text-gray-200 hover:bg-gray-600 hover:text-white focus-visible:ring-white focus-visible:ring-offset-0" + className="h-auto min-w-[6rem] gap-1 rounded-sm px-1 py-0 text-xs text-gray-200 hover:bg-gray-600 hover:text-white focus-visible:ring-white focus-visible:ring-offset-0" onClick={handleToggleCode} > {showCode ? : } @@ -358,17 +368,8 @@ const Mermaid: React.FC = memo(({ children, id, theme }) => { className="h-auto gap-1 rounded-sm px-1 py-0 text-xs text-gray-200 hover:bg-gray-600 hover:text-white focus-visible:ring-white focus-visible:ring-offset-0" onClick={handleCopy} > - {isCopied ? ( - <> - - {localize('com_ui_copied')} - - ) : ( - <> - - {localize('com_ui_copy_code')} - - )} + {isCopied ? : } + {localize('com_ui_copy_code')} )} @@ -496,15 +497,18 @@ const Mermaid: React.FC = memo(({ children, id, theme }) => { // Full-screen dialog - rendered inline, not as function component to avoid recreation const expandedDialog = ( - - + + {localize('com_ui_mermaid')}
+ + + {localize('com_ui_close')} +
{dialogShowCode && (