mirror of
https://github.com/zadam/trilium.git
synced 2025-12-21 06:44:24 +01:00
feat(breadcrumb): color selector
This commit is contained in:
parent
d1575a28ad
commit
d1820a6bc3
@ -16,7 +16,7 @@ function openContextMenu(notePath: string, e: ContextMenuEvent, viewScope: ViewS
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getItems(e: ContextMenuEvent | LeafletMouseEvent): MenuItem<CommandNames>[] {
|
function getItems(e: ContextMenuEvent | LeafletMouseEvent): MenuItem<"openNoteInNewTab" | "openNoteInNewSplit" | "openNoteInNewWindow" | "openNoteInPopup">[] {
|
||||||
const ntxId = getNtxId(e);
|
const ntxId = getNtxId(e);
|
||||||
const isMobileSplitOpen = isMobile() && appContext.tabManager.getNoteContextById(ntxId).getMainContext().getSubContexts().length > 1;
|
const isMobileSplitOpen = isMobile() && appContext.tabManager.getNoteContextById(ntxId).getMainContext().getSubContexts().length > 1;
|
||||||
|
|
||||||
@ -59,9 +59,9 @@ function getNtxId(e: ContextMenuEvent | LeafletMouseEvent) {
|
|||||||
return subContexts[subContexts.length - 1].ntxId;
|
return subContexts[subContexts.length - 1].ntxId;
|
||||||
} else if (e.target instanceof HTMLElement) {
|
} else if (e.target instanceof HTMLElement) {
|
||||||
return getClosestNtxId(e.target);
|
return getClosestNtxId(e.target);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@ -3,11 +3,13 @@ import "./Breadcrumb.css";
|
|||||||
import { useContext, useRef, useState } from "preact/hooks";
|
import { useContext, useRef, useState } from "preact/hooks";
|
||||||
import { Fragment } from "preact/jsx-runtime";
|
import { Fragment } from "preact/jsx-runtime";
|
||||||
|
|
||||||
import appContext from "../../components/app_context";
|
import appContext, { CommandNames } from "../../components/app_context";
|
||||||
import NoteContext from "../../components/note_context";
|
import NoteContext from "../../components/note_context";
|
||||||
import FNote from "../../entities/fnote";
|
import FNote from "../../entities/fnote";
|
||||||
import contextMenu from "../../menus/context_menu";
|
import contextMenu, { MenuItem } from "../../menus/context_menu";
|
||||||
|
import NoteColorPicker from "../../menus/custom-items/NoteColorPicker";
|
||||||
import link_context_menu from "../../menus/link_context_menu";
|
import link_context_menu from "../../menus/link_context_menu";
|
||||||
|
import { TreeCommandNames } from "../../menus/tree_context_menu";
|
||||||
import attributes from "../../services/attributes";
|
import attributes from "../../services/attributes";
|
||||||
import branches from "../../services/branches";
|
import branches from "../../services/branches";
|
||||||
import { executeBulkActions } from "../../services/bulk_action";
|
import { executeBulkActions } from "../../services/bulk_action";
|
||||||
@ -186,59 +188,68 @@ function BreadcrumbItem({ index, notePath, noteContext, notePathLength }: { inde
|
|||||||
const parentNote = isNotRoot && branch ? await froca.getNote(branch.parentNoteId) : null;
|
const parentNote = isNotRoot && branch ? await froca.getNote(branch.parentNoteId) : null;
|
||||||
const parentNotSearch = !parentNote || parentNote.type !== "search";
|
const parentNotSearch = !parentNote || parentNote.type !== "search";
|
||||||
|
|
||||||
contextMenu.show({
|
const items = [
|
||||||
items: [
|
...link_context_menu.getItems(e),
|
||||||
...link_context_menu.getItems(e),
|
{
|
||||||
{
|
title: `${t("tree-context-menu.hoist-note")}`,
|
||||||
title: `${t("tree-context-menu.hoist-note")}`,
|
command: "toggleNoteHoisting",
|
||||||
command: "toggleNoteHoisting",
|
uiIcon: "bx bxs-chevrons-up",
|
||||||
uiIcon: "bx bxs-chevrons-up",
|
enabled: notSearch
|
||||||
enabled: notSearch
|
},
|
||||||
},
|
{ kind: "separator" },
|
||||||
{ kind: "separator" },
|
{
|
||||||
{
|
title: t("tree-context-menu.move-to"),
|
||||||
title: t("tree-context-menu.move-to"),
|
command: "moveNotesTo",
|
||||||
command: "moveNotesTo",
|
uiIcon: "bx bx-transfer",
|
||||||
uiIcon: "bx bx-transfer",
|
enabled: isNotRoot && !isHoisted && parentNotSearch
|
||||||
enabled: isNotRoot && !isHoisted && parentNotSearch
|
},
|
||||||
},
|
{
|
||||||
{
|
title: t("tree-context-menu.clone-to"),
|
||||||
title: t("tree-context-menu.clone-to"),
|
command: "cloneNotesTo",
|
||||||
command: "cloneNotesTo",
|
uiIcon: "bx bx-duplicate",
|
||||||
uiIcon: "bx bx-duplicate",
|
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.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 },
|
||||||
{ title: t("tree-context-menu.recent-changes-in-subtree"), command: "recentChangesInSubtree", uiIcon: "bx bx-history", enabled: notOptionsOrHelp },
|
{ kind: "separator" },
|
||||||
{ kind: "separator" },
|
{
|
||||||
{
|
title: t("tree-context-menu.duplicate"),
|
||||||
title: t("tree-context-menu.duplicate"),
|
command: "duplicateSubtree",
|
||||||
command: "duplicateSubtree",
|
uiIcon: "bx bx-outline",
|
||||||
uiIcon: "bx bx-outline",
|
enabled: parentNotSearch && isNotRoot && !isHoisted && notOptionsOrHelp && note.isContentAvailable(),
|
||||||
enabled: parentNotSearch && isNotRoot && !isHoisted && notOptionsOrHelp && note.isContentAvailable(),
|
handler: () => note_create.duplicateSubtree(noteId, branch.parentNoteId)
|
||||||
handler: () => note_create.duplicateSubtree(noteId, branch.parentNoteId)
|
},
|
||||||
},
|
|
||||||
|
|
||||||
{
|
{
|
||||||
title: !isArchived ? t("tree-context-menu.archive") : t("tree-context-menu.unarchive"),
|
title: !isArchived ? t("tree-context-menu.archive") : t("tree-context-menu.unarchive"),
|
||||||
uiIcon: !isArchived ? "bx bx-archive" : "bx bx-archive-out",
|
uiIcon: !isArchived ? "bx bx-archive" : "bx bx-archive-out",
|
||||||
handler: () => {
|
handler: () => {
|
||||||
if (!isArchived) {
|
if (!isArchived) {
|
||||||
attributes.addLabel(note.noteId, "archived");
|
attributes.addLabel(note.noteId, "archived");
|
||||||
} else {
|
} else {
|
||||||
attributes.removeOwnedLabelByName(note, "archived");
|
attributes.removeOwnedLabelByName(note, "archived");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t("tree-context-menu.delete"),
|
|
||||||
command: "deleteNotes",
|
|
||||||
uiIcon: "bx bx-trash destructive-action-icon",
|
|
||||||
enabled: isNotRoot && !isHoisted && parentNotSearch && notOptionsOrHelp,
|
|
||||||
handler: () => branches.deleteNotes([ branchId ])
|
|
||||||
}
|
}
|
||||||
],
|
},
|
||||||
|
{
|
||||||
|
title: t("tree-context-menu.delete"),
|
||||||
|
command: "deleteNotes",
|
||||||
|
uiIcon: "bx bx-trash destructive-action-icon",
|
||||||
|
enabled: isNotRoot && !isHoisted && parentNotSearch && notOptionsOrHelp,
|
||||||
|
handler: () => branches.deleteNotes([ branchId ])
|
||||||
|
},
|
||||||
|
{ kind: "separator"},
|
||||||
|
(notOptionsOrHelp ? {
|
||||||
|
kind: "custom",
|
||||||
|
componentFn: () => {
|
||||||
|
return NoteColorPicker({note});
|
||||||
|
}
|
||||||
|
} : null),
|
||||||
|
];
|
||||||
|
|
||||||
|
contextMenu.show({
|
||||||
|
items: items.filter(Boolean) as MenuItem<TreeCommandNames>[],
|
||||||
x: e.pageX,
|
x: e.pageX,
|
||||||
y: e.pageY,
|
y: e.pageY,
|
||||||
selectMenuItemHandler: ({ command }) => {
|
selectMenuItemHandler: ({ command }) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user