mirror of
https://github.com/zadam/trilium.git
synced 2025-12-21 06:44:24 +01:00
feat(breadcrumb): relocate copy note path to empty area
This commit is contained in:
parent
d28c3f0851
commit
7e07280eb3
@ -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) {
|
parentComponent?.triggerCommand(command, {
|
||||||
case "copyNotePathToClipboard":
|
noteId,
|
||||||
copyTextWithToast(`#${notePath}`);
|
notePath,
|
||||||
break;
|
selectedOrActiveBranchIds: [ branchId ],
|
||||||
case "recentChangesInSubtree":
|
selectedOrActiveNoteIds: [ noteId ]
|
||||||
parentComponent?.triggerCommand("showRecentChanges", { ancestorNoteId: noteId });
|
});
|
||||||
break;
|
|
||||||
default:
|
|
||||||
parentComponent?.triggerCommand(command, {
|
|
||||||
noteId,
|
|
||||||
notePath,
|
|
||||||
selectedOrActiveBranchIds: [ branchId ],
|
|
||||||
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,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user