Skip to content

Build your personal knowledge base with Trilium Notes

added today launcher

zadame41104208a4e
diff --git a/src/public/app/widgets/buttons/launcher/note_launcher.js b/src/public/app/widgets/buttons/launcher/note_launcher.js
index 9bac3b6dbb..b3bcf899fd 100644
--- a/src/public/app/widgets/buttons/launcher/note_launcher.js
+++ b/src/public/app/widgets/buttons/launcher/note_launcher.js
@@ -32,12 +32,13 @@ export default class NoteLauncher extends AbstractLauncher {
}
async launch(evt) {
- const targetNoteId = this.getTargetNoteId();
+ // await because subclass overrides can be async
+ const targetNoteId = await this.getTargetNoteId();
if (!targetNoteId) {
return;
}
- const hoistedNoteId = this.getHoistedNoteId();
+ const hoistedNoteId = await this.getHoistedNoteId();
if (!evt) {
// keyboard shortcut
diff --git a/src/public/app/widgets/buttons/launcher/today_launcher.js b/src/public/app/widgets/buttons/launcher/today_launcher.js
new file mode 100644
index 0000000000..dd8dea1a42
--- /dev/null
+++ b/src/public/app/widgets/buttons/launcher/today_launcher.js
@@ -0,0 +1,15 @@
+import NoteLauncher from "./note_launcher.js";
+import dateNotesService from "../../../services/date_notes.js";
+import appContext from "../../../components/app_context.js";
+
+export default class TodayLauncher extends NoteLauncher {
+ async getTargetNoteId() {
+ const todayNote = await dateNotesService.getTodayNote();
+
+ return todayNote.noteId;
+ }
+
+ getHoistedNoteId() {
+ return appContext.tabManager.getActiveContext().hoistedNoteId;
+ }
+}
diff --git a/src/public/app/widgets/containers/launcher.js b/src/public/app/widgets/containers/launcher.js
index 693540942c..68fcf322c7 100644
--- a/src/public/app/widgets/containers/launcher.js
+++ b/src/public/app/widgets/containers/launcher.js
@@ -10,6 +10,7 @@ import NoteLauncher from "../buttons/launcher/note_launcher.js";
import ScriptLauncher from "../buttons/launcher/script_launcher.js";
import CommandButtonWidget from "../buttons/command_button.js";
import utils from "../../services/utils.js";
+import TodayLauncher from "../buttons/launcher/today_launcher.js";
export default class LauncherWidget extends BasicWidget {
constructor() {
@@ -101,6 +102,8 @@ export default class LauncherWidget extends BasicWidget {
return new BackInHistoryButtonWidget();
} else if (builtinWidget === 'forwardInHistoryButton') {
return new ForwardInHistoryButtonWidget();
+ } else if (builtinWidget === 'todayInJournal') {
+ return new TodayLauncher(note);
} else {
throw new Error(`Unrecognized builtin widget ${builtinWidget} for launcher ${note.noteId} "${note.title}"`);
}
diff --git a/src/services/hidden_subtree.js b/src/services/hidden_subtree.js
index 0e8232b8d7..aef4705564 100644
--- a/src/services/hidden_subtree.js
+++ b/src/services/hidden_subtree.js
@@ -192,6 +192,7 @@ const HIDDEN_SUBTREE_DEFINITION = {
] },
{ id: 'lbSpacer1', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "50", growthFactor: "0" },
{ id: 'lbBookmarks', title: 'Bookmarks', type: 'launcher', builtinWidget: 'bookmarks', icon: 'bx bx-bookmark' },
+ { id: 'lbToday', title: "Open Today's Journal Note", type: 'launcher', builtinWidget: 'todayInJournal', icon: 'bx bx-calendar-star' },
{ id: 'lbSpacer2', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "0", growthFactor: "1" },
{ id: 'lbProtectedSession', title: 'Protected Session', type: 'launcher', builtinWidget: 'protectedSession', icon: 'bx bx bx-shield-quarter' },
{ id: 'lbSyncStatus', title: 'Sync Status', type: 'launcher', builtinWidget: 'syncStatus', icon: 'bx bx-wifi' }