summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/static_site_editor/components/edit_area.vue
blob: dff21d919a9f4563171f348438fceb411fdc40f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<script>
import RichContentEditor from '~/vue_shared/components/rich_content_editor/rich_content_editor.vue';
import PublishToolbar from './publish_toolbar.vue';
import EditHeader from './edit_header.vue';

export default {
  components: {
    RichContentEditor,
    PublishToolbar,
    EditHeader,
  },
  props: {
    title: {
      type: String,
      required: true,
    },
    content: {
      type: String,
      required: true,
    },
    savingChanges: {
      type: Boolean,
      required: true,
    },
    returnUrl: {
      type: String,
      required: false,
      default: '',
    },
  },
  data() {
    return {
      editableContent: this.content,
      saveable: false,
    };
  },
  computed: {
    modified() {
      return this.content !== this.editableContent;
    },
  },
  methods: {
    onSubmit() {
      this.$emit('submit', { content: this.editableContent });
    },
  },
};
</script>
<template>
  <div class="d-flex flex-grow-1 flex-column">
    <edit-header class="py-2" :title="title" />
    <rich-content-editor v-model="editableContent" class="mb-9" />
    <publish-toolbar
      class="gl-fixed gl-left-0 gl-bottom-0 gl-w-full"
      :return-url="returnUrl"
      :saveable="modified"
      :saving-changes="savingChanges"
      @submit="onSubmit"
    />
  </div>
</template>