forked from F-loat/vue-simplemde
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.vue
87 lines (77 loc) · 2.17 KB
/
index.vue
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<template>
<div>
<!-- use v-model control value -->
<vue-simplemde v-model="content" ref="markdownEditor" />
<!-- use event control value -->
<vue-simplemde :value="content" @input="handleInput" />
<!-- add config -->
<vue-simplemde :configs="configs" />
<!-- disable auto init -->
<vue-simplemde :autoinit="false" />
</div>
</template>
<script>
import VueSimplemde from 'vue-simplemde/src/vue-simplemde'
// Base example
export default {
components: {
VueSimplemde
},
data () {
return {
content: '',
configs: {
spellChecker: false // disable spell check
}
}
}
}
// Complete example
export default {
components: {
VueSimplemde
},
data () {
return {
content: '',
configs: {
status: false, // disable the status bar at the bottom
spellChecker: false // disable spell check
}
}
},
computed: {
simplemde () {
return this.$refs.markdownEditor.simplemde
}
},
mounted () {
console.log(this.simplemde)
this.simplemde.togglePreview()
// 'change' envent has bound, via @input attache an event listener
// You can attache events in this [list](https://codemirror.net/doc/manual.html#events) yourself if necessary
this.simplemde.codemirror.on('beforeChange', (instance, changeObj) => {
// do some things
})
// remove SimpleMDE, when component destroy will invoke
this.simplemde = null
// some useful methods
this.$refs.markdownEditor.initialize() // init
this.simplemde.toTextArea()
this.simplemde.isPreviewActive() // returns boolean
this.simplemde.isSideBySideActive() // returns boolean
this.simplemde.isFullscreenActive() // returns boolean
this.simplemde.clearAutosavedValue() // no returned value
this.simplemde.markdown(this.content) // returns parsed html
this.simplemde.codemirror.refresh() // refresh codemirror
},
methods: {
handleInput () {
// do some things
}
}
}
</script>
<style>
@import '~simplemde/dist/simplemde.min.css';
</style>