From 07f826b1b510ed41322cddaacae80c865e45532a Mon Sep 17 00:00:00 2001 From: "kyuwoo.choi" Date: Fri, 30 Mar 2018 09:01:53 +0900 Subject: [PATCH 1/7] feature: send hostname --- bower.json | 2 +- examples/example01-basic.html | 2 +- examples/example02-mobile.html | 2 +- package-lock.json | 37 ++++++++++++++++++++-------------- package.json | 2 +- src/js/imageEditor.js | 10 ++++++++- src/js/util.js | 18 ++++++++++++++++- test/imageEditor.spec.js | 37 ++++++++++++++++++++++++++++++++++ 8 files changed, 89 insertions(+), 21 deletions(-) create mode 100644 test/imageEditor.spec.js diff --git a/bower.json b/bower.json index d4a8fdc1b..92701e9d7 100644 --- a/bower.json +++ b/bower.json @@ -29,7 +29,7 @@ ], "dependencies": { "fabric": "~1.6.4", - "tui-code-snippet": "^1.2.5" + "tui-code-snippet": "^1.3.0" }, "devDependencies": { "tui-component-colorpicker": "~1.0.1", diff --git a/examples/example01-basic.html b/examples/example01-basic.html index 712391227..7560e4faf 100644 --- a/examples/example01-basic.html +++ b/examples/example01-basic.html @@ -223,7 +223,7 @@
- + diff --git a/examples/example02-mobile.html b/examples/example02-mobile.html index 3789db3d9..f4a389fcb 100644 --- a/examples/example02-mobile.html +++ b/examples/example02-mobile.html @@ -172,7 +172,7 @@

Menu Scrolling Left ⇔ Right

- + diff --git a/package-lock.json b/package-lock.json index bcb809342..36d97970d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1290,9 +1290,9 @@ } }, "commander": { - "version": "2.12.2", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz", - "integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==", + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", "dev": true }, "commondir": { @@ -3588,8 +3588,8 @@ "requires": { "bluebird": "2.11.0", "chalk": "1.1.3", - "commander": "2.12.2", - "is-my-json-valid": "2.17.1" + "commander": "2.15.1", + "is-my-json-valid": "2.17.2" }, "dependencies": { "bluebird": { @@ -3991,14 +3991,21 @@ "is-extglob": "1.0.0" } }, + "is-my-ip-valid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz", + "integrity": "sha512-gmh/eWXROncUzRnIa1Ubrt5b8ep/MGSnfAUI3aRp+sqTCs1tv1Isl8d8F6JmkN3dXKc3ehZMrtiPN9eL03NuaQ==", + "dev": true + }, "is-my-json-valid": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.17.1.tgz", - "integrity": "sha512-Q2khNw+oBlWuaYvEEHtKSw/pCxD2L5Rc1C+UQme9X6JdRDh7m5D7HkozA0qa3DUkQ6VzCnEm8mVIQPyIRkI5sQ==", + "version": "2.17.2", + "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.17.2.tgz", + "integrity": "sha512-IBhBslgngMQN8DDSppmgDv7RNrlFotuuDsKcrCP3+HbFaVivIBU7u9oiiErw8sH4ynx3+gOGQ3q2otkgiSi6kg==", "dev": true, "requires": { "generate-function": "2.0.0", "generate-object-property": "1.2.0", + "is-my-ip-valid": "1.0.0", "jsonpointer": "4.0.1", "xtend": "4.0.1" } @@ -5634,7 +5641,7 @@ "oauth-sign": "0.6.0", "qs": "2.4.2", "stringstream": "0.0.5", - "tough-cookie": "2.3.3", + "tough-cookie": "2.3.4", "tunnel-agent": "0.4.3" }, "dependencies": { @@ -6433,9 +6440,9 @@ "dev": true }, "tough-cookie": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", - "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -6460,9 +6467,9 @@ "dev": true }, "tui-code-snippet": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/tui-code-snippet/-/tui-code-snippet-1.2.9.tgz", - "integrity": "sha512-hCNeB81R3dlnbojYhcfu3Z8binnarFanbJiS3hFkORt5FiEqHfQ1YL82xyQLby5IUaykZJAdCY7l+6hJxwfVSw==" + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/tui-code-snippet/-/tui-code-snippet-1.3.0.tgz", + "integrity": "sha512-OJUibhjdfq6jsav8ss6bg3qB8Mi7ugXprXZBOSAaNLy8GRUD3tt9TP9tF154419CCfo2tIIYl9KEJqznJg4+rA==" }, "tui-jsdoc-template": { "version": "1.2.2", diff --git a/package.json b/package.json index 9cb6ee431..31de468b5 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,6 @@ }, "dependencies": { "core-js": "2.4.1", - "tui-code-snippet": "^1.2.5" + "tui-code-snippet": "^1.3.0" } } diff --git a/src/js/imageEditor.js b/src/js/imageEditor.js index a20e226bb..3f5f42c26 100644 --- a/src/js/imageEditor.js +++ b/src/js/imageEditor.js @@ -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; @@ -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} [options.usageStatistics=true] - send hostname to google analytics */ class ImageEditor { constructor(wrapper, option) { - option = option || {}; + option = snippet.extend({ + usageStatistics: true + }, option); /** * Invoker @@ -64,6 +68,10 @@ class ImageEditor { if (option.selectionStyle) { this._setSelectionStyle(option.selectionStyle); } + + if (option.usageStatistics) { + sendHostName(); + } } /** diff --git a/src/js/util.js b/src/js/util.js index 7da74c8bd..c38f27658 100644 --- a/src/js/util.js +++ b/src/js/util.js @@ -2,7 +2,7 @@ * @author NHN Ent. FE Development Team * @fileoverview Util */ -import {forEach} from 'tui-code-snippet'; +import {forEach, imagePing} from 'tui-code-snippet'; const {min, max} = Math; module.exports = { @@ -71,5 +71,21 @@ module.exports = { } return props; + }, + + /** + * send hostname + */ + sendHostName() { + const {hostname} = location; + + imagePing('https://www.google-analytics.com/collect', { + v: 1, + t: 'event', + tid: 'UA-115377265-9', + cid: hostname, + dp: hostname, + dh: 'image-editor' + }); } }; diff --git a/test/imageEditor.spec.js b/test/imageEditor.spec.js new file mode 100644 index 000000000..bbba85577 --- /dev/null +++ b/test/imageEditor.spec.js @@ -0,0 +1,37 @@ +/** + * @fileoverview Test env + * @author NHN Ent. FE Development Lab + */ + +import snippet from 'tui-code-snippet'; +import ImageEditor from '../src/js/imageEditor'; + +describe('ImageEditor', () => { + describe('constructor', () => { + let imageEditor; + + afterEach(() => { + imageEditor.destroy(); + }); + + it('should send hostname by default', () => { + const el = document.createElement('div'); + spyOn(snippet, 'imagePing'); + + imageEditor = new ImageEditor(el); + + expect(snippet.imagePing).toHaveBeenCalled(); + }); + + it('should not send hostname on usageStatistics option false', () => { + const el = document.createElement('div'); + spyOn(snippet, 'imagePing'); + + imageEditor = new ImageEditor(el, { + usageStatistics: false + }); + + expect(snippet.imagePing).not.toHaveBeenCalled(); + }); + }); +}); From 7b614642374cbb2b1498331d0bd61ae5ee72f961 Mon Sep 17 00:00:00 2001 From: "kyuwoo.choi" Date: Fri, 30 Mar 2018 15:48:17 +0900 Subject: [PATCH 2/7] chore: add editor config --- .editorconfig | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..47368586f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +end_of_line = lf \ No newline at end of file From 96691c03d2f2f73a9b4d26aa19bf1d7b690a311d Mon Sep 17 00:00:00 2001 From: "kyuwoo.choi" Date: Wed, 11 Apr 2018 13:38:52 +0900 Subject: [PATCH 3/7] feat: send hostname --- README.md | 2 +- examples/example01-basic.html | 2 +- examples/example02-mobile.html | 2 +- src/js/imageEditor.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e1c2b35fa..cf587ad5e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/examples/example01-basic.html b/examples/example01-basic.html index 7560e4faf..0ae868210 100644 --- a/examples/example01-basic.html +++ b/examples/example01-basic.html @@ -223,7 +223,7 @@
- + diff --git a/examples/example02-mobile.html b/examples/example02-mobile.html index f4a389fcb..1a62fc8a2 100644 --- a/examples/example02-mobile.html +++ b/examples/example02-mobile.html @@ -172,7 +172,7 @@

Menu Scrolling Left ⇔ Right

- + diff --git a/src/js/imageEditor.js b/src/js/imageEditor.js index 3f5f42c26..483b87da0 100644 --- a/src/js/imageEditor.js +++ b/src/js/imageEditor.js @@ -21,7 +21,7 @@ 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} [options.usageStatistics=true] - send hostname to google analytics + * @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) { From 4d02efb73ddc55be78ac72fcbb5a1457ff27824d Mon Sep 17 00:00:00 2001 From: "kyuwoo.choi" Date: Wed, 11 Apr 2018 21:21:42 +0900 Subject: [PATCH 4/7] test: add test for send hostname --- src/js/util.js | 5 +++++ test/imageEditor.spec.js | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/js/util.js b/src/js/util.js index c38f27658..88e634c72 100644 --- a/src/js/util.js +++ b/src/js/util.js @@ -4,6 +4,7 @@ */ import {forEach, imagePing} from 'tui-code-snippet'; const {min, max} = Math; +let hostnameSent = false; module.exports = { /** @@ -78,6 +79,10 @@ module.exports = { */ sendHostName() { const {hostname} = location; + if (hostnameSent) { + return; + } + hostnameSent = true; imagePing('https://www.google-analytics.com/collect', { v: 1, diff --git a/test/imageEditor.spec.js b/test/imageEditor.spec.js index bbba85577..8fe882a4c 100644 --- a/test/imageEditor.spec.js +++ b/test/imageEditor.spec.js @@ -7,26 +7,27 @@ 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; + let imageEditor, el; + + beforeEach(() => { + el = document.createElement('div'); + spyOn(snippet, 'imagePing'); + }); afterEach(() => { imageEditor.destroy(); }); - it('should send hostname by default', () => { - const el = document.createElement('div'); - spyOn(snippet, 'imagePing'); - + xit('should send hostname by default', () => { imageEditor = new ImageEditor(el); expect(snippet.imagePing).toHaveBeenCalled(); }); - it('should not send hostname on usageStatistics option false', () => { - const el = document.createElement('div'); - spyOn(snippet, 'imagePing'); - + xit('should not send hostname on usageStatistics option false', () => { imageEditor = new ImageEditor(el, { usageStatistics: false }); From 2c37314ee548cb7f20566467007dbed5303ccd12 Mon Sep 17 00:00:00 2001 From: KyuWoo Choi Date: Fri, 13 Apr 2018 16:42:27 +0900 Subject: [PATCH 5/7] docs: add install via CDN guide (#29) * docs: add install via CDN guide * docs: apply code review (ref #29) --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index cf587ad5e..a0c88a2fc 100644 --- a/README.md +++ b/README.md @@ -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 + +``` + +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) From 9e7fa91a0824c3aeb30becb10a437a981120d553 Mon Sep 17 00:00:00 2001 From: KyuWoo Choi Date: Fri, 13 Apr 2018 16:57:30 +0900 Subject: [PATCH 6/7] test: fix broken test (#30) --- bower.json | 3 +++ test/text.spec.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 92701e9d7..43a262951 100644 --- a/bower.json +++ b/bower.json @@ -34,5 +34,8 @@ "devDependencies": { "tui-component-colorpicker": "~1.0.1", "filesaver": "*" + }, + "resolutions": { + "tui-code-snippet": "^1.3.0" } } diff --git a/test/text.spec.js b/test/text.spec.js index 8538b4b2b..fd81950e7 100644 --- a/test/text.spec.js +++ b/test/text.spec.js @@ -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); From 245e7eadd54583ed6695dbf075f6f3b66df21b74 Mon Sep 17 00:00:00 2001 From: "kyuwoo.choi" Date: Fri, 13 Apr 2018 21:49:48 +0900 Subject: [PATCH 7/7] chore: version update to 3.1.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 36d97970d..78c02998b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "tui-image-editor", - "version": "3.0.1", + "version": "3.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 31de468b5..9c457ca71 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tui-image-editor", "author": "NHNEnt FE Development Lab ", - "version": "3.0.1", + "version": "3.1.0", "license": "MIT", "repository": "https://github.com/nhnent/tui.image-editor", "main": "dist/tui-image-editor.js",