diff --git a/apps/web/src/components/files/FilePreviewPanel.tsx b/apps/web/src/components/files/FilePreviewPanel.tsx index c69cb6167e458..13a74c131eea3 100644 --- a/apps/web/src/components/files/FilePreviewPanel.tsx +++ b/apps/web/src/components/files/FilePreviewPanel.tsx @@ -1428,6 +1428,25 @@ export default function FilePreviewPanel({ !renderMermaid && !(isMarkdown && renderMarkdown) && !(tableDelimiter && renderTable); + const copyableContents = + previewPath !== null && + !isMedia && + !isDocument && + !isPdf && + file.data && + !file.data.truncated && + file.data.contents.length > 0 + ? file.data.contents + : null; + const { copyToClipboard, isCopied } = useCopyToClipboard({ + target: namedClipboardTarget(previewPath ?? ""), + onError: (error) => + toastManager.add({ + type: "error", + title: gt("Could not copy file"), + description: error.message, + }), + }); const contentFocusRef = useRef(null); const fileEditorRef = useRef(null); const focusEditorFromContent = () => { @@ -1652,6 +1671,14 @@ export default function FilePreviewPanel({ ) : null} + {copyableContents !== null ? ( + copyToClipboard(copyableContents, undefined)} + > + {isCopied ? : } + + ) : null} {canOpenInBrowser ? (