forked from NikulinIlya/vue-easymde
/
index.vue
72 lines (63 loc) 路 1.8 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
<template>
<div>
<!-- use v-model control value -->
<vue-easyemde v-model="content" ref="markdownEditor"/>
<!-- use event control value -->
<vue-easyemde :value="content" @input="handleInput"/>
<!-- add config -->
<vue-easyemde :configs="configs"/>
<!-- disable auto init -->
<vue-easyemde :autoinit="false"/>
</div>
</template>
<script>
import VueEasymde from 'vue-easymde';
// Complete example
export default {
components: {
VueEasymde,
},
data() {
return {
content: '',
configs: {
status: false, // disable the status bar at the bottom
spellChecker: false // disable spell check
},
};
},
computed: {
easymde() {
return this.$refs.markdownEditor.easymde;
},
},
mounted() {
console.log(this.easymde);
this.easymde.togglePreview();
// 'change' event 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.easymde.codemirror.on('beforeChange', (instance, changeObj) => {
// do some things
});
// remove EasyMDE, when component destroy will invoke
this.easymde = null;
// some useful methods
this.$refs.markdownEditor.initialize(); // init
this.easymde.toTextArea();
this.easymde.isPreviewActive(); // returns boolean
this.easymde.isSideBySideActive(); // returns boolean
this.easymde.isFullscreenActive(); // returns boolean
this.easymde.clearAutosavedValue(); // no returned value
this.easymde.markdown(this.content); // returns parsed html
this.easymde.codemirror.refresh(); // refresh codemirror
},
methods: {
handleInput() {
// do some things
},
},
};
</script>
<style>
@import '~easymde/dist/easymde.min.css';
</style>