From 9a3ce0207c81599aed8f06d567f41e76ec4020d6 Mon Sep 17 00:00:00 2001 From: ivictbor Date: Wed, 28 Jun 2017 11:29:04 +0300 Subject: [PATCH] fix when params not passed, generating file with version --- .gitignore | 2 +- README.md | 16 ++++++++++++++++ build/index.html | 11 +++-------- js/main.js | 2 +- js/params.js | 1 + package.json | 2 +- webpack.config.js | 13 ++++++++++++- 7 files changed, 35 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index d7e93b2..3c815d1 100644 --- a/.gitignore +++ b/.gitignore @@ -60,4 +60,4 @@ typings/ .idea # custom -build/painterro.* +build/painterro* diff --git a/README.md b/README.md index b7729f9..1e715b5 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Table of contents ================= * [Table of contents](#table-of-contents) + * [Installation](#installation) * [Supported hotkeys](#supported-hotkeys) * [Configuration](#configuration) * [UI color scheme](#ui-color-scheme) @@ -39,6 +40,21 @@ Table of contents * [ToDo list](#todo-list) +Installation +============ + +If you are using npm you can run: +```bash +npm install painterro --save +``` +Then in your code + +```js +import Painterro from 'painterro' +... +Painterro().show() +``` + Supported hotkeys ================= diff --git a/build/index.html b/build/index.html index bf2cde3..8e4db5f 100644 --- a/build/index.html +++ b/build/index.html @@ -28,7 +28,8 @@ - + + diff --git a/js/main.js b/js/main.js index a284a62..3796c80 100644 --- a/js/main.js +++ b/js/main.js @@ -381,7 +381,7 @@ class PainterroProc { '' + rightBar + '' + '' + '' + - ``; + ``; this.saveBtn = document.getElementById(this.tools.filter((t) => t.name === 'save')[0].buttonId); this.saveBtn.setAttribute('disabled', true); diff --git a/js/params.js b/js/params.js index 23a8e15..625ec6d 100644 --- a/js/params.js +++ b/js/params.js @@ -1,6 +1,7 @@ import { HexToRGBA } from './colorPicker'; export function setDefaults(params) { + params = params || {}; params.activeColor = params.activeColor || "#ff0000"; params.activeColorAlpha = params.activeColorAlpha || 1.0; params.activeAlphaColor = HexToRGBA(params.activeColor, params.activeColorAlpha); diff --git a/package.json b/package.json index b2b887f..f0dc6a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "painterro", - "version": "0.1.4", + "version": "0.1.5", "description": "Embуedded html image editor", "main": "build/painterro.commonjs2.js", "scripts": { diff --git a/webpack.config.js b/webpack.config.js index 5ccb2bd..adf9d71 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,11 +3,21 @@ var webpack = require('webpack'); function webpackConfig(target) { + let filename; + if (target === 'var') { + filename = `painterro-${require("./package.json").version}.min.js` + } else if (target === 'var-latest') { + filename = `painterro.min.js` + target = 'var' + } else { + filename = `painterro.${target}.js` + } + return { entry: './js/main.js', output: { path: path.resolve(__dirname, 'build'), - filename: `painterro.${target == 'var' && '' || target}.js`, + filename: filename, library: 'Painterro', // export as library libraryTarget: target }, @@ -46,6 +56,7 @@ function webpackConfig(target) { module.exports = [ webpackConfig('var'), + webpackConfig('var-latest'), webpackConfig('commonjs2'), webpackConfig('amd'), webpackConfig('umd')