added: select theme

changed: css details
This commit is contained in:
quenousimporte 2023-01-23 12:29:53 +01:00
parent fcbe08e709
commit 2dc58df8f7
2 changed files with 62 additions and 8 deletions

65
main.js
View File

@ -1,11 +1,12 @@
var defaultsettings =
{
savedelay: 5000,
bgcolor: "white",
fontfamily: "'Inconsolata', 'Consolas', monospace",
fontsize: "90%",
fontcolor: "black",
lineheight: "130%",
savedelay: 5000,
foldmarkstart: 22232,
defaultpreviewinsplit: false,
enablefolding: false,
@ -31,6 +32,34 @@ var tags = null;
var currentvault = "";
var currenttag = "";
var themes =
{
Default:
{
bgcolor: "white",
fontfamily: "'Inconsolata', 'Consolas', monospace",
fontsize: "90%",
fontcolor: "black",
lineheight: "130%"
},
Notion:
{
bgcolor: "white",
fontfamily: "ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, 'Apple Color Emoji', Arial, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'",
fontsize: "16px",
fontcolor: "rgb(55,53,47)",
lineheight: "24px"
},
Monkey:
{
bgcolor: "rgb(227,227,227)",
fontfamily: "'Hack', 'Consolas', monospace",
fontsize: "14px",
fontcolor: "rgb(55,55,55)",
lineheight: "26px"
}
};
var commands = [
{
hint: "Close menu"
@ -218,6 +247,11 @@ var commands = [
action: addtagfilter,
shortcut: "ctrl+shift+F",
savedonly: true
},
{
hint: "Select theme",
savedonly: true,
action: selecttheme
}];
var snippets = [
@ -252,6 +286,20 @@ var snippets = [
cursor: 0
}];
function selecttheme()
{
searchinlist(Object.keys(themes))
.then(theme => {
for (var i in themes[theme])
{
settings[i] = themes[theme][i];
}
applystyle();
resize();
window.localStorage.setItem("settings", JSON.stringify(settings));
});
}
function addtagfilter()
{
var command = commands.find(c => c.action == addtagfilter);
@ -612,6 +660,15 @@ function loadstorage()
}
}
function applystyle()
{
document.body.style.background = settings.bgcolor;
document.body.style.fontFamily = settings.fontfamily;
document.body.style.fontSize = settings.fontsize;
document.body.style.lineHeight = settings.lineheight;
document.body.style.color = settings.fontcolor;
}
function loadsettings()
{
settings = {...defaultsettings};
@ -628,11 +685,7 @@ function loadsettings()
}
}
document.body.style.background = settings.bgcolor;
document.body.style.fontFamily = settings.fontfamily;
document.body.style.fontSize = settings.fontsize;
document.body.style.lineHeight = settings.lineheight;
document.body.style.color = settings.fontcolor;
applystyle();
if (!settings.enablefolding)
{

View File

@ -1,8 +1,8 @@
/* globals */
body {
margin-left: 5%;
margin-right: 5%;
margin-left: 7%;
margin-right: 7%;
caret-color: #5AA7CE;
}
@ -13,6 +13,7 @@ input {
font-family: inherit;
font-size: inherit;
line-height: inherit;
color: inherit;
}
/* scrollbars */