2024-02-18 10:07:49 +01:00
|
|
|
{{define "page-content"}}
|
2024-02-24 09:54:25 +01:00
|
|
|
<h2>Editor</h2>
|
2024-04-07 18:57:03 +02:00
|
|
|
|
2024-07-13 13:58:36 +02:00
|
|
|
<form id="edit-area">
|
2024-04-01 14:22:59 +02:00
|
|
|
<div class="flex flex-col gap-y-1">
|
|
|
|
<label for="article-title">Titel</label>
|
2024-07-17 23:25:57 +02:00
|
|
|
<input name="article-title" type="text" value="{{.Title}}" />
|
2024-04-01 14:22:59 +02:00
|
|
|
</div>
|
|
|
|
<div class="flex flex-col">
|
|
|
|
<label for="article-description">Beschreibung</label>
|
2024-07-17 23:25:57 +02:00
|
|
|
<textarea name="article-description">{{.Description}}</textarea>
|
2024-04-01 14:22:59 +02:00
|
|
|
</div>
|
|
|
|
<div class="flex flex-col">
|
|
|
|
<label for="article-content">Artikel</label>
|
2024-08-08 21:09:38 +02:00
|
|
|
<textarea id="easyMDE">{{.Content}}</textarea>
|
2024-03-28 08:41:38 +01:00
|
|
|
</div>
|
2024-08-08 21:09:38 +02:00
|
|
|
<input id="article-content" name="article-content" type="hidden" />
|
2024-03-28 08:41:38 +01:00
|
|
|
|
2024-04-03 18:08:56 +02:00
|
|
|
<div>
|
|
|
|
<span>Tags</span>
|
2024-04-03 19:51:27 +02:00
|
|
|
<div class="flex flex-wrap gap-x-4">
|
2024-07-17 23:25:57 +02:00
|
|
|
{{range .Tags}}
|
2024-04-03 18:08:56 +02:00
|
|
|
<div>
|
|
|
|
<input id="{{.Name}}" name="tags" type="checkbox" value="{{.ID}}" />
|
|
|
|
<label for="{{.Name}}">{{.Name}}</label>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2024-03-28 08:41:38 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2024-04-01 14:22:59 +02:00
|
|
|
<div class="btn-area">
|
2024-08-30 15:42:53 +02:00
|
|
|
<input class="action-btn" type="submit" value="Senden" hx-post="/article/submit" hx-target="#page-content" />
|
2024-04-03 20:24:54 +02:00
|
|
|
<button class="btn" hx-get="/hub" hx-target="#page-content">Abbrechen</button>
|
2024-04-01 14:22:59 +02:00
|
|
|
</div>
|
2024-02-18 10:07:49 +01:00
|
|
|
</form>
|
2024-03-28 08:41:38 +01:00
|
|
|
|
2024-03-29 09:07:17 +01:00
|
|
|
<script>
|
2024-08-08 21:09:38 +02:00
|
|
|
var easyMDE = new EasyMDE({
|
|
|
|
element: document.getElementById('easyMDE'),
|
|
|
|
hideIcons: ['image'],
|
|
|
|
imageTexts: {sbInit: ''},
|
|
|
|
showIcons: ["code", "table", "upload-image"],
|
|
|
|
uploadImage: true,
|
2024-03-29 09:07:17 +01:00
|
|
|
|
2024-08-08 21:09:38 +02:00
|
|
|
imageUploadFunction: function (file, onSuccess, onError) {
|
|
|
|
var formData = new FormData();
|
|
|
|
formData.append('article-image', file);
|
2024-03-29 09:07:17 +01:00
|
|
|
|
2024-08-30 16:06:19 +02:00
|
|
|
fetch('/image/upload', {
|
2024-08-08 21:09:38 +02:00
|
|
|
method: 'POST',
|
|
|
|
body: formData
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
onSuccess(data);
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
onError(error);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2024-03-29 09:07:17 +01:00
|
|
|
|
2024-08-08 21:09:38 +02:00
|
|
|
easyMDE.codemirror.on("change", () => {
|
|
|
|
document.getElementById('article-content').value = easyMDE.value();
|
|
|
|
});
|
2024-03-29 09:07:17 +01:00
|
|
|
</script>
|
|
|
|
{{end}}
|