mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
added today launcher
This commit is contained in:
parent
5fca606730
commit
e41104208a
@ -32,12 +32,13 @@ export default class NoteLauncher extends AbstractLauncher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async launch(evt) {
|
async launch(evt) {
|
||||||
const targetNoteId = this.getTargetNoteId();
|
// await because subclass overrides can be async
|
||||||
|
const targetNoteId = await this.getTargetNoteId();
|
||||||
if (!targetNoteId) {
|
if (!targetNoteId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hoistedNoteId = this.getHoistedNoteId();
|
const hoistedNoteId = await this.getHoistedNoteId();
|
||||||
|
|
||||||
if (!evt) {
|
if (!evt) {
|
||||||
// keyboard shortcut
|
// keyboard shortcut
|
||||||
|
15
src/public/app/widgets/buttons/launcher/today_launcher.js
Normal file
15
src/public/app/widgets/buttons/launcher/today_launcher.js
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ import NoteLauncher from "../buttons/launcher/note_launcher.js";
|
|||||||
import ScriptLauncher from "../buttons/launcher/script_launcher.js";
|
import ScriptLauncher from "../buttons/launcher/script_launcher.js";
|
||||||
import CommandButtonWidget from "../buttons/command_button.js";
|
import CommandButtonWidget from "../buttons/command_button.js";
|
||||||
import utils from "../../services/utils.js";
|
import utils from "../../services/utils.js";
|
||||||
|
import TodayLauncher from "../buttons/launcher/today_launcher.js";
|
||||||
|
|
||||||
export default class LauncherWidget extends BasicWidget {
|
export default class LauncherWidget extends BasicWidget {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -101,6 +102,8 @@ export default class LauncherWidget extends BasicWidget {
|
|||||||
return new BackInHistoryButtonWidget();
|
return new BackInHistoryButtonWidget();
|
||||||
} else if (builtinWidget === 'forwardInHistoryButton') {
|
} else if (builtinWidget === 'forwardInHistoryButton') {
|
||||||
return new ForwardInHistoryButtonWidget();
|
return new ForwardInHistoryButtonWidget();
|
||||||
|
} else if (builtinWidget === 'todayInJournal') {
|
||||||
|
return new TodayLauncher(note);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unrecognized builtin widget ${builtinWidget} for launcher ${note.noteId} "${note.title}"`);
|
throw new Error(`Unrecognized builtin widget ${builtinWidget} for launcher ${note.noteId} "${note.title}"`);
|
||||||
}
|
}
|
||||||
|
@ -192,6 +192,7 @@ const HIDDEN_SUBTREE_DEFINITION = {
|
|||||||
] },
|
] },
|
||||||
{ id: 'lbSpacer1', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "50", growthFactor: "0" },
|
{ 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: '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: '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: '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' }
|
{ id: 'lbSyncStatus', title: 'Sync Status', type: 'launcher', builtinWidget: 'syncStatus', icon: 'bx bx-wifi' }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user