From df98144a243c570d310e0573cd8aaf208010b461 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Wed, 22 Jul 2026 01:55:27 +0530 Subject: [PATCH] refactor: remove downloading functionality from EditorPanelContent for cleaner code --- .../components/editor-panel/editor-panel.tsx | 59 ------------------- 1 file changed, 59 deletions(-) diff --git a/surfsense_web/components/editor-panel/editor-panel.tsx b/surfsense_web/components/editor-panel/editor-panel.tsx index 4f2f598d8..54b964a41 100644 --- a/surfsense_web/components/editor-panel/editor-panel.tsx +++ b/surfsense_web/components/editor-panel/editor-panel.tsx @@ -4,7 +4,6 @@ import { useAtomValue, useSetAtom } from "jotai"; import { Check, Copy, - Download, FileQuestionMark, FileText, Pencil, @@ -163,7 +162,6 @@ export function EditorPanelContent({ const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); const [saving, setSaving] = useState(false); - const [downloading, setDownloading] = useState(false); const [isEditing, setIsEditing] = useState(false); const [memoryLimits, setMemoryLimits] = useState(null); @@ -514,62 +512,6 @@ export function EditorPanelContent({ setIsEditing(false); }, [editorDoc?.source_markdown]); - const handleDownloadMarkdown = useCallback(async () => { - if (!workspaceId || !documentId) return; - setDownloading(true); - try { - const response = await authenticatedFetch( - buildBackendUrl( - `/api/v1/workspaces/${workspaceId}/documents/${documentId}/download-markdown` - ), - { method: "GET" } - ); - if (!response.ok) throw new Error("Download failed"); - const blob = await response.blob(); - const url = URL.createObjectURL(blob); - const a = document.createElement("a"); - a.href = url; - const disposition = response.headers.get("content-disposition"); - const match = disposition?.match(/filename="(.+)"/); - a.download = match?.[1] ?? `${editorDoc?.title || "document"}.md`; - document.body.appendChild(a); - a.click(); - a.remove(); - URL.revokeObjectURL(url); - toast.success("Download started"); - } catch { - toast.error("Failed to download document"); - } finally { - setDownloading(false); - } - }, [documentId, editorDoc?.title, workspaceId]); - - const largeDocAlert = viewerMode === "monaco" && !isLocalFileMode && editorDoc && ( - - - - - This document is too large for the editor ( - {formatBytes(editorDoc.content_size_bytes ?? 0)}, {docLineCount.toLocaleString()} lines,{" "} - {editorDoc.chunk_count ?? 0} chunks). Showing raw markdown below. - - - - - ); - return ( <> {showDesktopHeader ? ( @@ -807,7 +749,6 @@ export function EditorPanelContent({ ) : viewerMode === "monaco" && !isLocalFileMode ? ( // Large doc — raw markdown in Monaco. Rich renderers are intentionally skipped.
- {largeDocAlert}