Skip to content

Commit 9a3ce02

Browse files
committed
fix when params not passed, generating file with version
1 parent ec800fb commit 9a3ce02

7 files changed

Lines changed: 35 additions & 12 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ typings/
6060
.idea
6161

6262
# custom
63-
build/painterro.*
63+
build/painterro*

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Table of contents
2525
=================
2626

2727
* [Table of contents](#table-of-contents)
28+
* [Installation](#installation)
2829
* [Supported hotkeys](#supported-hotkeys)
2930
* [Configuration](#configuration)
3031
* [UI color scheme](#ui-color-scheme)
@@ -39,6 +40,21 @@ Table of contents
3940
* [ToDo list](#todo-list)
4041

4142

43+
Installation
44+
============
45+
46+
If you are using npm you can run:
47+
```bash
48+
npm install painterro --save
49+
```
50+
Then in your code
51+
52+
```js
53+
import Painterro from 'painterro'
54+
...
55+
Painterro().show()
56+
```
57+
4258
Supported hotkeys
4359
=================
4460

build/index.html

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
</div>
2929
</div>
3030

31-
<script src="/painterro.js"></script>
31+
<script src="/painterro.min.js"></script>
32+
3233
<script>
3334

3435
// Painterro({
@@ -42,13 +43,7 @@
4243
// }
4344
// });
4445

45-
Painterro({
46-
id: 'conatiner',
47-
activeColor: '#00b400',
48-
// defaultSize: '200x100',
49-
colorScheme: {
50-
}
51-
}).show();
46+
Painterro().show();
5247
</script>
5348
</body>
5449
</html>

js/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ class PainterroProc {
381381
'<span class="ptro-bar-right">' + rightBar + '</span>' +
382382
'<input id="ptro-file-input" type="file" style="display: none;" accept="image/x-png,image/gif,image/jpeg" />' +
383383
'</div>' +
384-
`<style>${params.styles}</style>`;
384+
`<style>${this.params.styles}</style>`;
385385

386386
this.saveBtn = document.getElementById(this.tools.filter((t) => t.name === 'save')[0].buttonId);
387387
this.saveBtn.setAttribute('disabled', true);

js/params.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { HexToRGBA } from './colorPicker';
22

33
export function setDefaults(params) {
4+
params = params || {};
45
params.activeColor = params.activeColor || "#ff0000";
56
params.activeColorAlpha = params.activeColorAlpha || 1.0;
67
params.activeAlphaColor = HexToRGBA(params.activeColor, params.activeColorAlpha);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "painterro",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"description": "Embуedded html image editor",
55
"main": "build/painterro.commonjs2.js",
66
"scripts": {

webpack.config.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@ var webpack = require('webpack');
33

44

55
function webpackConfig(target) {
6+
let filename;
7+
if (target === 'var') {
8+
filename = `painterro-${require("./package.json").version}.min.js`
9+
} else if (target === 'var-latest') {
10+
filename = `painterro.min.js`
11+
target = 'var'
12+
} else {
13+
filename = `painterro.${target}.js`
14+
}
15+
616
return {
717
entry: './js/main.js',
818
output: {
919
path: path.resolve(__dirname, 'build'),
10-
filename: `painterro.${target == 'var' && '' || target}.js`,
20+
filename: filename,
1121
library: 'Painterro', // export as library
1222
libraryTarget: target
1323
},
@@ -46,6 +56,7 @@ function webpackConfig(target) {
4656

4757
module.exports = [
4858
webpackConfig('var'),
59+
webpackConfig('var-latest'),
4960
webpackConfig('commonjs2'),
5061
webpackConfig('amd'),
5162
webpackConfig('umd')

0 commit comments

Comments
 (0)