mirror of
https://github.com/zadam/trilium.git
synced 2025-12-20 22:34:23 +01:00
feat(breadcrumb): add clone to/move to options
This commit is contained in:
parent
51fcda646d
commit
e91cb1a198
@ -160,12 +160,23 @@ function BreadcrumbItem({ index, notePath, noteContext, notePathLength }: { inde
|
|||||||
onContextMenu={async (e) => {
|
onContextMenu={async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const noteId = notePath.split("/").at(-1);
|
const notePathComponents = notePath.split("/");
|
||||||
if (!noteId) return;
|
const parentNoteId = notePathComponents.at(-2);
|
||||||
|
const noteId = notePathComponents.at(-1);
|
||||||
|
if (!parentNoteId || !noteId) return;
|
||||||
|
|
||||||
|
const branchId = await froca.getBranchId(parentNoteId, noteId);
|
||||||
|
if (!branchId) return;
|
||||||
|
const branch = froca.getBranch(branchId);
|
||||||
|
|
||||||
const note = await froca.getNote(noteId);
|
const note = await froca.getNote(noteId);
|
||||||
if (!note) return;
|
if (!note) return;
|
||||||
|
|
||||||
const notSearch = note?.type !== "search";
|
const notSearch = note?.type !== "search";
|
||||||
|
const isNotRoot = note?.noteId !== "root";
|
||||||
|
const isHoisted = note?.noteId === appContext.tabManager.getActiveContext()?.hoistedNoteId;
|
||||||
|
const parentNote = isNotRoot && branch ? await froca.getNote(branch.parentNoteId) : null;
|
||||||
|
const parentNotSearch = !parentNote || parentNote.type !== "search";
|
||||||
|
|
||||||
contextMenu.show({
|
contextMenu.show({
|
||||||
items: [
|
items: [
|
||||||
@ -177,6 +188,21 @@ function BreadcrumbItem({ index, notePath, noteContext, notePathLength }: { inde
|
|||||||
uiIcon: "bx bxs-chevrons-up",
|
uiIcon: "bx bxs-chevrons-up",
|
||||||
enabled: notSearch
|
enabled: notSearch
|
||||||
},
|
},
|
||||||
|
{ kind: "separator" },
|
||||||
|
{
|
||||||
|
title: t("tree-context-menu.move-to"),
|
||||||
|
command: "moveNotesTo",
|
||||||
|
keyboardShortcut: "moveNotesTo",
|
||||||
|
uiIcon: "bx bx-transfer",
|
||||||
|
enabled: isNotRoot && !isHoisted && parentNotSearch
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t("tree-context-menu.clone-to"),
|
||||||
|
command: "cloneNotesTo",
|
||||||
|
keyboardShortcut: "cloneNotesTo",
|
||||||
|
uiIcon: "bx bx-duplicate",
|
||||||
|
enabled: isNotRoot && !isHoisted
|
||||||
|
},
|
||||||
],
|
],
|
||||||
x: e.pageX,
|
x: e.pageX,
|
||||||
y: e.pageY,
|
y: e.pageY,
|
||||||
@ -187,7 +213,9 @@ function BreadcrumbItem({ index, notePath, noteContext, notePathLength }: { inde
|
|||||||
|
|
||||||
if (command) {
|
if (command) {
|
||||||
parentComponent?.triggerCommand(command, {
|
parentComponent?.triggerCommand(command, {
|
||||||
noteId
|
noteId,
|
||||||
|
selectedOrActiveBranchIds: [ branchId ],
|
||||||
|
selectedOrActiveNoteIds: [ noteId ]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user