diff options
| author | MohamedBassem <me@mbassem.com> | 2024-04-19 20:01:51 +0100 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2024-04-20 00:05:31 +0100 |
| commit | 4402e6f04170cbb0613d35fe94471162253e91b2 (patch) | |
| tree | 696f6511cefa7d1c6bc3a1f8bc2de755870310cc /apps/web/components/dashboard/preview/TextContentSection.tsx | |
| parent | b4a13ce3d92ee505124fc98804935c1122978550 (diff) | |
| download | karakeep-4402e6f04170cbb0613d35fe94471162253e91b2.tar.zst | |
feature: Download images and screenshots
Diffstat (limited to 'apps/web/components/dashboard/preview/TextContentSection.tsx')
| -rw-r--r-- | apps/web/components/dashboard/preview/TextContentSection.tsx | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/apps/web/components/dashboard/preview/TextContentSection.tsx b/apps/web/components/dashboard/preview/TextContentSection.tsx index a73ad722..eba7d28b 100644 --- a/apps/web/components/dashboard/preview/TextContentSection.tsx +++ b/apps/web/components/dashboard/preview/TextContentSection.tsx @@ -4,36 +4,14 @@ import Markdown from "react-markdown"; import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; export function TextContentSection({ bookmark }: { bookmark: ZBookmark }) { - let content; - switch (bookmark.content.type) { - case "link": { - if (!bookmark.content.htmlContent) { - content = ( - <div className="text-destructive"> - Failed to fetch link content ... - </div> - ); - } else { - content = ( - <div - dangerouslySetInnerHTML={{ - __html: bookmark.content.htmlContent || "", - }} - className="prose mx-auto dark:prose-invert" - /> - ); - } - break; - } - case "text": { - content = ( - <Markdown className="prose mx-auto dark:prose-invert"> - {bookmark.content.text} - </Markdown> - ); - break; - } + if (bookmark.content.type != "text") { + throw new Error("Invalid content type"); } - - return <ScrollArea className="h-full">{content}</ScrollArea>; + return ( + <ScrollArea className="h-full"> + <Markdown className="prose mx-auto dark:prose-invert"> + {bookmark.content.text} + </Markdown> + </ScrollArea> + ); } |
