Files
kandev/apps/web/components/task/file-editor-content.tsx
T
Corey Fogg d4742089fc feat(web): add manual file upload and download to the Files panel (#3292)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Carlos Florencio <carlosmflorencio@gmail.com>
2026-09-03 08:07:13 +00:00

58 lines
1.7 KiB
TypeScript

"use client";
import { memo } from "react";
import { useEditorProvider } from "@/hooks/use-editor-resolver";
import { MonacoCodeEditor } from "@/components/editors/monaco/monaco-code-editor";
import { CodeMirrorCodeEditor } from "@/components/editors/codemirror/codemirror-code-editor";
import { MarkdownPreviewContent } from "./markdown-preview-content";
export type FileEditorContentProps = {
path: string;
content: string;
originalContent: string;
isDirty: boolean;
hasRemoteUpdate?: boolean;
vcsDiff?: string;
isSaving: boolean;
sessionId?: string;
taskId?: string | null;
repositoryId?: string | null;
worktreePath?: string;
repo?: string;
enableComments?: boolean;
markdownPreview?: boolean;
onToggleMarkdownPreview?: () => void;
onChange: (newContent: string) => void;
onSave: () => void;
onReloadFromAgent?: () => void;
onDelete?: () => void;
onDownload?: () => void;
};
export const FileEditorContent = memo(function FileEditorContent(props: FileEditorContentProps) {
const provider = useEditorProvider("code-editor");
if (props.markdownPreview && props.onToggleMarkdownPreview) {
return (
<MarkdownPreviewContent
path={props.path}
content={props.content}
worktreePath={props.worktreePath}
sessionId={props.sessionId}
taskId={props.taskId}
repositoryId={props.repositoryId}
repositoryName={props.repo}
enableComments={props.enableComments}
onDownload={props.onDownload}
onTogglePreview={props.onToggleMarkdownPreview}
/>
);
}
return provider === "monaco" ? (
<MonacoCodeEditor {...props} />
) : (
<CodeMirrorCodeEditor {...props} />
);
});