diff --git a/components/Editor/Editor.vue b/components/Editor/Editor.vue
index 9e25e1daa..2a68da45a 100644
--- a/components/Editor/Editor.vue
+++ b/components/Editor/Editor.vue
@@ -71,19 +71,19 @@
')
+ .replace(/(\r\n|\n\r|\r|\n)/g, '
$1')
// replace all p tags with line breaks (and spaces) only by single linebreaks
// limit linebreaks to max 2 (equivalent to html "br" linebreak)
diff --git a/pages/post/_slug/edit/_id.vue b/pages/post/_slug/edit/_id.vue
index c39423f11..2366ab65f 100644
--- a/pages/post/_slug/edit/_id.vue
+++ b/pages/post/_slug/edit/_id.vue
@@ -3,7 +3,7 @@
:width="{ base: '100%' }"
gutter="base"
>
-
+
@@ -14,6 +14,8 @@
>
@@ -38,25 +40,59 @@ export default {
},
data() {
return {
- content: ''
+ content: '',
+ loading: false,
+ disabled: false,
+ slug: null
}
},
watch: {
Post: {
immediate: true,
handler: function(post) {
- console.log('try to set content', this.content, post)
if (!post || !post[0].content) {
return
}
- console.log(post[0].content)
+ this.slug = post[0].slug
this.content = post[0].content
}
}
},
methods: {
save() {
- console.log(this.content)
+ this.loading = true
+ this.$apollo
+ .mutate({
+ mutation: gql`
+ mutation($id: ID!, $content: String!) {
+ UpdatePost(id: $id, content: $content) {
+ id
+ slug
+ content
+ contentExcerpt
+ }
+ }
+ `,
+ variables: {
+ id: 'p1',
+ content: this.content
+ }
+ })
+ .then(data => {
+ this.loading = false
+ this.$toast.success('Saved!')
+ this.disabled = true
+
+ this.$router.push({
+ name: 'post-slug',
+ params: { slug: this.slug }
+ })
+ })
+ .catch(err => {
+ this.$toast.error(err.message)
+ this.loading = false
+ this.disabled = false
+ })
}
//onUpdate(data) {
// console.log('onUpdate', data)