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
| <template>
| <div class="app-container">
| <p class="warn-content">
| Markdown 基于
| <el-link type="primary" href="https://github.com/hinesboy/mavonEditor" target="_blank">MavonEditor</el-link>
| </p>
| <mavon-editor ref="md" :style="'height:' + height" @imgAdd="imgAdd" />
| </div>
| </template>
|
| <script>
| import { upload } from '@/utils/upload'
| import { mapGetters } from 'vuex'
| import { mavonEditor } from 'mavon-editor'
| import 'mavon-editor/dist/css/index.css'
|
| export default {
| name: 'Markdown',
| components: {
| mavonEditor
| },
| data() {
| return {
| height: document.documentElement.clientHeight - 200 + 'px'
| }
| },
| computed: {
| ...mapGetters([
| 'imagesUploadApi',
| 'baseApi'
| ])
| },
| mounted() {
| const that = this
| window.onresize = function temp() {
| that.height = document.documentElement.clientHeight - 200 + 'px'
| }
| },
| methods: {
| imgAdd(pos, $file) {
| upload(this.imagesUploadApi, $file).then(res => {
| const data = res.data
| const url = this.baseApi + '/file/' + data.type + '/' + data.realName
| this.$refs.md.$img2Url(pos, url)
| })
| }
| }
| }
| </script>
|
| <style scoped>
| .v-note-wrapper.shadow {
| z-index: 5;
| }
| </style>
|
|