App.vue 1.5 KB
Newer Older
璃白.'s avatar
璃白. 已提交
1
<template>
璃白.'s avatar
璃白. 已提交
2 3
  <div :class="['md_container', { active: isFocus }]">
    <markdown-header />
G
guoweijia 已提交
4 5
    <markdownPreview v-show="showPreview" />
    <markdown-editor v-show="!showPreview" />
璃白.'s avatar
璃白. 已提交
6 7 8 9
    <markdown-footer
      :can-attach-file="canAttachFile"
      v-if="!showPreview && canAttachFile"
    />
璃白.'s avatar
璃白. 已提交
10 11 12
  </div>
</template>
<script>
璃白.'s avatar
璃白. 已提交
13 14 15 16 17
import markdownHeader from "./components/header/md-header";
import markdownFooter from "./components/footer/md-footer";
import markdownEditor from "./components/content/md-textarea";
import markdownPreview from "./components/content/md-preview";
import { mapState } from "vuex";
璃白.'s avatar
璃白. 已提交
18
export default {
璃白.'s avatar
璃白. 已提交
19 20 21 22 23
  components: {
    markdownHeader,
    markdownFooter,
    markdownEditor,
    markdownPreview
璃白.'s avatar
璃白. 已提交
24
  },
璃白.'s avatar
璃白. 已提交
25
  computed: {
G
guoweijia 已提交
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
    ...mapState([
      "showPreview",
      "isFocus",
      "canAttachFile",
      "text",
      "html",
      "fileList"
    ])
  },
  watch: {
    html: {
      immediate: true,
      handler: function(val) {
        this.$emit("change", {
          text: this.text,
          html: this.html
        });
      }
    },
    fileList: {
      immediate: false,
      deep: true,
      handler: function(val) {
        this.$emit("upload", val);
      }
    }
璃白.'s avatar
璃白. 已提交
52 53 54 55 56
  }
};
</script>
<style lang="less" scoped>
.md_container {
璃白.'s avatar
璃白. 已提交
57 58
  width: 100%;
  // margin: 200px auto;
璃白.'s avatar
璃白. 已提交
59
  border: 1px solid var(--md-editor-border-color);
璃白.'s avatar
璃白. 已提交
60 61 62
  border-radius: 4px;
  padding: 10px 16px;
  box-sizing: border-box;
璃白.'s avatar
璃白. 已提交
63 64
  transition: border 0.3s;
  &.active {
璃白.'s avatar
璃白. 已提交
65
    border: 1px solid var(--md-editor-border-color-active);
璃白.'s avatar
璃白. 已提交
66 67 68
  }
}
</style>