mirror of
https://github.com/zadam/trilium.git
synced 2025-12-04 22:44:25 +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,
|
||||
text: null,
|
||||
webView: null,
|
||||
aiChat: null
|
||||
aiChat: null,
|
||||
gallery: null
|
||||
};
|
||||
|
||||
export const byBookType: Record<ViewTypeOptions, string | null> = {
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)}`);
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user