diff --git a/internal/conf/templates/edit.tmpl.html b/internal/conf/templates/edit.tmpl.html index b8e9aff..e637b48 100644 --- a/internal/conf/templates/edit.tmpl.html +++ b/internal/conf/templates/edit.tmpl.html @@ -37,7 +37,7 @@ var commandBar = new TinyMDE.CommandBar({ '|', 'h1', 'h2', '|', - 'ul', 'ol', {name: "checklist", title: "Check List", action: makeChecklist}, + 'ul', 'ol', '|', 'blockquote', 'hr', '|', @@ -45,9 +45,23 @@ var commandBar = new TinyMDE.CommandBar({ ], }); +let editTimeout; +let autoSaveDelay = 2000; + +tinyMDE.addEventListener("change", function() { + clearTimeout(editTimeout); + editTimeout = setTimeout(() => { + let form = document.querySelector("form"); + let formData = new FormData(form); + + fetch("{{.urlSave}}", { + method: "POST", + body: formData, + }).then((data) => { + console.log("Saved Note") + }); + }, autoSaveDelay); +}); -function makeChecklist(editor) { - editor.wrapSelection("* [ ] ", "") -}; {{end}}