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 button for geo notes
Elian Doran868ca2d98247
diff --git a/src/public/app/layouts/desktop_layout.js b/src/public/app/layouts/desktop_layout.jsindex c5d14ffe96..e0f6958039 100644--- a/src/public/app/layouts/desktop_layout.js+++ b/src/public/app/layouts/desktop_layout.js@@ -86,6 +86,7 @@ import ClassicEditorToolbar from "../widgets/ribbon_widgets/classic_editor_toolbimport options from "../services/options.js";import utils from "../services/utils.js";import GeoMapButtons from "../widgets/floating_buttons/geo_map_button.js";+import ContextualHelpButton from "../widgets/floating_buttons/help_button.js";export default class DesktopLayout {constructor(customWidgets) {@@ -205,6 +206,7 @@ export default class DesktopLayout {.child(new CopyImageReferenceButton()).child(new SvgExportButton()).child(new BacklinksWidget())+ .child(new ContextualHelpButton()).child(new HideFloatingButtonsButton())).child(new MermaidWidget())diff --git a/src/public/app/widgets/floating_buttons/help_button.ts b/src/public/app/widgets/floating_buttons/help_button.tsnew file mode 100644index 0000000000..cdc394eb51--- /dev/null+++ b/src/public/app/widgets/floating_buttons/help_button.ts@@ -0,0 +1,62 @@+import appContext from "../../components/app_context.js";+import type { NoteType } from "../../entities/fnote.js";+import { t } from "../../services/i18n.js";+import NoteContextAwareWidget from "../note_context_aware_widget.js";++const TPL = `+<button class="open-contextual-help-button" title="${t("help-button.title")}">+ <span class="bx bx-help-circle"></span>+</button>+`;++const byNoteType: Record<NoteType, string | null> = {+ book: null,+ canvas: null,+ code: null,+ contentWidget: null,+ doc: null,+ file: null,+ geoMap: "foPEtsL51pD2",+ image: null,+ launcher: null,+ mermaid: null,+ mindMap: null,+ noteMap: null,+ relationMap: null,+ render: null,+ search: null,+ text: null,+ webView: null+};++export default class ContextualHelpButton extends NoteContextAwareWidget {++ private helpNoteIdToOpen?: string | null;++ isEnabled() {+ this.helpNoteIdToOpen = null;++ if (!super.isEnabled()) {+ return false;+ }++ if (this.note && byNoteType[this.note.type]) {+ this.helpNoteIdToOpen = byNoteType[this.note.type];+ }++ return !!this.helpNoteIdToOpen;+ }++ doRender() {+ this.$widget = $(TPL);+ this.$widget.on("click", () => {+ const subContexts = appContext.tabManager.getActiveContext().getSubContexts();+ const { ntxId } = subContexts[subContexts.length - 1];+ this.triggerCommand("openNewNoteSplit", {+ ntxId,+ notePath: `_help_${this.helpNoteIdToOpen}`+ })+ });+ }++}diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.jsonindex 956dbba403..4fcd77b1e4 100644--- a/src/public/translations/en/translation.json+++ b/src/public/translations/en/translation.json@@ -1644,5 +1644,8 @@"geo-map-context": {"open-location": "Open location","remove-from-map": "Remove from map"+ },+ "help-button": {+ "title": "Open the relevant help page"}}