Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(in_app_help): contextual help for book types
Elian Dorane73ea36161e5
diff --git a/src/public/app/services/note_list_renderer.ts b/src/public/app/services/note_list_renderer.tsindex 16aa0d7f2c..125e930054 100644--- a/src/public/app/services/note_list_renderer.ts+++ b/src/public/app/services/note_list_renderer.ts@@ -4,9 +4,11 @@ import ListOrGridView from "../widgets/view_widgets/list_or_grid_view.js";import type { ViewModeArgs } from "../widgets/view_widgets/view_mode.js";import type ViewMode from "../widgets/view_widgets/view_mode.js";+export type ViewTypeOptions = "list" | "grid" | "calendar";+export default class NoteListRenderer {- private viewType: string;+ private viewType: ViewTypeOptions;public viewMode: ViewMode | null;constructor($parent: JQuery<HTMLElement>, parentNote: FNote, noteIds: string[], showNotePath: boolean = false) {@@ -27,14 +29,14 @@ export default class NoteListRenderer {}}- #getViewType(parentNote: FNote): string {+ #getViewType(parentNote: FNote): ViewTypeOptions {const viewType = parentNote.getLabelValue("viewType");if (!["list", "grid", "calendar"].includes(viewType || "")) {// when not explicitly set, decide based on the note typereturn parentNote.type === "search" ? "list" : "grid";} else {- return viewType as string;+ return viewType as ViewTypeOptions;}}diff --git a/src/public/app/widgets/floating_buttons/help_button.ts b/src/public/app/widgets/floating_buttons/help_button.tsindex 74bb976bd8..c2147c75d2 100644--- a/src/public/app/widgets/floating_buttons/help_button.ts+++ b/src/public/app/widgets/floating_buttons/help_button.ts@@ -1,7 +1,8 @@-import appContext from "../../components/app_context.js";+import appContext, { type EventData } from "../../components/app_context.js";import type { NoteType } from "../../entities/fnote.js";import { t } from "../../services/i18n.js";import type { ViewScope } from "../../services/link.js";+import type { ViewTypeOptions } from "../../services/note_list_renderer.js";import NoteContextAwareWidget from "../note_context_aware_widget.js";const TPL = `@@ -10,8 +11,7 @@ const TPL = `</button>`;-const byNoteType: Record<NoteType, string | null> = {- book: null,+const byNoteType: Record<Exclude<NoteType, "book">, string | null> = {canvas: null,code: null,contentWidget: null,@@ -30,6 +30,12 @@ const byNoteType: Record<NoteType, string | null> = {webView: null};+const byBookType: Record<ViewTypeOptions, string | null> = {+ list: null,+ grid: null,+ calendar: "fDGg7QcJg3Xm"+};+export default class ContextualHelpButton extends NoteContextAwareWidget {private helpNoteIdToOpen?: string | null;@@ -41,8 +47,10 @@ export default class ContextualHelpButton extends NoteContextAwareWidget {return false;}- if (this.note && byNoteType[this.note.type]) {+ if (this.note && this.note.type !== "book" && byNoteType[this.note.type]) {this.helpNoteIdToOpen = byNoteType[this.note.type];+ } else if (this.note && this.note.type === "book") {+ this.helpNoteIdToOpen = byBookType[this.note.getAttributeValue("label", "viewType") as ViewTypeOptions ?? ""]}return !!this.helpNoteIdToOpen;@@ -73,4 +81,10 @@ export default class ContextualHelpButton extends NoteContextAwareWidget {});}+ entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {+ if (this.note?.type === "book" && loadResults.getAttributeRows().find((attr) => attr.noteId === this.noteId && attr.name === "viewType")) {+ this.refresh();+ }+ }+}diff --git a/src/public/app/widgets/view_widgets/calendar_view.ts b/src/public/app/widgets/view_widgets/calendar_view.tsindex d89642fba8..fe4da135bb 100644--- a/src/public/app/widgets/view_widgets/calendar_view.ts+++ b/src/public/app/widgets/view_widgets/calendar_view.ts@@ -33,6 +33,10 @@ const TPL = `margin-bottom: 0.5em;}+ body.desktop .calendar-container .fc-toolbar.fc-header-toolbar {+ padding-right: 5em;+ }+.calendar-container .fc-toolbar-title {font-size: 1.3rem;font-weight: normal;