mirror of
https://github.com/thomiceli/opengist.git
synced 2025-01-03 16:22:40 +00:00
Send Markdown preview data as form params (#347)
This commit is contained in:
parent
12696d23b0
commit
3068588111
2 changed files with 6 additions and 5 deletions
|
@ -251,7 +251,7 @@ func NewServer(isDev bool, sessionsPath string) *Server {
|
||||||
g1.Use(csrfInit)
|
g1.Use(csrfInit)
|
||||||
g1.GET("/", create, logged)
|
g1.GET("/", create, logged)
|
||||||
g1.POST("/", processCreate, logged)
|
g1.POST("/", processCreate, logged)
|
||||||
g1.GET("/preview", preview, logged)
|
g1.POST("/preview", preview, logged)
|
||||||
|
|
||||||
g1.GET("/healthcheck", healthcheck)
|
g1.GET("/healthcheck", healthcheck)
|
||||||
g1.GET("/metrics", metrics)
|
g1.GET("/metrics", metrics)
|
||||||
|
|
|
@ -71,11 +71,12 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
cmeditor!.classList.remove("hidden-important");
|
cmeditor!.classList.remove("hidden-important");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
fetch(`${baseUrl}/preview?` + new URLSearchParams({
|
const formData = new FormData();
|
||||||
content: editor.state.doc.toString()
|
formData.append('content', editor.state.doc.toString());
|
||||||
}), {
|
fetch(`${baseUrl}/preview`, {
|
||||||
method: 'GET',
|
method: 'POST',
|
||||||
credentials: 'same-origin',
|
credentials: 'same-origin',
|
||||||
|
body: formData
|
||||||
}).then(r => r.text()).then(r => {
|
}).then(r => r.text()).then(r => {
|
||||||
let divpreview = dom.querySelector("div.preview") as HTMLElement;
|
let divpreview = dom.querySelector("div.preview") as HTMLElement;
|
||||||
divpreview!.innerHTML = r;
|
divpreview!.innerHTML = r;
|
||||||
|
|
Loading…
Reference in a new issue