mirror of
https://github.com/rjNemo/go-wiki
synced 2026-06-06 02:36:40 +00:00
46 lines
1.1 KiB
HTML
46 lines
1.1 KiB
HTML
{{define "title"}} {{.Title}} | Go-Wiki {{end}} {{define "content"}}
|
|
<h1>Editing {{.Title}}</h1>
|
|
<!-- Include stylesheet -->
|
|
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet" />
|
|
|
|
<!-- Create the editor container -->
|
|
<div id="editor">
|
|
<h1>{{.Title}}</h1>
|
|
<p><br /></p>
|
|
<p>{{printf "%s" .Body}}</p>
|
|
<p><br /></p>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<form onsubmit="save()">
|
|
<input class="btn btn-primary" type="submit" value="Save changes" />
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Include the Quill library -->
|
|
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
|
|
|
|
<!-- Initialize Quill editor -->
|
|
<script>
|
|
let quill = new Quill("#editor", {
|
|
theme: "snow"
|
|
});
|
|
|
|
save = async () => {
|
|
// e.preventDefault();
|
|
console.log("send to backend");
|
|
let text = quill.getContents();
|
|
console.log(text);
|
|
|
|
response = await fetch("http://localhost:8080/editor", {
|
|
method: "POST",
|
|
body: JSON.stringify(text),
|
|
headers: {
|
|
Accept: "application/json",
|
|
"Content-Type": "application/json"
|
|
}
|
|
}).then(r => console.log(r.json()));
|
|
// return await response.json();
|
|
};
|
|
</script>
|
|
{{end}}
|