Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
kyuwoo.choi committed Apr 13, 2018
2 parents 59090ee + 245e7ea commit 2ea08e4
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Canvas image editor

## Dependency
* [fabric.js](https://github.com/kangax/fabric.js/releases/tag/v1.6.7) >=1.6.7
* [tui.code-snippet](https://github.com/nhnent/tui.code-snippet/releases/tag/v1.2.5) >=1.2.5
* [tui.code-snippet](https://github.com/nhnent/tui.code-snippet/releases/tag/v1.2.5) >=1.3.0

## Test Environment
### PC
Expand Down Expand Up @@ -92,6 +92,28 @@ var imageEditor = new tui.ImageEditor('.tui-image-editor', {
});
```

### Via Contents Delivery Network (CDN)
TOAST UI products are available over the CDN powered by [TOAST Cloud](https://www.toast.com).

You can use the CDN as below.

```html
<script src="https://uicdn.toast.com/tui-image-editor/latest/tui-image-editor.js"></script>
```

If you want to use a specific version, use the tag name instead of `latest` in the url's path.

The CDN directory has the following structure.

```
tui-image-editor/
├─ latest/
│ ├─ tui-image-editor.js
│ └─ tui-image-editor.min.js
├─ v3.1.0/
│ ├─ ...
```

### Download
* [Download bundle files from `dist` folder](https://github.com/nhnent/tui.image-editor/tree/production/dist)
* [Download all sources for each version](https://github.com/nhnent/tui.image-editor/releases)
Expand Down
5 changes: 4 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@
],
"dependencies": {
"fabric": "~1.6.4",
"tui-code-snippet": "^1.2.5"
"tui-code-snippet": "^1.3.0"
},
"devDependencies": {
"tui-component-colorpicker": "~1.0.1",
"filesaver": "*"
},
"resolutions": {
"tui-code-snippet": "^1.3.0"
}
}
2 changes: 1 addition & 1 deletion examples/example01-basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
<div class="tui-image-editor"></div>
</div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.6.7/fabric.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/nhnent/tui.code-snippet/v1.2.5/dist/tui-code-snippet.js"></script>
<script type="text/javascript" src="https://uicdn.toast.com/tui.code-snippet/v1.3.0/tui-code-snippet.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.3/FileSaver.min.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/nhnent/tui.component.colorpicker/1.0.2/dist/colorpicker.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/example02-mobile.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
<p class="msg">Menu Scrolling <b>Left ⇔ Right</b></p>
</div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.6.7/fabric.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/nhnent/tui.code-snippet/v1.2.5/dist/tui-code-snippet.js"></script>
<script type="text/javascript" src="https://uicdn.toast.com/tui.code-snippet/v1.3.0/tui-code-snippet.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.3/FileSaver.min.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/nhnent/tui.component.colorpicker/1.0.2/dist/colorpicker.min.js"></script>
Expand Down
39 changes: 23 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tui-image-editor",
"author": "NHNEnt FE Development Lab <dl_javascript@nhnent.com>",
"version": "3.0.2",
"version": "3.1.0",
"license": "MIT",
"repository": "https://github.com/nhnent/tui.image-editor",
"main": "dist/tui-image-editor.js",
Expand Down Expand Up @@ -57,6 +57,6 @@
},
"dependencies": {
"core-js": "2.4.1",
"tui-code-snippet": "^1.2.5"
"tui-code-snippet": "^1.3.0"
}
}
10 changes: 9 additions & 1 deletion src/js/imageEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Invoker from './invoker';
import commandFactory from './factory/command';
import Graphics from './graphics';
import consts from './consts';
import {sendHostName} from './util';

const events = consts.eventNames;
const commands = consts.commandNames;
Expand All @@ -20,10 +21,13 @@ const {isUndefined, forEach, CustomEvents} = snippet;
* @param {Object} [option] - Canvas max width & height of css
* @param {number} option.cssMaxWidth - Canvas css-max-width
* @param {number} option.cssMaxHeight - Canvas css-max-height
* @param {Boolean} [option.usageStatistics=true] - Let us know the hostname. If you don't want to send the hostname, please set to false.
*/
class ImageEditor {
constructor(wrapper, option) {
option = option || {};
option = snippet.extend({
usageStatistics: true
}, option);

/**
* Invoker
Expand Down Expand Up @@ -64,6 +68,10 @@ class ImageEditor {
if (option.selectionStyle) {
this._setSelectionStyle(option.selectionStyle);
}

if (option.usageStatistics) {
sendHostName();
}
}

/**
Expand Down
23 changes: 22 additions & 1 deletion src/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* @author NHN Ent. FE Development Team <dl_javascript@nhnent.com>
* @fileoverview Util
*/
import {forEach} from 'tui-code-snippet';
import {forEach, imagePing} from 'tui-code-snippet';
const {min, max} = Math;
let hostnameSent = false;

module.exports = {
/**
Expand Down Expand Up @@ -71,5 +72,25 @@ module.exports = {
}

return props;
},

/**
* send hostname
*/
sendHostName() {
const {hostname} = location;
if (hostnameSent) {
return;
}
hostnameSent = true;

imagePing('https://www.google-analytics.com/collect', {
v: 1,
t: 'event',
tid: 'UA-115377265-9',
cid: hostname,
dp: hostname,
dh: 'image-editor'
});
}
};
38 changes: 38 additions & 0 deletions test/imageEditor.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @fileoverview Test env
* @author NHN Ent. FE Development Lab <dl_javascript@nhnent.com>
*/

import snippet from 'tui-code-snippet';
import ImageEditor from '../src/js/imageEditor';

describe('ImageEditor', () => {
// hostnameSent module scope variable can not be reset.
// maintain cases with xit as it always fail, if you want to test these cases, change xit to fit one by one
describe('constructor', () => {
let imageEditor, el;

beforeEach(() => {
el = document.createElement('div');
spyOn(snippet, 'imagePing');
});

afterEach(() => {
imageEditor.destroy();
});

xit('should send hostname by default', () => {
imageEditor = new ImageEditor(el);

expect(snippet.imagePing).toHaveBeenCalled();
});

xit('should not send hostname on usageStatistics option false', () => {
imageEditor = new ImageEditor(el, {
usageStatistics: false
});

expect(snippet.imagePing).not.toHaveBeenCalled();
});
});
});
2 changes: 1 addition & 1 deletion test/text.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ describe('Text', () => {
const textareaStyles = textarea.style;

expect(textareaStyles['font-size']).toEqual(`${expected.fontSize / ratio}px`);
expect(textareaStyles['font-family'].replace(/'|"/g, '')).toEqual(expected.fontFamily);
expect(textareaStyles['font-family'].replace(/'|"|\\/g, '')).toEqual(expected.fontFamily);
expect(textareaStyles['font-weight']).toEqual(expected.fontWeight);
expect(textareaStyles['font-align']).toEqual(expected.fontAlign);
expect(textareaStyles['line-height']).toEqual(obj.getLineHeight() + 0.1);
Expand Down

0 comments on commit 2ea08e4

Please sign in to comment.