Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions apps/web/src/components/files/FilePreviewPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLDivElement>(null);
const fileEditorRef = useRef<FileEditor | null>(null);
const focusEditorFromContent = () => {
Expand Down Expand Up @@ -1652,6 +1671,14 @@ export default function FilePreviewPanel({
<WrapTextIcon className="size-3.5" />
</FileSurfaceAction>
) : null}
{copyableContents !== null ? (
<FileSurfaceAction
label={isCopied ? gt("Copied") : gt("Copy contents")}
onPress={() => copyToClipboard(copyableContents, undefined)}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
>
{isCopied ? <CheckIcon className="size-3.5" /> : <CopyIcon className="size-3.5" />}
</FileSurfaceAction>
) : null}
{canOpenInBrowser ? (
<FileSurfaceAction
label={gt("Open file in preview browser")}
Expand Down
Loading