From 3207264fc13c275d6dcfbd2628cc6b3974ceeaed Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Mon, 7 Apr 2025 01:03:26 +0100 Subject: feat: Allow editing bookmark details --- packages/shared-react/utils/bookmarkUtils.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'packages/shared-react') diff --git a/packages/shared-react/utils/bookmarkUtils.ts b/packages/shared-react/utils/bookmarkUtils.ts index 0a089f64..fc0fd97d 100644 --- a/packages/shared-react/utils/bookmarkUtils.ts +++ b/packages/shared-react/utils/bookmarkUtils.ts @@ -51,3 +51,20 @@ export function getSourceUrl(bookmark: ZBookmark) { } return null; } + +export function getBookmarkTitle(bookmark: ZBookmark) { + let title: string | null = null; + switch (bookmark.content.type) { + case BookmarkTypes.LINK: + title = bookmark.content.title ?? bookmark.content.url; + break; + case BookmarkTypes.TEXT: + title = null; + break; + case BookmarkTypes.ASSET: + title = bookmark.content.fileName ?? null; + break; + } + + return bookmark.title ? bookmark.title : title; +} -- cgit v1.2.3-70-g09d2