You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.1 KiB

  1. <template lang="pug">
  2. div.columns.is-gapless#editor(v-cloak="")
  3. div.column.is-6
  4. textarea.editorMarkdown_textarea(v-bind:value="input", v-debounce="update")
  5. div.column.is-6.has-background-white
  6. div.content.pt20.pb20.pr20.pl20
  7. div(v-html="compiledMarkdown")
  8. </template>
  9. <style scoped>
  10. .column.is-6.has-background-white {
  11. border-right: 1px solid #dbdbdb;
  12. border-top: 1px solid #dbdbdb;
  13. border-bottom: 1px solid #dbdbdb;
  14. }
  15. .content {
  16. line-height: 150%;
  17. }
  18. </style>
  19. <script>
  20. import * as marked from 'marked';
  21. import HTTP from './http';
  22. export default {
  23. data: () => ({
  24. input: '',
  25. project: Object,
  26. }),
  27. computed: {
  28. compiledMarkdown() {
  29. return marked(this.input, {
  30. sanitize: true,
  31. });
  32. },
  33. },
  34. created() {
  35. HTTP.get().then((response) => {
  36. this.input = response.data.guideline;
  37. this.project = response.data;
  38. });
  39. },
  40. methods: {
  41. update(value) {
  42. this.input = value;
  43. const payload = {
  44. guideline: this.input,
  45. };
  46. HTTP.patch('', payload).then((response) => {
  47. this.project = response.data;
  48. });
  49. },
  50. },
  51. };
  52. </script>