aboutsummaryrefslogtreecommitdiff
path: root/static/mde.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/mde.js')
-rw-r--r--static/mde.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/static/mde.js b/static/mde.js
new file mode 100644
index 0000000..a716ee4
--- /dev/null
+++ b/static/mde.js
@@ -0,0 +1,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();
+ });
+});
+