mirror of
https://github.com/zadam/trilium.git
synced 2025-12-17 05:39:55 +01:00
feat(breadcrumb): distinguish between workspace and hoisted notes
This commit is contained in:
@@ -2146,7 +2146,8 @@
|
|||||||
},
|
},
|
||||||
"breadcrumb": {
|
"breadcrumb": {
|
||||||
"hoisted_badge": "Hoisted",
|
"hoisted_badge": "Hoisted",
|
||||||
"hoisted_badge_title": "Unhoist"
|
"hoisted_badge_title": "Unhoist",
|
||||||
|
"workspace_badge": "Workspace"
|
||||||
},
|
},
|
||||||
"breadcrumb_badges": {
|
"breadcrumb_badges": {
|
||||||
"read_only_explicit": "Read-only",
|
"read_only_explicit": "Read-only",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import ActionButton from "../react/ActionButton";
|
|||||||
import { Badge } from "../react/Badge";
|
import { Badge } from "../react/Badge";
|
||||||
import Dropdown from "../react/Dropdown";
|
import Dropdown from "../react/Dropdown";
|
||||||
import { FormListItem } from "../react/FormList";
|
import { FormListItem } from "../react/FormList";
|
||||||
import { useChildNotes, useNoteProperty } from "../react/hooks";
|
import { useChildNotes, useNote, useNoteLabel, useNoteLabelBoolean, useNoteProperty } from "../react/hooks";
|
||||||
import Icon from "../react/Icon";
|
import Icon from "../react/Icon";
|
||||||
import NoteLink from "../react/NoteLink";
|
import NoteLink from "../react/NoteLink";
|
||||||
|
|
||||||
@@ -61,31 +61,38 @@ export default function Breadcrumb({ note, noteContext }: { note: FNote, noteCon
|
|||||||
|
|
||||||
function BreadcrumbRoot({ noteContext }: { noteContext: NoteContext | undefined }) {
|
function BreadcrumbRoot({ noteContext }: { noteContext: NoteContext | undefined }) {
|
||||||
const noteId = noteContext?.hoistedNoteId ?? "root";
|
const noteId = noteContext?.hoistedNoteId ?? "root";
|
||||||
|
if (noteId !== "root") {
|
||||||
// Root note is icon only.
|
return <BreadcrumbHoistedNoteRoot noteId={noteId} />;
|
||||||
if (noteId === "root") {
|
|
||||||
const note = froca.getNoteFromCache("root");
|
|
||||||
return (note &&
|
|
||||||
<ActionButton
|
|
||||||
className="root-note"
|
|
||||||
icon={note.getIcon()}
|
|
||||||
text={""}
|
|
||||||
onClick={() => noteContext?.setNote(note.noteId)}
|
|
||||||
onContextMenu={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
link_context_menu.openContextMenu(note.noteId, e);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Root note is icon only.
|
||||||
|
const note = froca.getNoteFromCache("root");
|
||||||
|
return (note &&
|
||||||
|
<ActionButton
|
||||||
|
className="root-note"
|
||||||
|
icon={note.getIcon()}
|
||||||
|
text={""}
|
||||||
|
onClick={() => noteContext?.setNote(note.noteId)}
|
||||||
|
onContextMenu={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
link_context_menu.openContextMenu(note.noteId, e);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function BreadcrumbHoistedNoteRoot({ noteId }: { noteId: string }) {
|
||||||
|
const note = useNote(noteId);
|
||||||
|
const [ workspace ] = useNoteLabelBoolean(note, "workspace");
|
||||||
|
|
||||||
// Hoisted workspace shows both text and icon and a way to exit easily out of the hoisting.
|
// Hoisted workspace shows both text and icon and a way to exit easily out of the hoisting.
|
||||||
return (
|
return (note &&
|
||||||
<>
|
<>
|
||||||
<Badge
|
<Badge
|
||||||
className="badge-hoisted"
|
className="badge-hoisted"
|
||||||
icon="bx bxs-chevrons-up"
|
icon={workspace ? "bx bx-folder-open" : "bx bxs-chevrons-up"}
|
||||||
text={t("breadcrumb.hoisted_badge")}
|
text={workspace ? t("breadcrumb.workspace_badge") : t("breadcrumb.hoisted_badge")}
|
||||||
tooltip={t("breadcrumb.hoisted_badge_title")}
|
tooltip={t("breadcrumb.hoisted_badge_title")}
|
||||||
onClick={() => hoisted_note.unhoist()}
|
onClick={() => hoisted_note.unhoist()}
|
||||||
/>
|
/>
|
||||||
@@ -98,7 +105,6 @@ function BreadcrumbRoot({ noteContext }: { noteContext: NoteContext | undefined
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function BreadcrumbLastItem({ notePath }: { notePath: string }) {
|
function BreadcrumbLastItem({ notePath }: { notePath: string }) {
|
||||||
const noteId = notePath.split("/").at(-1);
|
const noteId = notePath.split("/").at(-1);
|
||||||
const [ note ] = useState(() => froca.getNoteFromCache(noteId!));
|
const [ note ] = useState(() => froca.getNoteFromCache(noteId!));
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
type Labels = {
|
type Labels = {
|
||||||
color: string;
|
color: string;
|
||||||
iconClass: string;
|
iconClass: string;
|
||||||
|
workspace: boolean;
|
||||||
|
workspaceTabBackgroundColor: string;
|
||||||
workspaceIconClass: string;
|
workspaceIconClass: string;
|
||||||
executeButton: boolean;
|
executeButton: boolean;
|
||||||
executeDescription: string;
|
executeDescription: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user