Skip to content

Commit 9d4f618

Browse files
author
- -
committed
base
1 parent 0999339 commit 9d4f618

File tree

7 files changed

+171
-2
lines changed

7 files changed

+171
-2
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Dependency directories
7+
node_modules
8+
9+
# Optional npm cache directory
10+
.npm

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/*
2+
npm-debug.log*
3+
examples
4+
/examples
5+
examples/*

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Simon Babay
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,60 @@
1-
# vue-simplemde
2-
SimpleMDE - Markdown Editor component for Vue.js
1+
# Vue-SimpleMDE
2+
> SimpleMDE - Markdown Editor component for Vue.js
3+
4+
[![NPM](https://nodei.co/npm/vue-simplemde.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/vue-simplemde/)
5+
6+
# Example
7+
[Demo Page](https://F-loat.github.io/vue-simplemde/)
8+
9+
# Use Setup
10+
11+
## Install vue-simplemde
12+
13+
``` bash
14+
npm install vue-simplemde --save
15+
```
16+
17+
## Use
18+
``` javascript
19+
// import with ES6
20+
import Vue from 'vue'
21+
import VueSimplemde from 'vue-simplemde'
22+
23+
// require with Webpack/Node.js
24+
var Vue = require('vue')
25+
var VueSimplemde = require('vue-simplemde')
26+
27+
// use
28+
Vue.use(VueSimplemde)
29+
```
30+
31+
``` javascript
32+
// or use with component(ES6)
33+
import { markdownEditor } from 'vue-simplemde'
34+
35+
// use
36+
export default {
37+
components: {
38+
markdownEditor
39+
}
40+
}
41+
```
42+
43+
## Template
44+
``` html
45+
<!-- 通过 v-model 控制 value -->
46+
<markdown-editor v-model="content"></markdown-editor>
47+
48+
<!-- 通过事件控制 value -->
49+
<markdown-editor :value="content" @input="handleInput"></markdown-editor>
50+
```
51+
52+
## Dependencies
53+
54+
* [SimpleMDE](https://github.com/NextStepWebs/simplemde-markdown-editor)
55+
56+
## Licence
57+
58+
vue-simplemde is open source and released under the MIT Licence.
59+
60+
Copyright (c) 2016 F-loat

index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* vue-simplemde
3+
* @author F-loat
4+
*/
5+
6+
import markdownEditor from './markdown-editor'
7+
8+
const VueSimplemde = {
9+
markdownEditor,
10+
install (Vue) {
11+
Vue.component('markdown-editor', markdownEditor)
12+
}
13+
}
14+
15+
module.exports = VueSimplemde

markdown-editor.vue

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<template>
2+
<textarea class="markdown-editor"></textarea>
3+
</template>
4+
5+
<script>
6+
import SimpleMDE from 'simplemde'
7+
import 'simplemde/dist/simplemde.min.css'
8+
9+
export default {
10+
name: 'markdown-editor',
11+
props: {
12+
value: String
13+
},
14+
mounted () {
15+
this.initialize()
16+
},
17+
methods: {
18+
initialize () {
19+
this.simplemde = new SimpleMDE({ element: this.$el })
20+
this.simplemde.value(this.value)
21+
22+
// 绑定输入事件
23+
this.simplemde.codemirror.on('change', () => {
24+
this.$emit('input', this.simplemde.value())
25+
})
26+
}
27+
},
28+
watch: {
29+
value (val) {
30+
this.simplemde.value(val)
31+
}
32+
}
33+
}
34+
</script>

package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "vue-simplemde",
3+
"version": "0.1.4",
4+
"description": "SimpleMDE - Markdown Editor component for Vue.js",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [
10+
"Vue",
11+
"SimpleMDE",
12+
"Markdown"
13+
],
14+
"author": {
15+
"name": "F-loat",
16+
"email": "chaimaoyuan@foxmail.com"
17+
},
18+
"license": "MIT",
19+
"dependencies": {
20+
"simplemde": "^1.11.2"
21+
},
22+
"repository": {
23+
"type": "git",
24+
"url": "https://github.com/F-loat/vue-simplemde.git"
25+
}
26+
}

0 commit comments

Comments
 (0)