mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-09-17 10:45:24 +00:00
* ✨ feat: Add Download button for code blocks Adds a Download button next to Copy code in both the code block header bar and the floating bar, saving the block content as a file whose extension is inferred from the fenced-block language hint. - getCodeBlockFilename() maps language names to extensions (python → code.py), passes extension-like hints through unchanged (tsx → code.tsx), and falls back to code.txt; reuses the existing triggerDownload() util for the blob download and URL revocation. - useDownloadCode mirrors useCopyCode (focus restore, 3s reset timer). - DownloadButton mirrors CopyButton (icon animation, tooltip in icon-only mode, aria-label reflecting current state). Fixes #13470 * Address review: alias extensions + hide floating download on error - Map alphanumeric language aliases (python3, nodejs, node, golang) to their real extension so they download as code.py/.js/.go instead of code.python3 etc. — the bare-hint fallback previously passed them through verbatim. - Gate the floating-bar Download button behind error !== true, matching CodeBar, so error blocks (e.g. token-balance JSON) don't expose a download action once the header scrolls out of view. * style: show only Run Code with a label in the code block header Download and Copy code now render as icon-only buttons with tooltips, so the header reads as one labelled action plus two secondary icons. Below the md breakpoint Run Code drops its label too, leaving all three as icons on mobile. * refactor: extract the shared code bar action button CopyButton and DownloadButton were identical apart from the icon and their default labels. Both now wrap a single ActionButton that owns the class recipe, the icon swap, the label swap and the icon-only tooltip, so the two cannot drift apart as the bar evolves. The public props of both components are unchanged. * fix: keep the Run Code tooltip when its label is hidden Below the md breakpoint Run Code renders as a bare terminal icon, so it needs the same hover description Download and Copy already carry. The button is now always wrapped in the tooltip anchor rather than only in the explicit iconOnly mode. * docs: drop the em dash from the extension map comment --------- Co-authored-by: Marco Beretta <81851188+berry-13@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| public | ||
| scripts | ||
| src | ||
| sw | ||
| test | ||
| babel.config.cjs | ||
| check_updates.sh | ||
| index.html | ||
| jest.config.cjs | ||
| jest.resolver.cjs | ||
| nginx.conf | ||
| package.json | ||
| postcss.config.cjs | ||
| tailwind.config.cjs | ||
| tsconfig.json | ||
| vite.config.ts | ||