Skip to content

Commit 2fc8cb4

Browse files
committed
Changed skeleton structure and added all functionality.
1 parent c6e47ca commit 2fc8cb4

34 files changed

+820
-724
lines changed

.babelrc

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
2-
"presets": [
3-
["es2015", { "modules": false }]
4-
],
5-
"plugins": [
6-
"external-helpers"
7-
]
8-
}
2+
"presets": ["es2015", "stage-2"],
3+
"plugins": ["transform-runtime"],
4+
"comments": false
5+
}

.gitignore

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
*.log
21
.DS_Store
3-
node_modules
4-
dist
5-
.idea
2+
node_modules/
3+
npm-debug.log
4+
dist/
5+
es/

LICENSE

-21
This file was deleted.

README.md

-49
Original file line numberDiff line numberDiff line change
@@ -1,49 +0,0 @@
1-
Vue-Froala
2-
========
3-
4-
Vue wrapper module for the Froala editor.
5-
6-
* Supports both Vue 1.0 and Vue 2.0
7-
8-
## Requirements
9-
10-
- Vue: ^1.0.0 or ^2.0.0
11-
12-
## Install
13-
14-
From npm:
15-
16-
``` sh
17-
18-
$ npm install vue-froala --save
19-
20-
```
21-
22-
## Usage
23-
24-
See `/demo` folder for a usage example.
25-
26-
## Development
27-
28-
Run `node build.js` to convert your ES6 to an ES5 compatible build file
29-
30-
## Default Options
31-
```
32-
{
33-
toolbarButtons: ['bold', 'italic', 'underline', '|', 'paragraphFormat', 'align', 'formatOL', 'formatUL', 'insertTable', '|', 'insertLink', 'insertImage', 'insertVideo', 'insertFile', '|', 'undo', 'redo', 'clearFormatting', 'fullscreen', '|', 'html'],
34-
toolbarButtonsMD: ['bold', 'italic', 'underline', '|', 'paragraphFormat', 'align', 'formatOL', 'formatUL', 'insertTable', '|', 'insertLink', '|', 'undo', 'redo', 'clearFormatting', '|', 'html'],
35-
toolbarButtonsSM: ['bold', 'italic', 'underline', '|', 'insertLink', '|', 'undo', 'redo', 'clearFormatting'],
36-
toolbarButtonsXS: ['bold', 'italic', 'underline', '|', 'insertLink', '|', 'undo', 'redo', 'clearFormatting'],
37-
paragraphFormat: {
38-
n: 'Normal',
39-
h2: 'Heading 2',
40-
h3: 'Heading 3',
41-
h4: 'Heading 4',
42-
blockquote: 'Quote',
43-
pre: 'Code'
44-
},
45-
codeMirror: true,
46-
height: 400,
47-
theme: 'gray'
48-
}
49-
```

build.js

-54
This file was deleted.

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 UMD module...')
18+
spinner.start()
19+
20+
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
21+
rm('-rf', assetsPath)
22+
mkdir('-p', assetsPath)
23+
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

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

build/dev-server.js

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

build/utils.js

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

build/webpack.base.conf.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
var path = require('path')
2+
var config = require('../config')
3+
var utils = require('./utils')
4+
var projectRoot = path.resolve(__dirname, '../')
5+
6+
module.exports = {
7+
entry: {
8+
main: './src/main.js',
9+
},
10+
output: {
11+
path: config.build.assetsRoot,
12+
publicPath: config.build.assetsPublicPath,
13+
filename: '[name].js'
14+
},
15+
resolve: {
16+
extensions: ['', '.js', '.vue'],
17+
fallback: [path.join(__dirname, '../node_modules')],
18+
alias: {
19+
'src': path.resolve(__dirname, '../src')
20+
}
21+
},
22+
resolveLoader: {
23+
fallback: [path.join(__dirname, '../node_modules')]
24+
},
25+
module: {
26+
loaders: [
27+
{
28+
test: /\.vue$/,
29+
loader: 'vue'
30+
},
31+
{
32+
test: /\.js$/,
33+
loader: 'babel',
34+
include: projectRoot,
35+
exclude: /node_modules/
36+
},
37+
{
38+
test: /\.json$/,
39+
loader: 'json'
40+
},
41+
{
42+
test: /\.html$/,
43+
loader: 'vue-html'
44+
},
45+
{
46+
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
47+
loader: 'file',
48+
query: {
49+
limit: 10000,
50+
name: utils.assetsPath('img/[name].[ext]')
51+
}
52+
},
53+
{
54+
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
55+
loader: 'url',
56+
query: {
57+
limit: 10000,
58+
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
59+
}
60+
}
61+
]
62+
},
63+
vue: {
64+
loaders: utils.cssLoaders()
65+
}
66+
}

0 commit comments

Comments
 (0)