();
- const filteredTabs = useMemo(() => TAB_CONFIGURATION.filter(tab => tab.show?.(titleContext)), [ titleContext, note ]);
+ const filteredTabs = useMemo(() => TAB_CONFIGURATION.filter(tab => typeof tab.show === "boolean" ? tab.show : tab.show?.(titleContext)), [ titleContext, note ]);
return (
@@ -178,7 +181,9 @@ export default function Ribbon() {
return tab?.content && tab.content({
note,
hidden: !isActive,
- ntxId
+ ntxId,
+ hoistedNoteId,
+ notePath
});
})}
diff --git a/apps/client/src/widgets/ribbon/ribbon-interface.ts b/apps/client/src/widgets/ribbon/ribbon-interface.ts
index bc8186734..1165447e2 100644
--- a/apps/client/src/widgets/ribbon/ribbon-interface.ts
+++ b/apps/client/src/widgets/ribbon/ribbon-interface.ts
@@ -4,4 +4,6 @@ export interface TabContext {
note: FNote | null | undefined;
hidden: boolean;
ntxId?: string | null | undefined;
+ hoistedNoteId?: string;
+ notePath?: string;
}
diff --git a/apps/client/src/widgets/ribbon/style.css b/apps/client/src/widgets/ribbon/style.css
index 87baedfc2..dee220bf6 100644
--- a/apps/client/src/widgets/ribbon/style.css
+++ b/apps/client/src/widgets/ribbon/style.css
@@ -221,4 +221,28 @@
display: flex;
justify-content: space-evenly;
}
+/* #endregion */
+
+/* #region Note paths */
+.note-paths-widget {
+ padding: 12px;
+ max-height: 300px;
+ overflow-y: auto;
+}
+
+.note-path-list {
+ margin-top: 10px;
+}
+
+.note-path-list .path-current a {
+ font-weight: bold;
+}
+
+.note-path-list .path-archived a {
+ color: var(--muted-text-color) !important;
+}
+
+.note-path-list .path-search a {
+ font-style: italic;
+}
/* #endregion */
\ No newline at end of file
diff --git a/apps/client/src/widgets/ribbon_widgets/note_paths.ts b/apps/client/src/widgets/ribbon_widgets/note_paths.ts
deleted file mode 100644
index 9377a2198..000000000
--- a/apps/client/src/widgets/ribbon_widgets/note_paths.ts
+++ /dev/null
@@ -1,153 +0,0 @@
-import NoteContextAwareWidget from "../note_context_aware_widget.js";
-import treeService from "../../services/tree.js";
-import linkService from "../../services/link.js";
-import { t } from "../../services/i18n.js";
-import type FNote from "../../entities/fnote.js";
-import type { NotePathRecord } from "../../entities/fnote.js";
-import type { EventData } from "../../components/app_context.js";
-
-const TPL = /*html*/`
-`;
-
-export default class NotePathsWidget extends NoteContextAwareWidget {
-
- private $notePathIntro!: JQuery;
- private $notePathList!: JQuery;
-
- get name() {
- return "notePaths";
- }
-
- get toggleCommand() {
- return "toggleRibbonTabNotePaths";
- }
-
- getTitle() {
- return {
- show: true,
-
- };
- }
-
- doRender() {
- this.$widget = $(TPL);
- this.contentSized();
-
- this.$notePathIntro = this.$widget.find(".note-path-intro");
- this.$notePathList = this.$widget.find(".note-path-list");
- }
-
- async refreshWithNote(note: FNote) {
- this.$notePathList.empty();
-
- if (!this.note || this.noteId === "root") {
- this.$notePathList.empty().append(await this.getRenderedPath(["root"]));
-
- return;
- }
-
- const sortedNotePaths = this.note.getSortedNotePathRecords(this.hoistedNoteId).filter((notePath) => !notePath.isHidden);
-
- if (sortedNotePaths.length > 0) {
- this.$notePathIntro.text(t("note_paths.intro_placed"));
- } else {
- this.$notePathIntro.text(t("note_paths.intro_not_placed"));
- }
-
- const renderedPaths: JQuery[] = [];
-
- for (const notePathRecord of sortedNotePaths) {
- const notePath = notePathRecord.notePath;
-
- renderedPaths.push(await this.getRenderedPath(notePath, notePathRecord));
- }
-
- this.$notePathList.empty().append(...renderedPaths);
- }
-
- async getRenderedPath(notePath: string[], notePathRecord: NotePathRecord | null = null) {
- const $pathItem = $("");
- const pathSegments: string[] = [];
- const lastIndex = notePath.length - 1;
-
- for (let i = 0; i < notePath.length; i++) {
- const noteId = notePath[i];
- pathSegments.push(noteId);
- const title = await treeService.getNoteTitle(noteId);
- const $noteLink = await linkService.createLink(pathSegments.join("/"), { title });
-
- $noteLink.find("a").addClass("no-tooltip-preview tn-link");
- $pathItem.append($noteLink);
-
- if (i != lastIndex) {
- $pathItem.append(" / ");
- }
- }
-
- const icons: string[] = [];
-
- if (this.notePath === notePath.join("/")) {
- $pathItem.addClass("path-current");
- }
-
- if (!notePathRecord || notePathRecord.isInHoistedSubTree) {
- $pathItem.addClass("path-in-hoisted-subtree");
- } else {
- icons.push(``);
- }
-
- if (notePathRecord?.isArchived) {
- $pathItem.addClass("path-archived");
-
- icons.push(``);
- }
-
- if (notePathRecord?.isSearch) {
- $pathItem.addClass("path-search");
-
- icons.push(``);
- }
-
- if (icons.length > 0) {
- $pathItem.append(` ${icons.join(" ")}`);
- }
-
- return $pathItem;
- }
-
- entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
- if (loadResults.getBranchRows().find((branch) => branch.noteId === this.noteId) || (this.noteId != null && loadResults.isNoteReloaded(this.noteId))) {
- this.refresh();
- }
- }
-}