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 = var defaultsettings =
{ {
savedelay: 5000,
bgcolor: "white", bgcolor: "white",
fontfamily: "'Inconsolata', 'Consolas', monospace", fontfamily: "'Inconsolata', 'Consolas', monospace",
fontsize: "90%", fontsize: "90%",
fontcolor: "black", fontcolor: "black",
lineheight: "130%", lineheight: "130%",
savedelay: 5000,
foldmarkstart: 22232, foldmarkstart: 22232,
defaultpreviewinsplit: false, defaultpreviewinsplit: false,
enablefolding: false, enablefolding: false,
@ -31,6 +32,34 @@ var tags = null;
var currentvault = ""; var currentvault = "";
var currenttag = ""; 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 = [ var commands = [
{ {
hint: "Close menu" hint: "Close menu"
@ -218,6 +247,11 @@ var commands = [
action: addtagfilter, action: addtagfilter,
shortcut: "ctrl+shift+F", shortcut: "ctrl+shift+F",
savedonly: true savedonly: true
},
{
hint: "Select theme",
savedonly: true,
action: selecttheme
}]; }];
var snippets = [ var snippets = [
@ -252,6 +286,20 @@ var snippets = [
cursor: 0 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() function addtagfilter()
{ {
var command = commands.find(c => c.action == 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() function loadsettings()
{ {
settings = {...defaultsettings}; settings = {...defaultsettings};
@ -628,11 +685,7 @@ function loadsettings()
} }
} }
document.body.style.background = settings.bgcolor; applystyle();
document.body.style.fontFamily = settings.fontfamily;
document.body.style.fontSize = settings.fontsize;
document.body.style.lineHeight = settings.lineheight;
document.body.style.color = settings.fontcolor;
if (!settings.enablefolding) if (!settings.enablefolding)
{ {

View File

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