added: note shortcut in md header

This commit is contained in:
quenousimporte 2023-05-05 10:57:27 +02:00
parent ebf9b0ee99
commit 670cb9c697
1 changed files with 23 additions and 17 deletions

40
main.js
View File

@ -159,16 +159,6 @@ var commands = [
action: commandpalette, action: commandpalette,
excludepalette: true excludepalette: true
}, },
{
shortcut: "ctrl+t",
hint: "Open todo",
action: loadtodo
},
{
shortcut: "ctrl+q",
hint: "Open quick note",
action: loadquicknote
},
{ {
shortcut: "ctrl+g", shortcut: "ctrl+g",
hint: "Find in notes", hint: "Find in notes",
@ -336,11 +326,6 @@ var commands = [
{ {
hint: "Download all vaults", hint: "Download all vaults",
action: downloadallvaults action: downloadallvaults
},
{
hint: "Open press review",
action: loadreview,
shortcut: "ctrl+r"
}]; }];
var snippets = [ var snippets = [
@ -1066,6 +1051,7 @@ function loadstorage()
{ {
loadlast(); loadlast();
} }
initshortcuts();
} }
function applystyle() function applystyle()
@ -1145,6 +1131,27 @@ function initvault()
currentvault = window.localStorage.getItem("vault") || "local"; currentvault = window.localStorage.getItem("vault") || "local";
} }
function initshortcuts()
{
localdata
.filter(n => n.content.includes("shortcut: "))
.forEach(n => {
var hint = "Open " + n.title;
if (!commands.find(c => c.hint == hint))
{
var shortcut = n.content.match(/shortcut: (.*)/)[1];
commands.unshift({
hint: hint,
shortcut: shortcut,
action: function()
{
loadnote(n.title);
}
});
}
});
}
function init() function init()
{ {
loadsettings(); loadsettings();
@ -1162,9 +1169,8 @@ function init()
queryremote({action: "fetch"}) queryremote({action: "fetch"})
.then(data => .then(data =>
{ {
localdata = data;
window.localStorage.setItem("remote", JSON.stringify(data)); window.localStorage.setItem("remote", JSON.stringify(data));
loadlast(); loadstorage();
checkevents(); checkevents();
}) })
.catch(remotecallfailed); .catch(remotecallfailed);