diff --git a/assets/script.js b/assets/script.js index 3620ffa..5b5686f 100644 --- a/assets/script.js +++ b/assets/script.js @@ -78,10 +78,8 @@ function openEditor() { // Update body: rendered.innerHTML = result.rendered; - if (result.conflict) { - form.elements.title.value = result.title; - form.elements.body.value = result.body; - } + form.elements.title.value = result.title; + shadow.value = textarea.value = result.body; // Update form: form.elements.base_revision.value = result.revision; @@ -94,6 +92,7 @@ function openEditor() { } textarea.disabled = false; + autosizeTextarea(textarea, shadow); if (result.conflict) { alert("Your edit came into conflict with another change and has not been saved.\n" + diff --git a/src/resources/article_resource.rs b/src/resources/article_resource.rs index cdda16a..5d5b4b4 100644 --- a/src/resources/article_resource.rs +++ b/src/resources/article_resource.rs @@ -137,7 +137,7 @@ impl Resource for ArticleResource { slug: &'a str, revision: i32, title: &'a str, - body: Option<&'a str>, + body: &'a str, rendered: &'a str, last_updated: &'a str, } @@ -162,7 +162,7 @@ impl Resource for ArticleResource { slug: &updated.slug, revision: updated.revision, title: &updated.title, - body: None, + body: &updated.body, rendered: &Template { title: &updated.title, rendered: render_markdown(&updated.body), @@ -187,7 +187,7 @@ impl Resource for ArticleResource { slug: &base_article.slug, revision: base_article.revision, title: &title, - body: Some(&body), + body: &body, rendered: &Template { title: &title, rendered: render_markdown(&body), diff --git a/src/resources/new_article_resource.rs b/src/resources/new_article_resource.rs index c17aca3..cceceab 100644 --- a/src/resources/new_article_resource.rs +++ b/src/resources/new_article_resource.rs @@ -120,6 +120,7 @@ impl Resource for NewArticleResource { article_id: i32, revision: i32, title: &'a str, + body: &'a str, rendered: &'a str, last_updated: &'a str, } @@ -146,6 +147,7 @@ impl Resource for NewArticleResource { article_id: updated.article_id, revision: updated.revision, title: &updated.title, + body: &updated.body, rendered: &Template { title: &updated.title, rendered: render_markdown(&updated.body),