feat(breadcrumb): relocate copy note path to empty area

This commit is contained in:
Elian Doran 2025-12-16 16:14:08 +02:00
parent d28c3f0851
commit 7e07280eb3
No known key found for this signature in database

View File

@ -35,7 +35,7 @@ const INITIAL_ITEMS = 2;
const FINAL_ITEMS = 2; const FINAL_ITEMS = 2;
export default function Breadcrumb() { export default function Breadcrumb() {
const { note, notePaths, noteContext } = useNotePaths(); const { note, notePath, notePaths, noteContext } = useNotePaths();
const parentComponent = useContext(ParentComponent); const parentComponent = useContext(ParentComponent);
const [ hideArchivedNotes ] = useTriliumOptionBool("hideArchivedNotes_main"); const [ hideArchivedNotes ] = useTriliumOptionBool("hideArchivedNotes_main");
const separatorProps: Omit<BreadcrumbSeparatorProps, "notePath" | "activeNotePath"> = { noteContext, hideArchivedNotes }; const separatorProps: Omit<BreadcrumbSeparatorProps, "notePath" | "activeNotePath"> = { noteContext, hideArchivedNotes };
@ -73,7 +73,7 @@ export default function Breadcrumb() {
<div <div
className="filler" className="filler"
onContextMenu={buildEmptyAreaContextMenu(parentComponent)} onContextMenu={buildEmptyAreaContextMenu(parentComponent, notePath)}
/> />
</div> </div>
); );
@ -291,6 +291,7 @@ function useNotePaths() {
return { return {
note, note,
notePath,
notePaths: output, notePaths: output,
noteContext noteContext
}; };
@ -342,9 +343,6 @@ function buildContextMenu(notePath: string, parentComponent: Component | null) {
enabled: isNotRoot && !isHoisted enabled: isNotRoot && !isHoisted
}, },
{ kind: "separator" }, { kind: "separator" },
{ title: t("tree-context-menu.copy-note-path-to-clipboard"), command: "copyNotePathToClipboard", uiIcon: "bx bx-directions", enabled: true },
{ title: t("tree-context-menu.recent-changes-in-subtree"), command: "recentChangesInSubtree", uiIcon: "bx bx-history", enabled: notOptionsOrHelp },
{ kind: "separator" },
{ {
title: t("tree-context-menu.duplicate"), title: t("tree-context-menu.duplicate"),
command: "duplicateSubtree", command: "duplicateSubtree",
@ -379,6 +377,12 @@ function buildContextMenu(notePath: string, parentComponent: Component | null) {
} }
} : null), } : null),
{ kind: "separator" }, { kind: "separator" },
{
title: t("tree-context-menu.recent-changes-in-subtree"),
uiIcon: "bx bx-history",
enabled: notOptionsOrHelp,
handler: () => parentComponent?.triggerCommand("showRecentChanges", { ancestorNoteId: noteId })
},
{ {
title: t("tree-context-menu.search-in-subtree"), title: t("tree-context-menu.search-in-subtree"),
command: "searchInSubtree", command: "searchInSubtree",
@ -397,21 +401,12 @@ function buildContextMenu(notePath: string, parentComponent: Component | null) {
} }
if (!command) return; if (!command) return;
switch (command) {
case "copyNotePathToClipboard":
copyTextWithToast(`#${notePath}`);
break;
case "recentChangesInSubtree":
parentComponent?.triggerCommand("showRecentChanges", { ancestorNoteId: noteId });
break;
default:
parentComponent?.triggerCommand(command, { parentComponent?.triggerCommand(command, {
noteId, noteId,
notePath, notePath,
selectedOrActiveBranchIds: [ branchId ], selectedOrActiveBranchIds: [ branchId ],
selectedOrActiveNoteIds: [ noteId ] selectedOrActiveNoteIds: [ noteId ]
}); });
}
}, },
}); });
}; };
@ -419,7 +414,7 @@ function buildContextMenu(notePath: string, parentComponent: Component | null) {
//#endregion //#endregion
//#region Empty context menu //#region Empty context menu
function buildEmptyAreaContextMenu(parentComponent: Component | null) { function buildEmptyAreaContextMenu(parentComponent: Component | null, notePath: string | null | undefined) {
return (e: MouseEvent) => { return (e: MouseEvent) => {
const hideArchivedNotes = (options.get("hideArchivedNotes_main") === "true"); const hideArchivedNotes = (options.get("hideArchivedNotes_main") === "true");
@ -435,7 +430,14 @@ function buildEmptyAreaContextMenu(parentComponent: Component | null) {
parentComponent?.triggerEvent("frocaReloaded", {}); parentComponent?.triggerEvent("frocaReloaded", {});
}, },
checked: hideArchivedNotes checked: hideArchivedNotes
} },
{ kind: "separator" },
{
title: t("tree-context-menu.copy-note-path-to-clipboard"),
command: "copyNotePathToClipboard",
uiIcon: "bx bx-directions",
handler: () => copyTextWithToast(`#${notePath}`)
},
], ],
x: e.pageX, x: e.pageX,
y: e.pageY, y: e.pageY,