Auto save note
This commit is contained in:
parent
a90859e151
commit
33cc62b3fc
1 changed files with 18 additions and 4 deletions
|
|
@ -37,7 +37,7 @@ var commandBar = new TinyMDE.CommandBar({
|
||||||
'|',
|
'|',
|
||||||
'h1', 'h2',
|
'h1', 'h2',
|
||||||
'|',
|
'|',
|
||||||
'ul', 'ol', {name: "checklist", title: "Check List", action: makeChecklist},
|
'ul', 'ol',
|
||||||
'|',
|
'|',
|
||||||
'blockquote', 'hr',
|
'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("* [ ] ", "")
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue