From a4d5be3a3a031c039568b5cb4e7e2305f8e4f283 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 13 Apr 2025 14:04:39 +0000 Subject: feat: Allow editing the extracted content of an asset bookmark --- .../dashboard/bookmarks/EditBookmarkDialog.tsx | 35 ++++++++++++++++++---- apps/web/lib/i18n/locales/en/translation.json | 3 +- 2 files changed, 32 insertions(+), 6 deletions(-) (limited to 'apps') 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({ @@ -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 ( @@ -215,6 +218,28 @@ export function EditBookmarkDialog({ /> )} + {isAsset && ( + ( + + + {t("bookmark_editor.extracted_content")} + + +