hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB2c19dffBurak Boduroğlu2 months ago566 commits
| 1 | import { Show } from "solid-js"; |
| 2 | import type { Note } from "@/api/client"; |
| 3 | import type { NoteFileSource } from "@/lib/note-source"; |
| 4 | import { NoteFilesPanel } from "@/components/notes/note-files-panel"; |
| 5 | import { RagOutputsPanel } from "@/components/notes/rag-outputs-panel"; |
| 6 | import { SidePanel } from "@/components/ui/side-panel"; |
| 7 | import { toRichTextHtml } from "@/lib/rich-text"; |
| 8 | import { useT } from "@/stores/preferences-context"; |
| 9 | |
| 10 | export function NoteReaderPanel(props: { |
| 11 | note: Note | null; |
| 12 | source: NoteFileSource; |
| 13 | /** Read-only file section when false. Defaults to true. */ |
| 14 | canManage?: boolean; |
| 15 | open: boolean; |
| 16 | onOpenChange: (open: boolean) => void; |
| 17 | }) { |
| 18 | const t = useT(); |
| 19 | const note = () => props.note; |
| 20 | |
| 21 | return ( |
| 22 | <SidePanel |
| 23 | open={props.open && note() != null} |
| 24 | onOpenChange={props.onOpenChange} |
| 25 | title={note()?.title ?? t("notes.title")} |
| 26 | size="wide" |
| 27 | > |
| 28 | <Show when={note()}> |
| 29 | {(n) => ( |
| 30 | <div class="space-y-4"> |
| 31 | <article class="rounded-xl border border-border bg-card px-5 py-5 shadow-xs sm:px-7"> |
| 32 | <Show |
| 33 | when={note()?.content?.trim()} |
| 34 | fallback={<p class="text-sm italic text-muted-foreground">{t("notes.noContent")}</p>} |
| 35 | > |
| 36 | <div class="note-prose" innerHTML={toRichTextHtml(note()?.content)} /> |
| 37 | </Show> |
| 38 | </article> |
| 39 | <NoteFilesPanel noteId={n().id} source={props.source} canManage={props.canManage} active={props.open} /> |
| 40 | <Show when={props.source.listRagOutputs}> |
| 41 | <RagOutputsPanel noteId={n().id} source={props.source} canManage={props.canManage} active={props.open} /> |
| 42 | </Show> |
| 43 | </div> |
| 44 | )} |
| 45 | </Show> |
| 46 | </SidePanel> |
| 47 | ); |
| 48 | } |