mirror of
https://github.com/zadam/trilium.git
synced 2025-12-15 20:04:25 +01:00
feat(status_bar): integrate note paths widget
This commit is contained in:
parent
738fa6fd0e
commit
eb02330fdf
@ -49,11 +49,13 @@
|
|||||||
.dropdown-toggle {
|
.dropdown-toggle {
|
||||||
padding: 0.1em 0.25em;
|
padding: 0.1em 0.25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dropdown-menu {
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-note-info {
|
.dropdown-note-info {
|
||||||
width: max-content;
|
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
@ -76,6 +78,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dropdown-note-paths {
|
||||||
|
.note-paths-widget {
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.note-path-list {
|
||||||
|
margin: 1em;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> .attribute-list {
|
> .attribute-list {
|
||||||
|
|||||||
@ -24,22 +24,23 @@ import { ContentLanguagesModal, useLanguageSwitcher } from "../ribbon/BasicPrope
|
|||||||
import AttributeEditor, { AttributeEditorImperativeHandlers } from "../ribbon/components/AttributeEditor";
|
import AttributeEditor, { AttributeEditorImperativeHandlers } from "../ribbon/components/AttributeEditor";
|
||||||
import InheritedAttributesTab from "../ribbon/InheritedAttributesTab";
|
import InheritedAttributesTab from "../ribbon/InheritedAttributesTab";
|
||||||
import { NoteSizeWidget, useNoteMetadata } from "../ribbon/NoteInfoTab";
|
import { NoteSizeWidget, useNoteMetadata } from "../ribbon/NoteInfoTab";
|
||||||
|
import { NotePathsWidget, useSortedNotePaths } from "../ribbon/NotePathsTab";
|
||||||
import { useAttachments } from "../type_widgets/Attachment";
|
import { useAttachments } from "../type_widgets/Attachment";
|
||||||
import { useProcessedLocales } from "../type_widgets/options/components/LocaleSelector";
|
import { useProcessedLocales } from "../type_widgets/options/components/LocaleSelector";
|
||||||
import Breadcrumb from "./Breadcrumb";
|
import Breadcrumb from "./Breadcrumb";
|
||||||
import NotePathsTab, { useSortedNotePaths } from "../ribbon/NotePathsTab";
|
|
||||||
|
|
||||||
interface StatusBarContext {
|
interface StatusBarContext {
|
||||||
note: FNote;
|
note: FNote;
|
||||||
|
notePath: string | null | undefined;
|
||||||
noteContext: NoteContext;
|
noteContext: NoteContext;
|
||||||
viewScope?: ViewScope;
|
viewScope?: ViewScope;
|
||||||
hoistedNoteId?: string;
|
hoistedNoteId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function StatusBar() {
|
export default function StatusBar() {
|
||||||
const { note, noteContext, viewScope, hoistedNoteId } = useActiveNoteContext();
|
const { note, notePath, noteContext, viewScope, hoistedNoteId } = useActiveNoteContext();
|
||||||
const [ attributesShown, setAttributesShown ] = useState(false);
|
const [ attributesShown, setAttributesShown ] = useState(false);
|
||||||
const context: StatusBarContext | undefined | null = note && noteContext && { note, noteContext, viewScope, hoistedNoteId };
|
const context: StatusBarContext | undefined | null = note && noteContext && { note, notePath, noteContext, viewScope, hoistedNoteId };
|
||||||
const attributesContext: AttributesProps | undefined | null = context && { ...context, attributesShown, setAttributesShown };
|
const attributesContext: AttributesProps | undefined | null = context && { ...context, attributesShown, setAttributesShown };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -64,7 +65,7 @@ export default function StatusBar() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StatusBarDropdown({ children, icon, text, buttonClassName, titleOptions, ...dropdownProps }: Omit<DropdownProps, "hideToggleArrow" | "title" | "titlePosition"> & {
|
function StatusBarDropdown({ children, icon, text, buttonClassName, titleOptions, dropdownOptions, ...dropdownProps }: Omit<DropdownProps, "hideToggleArrow" | "title" | "titlePosition"> & {
|
||||||
title: string;
|
title: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
}) {
|
}) {
|
||||||
@ -79,6 +80,10 @@ function StatusBarDropdown({ children, icon, text, buttonClassName, titleOptions
|
|||||||
strategy: "fixed"
|
strategy: "fixed"
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
dropdownOptions={{
|
||||||
|
...dropdownOptions,
|
||||||
|
autoClose: "outside"
|
||||||
|
}}
|
||||||
text={<>
|
text={<>
|
||||||
{icon && (<><Icon icon={icon} /> </>)}
|
{icon && (<><Icon icon={icon} /> </>)}
|
||||||
{text}
|
{text}
|
||||||
@ -192,7 +197,6 @@ export function NoteInfoBadge({ note }: { note: FNote | null | undefined }) {
|
|||||||
icon="bx bx-info-circle"
|
icon="bx bx-info-circle"
|
||||||
title={t("status_bar.note_info_title")}
|
title={t("status_bar.note_info_title")}
|
||||||
dropdownContainerClassName="dropdown-note-info"
|
dropdownContainerClassName="dropdown-note-info"
|
||||||
dropdownOptions={{ autoClose: "outside" }}
|
|
||||||
>
|
>
|
||||||
<ul>
|
<ul>
|
||||||
<NoteInfoValue text={t("note_info_widget.created")} value={formatDateTime(metadata?.dateCreated)} />
|
<NoteInfoValue text={t("note_info_widget.created")} value={formatDateTime(metadata?.dateCreated)} />
|
||||||
@ -312,17 +316,21 @@ function AttributesPane({ note, noteContext, attributesShown, setAttributesShown
|
|||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region Note paths
|
//#region Note paths
|
||||||
function NotePaths({ note, hoistedNoteId }: StatusBarContext) {
|
function NotePaths({ note, hoistedNoteId, notePath }: StatusBarContext) {
|
||||||
const sortedNotePaths = useSortedNotePaths(note, hoistedNoteId);
|
const sortedNotePaths = useSortedNotePaths(note, hoistedNoteId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StatusBarDropdown
|
<StatusBarDropdown
|
||||||
title={t("status_bar.note_paths_title")}
|
title={t("status_bar.note_paths_title")}
|
||||||
|
dropdownContainerClassName="dropdown-note-paths"
|
||||||
icon="bx bx-link-alt"
|
icon="bx bx-link-alt"
|
||||||
text={sortedNotePaths?.length}
|
text={sortedNotePaths?.length}
|
||||||
>
|
>
|
||||||
|
<NotePathsWidget
|
||||||
|
sortedNotePaths={sortedNotePaths}
|
||||||
|
currentNotePath={notePath}
|
||||||
|
/>
|
||||||
</StatusBarDropdown>
|
</StatusBarDropdown>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|||||||
@ -11,7 +11,13 @@ import { TabContext } from "./ribbon-interface";
|
|||||||
|
|
||||||
export default function NotePathsTab({ note, hoistedNoteId, notePath }: TabContext) {
|
export default function NotePathsTab({ note, hoistedNoteId, notePath }: TabContext) {
|
||||||
const sortedNotePaths = useSortedNotePaths(note, hoistedNoteId);
|
const sortedNotePaths = useSortedNotePaths(note, hoistedNoteId);
|
||||||
|
return <NotePathsWidget sortedNotePaths={sortedNotePaths} currentNotePath={notePath} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function NotePathsWidget({ sortedNotePaths, currentNotePath }: {
|
||||||
|
sortedNotePaths: NotePathRecord[] | undefined;
|
||||||
|
currentNotePath?: string | null | undefined;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<div class="note-paths-widget">
|
<div class="note-paths-widget">
|
||||||
<>
|
<>
|
||||||
@ -23,7 +29,7 @@ export default function NotePathsTab({ note, hoistedNoteId, notePath }: TabConte
|
|||||||
{sortedNotePaths?.length ? sortedNotePaths.map(sortedNotePath => (
|
{sortedNotePaths?.length ? sortedNotePaths.map(sortedNotePath => (
|
||||||
<NotePath
|
<NotePath
|
||||||
key={sortedNotePath.notePath}
|
key={sortedNotePath.notePath}
|
||||||
currentNotePath={notePath}
|
currentNotePath={currentNotePath}
|
||||||
notePathRecord={sortedNotePath}
|
notePathRecord={sortedNotePath}
|
||||||
/>
|
/>
|
||||||
)) : undefined}
|
)) : undefined}
|
||||||
|
|||||||
@ -112,7 +112,7 @@ export const RIBBON_TAB_DEFINITIONS: TabConfiguration[] = [
|
|||||||
title: t("note_paths.title"),
|
title: t("note_paths.title"),
|
||||||
icon: "bx bx-collection",
|
icon: "bx bx-collection",
|
||||||
content: NotePathsTab,
|
content: NotePathsTab,
|
||||||
show: true,
|
show: !isNewLayout,
|
||||||
toggleCommand: "toggleRibbonTabNotePaths"
|
toggleCommand: "toggleRibbonTabNotePaths"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user