aboutsummaryrefslogtreecommitdiff
path: root/static/mde.js
blob: a716ee4d348e6d8c4d609558021b3378667dd7fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const form = document.getElementById('md_form');
const textarea = document.getElementById('raw');
textarea.value = "";

const editor = new EasyMDE({
    element: textarea,
    autosave: {
        enabled: true,
        uniqueId: "paterissa-post-editor",
        text: "Autosaved: ",
    },
    placeholder: "Post...",
    promptURLs: true,
});

form.addEventListener('submit', function(event) {
    event.preventDefault();
    
    const formData = new FormData();
    formData.set("raw", editor.value());

    fetch('/post/new', {
        method: 'POST',
        body: formData
    }).then(_ => {
        window.location.reload();
    });
});