added: dialog dash in lists

added: snippet for dialog dash
changed: html tag for "share as html"
refactor: init functions
added: snippets for md headings
fixed: onstorage event only in split mode
This commit is contained in:
quenousimporte 2023-01-19 14:06:19 +01:00 committed by GitHub
parent ae138a7a48
commit b0fd4efc49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 9 deletions

42
main.js
View File

@ -10,7 +10,7 @@ var defaultsettings =
};
//builtin
var markerslist = ["* ", "- ", " * ", " - ", ">> ", "> ", "=> "];
var markerslist = ["* ", "- ", " * ", " - ", ">> ", "> ", "=> ", "— "];
var sectionmarks = ["---", "### ", "## ", "# ", "```"];
var codelanguages = ["xml", "js", "sql"];
@ -224,6 +224,12 @@ var snippets = [
hint: "Standard answer (en)",
insert: "Hello ,\n\n\n\nKind regards,\nSimon",
cursor: -24
},
{
command: "/-",
hint: "Dialog mark",
insert: "— ",
cursor: 0
}];
function showinternallinks()
@ -368,7 +374,7 @@ function share(html)
{
navigator.share(
{
text: html ? "<html>" + md2html(getnotecontent()) + "</html>": getnotecontent(),
text: html ? md2html(getnotecontent()) : getnotecontent(),
title: currentnote.title
});
}
@ -494,14 +500,9 @@ function checksaved()
}
}
function init()
function initsnippets()
{
loadsettings();
window.onbeforeunload = checksaved;
window.onclick = focuseditor;
window.onstorage = loadstorage;
// code languages
codelanguages.forEach(lang =>
{
if (!snippets.includes(s => s.command == "/" + lang))
@ -516,6 +517,28 @@ function init()
}
});
// md headings
for (var i = 1; i <= 3; i++)
{
snippets.push(
{
command: "/" + i,
hint: "Heading " + i,
insert: "#".repeat(i) + " ",
cursor: 0
});
}
}
function init()
{
loadsettings();
window.onbeforeunload = checksaved;
window.onclick = focuseditor;
initsnippets();
if (settings.remote)
{
markunsaved();
@ -536,6 +559,7 @@ function init()
if (issplit())
{
window.onstorage = loadstorage;
if (settings.defaultpreviewinsplit && name == "right")
{
togglepreview();