Skip to content

Commit 3752693

Browse files
committed
first commit
0 parents  commit 3752693

33 files changed

+6838
-0
lines changed

.babelrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": ["es2015", "stage-2"],
3+
"plugins": ["transform-runtime"],
4+
"comments": false
5+
}

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/*.js
2+
config/*.js

.eslintrc.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
root: true,
3+
parser: 'babel-eslint',
4+
parserOptions: {
5+
sourceType: 'module'
6+
},
7+
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
8+
extends: 'standard',
9+
// required to lint *.vue files
10+
plugins: [
11+
'html'
12+
],
13+
// add your custom rules here
14+
'rules': {
15+
// allow paren-less arrow functions
16+
'arrow-parens': 0,
17+
// allow async-await
18+
'generator-star-spacing': 0,
19+
// allow debugger during development
20+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
21+
}
22+
}

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.DS_Store
2+
node_modules/
3+
dist/
4+
npm-debug.log
5+
test/unit/coverage
6+
test/e2e/reports
7+
selenium-debug.log
8+
.idea/
9+
.idea/encodings.xml
10+
.idea/hbb_growup_console2.iml
11+
.idea/jsLibraryMappings.xml
12+
.idea/misc.xml
13+
.idea/modules.xml
14+
.idea/vcs.xml
15+
.idea/workspace.xml

README.md

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Vue summernote plugin
2+
3+
> 一个Vue集成[summernote](http://summernote.org/)富文本插件
4+
5+
![](https://img.shields.io/npm/dm/vue-summernote.svg)
6+
![](https://img.shields.io/npm/v/vue-summernote.svg)
7+
8+
## Requirements
9+
10+
+ jQuery
11+
+ BootStrap
12+
+ summernote
13+
14+
15+
## Installation
16+
17+
``` bash
18+
npm i vue-summernote -S
19+
```
20+
21+
## Usage
22+
23+
使用须知:
24+
25+
**插件目前仅支持vue2.0以上版本**
26+
27+
### Install plugin
28+
29+
编辑`main.js`
30+
31+
``` javascript
32+
import VueSummernote from 'vue-summernote'
33+
34+
require('bootstrap')
35+
require('bootstrap/dist/css/bootstrap.min.css')
36+
37+
Vue.use(VueSummernote)
38+
```
39+
40+
编辑`webpack.base.conf.js`
41+
42+
**因为summernote依赖于BootStrap,而Bootstrap严重依赖jQuery,这里需要配置jQuery为全局使用,不然会报错,找不到jQuery**
43+
44+
``` javascript
45+
var webpack = require('webpack')
46+
var jquery = require('jquery')
47+
48+
module.exports = {
49+
plugins: [
50+
new webpack.ProvidePlugin({
51+
$: "jquery",
52+
jQuery: "jquery"
53+
})
54+
]
55+
}
56+
```
57+
58+
59+
### Examples
60+
61+
```
62+
<template>
63+
<div>
64+
<vue-summernote ref="editer" :callbacks="callbacks"></vue-summernote>
65+
<button @click="getVal">提交</button>
66+
</div>
67+
</template>
68+
69+
<script>
70+
let $editer
71+
export default {
72+
mounted () {
73+
$editer = this.$refs.editer
74+
},
75+
methods: {
76+
getVal () {
77+
console.log($editer.run('code'))
78+
}
79+
},
80+
data () {
81+
return {
82+
callbacks: {
83+
onImageUpload: function (files) {
84+
// 这里做上传图片的操作,上传成功之后便可以用到下面这句将图片插入到编辑框中
85+
$editer.run('insertImage', 'http://vuefe.cn/images/logo.png')
86+
}
87+
}
88+
}
89+
}
90+
}
91+
</script>
92+
```
93+
94+
### Props
95+
96+
| 参数 | 说明 | 类型 | 默认值
97+
| :--: | :--: | :--: | :--:
98+
| placeholder |占位符| String | '请输入内容'
99+
| height |富文本编辑器高度 | Number | 500
100+
| minHeight |富文本编辑器最小高度 | Number | 200
101+
| maxHeight |富文本编辑器最大高度 | Number | 700
102+
| focus | 富文本编辑器焦点 | Boolean | true
103+
| callbacks | 事件回调函数集合[参考summernote文档](http://summernote.org/deep-dive/#callbacks) | Object | 无
104+
105+
### Mothods
106+
107+
#### run(code, value)
108+
109+
参数说明:
110+
111+
| 参数 | 说明 | 类型 | 必需
112+
| :--: | :--: | :--: | :--:
113+
| code |对应[summernote API](http://summernote.org/deep-dive/#basic-api)的code| String | 是
114+
| value |传递的值 | String/Number | 否
115+
116+
## License
117+
118+
[MIT](http://opensource.org/licenses/MIT)

build/build.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// https://github.com/shelljs/shelljs
2+
require('shelljs/global')
3+
env.NODE_ENV = 'production'
4+
5+
var path = require('path')
6+
var config = require('../config')
7+
var ora = require('ora')
8+
var webpack = require('webpack')
9+
var webpackConfig = require('./webpack.prod.conf')
10+
11+
console.log(
12+
' Tip:\n' +
13+
' Built files are meant to be served over an HTTP server.\n' +
14+
' Opening index.html over file:// won\'t work.\n'
15+
)
16+
17+
var spinner = ora('building for production...')
18+
spinner.start()
19+
20+
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
21+
rm('-rf', assetsPath)
22+
mkdir('-p', assetsPath)
23+
cp('-R', 'static/*', assetsPath)
24+
25+
webpack(webpackConfig, function (err, stats) {
26+
spinner.stop()
27+
if (err) throw err
28+
process.stdout.write(stats.toString({
29+
colors: true,
30+
modules: false,
31+
children: false,
32+
chunks: false,
33+
chunkModules: false
34+
}) + '\n')
35+
})

build/dev-client.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* eslint-disable */
2+
require('eventsource-polyfill')
3+
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
4+
5+
hotClient.subscribe(function (event) {
6+
if (event.action === 'reload') {
7+
window.location.reload()
8+
}
9+
})

build/dev-server.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
var path = require('path')
2+
var express = require('express')
3+
var webpack = require('webpack')
4+
var config = require('../config')
5+
var opn = require('opn')
6+
var proxyMiddleware = require('http-proxy-middleware')
7+
var webpackConfig = process.env.NODE_ENV === 'testing'
8+
? require('./webpack.prod.conf')
9+
: require('./webpack.dev.conf')
10+
11+
// default port where dev server listens for incoming traffic
12+
var port = process.env.PORT || config.dev.port
13+
// Define HTTP proxies to your custom API backend
14+
// https://github.com/chimurai/http-proxy-middleware
15+
var proxyTable = config.dev.proxyTable
16+
17+
var app = express()
18+
var compiler = webpack(webpackConfig)
19+
20+
var devMiddleware = require('webpack-dev-middleware')(compiler, {
21+
publicPath: webpackConfig.output.publicPath,
22+
stats: {
23+
colors: true,
24+
chunks: false
25+
}
26+
})
27+
28+
var hotMiddleware = require('webpack-hot-middleware')(compiler)
29+
// force page reload when html-webpack-plugin template changes
30+
compiler.plugin('compilation', function (compilation) {
31+
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
32+
hotMiddleware.publish({ action: 'reload' })
33+
cb()
34+
})
35+
})
36+
37+
// proxy api requests
38+
Object.keys(proxyTable).forEach(function (context) {
39+
var options = proxyTable[context]
40+
if (typeof options === 'string') {
41+
options = { target: options }
42+
}
43+
app.use(proxyMiddleware(context, options))
44+
})
45+
46+
// handle fallback for HTML5 history API
47+
app.use(require('connect-history-api-fallback')())
48+
49+
// serve webpack bundle output
50+
app.use(devMiddleware)
51+
52+
// enable hot-reload and state-preserving
53+
// compilation error display
54+
app.use(hotMiddleware)
55+
56+
// serve pure static assets
57+
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
58+
app.use(staticPath, express.static('./static'))
59+
60+
module.exports = app.listen(port, function (err) {
61+
if (err) {
62+
console.log(err)
63+
return
64+
}
65+
var uri = 'http://localhost:' + port
66+
console.log('Listening at ' + uri + '\n')
67+
opn(uri)
68+
})

build/utils.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
var path = require('path')
2+
var config = require('../config')
3+
var ExtractTextPlugin = require('extract-text-webpack-plugin')
4+
5+
exports.assetsPath = function (_path) {
6+
var assetsSubDirectory = process.env.NODE_ENV === 'production'
7+
? config.build.assetsSubDirectory
8+
: config.dev.assetsSubDirectory
9+
return path.posix.join(assetsSubDirectory, _path)
10+
}
11+
12+
exports.cssLoaders = function (options) {
13+
options = options || {}
14+
// generate loader string to be used with extract text plugin
15+
function generateLoaders (loaders) {
16+
var sourceLoader = loaders.map(function (loader) {
17+
var extraParamChar
18+
if (/\?/.test(loader)) {
19+
loader = loader.replace(/\?/, '-loader?')
20+
extraParamChar = '&'
21+
} else {
22+
loader = loader + '-loader'
23+
extraParamChar = '?'
24+
}
25+
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
26+
}).join('!')
27+
28+
if (options.extract) {
29+
return ExtractTextPlugin.extract('vue-style-loader', sourceLoader)
30+
} else {
31+
return ['vue-style-loader', sourceLoader].join('!')
32+
}
33+
}
34+
35+
// http://vuejs.github.io/vue-loader/configurations/extract-css.html
36+
return {
37+
css: generateLoaders(['css']),
38+
postcss: generateLoaders(['css']),
39+
less: generateLoaders(['css', 'less']),
40+
sass: generateLoaders(['css', 'sass?indentedSyntax']),
41+
scss: generateLoaders(['css', 'sass']),
42+
stylus: generateLoaders(['css', 'stylus']),
43+
styl: generateLoaders(['css', 'stylus'])
44+
}
45+
}
46+
47+
// Generate loaders for standalone style files (outside of .vue)
48+
exports.styleLoaders = function (options) {
49+
var output = []
50+
var loaders = exports.cssLoaders(options)
51+
for (var extension in loaders) {
52+
var loader = loaders[extension]
53+
output.push({
54+
test: new RegExp('\\.' + extension + '$'),
55+
loader: loader
56+
})
57+
}
58+
return output
59+
}

0 commit comments

Comments
 (0)