diff options
| author | Mohamed Bassem <me@mbassem.com> | 2025-04-13 14:04:39 +0000 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2025-04-13 14:04:39 +0000 |
| commit | a4d5be3a3a031c039568b5cb4e7e2305f8e4f283 (patch) | |
| tree | c2721be51d72ea12cbe01efeee6d429de963f932 /apps/web/components/dashboard/bookmarks/EditBookmarkDialog.tsx | |
| parent | 8c6cfc8f5fdab4bbdae41060518c08731720976a (diff) | |
| download | karakeep-a4d5be3a3a031c039568b5cb4e7e2305f8e4f283.tar.zst | |
feat: Allow editing the extracted content of an asset bookmark
Diffstat (limited to 'apps/web/components/dashboard/bookmarks/EditBookmarkDialog.tsx')
| -rw-r--r-- | apps/web/components/dashboard/bookmarks/EditBookmarkDialog.tsx | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/apps/web/components/dashboard/bookmarks/EditBookmarkDialog.tsx b/apps/web/components/dashboard/bookmarks/EditBookmarkDialog.tsx index c7745acd..ab5d0364 100644 --- a/apps/web/components/dashboard/bookmarks/EditBookmarkDialog.tsx +++ b/apps/web/components/dashboard/bookmarks/EditBookmarkDialog.tsx @@ -35,6 +35,7 @@ import { CalendarIcon } from "lucide-react"; import { useForm } from "react-hook-form"; import { useUpdateBookmark } from "@karakeep/shared-react/hooks/bookmarks"; +import { getBookmarkTitle } from "@karakeep/shared-react/utils/bookmarkUtils"; import { BookmarkTypes, ZBookmark, @@ -61,11 +62,7 @@ export function EditBookmarkDialog({ const bookmarkToDefault = (bookmark: ZBookmark) => ({ bookmarkId: bookmark.id, summary: bookmark.summary, - title: bookmark.title - ? bookmark.title - : bookmark.content.type === BookmarkTypes.LINK - ? bookmark.content.title - : undefined, + title: getBookmarkTitle(bookmark), createdAt: bookmark.createdAt ?? new Date(), // Link specific defaults (only if bookmark is a link) url: @@ -88,6 +85,11 @@ export function EditBookmarkDialog({ bookmark.content.type === BookmarkTypes.LINK ? bookmark.content.datePublished : undefined, + // Asset specific fields + assetContent: + bookmark.content.type === BookmarkTypes.ASSET + ? bookmark.content.content + : undefined, }); const form = useForm<ZUpdateBookmarksRequest>({ @@ -130,6 +132,7 @@ export function EditBookmarkDialog({ }, [bookmark, form, open]); const isLink = bookmark.content.type === BookmarkTypes.LINK; + const isAsset = bookmark.content.type === BookmarkTypes.ASSET; return ( <Dialog open={open} onOpenChange={setOpen}> @@ -215,6 +218,28 @@ export function EditBookmarkDialog({ /> )} + {isAsset && ( + <FormField + control={form.control} + name="assetContent" + render={({ field }) => ( + <FormItem> + <FormLabel> + {t("bookmark_editor.extracted_content")} + </FormLabel> + <FormControl> + <Textarea + placeholder="Extracted Content" + {...field} + value={field.value ?? ""} + /> + </FormControl> + <FormMessage /> + </FormItem> + )} + /> + )} + {isLink && ( <div className="grid grid-cols-1 gap-4 md:grid-cols-2"> <FormField |
