diff --git a/surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/RowActions.tsx b/surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/RowActions.tsx index a8b85e20b..5b7451c61 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/RowActions.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/RowActions.tsx @@ -24,7 +24,7 @@ import { } from "@/components/ui/dropdown-menu"; import type { Document } from "./types"; -const EDITABLE_DOCUMENT_TYPES = ["NOTE"] as const; +const EDITABLE_DOCUMENT_TYPES = ["FILE", "NOTE"] as const; // SURFSENSE_DOCS are system-managed and cannot be deleted const NON_DELETABLE_DOCUMENT_TYPES = ["SURFSENSE_DOCS"] as const; diff --git a/surfsense_web/components/documents/DocumentNode.tsx b/surfsense_web/components/documents/DocumentNode.tsx index a562703e8..79cf2233b 100644 --- a/surfsense_web/components/documents/DocumentNode.tsx +++ b/surfsense_web/components/documents/DocumentNode.tsx @@ -40,6 +40,8 @@ import type { DocumentTypeEnum } from "@/contracts/types/document.types"; import { cn } from "@/lib/utils"; import { DND_TYPES } from "./FolderNode"; +const EDITABLE_DOCUMENT_TYPES = new Set(["FILE", "NOTE"]); + export interface DocumentNodeDoc { id: number; title: string; @@ -78,7 +80,9 @@ export const DocumentNode = React.memo(function DocumentNode({ const statusState = doc.status?.state ?? "ready"; const isSelectable = statusState !== "pending" && statusState !== "processing"; const isEditable = - doc.document_type === "NOTE" && statusState !== "pending" && statusState !== "processing"; + EDITABLE_DOCUMENT_TYPES.has(doc.document_type) && + statusState !== "pending" && + statusState !== "processing"; const handleCheckChange = useCallback(() => { if (isSelectable) { diff --git a/surfsense_web/components/editor-panel/editor-panel.tsx b/surfsense_web/components/editor-panel/editor-panel.tsx index f2f66eb48..aff1367b0 100644 --- a/surfsense_web/components/editor-panel/editor-panel.tsx +++ b/surfsense_web/components/editor-panel/editor-panel.tsx @@ -5,6 +5,7 @@ import { AlertCircle, XIcon } from "lucide-react"; import { useCallback, useEffect, useRef, useState } from "react"; import { toast } from "sonner"; import { closeEditorPanelAtom, editorPanelAtom } from "@/atoms/editor/editor-panel.atom"; +import { MarkdownViewer } from "@/components/markdown-viewer"; import { PlateEditor } from "@/components/editor/plate-editor"; import { Button } from "@/components/ui/button"; import { Drawer, DrawerContent, DrawerHandle, DrawerTitle } from "@/components/ui/drawer"; @@ -18,6 +19,8 @@ interface EditorContent { source_markdown: string; } +const EDITABLE_DOCUMENT_TYPES = new Set(["FILE", "NOTE"]); + function EditorPanelSkeleton() { return (
@@ -165,12 +168,16 @@ export function EditorPanelContent({ } }, [documentId, searchSpaceId]); + const isEditableType = editorDoc + ? EDITABLE_DOCUMENT_TYPES.has(editorDoc.document_type ?? "") + : false; + return ( <>

{displayTitle}

- {editedMarkdown !== null && ( + {isEditableType && editedMarkdown !== null && (

Unsaved changes

)}
@@ -193,7 +200,7 @@ export function EditorPanelContent({

{error || "An unknown error occurred"}

- ) : ( + ) : isEditableType ? ( + ) : ( +
+ +
)} diff --git a/surfsense_web/components/layout/ui/tabs/DocumentTabContent.tsx b/surfsense_web/components/layout/ui/tabs/DocumentTabContent.tsx index 7cec16bfa..ac279cd4d 100644 --- a/surfsense_web/components/layout/ui/tabs/DocumentTabContent.tsx +++ b/surfsense_web/components/layout/ui/tabs/DocumentTabContent.tsx @@ -41,6 +41,8 @@ interface DocumentTabContentProps { title?: string; } +const EDITABLE_DOCUMENT_TYPES = new Set(["FILE", "NOTE"]); + export function DocumentTabContent({ documentId, searchSpaceId, title }: DocumentTabContentProps) { const [doc, setDoc] = useState(null); const [isLoading, setIsLoading] = useState(true); @@ -171,6 +173,8 @@ export function DocumentTabContent({ documentId, searchSpaceId, title }: Documen ); } + const isEditable = EDITABLE_DOCUMENT_TYPES.has(doc.document_type ?? ""); + if (isEditing) { return (
@@ -218,7 +222,7 @@ export function DocumentTabContent({ documentId, searchSpaceId, title }: Documen

{doc.title || title || "Untitled"}

- {doc.document_type === "NOTE" && ( + {isEditable && (