From 6512d03c117a66ad5fa9ba5d7ad3101bfcf096e2 Mon Sep 17 00:00:00 2001 From: lzinga Date: Fri, 28 Nov 2025 14:23:29 -0800 Subject: [PATCH] feat(gallery): add gallery note type and update related translations and widget functionality --- apps/client/src/services/in_app_help.ts | 3 ++- apps/client/src/translations/en/translation.json | 5 ++++- apps/client/src/widgets/type_widgets/Gallery.tsx | 11 +++-------- apps/server/src/services/note_types.ts | 3 ++- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/client/src/services/in_app_help.ts b/apps/client/src/services/in_app_help.ts index 2f805783a..06e8352b1 100644 --- a/apps/client/src/services/in_app_help.ts +++ b/apps/client/src/services/in_app_help.ts @@ -18,7 +18,8 @@ export const byNoteType: Record, string | null> = { search: null, text: null, webView: null, - aiChat: null + aiChat: null, + gallery: null }; export const byBookType: Record = { diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index faaa48530..7ea66d3f7 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -2140,6 +2140,9 @@ "select_image": "Select Image", "show_child_images_btn": "Show Child Images", "hide_child_images_btn": "Hide Child Images", - "toggle_child_images_tooltip": "Toggle Child Images" + "toggle_child_images_tooltip": "Toggle Child Images", + "not_shared": "The gallery is not shared", + "shared_success": "The gallery is now being shared", + "unshared_success": "The gallery has stopped being shared" } } diff --git a/apps/client/src/widgets/type_widgets/Gallery.tsx b/apps/client/src/widgets/type_widgets/Gallery.tsx index 143780637..9faf42347 100644 --- a/apps/client/src/widgets/type_widgets/Gallery.tsx +++ b/apps/client/src/widgets/type_widgets/Gallery.tsx @@ -9,6 +9,7 @@ import { t } from "../../services/i18n"; import dialog from "../../services/dialog"; import server from "../../services/server"; import toast from "../../services/toast"; +import froca from "../../services/froca"; import appContext from "../../components/app_context"; import { formatSize } from "../../services/utils"; import branches from "../../services/branches"; @@ -176,11 +177,6 @@ export default function Gallery({ note }: TypeWidgetProps) { async function handleToggleShare() { if (isGalleryShared) { - // Unshare the gallery - if (note.getParentBranches().length === 1 && !(await dialog.confirm(t("gallery.confirm_unshare_only_location")))) { - return; - } - const shareBranch = note.getParentBranches().find((b) => b.parentNoteId === "_share"); if (shareBranch?.branchId) { await server.remove(`branches/${shareBranch.branchId}`); @@ -197,6 +193,7 @@ export default function Gallery({ note }: TypeWidgetProps) { } } + // Your current handleCopyImageLink is actually fine for both Electron and web async function handleCopyImageLink(img: ImageItem, e: MouseEvent) { e.stopPropagation(); @@ -208,14 +205,12 @@ export default function Gallery({ note }: TypeWidgetProps) { let imageUrl: string; if (img.type === 'note') { - // For image notes, get their share URL - const imageNote = note.froca.getNoteFromCache(img.id); + const imageNote = froca.getNoteFromCache(img.id); if (!imageNote) return; const shareId = imageNote.getOwnedLabelValue("shareAlias") || img.id; imageUrl = getAbsoluteUrl(`/share/api/images/${shareId}/${encodeURIComponent(img.title)}`); } else { - // For attachments, use the attachment API imageUrl = getAbsoluteUrl(`/share/api/attachments/${img.id}/image/${encodeURIComponent(img.title)}`); } diff --git a/apps/server/src/services/note_types.ts b/apps/server/src/services/note_types.ts index 2aa86d0b6..2a998a1e8 100644 --- a/apps/server/src/services/note_types.ts +++ b/apps/server/src/services/note_types.ts @@ -15,7 +15,8 @@ const noteTypes = [ { type: "doc", defaultMime: "" }, { type: "contentWidget", defaultMime: "" }, { type: "mindMap", defaultMime: "application/json" }, - { type: "aiChat", defaultMime: "application/json" } + { type: "aiChat", defaultMime: "application/json" }, + { type: "gallery", defaultMime: "" } ]; function getDefaultMimeForNoteType(typeName: string) {