From b0fd4efc4939cd956e16d6b9e54942f47145b312 Mon Sep 17 00:00:00 2001 From: quenousimporte <76260127+quenousimporte@users.noreply.github.com> Date: Thu, 19 Jan 2023 14:06:19 +0100 Subject: [PATCH] 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 --- main.js | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/main.js b/main.js index 06d54ff..705ef48 100644 --- a/main.js +++ b/main.js @@ -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 ? "" + md2html(getnotecontent()) + "": 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();