From 129e4114116bf1d0ae50b17cd2b85855dcf0039f Mon Sep 17 00:00:00 2001 From: Rai Date: Sun, 21 Nov 2021 19:47:44 +0100 Subject: [PATCH] Add custom buttons and description of how to add them to mobile frontend. --- Custom-buttons.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Custom-buttons.md diff --git a/Custom-buttons.md b/Custom-buttons.md new file mode 100644 index 0000000..5ddddc6 --- /dev/null +++ b/Custom-buttons.md @@ -0,0 +1,22 @@ +You can create custom buttons that run your frontend code, and assign shortcuts to them. The default database has an example of a button that opens today's page: + +```javascript +api.addButtonToToolbar({ + title: 'Today', + icon: 'calendar', + shortcut: 'alt+t', + action: async function() { + const todayNote = await api.getTodayNote(); + + await api.waitUntilSynced(); + + api.activateNote(todayNote.noteId); + } +}); +``` + +You can add the button to Trilium by creating a note of type "JS frontend" with this code. + +To add the button on startup of the "desktop frontend", add a `#run=frontendStartup` attribute. + +To add the button into the "mobile frontend", add `#run=mobileStartup`. \ No newline at end of file