Skip to content

Commit

Permalink
Merge pull request #17 from ethancedwards8/inserttodaytext
Browse files Browse the repository at this point in the history
Add new command to insert the text 'Today' instead of the Date
  • Loading branch information
leenzhu authored Aug 14, 2023
2 parents c4a9afa + 6f0050c commit b54763d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,24 @@ joplin.plugins.register({
}
});

await joplin.commands.register({
name: "linkTodayNoteWithLabel",
label: "Insert link to Today's Note with label 'Today'",
execute: async () => {
const d = new Date();
const ds = new Date(`${d.getFullYear()}-${padding(d.getMonth() + 1)}-${padding(d.getDate())}`);
const note = await createNoteByDate(ds);
await joplin.commands.execute("insertText", `[Today](:/${note.id})`);
await joplin.commands.execute('editor.focus');
}
});


await joplin.views.menus.create('journal-menu', 'Journal', [
{ label: "Open Today's Note", commandName: "openTodayNote", accelerator: "CmdOrCtrl+Alt+D" },
{ label: "Open Another day's Note", commandName: "openOtherdayNote", accelerator: "CmdOrCtrl+Alt+O" },
{ label: "Insert link to Today's Note", commandName: "linkTodayNote", accelerator: "CmdOrCtrl+Alt+L" },
{ label: "Insert link to Today's Note with Label", commandName: "linkTodayNoteWithLabel", accelerator: "CmdOrCtrl+Alt+I" },
{ label: "Insert link to Another day's Note", commandName: "linkOtherDayNote", accelerator: "CmdOrCtrl+Alt+T" },
]);

Expand Down

0 comments on commit b54763d

Please sign in to comment.