mirror of
https://github.com/zadam/trilium.git
synced 2025-12-06 15:34:26 +01:00
feat(gallery): add gallery note type and update related translations and widget functionality
This commit is contained in:
parent
b872c2953e
commit
6512d03c11
@ -18,7 +18,8 @@ export const byNoteType: Record<Exclude<NoteType, "book">, string | null> = {
|
|||||||
search: null,
|
search: null,
|
||||||
text: null,
|
text: null,
|
||||||
webView: null,
|
webView: null,
|
||||||
aiChat: null
|
aiChat: null,
|
||||||
|
gallery: null
|
||||||
};
|
};
|
||||||
|
|
||||||
export const byBookType: Record<ViewTypeOptions, string | null> = {
|
export const byBookType: Record<ViewTypeOptions, string | null> = {
|
||||||
|
|||||||
@ -2140,6 +2140,9 @@
|
|||||||
"select_image": "Select Image",
|
"select_image": "Select Image",
|
||||||
"show_child_images_btn": "Show Child Images",
|
"show_child_images_btn": "Show Child Images",
|
||||||
"hide_child_images_btn": "Hide 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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import { t } from "../../services/i18n";
|
|||||||
import dialog from "../../services/dialog";
|
import dialog from "../../services/dialog";
|
||||||
import server from "../../services/server";
|
import server from "../../services/server";
|
||||||
import toast from "../../services/toast";
|
import toast from "../../services/toast";
|
||||||
|
import froca from "../../services/froca";
|
||||||
import appContext from "../../components/app_context";
|
import appContext from "../../components/app_context";
|
||||||
import { formatSize } from "../../services/utils";
|
import { formatSize } from "../../services/utils";
|
||||||
import branches from "../../services/branches";
|
import branches from "../../services/branches";
|
||||||
@ -176,11 +177,6 @@ export default function Gallery({ note }: TypeWidgetProps) {
|
|||||||
|
|
||||||
async function handleToggleShare() {
|
async function handleToggleShare() {
|
||||||
if (isGalleryShared) {
|
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");
|
const shareBranch = note.getParentBranches().find((b) => b.parentNoteId === "_share");
|
||||||
if (shareBranch?.branchId) {
|
if (shareBranch?.branchId) {
|
||||||
await server.remove(`branches/${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) {
|
async function handleCopyImageLink(img: ImageItem, e: MouseEvent) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
@ -208,14 +205,12 @@ export default function Gallery({ note }: TypeWidgetProps) {
|
|||||||
let imageUrl: string;
|
let imageUrl: string;
|
||||||
|
|
||||||
if (img.type === 'note') {
|
if (img.type === 'note') {
|
||||||
// For image notes, get their share URL
|
const imageNote = froca.getNoteFromCache(img.id);
|
||||||
const imageNote = note.froca.getNoteFromCache(img.id);
|
|
||||||
if (!imageNote) return;
|
if (!imageNote) return;
|
||||||
|
|
||||||
const shareId = imageNote.getOwnedLabelValue("shareAlias") || img.id;
|
const shareId = imageNote.getOwnedLabelValue("shareAlias") || img.id;
|
||||||
imageUrl = getAbsoluteUrl(`/share/api/images/${shareId}/${encodeURIComponent(img.title)}`);
|
imageUrl = getAbsoluteUrl(`/share/api/images/${shareId}/${encodeURIComponent(img.title)}`);
|
||||||
} else {
|
} else {
|
||||||
// For attachments, use the attachment API
|
|
||||||
imageUrl = getAbsoluteUrl(`/share/api/attachments/${img.id}/image/${encodeURIComponent(img.title)}`);
|
imageUrl = getAbsoluteUrl(`/share/api/attachments/${img.id}/image/${encodeURIComponent(img.title)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,8 @@ const noteTypes = [
|
|||||||
{ type: "doc", defaultMime: "" },
|
{ type: "doc", defaultMime: "" },
|
||||||
{ type: "contentWidget", defaultMime: "" },
|
{ type: "contentWidget", defaultMime: "" },
|
||||||
{ type: "mindMap", defaultMime: "application/json" },
|
{ type: "mindMap", defaultMime: "application/json" },
|
||||||
{ type: "aiChat", defaultMime: "application/json" }
|
{ type: "aiChat", defaultMime: "application/json" },
|
||||||
|
{ type: "gallery", defaultMime: "" }
|
||||||
];
|
];
|
||||||
|
|
||||||
function getDefaultMimeForNoteType(typeName: string) {
|
function getDefaultMimeForNoteType(typeName: string) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user