From b147c8e5df75bdeafb1f0eeb2e6ce08e0dec7e37 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sat, 5 Oct 2024 18:16:19 +0000 Subject: feature: Persevere the source URL of clipped texts from the extension. Fixes #448 --- packages/shared-react/utils/bookmarkUtils.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'packages/shared-react/utils') diff --git a/packages/shared-react/utils/bookmarkUtils.ts b/packages/shared-react/utils/bookmarkUtils.ts index e7322712..0a089f64 100644 --- a/packages/shared-react/utils/bookmarkUtils.ts +++ b/packages/shared-react/utils/bookmarkUtils.ts @@ -38,3 +38,16 @@ export function isBookmarkStillTagging(bookmark: ZBookmark) { export function isBookmarkStillLoading(bookmark: ZBookmark) { return isBookmarkStillTagging(bookmark) || isBookmarkStillCrawling(bookmark); } + +export function getSourceUrl(bookmark: ZBookmark) { + if (bookmark.content.type === BookmarkTypes.LINK) { + return bookmark.content.url; + } + if (bookmark.content.type === BookmarkTypes.ASSET) { + return bookmark.content.sourceUrl ?? null; + } + if (bookmark.content.type === BookmarkTypes.TEXT) { + return bookmark.content.sourceUrl ?? null; + } + return null; +} -- cgit v1.2.3-70-g09d2